/* Steward: the colony as a pixel board on a table, every question a card in your hand. */

/* Both faces are self-hosted from public/fonts under the SIL Open Font License (licences beside them). */
@font-face { font-family: "VT323"; src: url("fonts/vt323-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Silkscreen"; src: url("fonts/silkscreen-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
:root {
  --ink: #050a14;        /* the gap inside every frame, and text on light chips */
  --deep: #0b1529;       /* the table at its edges */
  --table: #0d1830;      /* the table */
  --panel: #101d33;      /* a card face, a panel */
  --raised: #142640;     /* a hovered or open surface */
  --line: #1f3657;       /* quiet dividers and unlit pips */
  --ice: #e8f1ff;        /* text */
  --dim: #a8bad2;        /* secondary text */
  --mute: #8197bb;       /* tertiary text */
  --cyan: #4de3ff;       /* your signal: frames, focus, the mast */
  --gold: #ffd166;       /* reach and insight */
  --coral: #ff5d8f;      /* critical, failing, loss */
  --good: #8fe0a8;       /* gain */
  --plinth: #081122;     /* the shadow a frame casts on the table */

  --ring: 0 0 0 2px var(--ink), 0 0 0 5px var(--cyan), 0 5px 0 5px var(--plinth);
  --ring-quiet: 0 0 0 2px var(--ink), 0 0 0 4px var(--line);

  --display: "Silkscreen", "VT323", ui-monospace, monospace;   /* multiples of 8px only: its pixel grid */
  --label: 18px/1 "VT323", ui-monospace, monospace;            /* small capitals labels */
  --step: steps(4, end);                                        /* pixel things move in steps */
  --body: "VT323", ui-monospace, monospace;
  --gutter: 28px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--table);
  color: var(--ice);
  font: 20px/1.15 var(--body);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);   /* never let the hand widen the page */
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: none;
  font-smooth: never;
}
::selection { background: var(--cyan); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
textarea { caret-color: var(--cyan); }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); }
::-webkit-scrollbar-track { background: transparent; }

.px { width: 16px; height: 16px; display: block; flex-shrink: 0; }
.short { display: none; }
[data-icon] { display: inline-flex; }

/* ── the sky ── */
.sky { position: relative; height: 112px; overflow: hidden; background: #44679f; }
#skyc { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.sky-row { position: relative; height: 100%; display: flex; align-items: center; gap: 24px; padding: 0 var(--gutter); }
.mark { margin-right: auto; }
.word {
  font: 400 40px/1 var(--display);
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--ice);
  text-shadow: -3px 0 0 var(--cyan), 3px 0 0 var(--coral), 0 4px 0 var(--table);
}
.role { display: inline-block; margin-top: 10px; padding: 2px 8px; font-size: 20px; letter-spacing: 1.5px; color: var(--ice); background: var(--table); }
.clock { display: flex; align-items: center; gap: 16px; }
.day {
  font: 400 16px/1 var(--display); letter-spacing: 2px; text-transform: uppercase;
  background: var(--table); color: var(--gold); padding: 10px 12px; box-shadow: var(--ring-quiet);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.speed { display: flex; background: var(--table); box-shadow: var(--ring-quiet); }
.speed button { width: 40px; height: 36px; display: grid; place-items: center; color: var(--mute); }
.speed button:hover { color: var(--ice); background: var(--raised); }
.speed button.on { background: var(--cyan); color: var(--ink); }

/* your tools, in the sky beside the clock */
.deck { display: flex; align-items: center; gap: 12px; }
.deck button {
  position: relative; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  background: var(--table); box-shadow: var(--ring-quiet);
  font: var(--label); letter-spacing: 1px; text-transform: uppercase; color: var(--dim);
}
.deck button:hover, .deck button[aria-expanded="true"] { background: var(--raised); color: var(--ice); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--cyan); }
.deck button .px { color: var(--cyan); }
.deck button.quiet { padding: 0 10px; }
.deck button.quiet .px { color: var(--mute); }
.deck button.quiet:hover .px { color: var(--ice); }
.count { position: absolute; right: -8px; top: -9px; font: var(--label); font-style: normal; background: var(--gold); color: var(--ink); padding: 1px 5px; box-shadow: 0 0 0 2px var(--ink); }
.count:empty { display: none; }

