/* Duel — Swiss poster meets scoreboard. One family (Archivo, variable width + weight), square geometry,
   two signal colours: ultramarine = rows (first player), signal yellow = columns (second player). */

@font-face {
  font-family: "Archivo";
  src: url("../assets/fonts/archivo-var.woff2") format("woff2-variations"), url("../assets/fonts/archivo-var.woff2") format("woff2");
  font-weight: 100 900; font-stretch: 62% 125%; font-style: normal; font-display: swap;
}

:root {
  --bg: #ffffff;
  --ink: #0d0e12;
  --ink-2: #464953;
  --ink-3: #868a94;
  --hair: #d9dce2;
  --sq: #eceef2;
  --sq-hi: #dfe2e8;
  --tile: #0d0e12;
  --tile-ink: #ffffff;
  --rows: #2340ff;        /* fills, bars, text on bg */
  --rows-ink: #ffffff;    /* text on a rows fill */
  --rows-soft: #e3e7ff;
  --cols: #ffc400;
  --cols-ink: #0d0e12;
  --cols-text: #0d0e12;   /* yellow is never used as text on a light background */
  --cols-soft: #fff3c4;
  --last: #ffffff;
  --rule: 3px;
  --gap: 5px;
  --pad: 16px;
  --ease: cubic-bezier(.2, .9, .25, 1);
  --t: 1;                 /* motion multiplier (0 with reduced motion) */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    /* night scoreboard: graphite tiles with white numerals, outlined empty squares, brighter signals */
    --bg: #0c0d11;
    --ink: #f2f2ee;
    --ink-2: #b4b7bf;
    --ink-3: #7a7e88;
    --hair: #2a2d35;
    --sq: transparent;
    --sq-hi: #191b21;
    --tile: #2b2f39;
    --tile-ink: #ffffff;
    --rows: #5068ff;
    --rows-ink: #ffffff;
    --rows-soft: #1a2150;
    --cols: #ffc81a;
    --cols-ink: #0c0d11;
    --cols-text: #ffc81a;
    --cols-soft: #3a300a;
    --last: #ffffff;
    color-scheme: dark;
  }
}
@media (prefers-reduced-motion: reduce) { :root { --t: 0; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif; font-weight: 440; font-stretch: 100%;
  font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; border-radius: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--rows); outline-offset: 2px; }
[hidden] { display: none !important; }
b { font-weight: 750; }

.app {
  min-height: 100vh; min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) max(var(--pad), env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(var(--pad), env(safe-area-inset-left));
  max-width: 1320px; margin: 0 auto;
}

/* ---------- type helpers ---------- */
.lab, .field-l, .sect-h, .side-foot, .side-who, .note-cap {
  font-size: 11.5px; font-weight: 720; letter-spacing: .09em; text-transform: uppercase; font-stretch: 100%;
}
.t-rows { color: var(--rows); }
.t-cols { box-shadow: inset 0 -0.42em 0 var(--cols); color: var(--ink); padding: 0 1px; }
@media (prefers-color-scheme: dark) { .t-cols { box-shadow: none; color: var(--cols); padding: 0; } }

/* ---------- wordmark ---------- */
.wordmark {
  margin: 0; font-weight: 900; font-stretch: 125%; letter-spacing: -.035em; line-height: .78;
  font-size: 80px; font-size: min(96px, 25cqw); display: flex; align-items: flex-end;
}
.wordmark::after { /* the tile motif: a square with a rows bar and a columns bar */
  content: ""; width: .34em; height: .34em; margin-left: .06em; margin-bottom: .005em; flex: none;
  background: linear-gradient(var(--rows), var(--rows)) left bottom / 100% 26% no-repeat,
              linear-gradient(var(--cols), var(--cols)) left top / 26% 100% no-repeat, var(--ink);
}
.tagline { font-size: 16.5px; line-height: 1.38; margin: 18px 0 0; max-width: 34em; color: var(--ink); font-weight: 470; }
.ghost-btn {
  font-size: 12px; font-weight: 720; letter-spacing: .09em; text-transform: uppercase;
  padding: 10px 12px; min-height: 40px; border: 2px solid var(--ink); white-space: nowrap;
}
.ghost-btn:active { background: var(--ink); color: var(--bg); }
.ghost-btn.big { min-height: 52px; font-size: 13px; }

