/* BRASS & FOG - field-desk chrome around a 1916 survey sheet */
:root {
  --bg: #1b1a15;
  --bg2: #25231c;
  --ink: #e9dfc6;
  --ink2: #b7aa8b;
  --muted: #8a7f66;
  --paper: #e6d9bb;
  --paper-ink: #34291c;
  --brass: #c9973f;
  --brass2: #8c6424;
  --ochre: #c07a2c;
  --slate: #6f8497;
  --red: #b0412e;
  --line: #3a362b;
  --ok: #7f9a52;
  --radius: 10px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: "Courier New", Courier, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { overflow: hidden; overscroll-behavior: none; touch-action: manipulation; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 600; margin: 0; letter-spacing: .02em; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink2); margin: 22px 0 8px; }
.note { color: var(--ink2); font-size: 14px; line-height: 1.45; margin: 6px 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }

/* ---------------------------------------------------------------- buttons */
.btn {
  appearance: none; border: 1px solid #4a4435; background: linear-gradient(#2f2c23, #26241d);
  color: var(--ink); padding: 10px 14px; border-radius: var(--radius); cursor: pointer;
  min-height: 44px; font-size: 15px; line-height: 1.1; touch-action: manipulation;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.btn:hover { border-color: #6a604a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: linear-gradient(#d6a54c, #a87a2c); color: #1f1708; border-color: #e2b862; font-weight: 700; }
.btn.danger { border-color: #7a3325; color: #f0c2b6; }
.btn.big { font-size: 17px; padding: 14px 18px; min-height: 52px; }
.btn.icon { min-width: 44px; padding: 8px; font-size: 20px; }
.btn.on { border-color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass); color: #f5d99a; }
.btn b { color: #f5d99a; margin-left: 4px; }
.padfocus { outline: 3px solid #f5d99a !important; outline-offset: 2px; }

input { background: #14130f; border: 1px solid #4a4435; border-radius: var(--radius); padding: 10px 12px; min-height: 44px; width: 100%; font-size: 16px; }
.code-in { text-transform: uppercase; letter-spacing: .3em; font-family: var(--mono); font-weight: 700; max-width: 180px; }

/* ---------------------------------------------------------------- screens */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
.screen.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.bar { display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) 8px calc(10px + var(--safe-l));
  background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar h2 { font-size: 19px; flex: 1; }
.page { padding: 8px calc(16px + var(--safe-r)) calc(28px + var(--safe-b)) calc(16px + var(--safe-l)); max-width: 760px; width: 100%; margin: 0 auto; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 14px; margin: 12px 0; }
.card h3 { margin-top: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #6b3a2e; box-shadow: 0 0 0 2px #0006; }
.dot.on { background: #8fb35a; }

/* ---------------------------------------------------------------- title */
#scr-title { background: #0f0e0b; }
#poster { position: absolute; inset: 0; width: 100%; height: 100%; }
.title-lockup { position: relative; padding: calc(40px + var(--safe-t)) 24px 0; text-shadow: 0 2px 18px #000c; }
.title-lockup .kicker, .kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .28em; color: #d9b36a; }
.title-lockup h1 { font-size: clamp(44px, 12vw, 92px); line-height: .95; margin-top: 8px; color: #f1e6c8; letter-spacing: .04em; }
.title-lockup h1 span { color: #d6a54c; font-style: italic; }
/* landscape: the lockup must finish inside the dark left ~46% the poster keeps for it */
@media (orientation: landscape) { .title-lockup h1 { font-size: clamp(38px, 5.6vw, 92px); } .title-lockup .tag { max-width: 36vw; } }
.title-lockup .tag { margin-top: 12px; font-size: 16px; color: #d8ccaf; font-style: italic; max-width: 26em; }
.title-menu { position: relative; margin-top: auto; padding: 0 24px calc(28px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.title-menu .row .btn { flex: 1; }
.title-menu .btn:not(.primary) { background: rgba(28,26,20,.82); backdrop-filter: blur(4px); }
@media (min-width: 900px) and (min-height: 560px) {
  .title-lockup { padding-left: 64px; padding-top: 80px; }
  .title-menu { padding-left: 64px; padding-bottom: 64px; }
}

/* ---------------------------------------------------------------- config */
.maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.map-card { background: var(--bg2); border: 2px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer; text-align: left; color: var(--ink); }
.map-card.on { border-color: var(--brass); background: #2f2a1d; }
.map-card canvas { width: 100%; aspect-ratio: 1; display: block; border-radius: 6px; background: #14130f; object-fit: contain; }
.map-card .mn { font-weight: 700; margin-top: 6px; font-size: 15px; }
.map-card .ms { font-size: 12px; color: var(--ink2); line-height: 1.35; margin-top: 2px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg .btn { flex: 1 1 auto; }
.seg .btn small { display: block; font-size: 11px; color: var(--ink2); margin-top: 3px; font-weight: 400; }
.seg .btn.primary small, .seg .btn.on small { color: inherit; opacity: .8; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.preset { text-align: left; }
.preset .pn { font-weight: 700; }
.preset .ps { font-size: 12px; color: var(--ink2); margin-top: 3px; line-height: 1.3; }
.twists-wrap { margin-top: 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; }
.twists-wrap summary { padding: 14px; cursor: pointer; font-weight: 600; list-style: none; min-height: 44px; }
.twists-wrap summary::after { content: ' \25BE'; color: var(--muted); }
.twists-wrap[open] summary::after { content: ' \25B4'; }
#cfg-twist-count { color: var(--brass); font-weight: 400; margin-left: 6px; }
.twists { padding: 0 14px 10px; }
.twist { padding: 12px 0; border-top: 1px solid var(--line); }
.twist .tn { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 600; }
.twist .td { font-size: 13px; color: var(--ink2); line-height: 1.4; margin-top: 6px; }
.twist .seg .btn { min-height: 38px; padding: 6px 10px; font-size: 14px; flex: 0 0 auto; }
.switch { position: relative; width: 52px; height: 30px; border-radius: 15px; background: #3a362b; border: 1px solid #555; flex: 0 0 auto; cursor: pointer; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #9a8f76; transition: left .15s; }
.switch.on { background: #8c6424; border-color: var(--brass); }
.switch.on::after { left: 25px; background: #f5d99a; }
.go-row { margin-top: 26px; }
.go-row .btn { width: 100%; }

/* ---------------------------------------------------------------- online */
.games { display: flex; flex-direction: column; gap: 8px; }
.game-row { display: flex; align-items: center; gap: 10px; background: #1f1d17; border: 1px solid var(--line); border-radius: 10px; padding: 8px 8px 8px 12px; }
.game-row .gi { flex: 1; min-width: 0; }
.game-row .gc { font-family: var(--mono); font-weight: 700; letter-spacing: .15em; }
.game-row .gs { font-size: 13px; color: var(--ink2); }
.game-row.yours { border-color: var(--brass); }
.game-row.yours .gs { color: #f5d99a; }
.share { text-align: center; }
.share .code { font-family: var(--mono); font-size: 42px; font-weight: 700; letter-spacing: .3em; color: #f5d99a; margin: 8px 0; }
.share svg { width: 180px; height: 180px; background: #fff; border-radius: 8px; padding: 6px; }

/* ---------------------------------------------------------------- game */
.gamebar .status { flex: 1; min-width: 0; text-align: center; }
#g-status { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#g-status.you { color: #f5d99a; }
.gamebar .sub { font-size: 12px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#board-wrap { position: relative; flex: 0 0 auto; display: flex; justify-content: center; align-items: center; padding: 6px calc(6px + var(--safe-r)) 4px calc(6px + var(--safe-l)); }
/* the sheet lies on a dark desk under the same lamp the canvas is lit by (upper left) */
#board-wrap { background:
    radial-gradient(ellipse 70% 60% at 30% 22%, rgba(255,196,120,.16), rgba(255,196,120,0) 70%),
    repeating-linear-gradient(94deg, rgba(0,0,0,.05) 0 2px, rgba(255,255,255,.012) 2px 7px, rgba(0,0,0,.03) 7px 11px),
    linear-gradient(#271f15, #120e09); }
#board { display: block; touch-action: none; border-radius: 2px; will-change: transform;
  box-shadow: 10px 16px 30px rgba(0,0,0,.6), 3px 5px 8px rgba(0,0,0,.45), 0 0 0 1px rgba(40,26,10,.6); }
#panel { flex: 1; min-height: 0; overflow-y: auto; padding: 6px calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l)); }
@media (orientation: landscape) and (min-width: 640px) {
  .game-body { flex-direction: row; }
  #board-wrap { flex: 1 1 auto; min-width: 0; padding: 8px; }
  #panel { flex: 0 0 min(360px, 38vw); border-left: 1px solid var(--line); background: #1e1c16; }
}
.tray { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { display: flex; align-items: center; gap: 6px; border: 1px solid #4a4435; background: #26241d; border-radius: 22px; padding: 4px 10px 4px 4px; min-height: 44px; cursor: pointer; color: var(--ink); }
.chip canvas { width: 34px; height: 34px; }
.chip .cn { font-size: 13px; }
.chip .cc { font-family: var(--mono); font-weight: 700; color: #f5d99a; }
.chip.on { border-color: var(--brass); background: #3a311d; }
.chip.empty { opacity: .35; }
.actions { margin-bottom: 8px; }
.actions .btn { flex: 1 1 auto; }
.roster-wrap { background: #1f1d17; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.roster-head { display: flex; justify-content: space-between; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink2); margin-bottom: 6px; }
.roster { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.rk { display: flex; align-items: center; gap: 4px; font-size: 13px; min-width: 64px; }
.rk canvas { width: 26px; height: 26px; }
.rk .rc { font-family: var(--mono); font-weight: 700; }
.rk.gone { opacity: .35; text-decoration: line-through; }
.log-wrap { margin-top: 10px; }
.log-wrap summary { cursor: pointer; color: var(--ink2); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; padding: 6px 0; min-height: 32px; }
.log { list-style: none; margin: 0; padding: 0; font-size: 14px; line-height: 1.4; max-height: 30vh; overflow-y: auto; }
.log li { padding: 4px 0; border-bottom: 1px dashed #3a362b; color: #d8ccaf; }
.log li:first-child { color: #f5d99a; }
.toast { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(22,20,15,.94); border: 1px solid var(--brass2);
  border-radius: 12px; padding: 10px 14px; font-size: 15px; max-width: 92%; text-align: center; pointer-events: none; box-shadow: 0 8px 30px #000c; z-index: 4; }
.toast .vs { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 6px; }
.toast canvas { width: 46px; height: 46px; }
.toast .res { font-weight: 700; color: #f5d99a; }

/* ---------------------------------------------------------------- overlays */
.curtain { position: fixed; inset: 0; z-index: 50; background: radial-gradient(ellipse at 50% 40%, #2c281d, #0d0c09); display: flex; align-items: center; justify-content: center; padding: 24px; }
.curtain-card { text-align: center; max-width: 360px; }
.curtain-card h2 { font-size: 34px; margin: 10px 0; }
.curtain-card .btn { width: 100%; margin-top: 18px; }
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(8,7,5,.72); display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .modal { align-items: center; } }
.modal-card { position: relative; background: var(--bg2); border: 1px solid #4a4435; border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; box-shadow: 0 -10px 40px #000a; }
@media (min-width: 640px) { .modal-card { border-radius: 16px; } }
.modal-card .close { position: absolute; top: 8px; right: 8px; }
.modal-card h2 { font-size: 22px; margin: 0 40px 8px 0; }
.modal-card .btns { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.modal-card .btns .btn { width: 100%; }
.rank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 10px; }
.rank-grid .btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; }
.rank-grid canvas { width: 40px; height: 40px; }
.claim-vs { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 12px 0; }
.claim-vs canvas { width: 64px; height: 64px; }
.claim-vs .lab { font-size: 13px; color: var(--ink2); text-align: center; margin-top: 4px; }
.big-claim { font-size: 26px; color: #f5d99a; font-weight: 700; letter-spacing: .06em; }
.win-title { font-size: 30px !important; }
.tele-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plans .row { margin: 6px 0; }
.plans .row .pl { flex: 1; }

/* ---------------------------------------------------------------- help */
.prose { font-size: 16px; line-height: 1.55; }
.prose h3 { margin-top: 26px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; }
.prose td, .prose th { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: left; vertical-align: top; }
.prose canvas { width: 30px; height: 30px; vertical-align: middle; }
.prose b { color: #f5d99a; font-weight: 600; }