/* ── the table ── */
.table {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 210px;
  gap: 28px;
  padding: 8px var(--gutter) 8px;
  min-height: 0;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 55%, rgba(5, 10, 20, .35) 100%),
    var(--table);
}

/* measures: one track per measure, segmented like a board's scoring track */
.measures { min-height: 0; display: flex; flex-direction: column; justify-content: center; }
.tracks { display: flex; flex-direction: column; gap: 14px; }
.stat { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 5px 8px; }
.stat label { font: var(--label); letter-spacing: 1px; text-transform: uppercase; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .val { font-size: 22px; line-height: .8; color: var(--ice); font-variant-numeric: tabular-nums; }
.stat .seg { grid-column: 1 / 3; }
.seg { display: flex; gap: 2px; height: 10px; }
.seg > b { flex: 1; background: var(--ink); box-shadow: 0 0 0 1px var(--line); transition: background .2s steps(1, end); }
.seg > b.on { background: var(--c, var(--cyan)); box-shadow: 0 0 0 1px var(--ink); }
.stat.low label, .stat.low .val { color: var(--coral); }
.stat.low .seg > b.on { animation: blink 1s steps(2, jump-none) infinite; }
@keyframes blink { 50% { background: var(--coral); } }

/* the board, with the reach track running right round its frame */
.boardwrap { min-width: 0; min-height: 0; display: flex; padding: 24px; }
.board { position: relative; flex: 1; min-height: 0; box-shadow: var(--ring); background: #1d3b2b; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; display: block; touch-action: manipulation; }
.track { position: absolute; inset: -24px; pointer-events: none; --t: 10px; }
.tk { position: absolute; display: flex; gap: 3px; }
.tk-t { left: 0; right: 0; top: 0; height: var(--t); }
.tk-b { left: 0; right: 0; bottom: 0; height: var(--t); flex-direction: row-reverse; }
.tk-r { right: 0; top: calc(var(--t) + 3px); bottom: calc(var(--t) + 3px); width: var(--t); flex-direction: column; }
.tk-l { left: 0; top: calc(var(--t) + 3px); bottom: calc(var(--t) + 3px); width: var(--t); flex-direction: column-reverse; }
.tk i { flex: 1; background: var(--line); box-shadow: 0 0 0 1px var(--ink); }
.tk i.on { background: var(--gold); }
.tk i.goal { background: var(--ink); box-shadow: 0 0 0 2px var(--gold); }

/* reach: the score, large, at the board's right */
.reach { display: flex; flex-direction: column; justify-content: center; gap: 6px; min-width: 0; color: var(--dim); font-size: 20px; line-height: 1.1; }
.reach-now { font: 400 64px/1 var(--display); color: var(--gold); letter-spacing: 0; font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.reach-now.mid { font-size: 48px; }
.reach-now.long { font-size: 32px; }
.reach-of { color: var(--ice); }
.reach-stage { margin-top: 14px; }
.reach-stage span:first-child { color: var(--cyan); }
.reach-next { color: var(--mute); }

/* events on the board: the crisis card and the Ark */
.event {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  width: min(440px, calc(100% - 36px));
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px 14px;
  padding: 12px 14px; background: var(--panel);
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px var(--coral), 0 5px 0 5px var(--plinth);
  z-index: 2;
}
.event > [data-icon] { color: var(--coral); }
.event .px { width: 24px; height: 24px; }
.event .btn { grid-column: 2; justify-self: start; }
.event b { display: block; font: 400 16px/1.1 var(--display); letter-spacing: 1px; text-transform: uppercase; }
.event span { display: block; color: var(--dim); font-size: 19px; margin-top: 2px; }
.event.cut { animation: alarm 1.2s steps(2, jump-none) infinite; }
@keyframes alarm { 50% { box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px var(--ink), 0 5px 0 5px var(--plinth); } }
.event-ark { top: auto; bottom: 18px; box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px var(--gold), 0 5px 0 5px var(--plinth); }
.event-ark > [data-icon] { color: var(--gold); }
.event-ark .seg { margin-top: 6px; --c: var(--gold); }

/* toasts: outcome slips dealt onto the board's corner */
.toasts { position: absolute; left: 16px; bottom: 16px; width: min(340px, calc(100% - 32px)); display: flex; flex-direction: column-reverse; gap: 12px; pointer-events: none; z-index: 2; }
.toast { padding: 10px 12px; background: var(--panel); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--good); animation: deal .3s var(--step); }
.toast.bad { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--coral); }
.toast b { font: 400 16px/1.2 var(--display); letter-spacing: 1px; text-transform: uppercase; }
.toast p { margin: 4px 0 6px; color: var(--dim); font-size: 19px; }
@keyframes deal { from { translate: 0 16px; opacity: 0; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 17px; line-height: 1; padding: 3px 6px; background: var(--ink); color: var(--good); }
.chip.dn { color: var(--coral); }

/* ── the hand: a fan of cards centred under the board, compute tokens beside it ── */
.hand-row { display: flex; justify-content: center; align-items: flex-end; gap: 28px; padding: 0 var(--gutter) 10px; min-height: 0; }
.tokens { flex-shrink: 0; padding-bottom: 14px; }
.tokens-label { display: block; font: var(--label); letter-spacing: 1px; text-transform: uppercase; color: var(--dim); margin-bottom: 8px; }
.pips { display: grid; grid-template-columns: repeat(4, 22px); gap: 7px; }
.pips i { width: 22px; height: 22px; display: grid; place-items: center; background: var(--ink); box-shadow: 0 0 0 2px var(--line); color: var(--line); }
.pips i .px { width: 14px; height: 14px; }
.pips i.on { background: var(--cyan); box-shadow: 0 0 0 2px var(--ink); color: var(--ink); }
.pips i.half { background: linear-gradient(90deg, var(--cyan) 50%, var(--ink) 50%); box-shadow: 0 0 0 2px var(--ink); color: transparent; }
.tokens small { display: block; margin-top: 8px; font-size: 18px; color: var(--mute); }

.hand { display: flex; align-items: flex-end; min-width: 0; min-height: 276px; padding: 30px 8px 30px; --ov: -12px; }
.card {
  --suit: var(--cyan);
  position: relative; flex: 0 0 172px; height: 196px; margin-left: var(--ov);
  display: flex; flex-direction: column; gap: 6px; padding: 12px 12px 10px;
  text-align: left; background: var(--panel); color: var(--ice);
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px var(--suit), 0 6px 0 5px var(--plinth);
  translate: 0 var(--y, 0px); rotate: var(--r, 0deg); transform-origin: 50% 100%;
  transition: translate .2s var(--step), rotate .2s var(--step);
  animation: deal .3s var(--step) backwards;
}
.card:first-child, .offline-card + .card { margin-left: 0; }
.card:hover, .card:focus-visible { translate: 0 -16px; rotate: 0deg; z-index: 5; }
.card.lead { flex-basis: 220px; height: 230px; translate: 0 -14px; rotate: 0deg; z-index: 2; }
.card.lead + .card { margin-left: 8px; }
.card.lead:hover, .card.lead:focus-visible { translate: 0 -22px; z-index: 5; }
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-suit { display: flex; gap: 3px; color: var(--suit); flex-shrink: 0; padding-top: 1px; }
.card-suit .px { width: 18px; height: 18px; }
.card-who { min-width: 0; }
.card-who b { display: block; font-weight: 400; font-size: 21px; line-height: 1; overflow-wrap: anywhere; }
.card-who small { color: var(--mute); font-size: 17px; }
.card-q { font-size: 19px; line-height: 20px; max-height: 80px; color: var(--dim); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.card.lead .card-q { max-height: 100px; -webkit-line-clamp: 5; color: var(--ice); }
.card-foot { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; min-height: 18px; }
.card-foot .card-suit { rotate: 180deg; padding: 0; }
.card-state { font-size: 17px; line-height: 1; color: var(--cyan); }
.timer { display: block; height: 6px; background: var(--ink); flex-shrink: 0; }
.timer i { display: block; height: 100%; background: var(--suit); }
.timer i.late { background: var(--coral); animation: blinkfill .5s steps(2, jump-none) infinite; }
@keyframes blinkfill { 50% { opacity: .35; } }
.card.crit { --suit: var(--coral); background: #24152a; }
.card.council { --suit: var(--gold); }
.card.agent { background: #0c1628; --suit: var(--line); }
.card.agent .card-suit { color: var(--mute); }
.card.agent .card-q, .card.agent .card-who { opacity: .55; }
.card.proc .card-state { animation: blinkfill 1s steps(2, jump-none) infinite; }
.card.dark { filter: grayscale(1) brightness(.6); pointer-events: none; }
.hand-empty { align-self: center; color: var(--mute); font-size: 20px; padding: 0 4px 30px; max-width: 46ch; text-align: center; }
.offline-card {
  flex: 0 0 292px; height: 196px; padding: 14px; display: flex; flex-direction: column; gap: 8px; margin-right: 22px;
  background: #24152a; box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px var(--coral), 0 6px 0 5px var(--plinth);
}
.offline-card b { font: 400 16px/1.1 var(--display); letter-spacing: 1px; text-transform: uppercase; color: var(--coral); }
.offline-card p { color: var(--dim); font-size: 19px; flex: 1; }

/* ── buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px 18px; background: var(--panel); color: var(--ice);
  font: 400 16px/1 var(--display); letter-spacing: 1px; text-transform: uppercase;
  box-shadow: var(--ring);
}
.btn:hover:not(:disabled) { background: var(--raised); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px var(--cyan), 0 3px 0 5px var(--plinth); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--cyan); color: var(--ink); box-shadow: 0 0 0 2px var(--ink), 0 5px 0 2px var(--plinth); }
.btn-primary:hover:not(:disabled) { background: #8beeff; }
.btn-crit { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--coral); padding: 9px 12px; }
.btn-gold { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--gold); padding: 9px 12px; }
.btn-ghost { box-shadow: var(--ring-quiet); background: transparent; color: var(--dim); }
.btn-ghost:hover:not(:disabled) { color: var(--ice); }
.link { color: var(--cyan); text-decoration: underline; text-underline-offset: 3px; font-size: 18px; }
.link:hover { color: var(--ice); }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; color: var(--dim); box-shadow: var(--ring-quiet); }
.icon-btn:hover { color: var(--ice); background: var(--raised); }
kbd { font: var(--label); text-transform: uppercase; background: var(--ink); color: var(--cyan); padding: 1px 6px; }

/* ── the drawer: outcomes, agents, training ── */
.drawer {
  position: fixed; top: 128px; right: 24px; bottom: 24px; width: min(440px, calc(100% - 48px)); z-index: 12;
  display: flex; flex-direction: column; background: var(--table); box-shadow: var(--ring);
  animation: slide .3s var(--step);
}
@keyframes slide { from { translate: 24px 0; opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 12px; }
.drawer-head h2 { font: 400 24px/1 var(--display); letter-spacing: 2px; text-transform: uppercase; }
.pane { flex: 1; overflow-y: auto; padding: 4px 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.note { color: var(--dim); font-size: 19px; line-height: 1.2; }
.note b { color: var(--gold); font-weight: 400; }
.empty { color: var(--mute); font-size: 20px; line-height: 1.2; padding: 12px 0; }
.entry { padding: 10px 12px; background: var(--panel); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--line); flex-shrink: 0; }
.entry.good { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px #2c5a45; }
.entry.bad { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px #5a2c41; }
.eh { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.eh b { font-weight: 400; font-size: 21px; }
.eh span { color: var(--mute); font-size: 16px; white-space: nowrap; }
.entry p { margin: 4px 0 8px; color: var(--dim); font-size: 19px; line-height: 1.15; }
.said { color: var(--cyan) !important; }
.dept { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--panel); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--line); flex-shrink: 0; }
.dh { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dh b { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 21px; }
.dh b .px { color: var(--suit, var(--cyan)); }
.dept small { color: var(--mute); font-size: 18px; line-height: 1.15; min-height: 1em; }
.dept small b { color: var(--ice); font-weight: 400; }
.dept select {
  appearance: none; background: var(--ink); color: var(--ice); border: 0; box-shadow: 0 0 0 2px var(--line); padding: 7px 10px; font-size: 19px;
  background-image: linear-gradient(45deg, transparent 50%, var(--cyan) 50%), linear-gradient(-45deg, transparent 50%, var(--cyan) 50%);
  background-size: 6px 6px; background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%; background-repeat: no-repeat;
}
.lv { display: flex; gap: 5px; }
.lv i { width: 12px; height: 12px; background: var(--ink); box-shadow: 0 0 0 2px var(--line); }
.lv i.on { background: var(--gold); box-shadow: 0 0 0 2px var(--ink); }
.train { align-self: flex-start; }

/* ── dialogs ── */
#modal, #puzzle, #settings, #overlay {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(5, 10, 20, .72);
}
#puzzle { z-index: 22; } #settings { z-index: 23; } #overlay { z-index: 25; background: rgba(5, 10, 20, .86); }
.dialog {
  --suit: var(--cyan);
  width: min(680px, 100%); max-height: 100%; overflow-y: auto;
  padding: 22px 24px 18px; background: var(--table);
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 6px var(--suit), 0 8px 0 6px var(--plinth);
  animation: lift .3s var(--step);
}
@keyframes lift { from { translate: 0 16px; opacity: 0; } }
.dialog.critd { --suit: var(--coral); }
.mh { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mh .suit { color: var(--suit); }
.mh .suit .px { width: 28px; height: 28px; }
.mh b { font-weight: 400; font-size: 26px; line-height: 1; }
.mrole { color: var(--mute); font-size: 20px; }
.cat { font: var(--label); letter-spacing: 1px; text-transform: uppercase; color: var(--suit); }
.mtrust { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 18px; }
.mtrust .seg { width: 80px; --c: var(--cyan); }
blockquote { margin: 18px 0 18px; font-size: 28px; line-height: 1.1; color: var(--ice); }
.warn { color: var(--coral); font-size: 19px; margin: -4px 0 14px; }
.dialog label, .lbl { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font: var(--label); letter-spacing: 1px; text-transform: uppercase; color: var(--dim); }
.lcost { font: 18px var(--body); letter-spacing: 0; text-transform: none; color: var(--cyan); }
#reply {
  width: 100%; margin: 10px 0 10px; padding: 12px 14px; resize: vertical; min-height: 92px;
  background: var(--ink); color: var(--ice); border: 0; box-shadow: 0 0 0 2px var(--line); font-size: 21px; line-height: 1.15;
}
#reply:focus { outline: none; box-shadow: 0 0 0 2px var(--cyan); }
#reply::placeholder { color: var(--mute); }
#reply:disabled { opacity: .55; }
.sendrow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.sendrow > .err { flex: 1 1 100%; }
.sendrow .hintline { flex: 1; color: var(--mute); font-size: 18px; }
.err { color: var(--coral); font-size: 18px; }
.err:empty { display: none; }
.opts { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 18px; }
.opts button {
  display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start; text-align: left;
  padding: 11px 14px 11px 10px; background: var(--panel); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--line);
  font-size: 20px; line-height: 1.12; color: var(--dim);
}
.opts button .cur { color: transparent; padding-top: 2px; }
.opts button kbd { grid-column: 1; grid-row: 1; justify-self: center; margin-top: 1px; }
.opts button:hover:not(:disabled), .opts button:focus-visible { background: var(--raised); color: var(--ice); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--cyan); outline: none; }
.opts button:hover:not(:disabled) kbd, .opts button:focus-visible kbd { background: var(--cyan); color: var(--ink); }
.opts button:disabled { opacity: .45; cursor: not-allowed; }
.opts button.risky { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px #5a2c41; }
.flag { display: block; margin-top: 6px; color: var(--coral); font-style: normal; font-size: 17px; }
.mf { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; color: var(--mute); font-size: 18px; }

/* sheets: intro, stage, crisis, game over */
.sheet {
  width: min(580px, 100%); max-height: 100%; overflow-y: auto; padding: 30px 32px 28px; background: var(--table);
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 6px var(--cyan), 0 8px 0 6px var(--plinth);
  animation: lift .3s var(--step);
}
.sheet.alarm { box-shadow: 0 0 0 2px var(--ink), 0 0 0 6px var(--coral), 0 8px 0 6px var(--plinth); }
.sheet.gold { box-shadow: 0 0 0 2px var(--ink), 0 0 0 6px var(--gold), 0 8px 0 6px var(--plinth); }
.sheet h1 { font: 400 40px/1 var(--display); letter-spacing: 2px; text-transform: uppercase; text-wrap: balance; }
.sheet .meta { margin: 10px 0 20px; font-size: 20px; color: var(--cyan); letter-spacing: 1px; }
.sheet.alarm .meta { color: var(--coral); }
.sheet.gold .meta { color: var(--gold); }
.sheet p { font-size: 21px; line-height: 1.2; color: var(--dim); margin-bottom: 12px; max-width: 60ch; }
.sheet p b { color: var(--ice); font-weight: 400; }
.sheet .dim { color: var(--mute); }
.rules { list-style: none; padding: 0; margin: 18px 0 24px; display: flex; flex-direction: column; gap: 10px; }
.rules li { display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start; font-size: 20px; line-height: 1.15; color: var(--dim); }
.rules li .px { color: var(--cyan); margin-top: 2px; }
.rules li b { color: var(--ice); font-weight: 400; }
.sheet .btn { margin-top: 10px; }

/* the reconnection puzzles */
.puzzle { width: min(460px, 100%); --suit: var(--coral); --wire: var(--gold); }
.p-drain { --wire: #5aa9f0; }
.p-relay { --wire: var(--good); }
.ptext { color: var(--dim); font-size: 20px; line-height: 1.15; margin: 12px 0 18px; }
.grid { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; margin: 0 auto 18px; width: min(340px, 100%); }
.tile { position: relative; aspect-ratio: 1; background: var(--ink); box-shadow: 0 0 0 2px var(--line); --w: #2a3b55; }
.tile:hover { box-shadow: 0 0 0 2px var(--mute); }
.tile.lit { --w: var(--wire); }
.tile .arm { position: absolute; background: var(--w); }
.tile .a0 { left: 40%; width: 20%; top: 0; height: 50%; }
.tile .a1 { top: 40%; height: 20%; left: 50%; width: 50%; }
.tile .a2 { left: 40%; width: 20%; top: 50%; height: 50%; }
.tile .a3 { top: 40%; height: 20%; left: 0; width: 50%; }
.tile .hub { position: absolute; left: 32%; top: 32%; width: 36%; height: 36%; background: var(--w); display: grid; place-items: center; font-style: normal; color: var(--ink); }
.tile.src .hub { left: 22%; top: 22%; width: 56%; height: 56%; }
.tile.src .hub .px { width: 60%; height: 60%; }
.tile.relay .hub { left: 22%; top: 22%; width: 56%; height: 56%; }
.puzzle.solved .grid { animation: surge .5s steps(3, end); }
@keyframes surge { 50% { filter: brightness(1.6); } }
.pstat { color: var(--dim); font-size: 19px; }

/* judging settings */
.jdialog { --suit: var(--cyan); width: min(580px, 100%); }
.jopt { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; margin-bottom: 12px; cursor: pointer; background: var(--panel); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--line); font: 20px var(--body); letter-spacing: 0; text-transform: none; color: var(--ice); }
.jopt:has(input:checked) { background: var(--raised); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--cyan); }
.jopt input[type=radio] { appearance: none; width: 16px; height: 16px; margin: 3px 0 0; flex-shrink: 0; background: var(--ink); box-shadow: 0 0 0 2px var(--line); }
.jopt input[type=radio]:checked { background: var(--cyan); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--cyan); }
.jopt > div { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.jopt b { font: 400 16px/1.2 var(--display); letter-spacing: 1px; text-transform: uppercase; }
.jopt small { color: var(--dim); font-size: 18px; line-height: 1.15; }
.jopt a { color: var(--cyan); text-underline-offset: 3px; }
.jopt input[type=password], .jopt select { background: var(--ink); color: var(--ice); border: 0; box-shadow: 0 0 0 2px var(--line); padding: 7px 9px; font-size: 18px; width: 100%; }
.jopt input[type=password]:focus { outline: none; box-shadow: 0 0 0 2px var(--cyan); }
.jdialog .hintline { color: var(--mute); font-size: 18px; margin: 6px 0 14px; }
.jbtns { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ── large screens: room to breathe ── */
@media (min-width: 1500px) {
  .table { grid-template-columns: 240px minmax(0, 1fr) 240px; gap: 40px; padding-inline: 44px; }
  .hand-row { padding-inline: 44px; gap: 36px; }
}

/* ── narrower desktops: tools become icons, the side columns tighten ── */
@media (max-width: 1180px) {
  .table { grid-template-columns: 168px minmax(0, 1fr) 168px; gap: 20px; }
  .deck { gap: 10px; }
  .deck button { padding: 0 10px; }
  .deck button .full { display: none; }
  .word { font-size: 32px; letter-spacing: 3px; }
  .reach-now { font-size: 48px; }
  .reach-now.mid { font-size: 40px; }
  .reach-now.long { font-size: 24px; }
}

/* ── phones and small tablets: sky, measures, board, reach, tools, hand, stacked ── */
@media (max-width: 760px) {
  :root { --gutter: 14px; }
  body { font-size: 19px; }
  .sky { height: 64px; }
  .sky-row { gap: 10px; }
  .word { font-size: 24px; letter-spacing: 2px; padding: 4px 8px 6px; background: var(--table); text-shadow: 2px 0 0 var(--coral); }
  .role { display: none; }
  .clock { gap: 10px; }
  .day { padding: 8px 8px; letter-spacing: 1px; }
  .speed button { width: 34px; height: 32px; }
  .speed button[data-s="4"] { display: none; }

  .table { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 8px; padding: 10px var(--gutter) 6px; }
  .tracks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 12px; }
  .stat label { font-size: 17px; letter-spacing: .5px; text-transform: none; }
  .stat .val { font-size: 18px; }
  .seg { height: 7px; gap: 1px; }
  .boardwrap { padding: 16px; }
  .track { inset: -16px; --t: 6px; }
  .tk { gap: 2px; }
  .event { top: 10px; grid-template-columns: auto 1fr; padding: 9px 10px; gap: 10px; }
  .event .btn { grid-column: 1 / 3; justify-self: stretch; }
  .event span { font-size: 17px; }
  .toasts { left: 10px; bottom: 10px; width: calc(100% - 20px); }
  .toast p { font-size: 17px; }

  .reach { flex-direction: row; align-items: baseline; justify-content: flex-start; gap: 8px; font-size: 18px; white-space: nowrap; overflow: hidden; }
  .reach-now, .reach-now.mid, .reach-now.long { font-size: 24px; letter-spacing: 1px; margin: 0; }
  .reach-stage { margin: 0 0 0 auto; }
  .reach-next { display: none; }

  .full { display: none; }
  .short { display: inline; }
  .deck { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding: 3px 3px 5px; }
  .deck button { flex-direction: column; justify-content: center; height: auto; gap: 3px; padding: 6px 2px 5px; background: var(--panel); font-size: 17px; letter-spacing: .5px; text-transform: none; }
  .deck button.quiet { padding: 6px 2px 5px; }
  .count { right: -4px; top: -7px; }

  .hand-row { flex-direction: column; align-items: stretch; gap: 4px; padding: 0 0 calc(8px + env(safe-area-inset-bottom)); }
  .tokens { display: flex; align-items: center; gap: 10px; padding: 0 var(--gutter); }
  .tokens-label { margin: 0; text-transform: none; letter-spacing: .5px; }
  .pips { display: flex; gap: 5px; }
  .pips i { width: 18px; height: 18px; }
  .pips i .px { width: 11px; height: 11px; }
  .tokens small { margin: 0 0 0 auto; font-size: 17px; }
  .hand { min-height: 0; padding: 18px var(--gutter) 10px; gap: 14px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; }
  .card { flex: 0 0 150px; height: 168px; margin-left: 0; padding: 10px 10px 8px; translate: none; rotate: none; scroll-snap-align: center; }
  .card.lead { flex-basis: 178px; height: 178px; translate: none; }
  .card.lead + .card { margin-left: 0; }
  .card:hover, .card:focus-visible, .card.lead:hover, .card.lead:focus-visible { translate: 0 -8px; }
  .card-who b { font-size: 19px; }
  .card-q { font-size: 17px; line-height: 18px; max-height: 54px; -webkit-line-clamp: 3; }
  .card.lead .card-q { max-height: 72px; -webkit-line-clamp: 4; }
  .offline-card { flex-basis: 240px; height: 168px; margin-right: 0; }

  .drawer { top: 0; right: 0; bottom: 0; left: 0; width: auto; box-shadow: none; }
  #modal, #puzzle, #settings, #overlay { padding: 12px; align-items: flex-end; }
  .dialog, .sheet { padding: 18px 16px 16px; max-height: calc(100dvh - 24px); }
  blockquote { font-size: 23px; margin: 14px 0; }
  .opts button { font-size: 19px; }
  .sheet h1 { font-size: 24px; letter-spacing: 1px; }
  .sheet p, .rules li { font-size: 19px; }
  .mtrust { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