/* ---------- setup ---------- */
.setup { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding-bottom: 8px; }
.setup-intro { padding-top: 6px; container-type: inline-size; }
.howto { margin-top: 16px; }
.explain { display: none; }
.sect { margin-top: 26px; }
.sect-h { display: flex; align-items: baseline; gap: 10px; border-top: var(--rule) solid var(--ink); padding-top: 9px; margin-bottom: 12px; }
.sect-h .num { font-weight: 900; font-stretch: 125%; font-size: 12px; letter-spacing: 0; }

.modes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.modes button { text-align: left; padding: 12px 12px 13px; border: 2px solid var(--ink); min-height: 74px; display: flex; flex-direction: column; justify-content: space-between; }
.modes button + button { border-left: 0; }
.modes b { font-size: 17px; font-weight: 850; font-stretch: 112%; line-height: 1.05; letter-spacing: -.01em; }
.modes span { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.modes button.on { background: var(--ink); color: var(--bg); }
.modes button.on span { color: inherit; opacity: .72; }

.opps { display: grid; border-top: 2px solid var(--ink); }
.opp { display: grid; grid-template-columns: 30px 1fr auto; gap: 2px 10px; align-items: baseline; text-align: left; padding: 10px 10px 11px 8px; border-bottom: 1px solid var(--hair); }
.opp:last-child { border-bottom: 2px solid var(--ink); }
.opp .ix { font-weight: 900; font-stretch: 125%; font-size: 13px; color: var(--ink-3); }
.opp .nm { font-size: 16px; font-weight: 800; font-stretch: 108%; }
.opp .lv { display: flex; gap: 3px; align-self: center; }
.opp .lv i { width: 7px; height: 7px; background: var(--hair); }
.opp .lv i.f { background: var(--ink); }
.opp .ds { grid-column: 2 / 4; font-size: 13px; color: var(--ink-2); line-height: 1.35; }
.opp.on { background: var(--ink); color: var(--bg); border-bottom-color: var(--ink); }
.opp.on .ix, .opp.on .ds { color: inherit; opacity: .75; }
.opp.on .lv i { background: color-mix(in srgb, var(--bg) 30%, transparent); }
.opp.on .lv i.f { background: var(--bg); }

.fields { display: grid; gap: 16px; }
.field { min-width: 0; }
.field-l { margin-bottom: 7px; color: var(--ink); }
.sect#sect-cpu .field { margin-top: 18px; }
.seg { display: flex; }
.seg button {
  flex: 1 1 0; min-height: 44px; padding: 6px 8px; border: 2px solid var(--ink); margin-left: -2px;
  font-weight: 760; font-size: 14.5px; font-stretch: 105%; white-space: nowrap; line-height: 1.1;
}
.seg button:first-child { margin-left: 0; }
.seg button.on { background: var(--ink); color: var(--bg); position: relative; }
.seg button:disabled { color: var(--ink-3); cursor: not-allowed; background: repeating-linear-gradient(135deg, transparent 0 5px, var(--hair) 5px 6px); }
.seg.wrap { flex-wrap: wrap; margin-top: -2px; }
.seg.wrap button { flex: 1 1 auto; margin-top: -2px; padding: 6px 12px; }
.seg.wrap button:first-child { margin-left: 0; }
.seg button .sub { display: block; font-size: 10px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; opacity: .7; margin-top: 2px; }
.note { margin: 7px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.4; min-height: 1.4em; }
.note:empty { display: none; }

.names { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.name { display: block; border: 2px solid var(--ink); padding: 9px 10px 6px; position: relative; min-width: 0; }
.name + .name { border-left: 0; }
.name::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; }
.name-rows::before { background: var(--rows); }
.name-cols::before { background: var(--cols); }
.name span { display: block; font-size: 11px; font-weight: 720; letter-spacing: .09em; text-transform: uppercase; margin-top: 4px; color: var(--ink-2); }
.name input {
  width: 100%; min-width: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: 19px; font-weight: 820; font-stretch: 110%;
  padding: 4px 0 2px; outline: none; border-radius: 0;
}
.name input::placeholder { color: var(--ink-3); }

.go-bar {
  position: sticky; bottom: 0; z-index: 5; background: var(--bg); margin: 22px calc(-1 * var(--pad)) 0; padding: 10px var(--pad) max(12px, env(safe-area-inset-bottom));
  border-top: var(--rule) solid var(--ink);
}
.record { margin: 0 0 8px; font-size: 12.5px; color: var(--ink-2); font-weight: 560; letter-spacing: .01em; }
.record:empty { display: none; }
.record b { color: var(--ink); font-weight: 800; }
.go {
  width: 100%; min-height: 60px; background: var(--ink); color: var(--bg); display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; font-weight: 900; font-stretch: 125%; font-size: 26px; letter-spacing: -.01em; text-transform: uppercase;
}
.go .go-sum { font-size: 11.5px; font-weight: 650; font-stretch: 100%; letter-spacing: .07em; opacity: .75; text-align: right; line-height: 1.3; }
.go:active { background: var(--rows); color: var(--rows-ink); }
.go.small { min-height: 52px; font-size: 20px; justify-content: center; }

/* ---------- explainer (desktop setup + dialog) ---------- */
.ex-sec { margin-top: 18px; }
.ex-sec h3 { margin: 0 0 6px; font-size: 11.5px; font-weight: 760; letter-spacing: .09em; text-transform: uppercase; display: flex; gap: 8px; align-items: baseline; }
.ex-sec h3 em { font-style: normal; color: var(--ink-3); }
.ex-sec p { margin: 0 0 6px; font-size: 14.5px; line-height: 1.45; color: var(--ink); }
.ex-line { display: flex; align-items: center; gap: 4px; margin: 10px 0 2px; flex-wrap: wrap; }
.ex-line .mt {
  width: 34px; height: 34px; background: var(--tile); color: var(--tile-ink); display: grid; place-items: center; position: relative;
  font-weight: 900; font-stretch: 112%; font-size: 17px;
}
.ex-line .mt.sc::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--rows); }
.ex-line .eq { margin-left: 8px; font-weight: 900; font-stretch: 125%; font-size: 20px; }
.ex-line .eqv { min-width: 34px; height: 34px; padding: 0 6px; background: var(--rows); color: var(--rows-ink); display: grid; place-items: center; font-weight: 900; font-stretch: 112%; font-size: 17px; }
.ex-cap { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }

/* ---------- game ---------- */
.game { display: flex; flex-direction: column; min-height: calc(100dvh - max(12px, env(safe-area-inset-top)) - max(14px, env(safe-area-inset-bottom))); }
.game > * { flex: none; }
.gbar { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: var(--rule) solid var(--ink); }
.wm-s { font-weight: 900; font-stretch: 125%; font-size: 24px; letter-spacing: -.03em; line-height: 1; padding: 6px 0; }
.gbar-sum { flex: 1; min-width: 0; font-size: 11.5px; font-weight: 700; font-stretch: 78%; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); line-height: 1.3; text-align: right; }
.gbar-sum b { color: var(--ink); font-weight: 800; }

.hud { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 12px; }
.side { position: relative; padding: 14px 12px 9px; border: 2px solid var(--ink); min-width: 0; transition: background-color calc(var(--t) * 180ms), color calc(var(--t) * 180ms); }
.side + .side { border-left: 0; }
.side::before { content: ""; position: absolute; left: -2px; right: -2px; top: -2px; height: 7px; }
.side-rows::before { background: var(--rows); }
.side-cols::before { background: var(--cols); }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 16px; }
.side-who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-total { font-weight: 900; font-stretch: 125%; font-size: 46px; line-height: .9; margin-top: 6px; letter-spacing: -.02em; }
.side-foot { display: flex; justify-content: space-between; margin-top: 7px; font-size: 10.5px; color: var(--ink-2); }
.side.turn.side-rows { background: var(--rows); color: var(--rows-ink); }
.side.turn.side-cols { background: var(--cols); color: var(--cols-ink); }
.side.turn .side-foot { color: inherit; opacity: .8; }
.side.win.side-rows { background: var(--rows); color: var(--rows-ink); }
.side.win.side-cols { background: var(--cols); color: var(--cols-ink); }
.side.win .side-foot { color: inherit; }
.side.lose { color: var(--ink-3); }
.think { display: none; gap: 3px; }
.side.thinking .think { display: flex; }
.think i { width: 6px; height: 6px; background: currentColor; animation: think 900ms steps(1) infinite; }
.think i:nth-child(2) { animation-delay: 150ms; } .think i:nth-child(3) { animation-delay: 300ms; }
@keyframes think { 0%, 100% { opacity: .25; } 33% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .think i { animation: none; opacity: .8; } }

/* tray: the dice in hand sit under the player who holds them */
.tray { position: relative; height: 88px; margin-top: 10px; display: flex; align-items: center; gap: 12px; }
.tray.right { flex-direction: row-reverse; }
.tray .dice { display: flex; gap: 8px; flex: none; }
.tray.right .dice { flex-direction: row-reverse; }
.tray .msg { flex: 1; min-width: 0; font-size: 14px; line-height: 1.3; }
.tray.right .msg { text-align: right; }
.tray .msg .who { display: block; font-size: 11px; font-weight: 760; letter-spacing: .09em; text-transform: uppercase; margin-bottom: 3px; }
.tray .msg .who.r { color: var(--rows); }
.tray .msg .who.c { color: var(--ink); }
.tray .msg .who.c::before { content: ""; display: inline-block; width: 9px; height: 9px; background: var(--cols); margin-right: 6px; vertical-align: 0; }
.tray .msg .who.r::before { content: ""; display: inline-block; width: 9px; height: 9px; background: var(--rows); margin-right: 6px; vertical-align: 0; }
@media (prefers-color-scheme: dark) { .tray .msg .who.c { color: var(--cols); } }
.die {
  --s: 58px; width: var(--s); height: var(--s); background: var(--tile); color: var(--tile-ink); display: grid; place-items: center; position: relative; flex: none;
  font-weight: 900; font-stretch: 118%; font-size: calc(var(--s) * .52); line-height: 1;
}
.die.two { font-stretch: 100%; font-size: calc(var(--s) * .44); letter-spacing: -.03em; }
.die .cap { position: absolute; top: calc(100% + 9px); left: 0; right: 0; text-align: center; font-size: 9.5px; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
button.die { cursor: pointer; }
.die.sel { outline: 4px solid var(--selc, var(--ink)); outline-offset: 3px; }
.die.dim { opacity: .5; }
.die.gone { opacity: 0; transform: scale(.6); transition: opacity calc(var(--t) * 220ms), transform calc(var(--t) * 220ms); }
.tray .dice.pickable { gap: 16px; padding: 0 4px; }
.tray .dice.pickable .die { outline: 2px dashed var(--ink-3); outline-offset: 3px; }
.tray .dice.pickable .die:hover { outline: 4px solid var(--selc, var(--ink)); }

.board-wrap { flex: none; min-height: 0; display: flex; align-items: flex-start; justify-content: center; margin-top: 14px; }
.board { --cell: 60px; --mark: calc(var(--cell) * .62); display: grid; gap: var(--gap); grid-template-columns: repeat(var(--n), var(--cell)) var(--mark); grid-template-rows: repeat(var(--n), var(--cell)) var(--mark); }
.board .cs-row { display: contents; }
.cell {
  position: relative; width: var(--cell); height: var(--cell); background: var(--sq); display: grid; place-items: center;
  font-weight: 900; font-stretch: 118%; font-size: calc(var(--cell) * .5); line-height: 1; color: var(--tile-ink); overflow: hidden;
}
@media (prefers-color-scheme: dark) { .cell:not(.f) { box-shadow: inset 0 0 0 1.5px var(--hair); } }
.cell.f { background: var(--tile); cursor: default; }
.cell.two .n { font-stretch: 100%; font-size: calc(var(--cell) * .4); letter-spacing: -.03em; }
.cell .n { position: relative; z-index: 1; }
.cell.can { cursor: pointer; }
@media (hover: hover) {
  .cell.can:hover { background: var(--sq-hi); }
  .cell.can:hover::after { content: attr(data-ghost); color: var(--ink); opacity: .28; }
}
.cell .br, .cell .bc { position: absolute; opacity: 0; transition: opacity calc(var(--t) * 160ms); }
.cell .br { left: 0; right: 0; bottom: 0; height: max(5px, calc(var(--cell) * .11)); background: var(--rows); }
.cell .bc { top: 0; bottom: 0; left: 0; width: max(5px, calc(var(--cell) * .11)); background: var(--cols); }
.cell.sr .br, .cell.sc .bc { opacity: 1; }
.cell.last::before { content: ""; position: absolute; inset: max(4px, calc(var(--cell) * .08)); border: 2px solid var(--last); opacity: .9; pointer-events: none; }
.cell.drop .n { animation: drop calc(var(--t) * 200ms) var(--ease) both; }
.cell.drop { animation: dropbg calc(var(--t) * 200ms) var(--ease) both; }
@keyframes drop { from { transform: scale(1.5); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes dropbg { from { transform: scale(.82); } to { transform: none; } }
.cell.flash-r { animation: flr calc(var(--t) * 480ms) ease-out; }
.cell.flash-c { animation: flc calc(var(--t) * 480ms) ease-out; }
@keyframes flr { 25% { background-color: var(--rows); color: var(--rows-ink); transform: scale(.94); } 100% { transform: none; } }
@keyframes flc { 25% { background-color: var(--cols); color: var(--cols-ink); transform: scale(.94); } 100% { transform: none; } }

.ls, .cs {
  display: grid; place-items: center; font-weight: 900; font-stretch: 110%; font-size: clamp(13px, calc(var(--cell) * .3), 30px); line-height: 1;
  transition: background-color calc(var(--t) * 160ms);
}
.ls { width: var(--mark); height: var(--cell); background: var(--rows); color: var(--rows-ink); }
.cs { width: var(--cell); height: var(--mark); background: var(--cols); color: var(--cols-ink); }
.ls.z, .cs.z { background: transparent; color: var(--ink-3); font-weight: 600; }
.ls.z { box-shadow: inset 3px 0 0 var(--rows); }
.cs.z { box-shadow: inset 0 3px 0 var(--cols); }
.ls.tick, .cs.tick { animation: tick calc(var(--t) * 260ms) var(--ease); }
@keyframes tick { 0% { transform: scale(1); } 35% { transform: scale(1.18); } 100% { transform: none; } }
.ls.flash, .cs.flash { animation: tick calc(var(--t) * 420ms) var(--ease); }
.corner { width: var(--mark); height: var(--mark); display: grid; place-items: center; font-size: 10px; font-weight: 760; color: var(--ink-3); letter-spacing: .04em; }

.foot { margin-top: 12px; min-height: 64px; }
.status { margin: 0; font-size: 13.5px; color: var(--ink-2); min-height: 1.4em; line-height: 1.35; }
.status b { color: var(--ink); }
.end-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.foot .record { margin: 10px 0 0; }

/* result banner (in the tray when the game ends) */
.result { display: flex; align-items: stretch; width: 100%; height: 100%; }
.result .res-h { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 0 14px; background: var(--ink); color: var(--bg); min-width: 0; }
.result.w0 .res-h { background: var(--rows); color: var(--rows-ink); }
.result.w1 .res-h { background: var(--cols); color: var(--cols-ink); }
.result .res-k { font-size: 11px; font-weight: 760; letter-spacing: .09em; text-transform: uppercase; opacity: .85; }
.result .res-t { font-weight: 900; font-stretch: 125%; font-size: 34px; line-height: 1; letter-spacing: -.02em; margin-top: 5px; white-space: nowrap; overflow: hidden; }
.result .res-s { display: grid; place-items: center; padding: 0 14px; border: 2px solid var(--ink); border-left: 0; font-weight: 900; font-stretch: 125%; font-size: clamp(22px, 7vw, 34px); white-space: nowrap; }
.result.anim .res-h { animation: slidein calc(var(--t) * 320ms) var(--ease) both; }
@keyframes slidein { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.breakdown { display: grid; gap: 6px; margin-top: 2px; }
.bd { display: flex; align-items: center; gap: 3px; min-width: 0; }
.bd .bd-l { width: 62px; flex: none; font-size: 10.5px; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd .ch { flex: 0 1 30px; min-width: 0; height: 26px; display: grid; place-items: center; font-weight: 850; font-stretch: 100%; font-size: 13px; letter-spacing: -.02em; }
.bd-r .ch { background: var(--rows); color: var(--rows-ink); }
.bd-c .ch { background: var(--cols); color: var(--cols-ink); }
.bd .ch.z { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1.5px var(--hair); }
.bd .ch.bn { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); font-size: 11.5px; }
.bd .op { font-weight: 800; color: var(--ink-3); font-size: 12px; padding: 0 1px; }
.bd .sum { flex: none; margin-left: 4px; font-weight: 900; font-stretch: 125%; font-size: 18px; }
.bd .op { flex: none; }
.aside { display: none; }

/* ---------- rules dialog ---------- */
.rules { border: 0; padding: 0; margin: auto; width: min(560px, 100vw); max-height: min(86dvh, 820px); background: var(--bg); color: var(--ink); border: var(--rule) solid var(--ink); }
.rules::backdrop { background: color-mix(in srgb, var(--ink) 55%, transparent); }
.rules[open] { animation: rin calc(var(--t) * 200ms) var(--ease); }
@keyframes rin { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.rules-in { padding: 18px 20px 22px; }
.rules-h { display: flex; justify-content: space-between; align-items: center; border-bottom: var(--rule) solid var(--ink); padding-bottom: 12px; }
.rules-h h2 { margin: 0; font-weight: 900; font-stretch: 125%; font-size: 26px; letter-spacing: -.02em; line-height: 1; }
@media (max-width: 600px) {
  .rules { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-width: var(--rule) 0 0; }
  .rules-in { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
}

/* ---------- phone tweaks ---------- */
@media (max-width: 370px) {
  :root { --pad: 12px; }
  .seg button { font-size: 13px; padding: 6px 4px; }
  .side-total { font-size: 38px; }
}

/* ---------- desktop ---------- */
@media (min-width: 960px) {
  :root { --pad: 40px; --gap: 6px; }
  .app { padding-top: 28px; padding-bottom: 28px; }
  .setup { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 64px; align-items: start; }
  .setup-intro { position: sticky; top: 28px; }
  .wordmark { font-size: 120px; font-size: min(150px, 25.5cqw); }
  .howto { display: none; }
  .tagline { font-size: 20px; margin-top: 26px; }
  .explain { display: block; margin-top: 30px; border-top: var(--rule) solid var(--ink); padding-top: 4px; }
  .setup-form .sect:first-child { margin-top: 6px; }
  .fields { grid-template-columns: 1fr 1fr; column-gap: 28px; row-gap: 18px; }
  .field.wide { grid-column: 1 / -1; }
  .opps { grid-template-columns: 1fr; }
  .go-bar { margin: 28px 0 0; padding: 14px 0 max(14px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 24px; box-shadow: 0 -16px 0 var(--bg); }
  .go-bar .record { margin: 0; flex: 1; order: 2; }
  .go-bar .go { width: auto; min-width: 360px; order: 1; }

  .game {
    display: grid; height: calc(100dvh - 56px); min-height: 600px;
    grid-template-columns: minmax(0, 1fr) 400px; grid-template-rows: auto auto auto auto 1fr; column-gap: 48px;
  }
  .gbar { grid-column: 1 / -1; }
  .board-wrap { grid-column: 1; grid-row: 2 / 6; margin-top: 24px; align-items: center; }
  .hud, .tray, .foot, .aside { grid-column: 2; }
  .aside { display: block; align-self: end; border-top: var(--rule) solid var(--ink); padding-top: 4px; margin-bottom: 2px; }
  .aside .ex-sec { margin-top: 12px; }
  .aside .ex-sec p { font-size: 13.5px; color: var(--ink-2); }
  .bd .bd-l { width: 92px; }
  .bd .ch { flex-basis: 32px; height: 30px; font-size: 14px; }
  .hud { margin-top: 24px; }
  .side-total { font-size: 64px; }
  .tray { height: 104px; margin-top: 18px; }
  .die { --s: 68px; }
  .tray .msg { font-size: 15px; }
  .foot { margin-top: 18px; }
  .status { font-size: 14.5px; }
  .result .res-s { font-size: 34px; }
}

