/* ==========================================================================
   NVP — application styles
   Order: reset, primitives, shell, menu, setup, play, overlays, responsive
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--purple-400);
  outline-offset: 3px;
  border-radius: 3px;
}

::selection { background: var(--purple-700); color: #fff; }

.sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- primitives --------------------------------------------------------- */

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--muted);
}

.mono { font-family: var(--font-mono); }
.dim { color: var(--muted); }
.faint { color: var(--faint); }

.btn {
  --btn-bg: var(--raised);
  --btn-fg: var(--text);
  --btn-line: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-2);
  min-height: 44px;
  padding: 0.6rem 1.1rem;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-line);
  border-radius: var(--radius);
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
              transform var(--fast) var(--ease), color var(--fast) var(--ease);
}

.btn:hover:not(:disabled) { border-color: var(--purple-700); background: #24242c; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn--primary {
  --btn-bg: var(--purple-500);
  --btn-fg: #12030f;
  --btn-line: var(--purple-400);
  font-weight: 700;
}
.btn--primary:hover:not(:disabled) { background: var(--purple-400); border-color: var(--purple-300); }

.btn--ghost { --btn-bg: transparent; --btn-line: var(--line); }
.btn--ghost:hover:not(:disabled) { background: var(--panel); }

.btn--quiet {
  --btn-bg: transparent;
  --btn-line: transparent;
  color: var(--muted);
  min-height: 36px;
  padding: 0.35rem 0.6rem;
}
.btn--quiet:hover:not(:disabled) { color: var(--text); background: var(--panel); border-color: var(--line); }

.btn--wide { width: 100%; }

.field {
  display: flex;
  flex-direction: column;
  gap: var(--gap-1);
}

.field input {
  width: 100%;
  /* Inputs default to an intrinsic ~20-character width, which at 320px forces
     the whole column wider than the viewport. */
  min-width: 0;
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  background: var(--sunken);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font: inherit;
}
.field input:focus { border-color: var(--purple-500); outline: none; }
.field input::placeholder { color: var(--faint); }

.field--code input {
  font-family: var(--font-mono);
  font-size: clamp(1.05rem, 4.5vw, 1.4rem);
  letter-spacing: clamp(0.12em, 2.5vw, 0.45em);
  text-align: center;
  text-transform: uppercase;
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.note {
  font-size: var(--step--1);
  color: var(--muted);
}

.alert {
  display: flex;
  gap: var(--gap-2);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--amber-700);
  background: var(--amber-900);
  color: var(--amber-300);
  font-size: var(--step--1);
}
.alert[hidden] { display: none; }

/* --- shell -------------------------------------------------------------- */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  padding: 0.7rem clamp(0.9rem, 3vw, 2rem);
  padding-top: max(0.7rem, env(safe-area-inset-top));
  padding-left: max(clamp(0.9rem, 3vw, 2rem), env(safe-area-inset-left));
  padding-right: max(clamp(0.9rem, 3vw, 2rem), env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__spacer { flex: 1; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.brand__mark { display: block; width: 26px; height: 26px; }

.brand__word {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--step-1);
  letter-spacing: 0.14em;
}

.brand:hover .brand__word { color: var(--purple-300); }

.screen {
  flex: 1;
  width: 100%;
  max-width: 68rem;
  margin: 0 auto;
  padding: clamp(1.2rem, 4vw, 3rem) clamp(1.1rem, 3vw, 2rem) var(--gap-5);
  padding-left: max(clamp(1.1rem, 3vw, 2rem), env(safe-area-inset-left));
  padding-right: max(clamp(1.1rem, 3vw, 2rem), env(safe-area-inset-right));
}

.screen--narrow { max-width: 34rem; }
.screen--play { max-width: 74rem; }

.footer {
  padding: var(--gap-3) clamp(0.9rem, 3vw, 2rem) var(--gap-4);
  padding-bottom: max(var(--gap-4), env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2) var(--gap-4);
  align-items: baseline;
  font-size: var(--step--1);
  color: var(--faint);
}
.footer a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.footer a:hover { color: var(--purple-300); border-color: var(--purple-700); }

/* --- menu --------------------------------------------------------------- */

.hero {
  display: grid;
  gap: var(--gap-4);
  padding-bottom: var(--gap-5);
}

.hero__title {
  font-size: var(--step-4);
  font-weight: 700;
  letter-spacing: var(--track-tight);
  line-height: 1;
}

/* The acronym, expanded. This is the explanation of the game and the logo at
   the same time: leading letters in a mono column, tinted by what they score. */
.keyword {
  display: grid;
  gap: var(--gap-3);
  font-family: var(--font-mono);
}

.keyword__row {
  display: grid;
  grid-template-columns: 1.6em auto;
  align-items: baseline;
  gap: 0.7rem;
}

.keyword__lead {
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1;
  text-align: center;
  border-bottom: 2px solid currentColor;
  padding-bottom: 0.12em;
}

.keyword__rest {
  font-size: var(--step-1);
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.keyword__gloss {
  grid-column: 2;
  margin-top: 0.1rem;
  font-family: var(--font-display);
  font-size: var(--step-0);
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.keyword__row--n { color: var(--text); }
.keyword__row--v .keyword__lead,
.keyword__row--v .keyword__rest { color: var(--value); }
.keyword__row--p .keyword__lead,
.keyword__row--p .keyword__rest { color: var(--position); }

.hero__lede {
  max-width: 34rem;
  color: var(--muted);
  font-size: var(--step-1);
}

.modes {
  display: grid;
  gap: var(--gap-3);
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.mode {
  display: grid;
  gap: var(--gap-2);
  padding: var(--gap-3);
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color var(--fast) var(--ease), transform var(--fast) var(--ease),
              background var(--fast) var(--ease);
}

.mode::after {
  content: '';
  position: absolute;
  inset: auto auto 0 0;
  height: 2px;
  width: 0;
  background: var(--purple-500);
  transition: width var(--slow) var(--ease);
}

.mode:hover { border-color: var(--purple-700); background: var(--raised); transform: translateY(-2px); }
.mode:hover::after { width: 100%; }

.mode__name {
  font-size: var(--step-2);
  font-weight: 700;
  letter-spacing: var(--track-tight);
}

.mode__desc { color: var(--muted); font-size: var(--step--1); }

.mode__tiles {
  display: flex;
  gap: 4px;
  margin-bottom: 0.2rem;
}

.mode__tile {
  width: 10px;
  height: 14px;
  border-radius: 2px;
  background: var(--line-strong);
}
.mode__tile--on { background: var(--purple-500); }
.mode__tile--half { background: var(--purple-900); border: 1px solid var(--purple-700); }

.topbar__status { display: flex; gap: var(--gap-1); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.pill--warn { border-color: var(--amber-700); color: var(--amber-300); background: var(--amber-900); }
.pill--action {
  border-color: var(--purple-700);
  color: var(--purple-300);
  background: var(--purple-900);
  cursor: pointer;
}
.pill--action:hover { border-color: var(--purple-500); color: var(--text); }

.install {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-2) var(--gap-3);
  padding: var(--gap-3);
  margin-bottom: var(--gap-3);
  background: var(--panel);
  border: 1px solid var(--purple-700);
  border-radius: var(--radius-lg);
}
.install__text { display: grid; gap: 0.2rem; flex: 1 1 16rem; min-width: 0; }
.install__text p:last-child { color: var(--muted); font-size: var(--step--1); }
.install__text strong { color: var(--text); }
.install__actions { display: flex; gap: var(--gap-2); flex: 0 0 auto; }

.settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2);
  margin-top: var(--gap-4);
  padding-top: var(--gap-3);
  border-top: 1px solid var(--line);
}

.chip-toggle {
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  cursor: pointer;
  transition: all var(--fast) var(--ease);
}
.chip-toggle--on {
  border-style: solid;
  border-color: var(--purple-700);
  color: var(--purple-300);
}
.chip-toggle:hover { border-color: var(--purple-500); color: var(--text); }

.mode--off { opacity: 0.45; cursor: not-allowed; }
.mode--off:hover { transform: none; border-color: var(--line); background: var(--panel); }
.mode--off:hover::after { width: 0; }

.statline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-2) var(--gap-4);
  padding-top: var(--gap-4);
  margin-top: var(--gap-4);
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
}
.statline b { color: var(--text); font-weight: 700; }

/* --- how to play -------------------------------------------------------- */

.prose { display: grid; gap: var(--gap-3); max-width: 40rem; }
.prose h2 { font-size: var(--step-2); letter-spacing: var(--track-tight); }
.prose p { color: var(--muted); }
.prose strong { color: var(--text); font-weight: 600; }

.rules { display: grid; gap: var(--gap-2); }
.rules li {
  display: grid;
  grid-template-columns: 1.2rem 1fr;
  gap: var(--gap-2);
  color: var(--muted);
}
.rules__mark {
  font-family: var(--font-mono);
  color: var(--purple-500);
}
.rules__text { min-width: 0; }

.worked {
  display: grid;
  gap: var(--gap-2);
  padding: var(--gap-3);
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* --- setup -------------------------------------------------------------- */

.setup { display: grid; gap: var(--gap-4); min-width: 0; }
/* Grid items default to min-width:auto and refuse to shrink below their
   min-content width; this lets them. */
.setup > * { min-width: 0; }

.setup__head { display: grid; gap: var(--gap-1); }
.setup__title { font-size: var(--step-3); font-weight: 700; letter-spacing: var(--track-tight); }
.setup__sub { color: var(--muted); }

.roster {
  display: grid;
  gap: var(--gap-3);
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.choices { display: grid; gap: var(--gap-2); }

.choice {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: var(--gap-3);
  padding: var(--gap-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.choice:hover { border-color: var(--purple-700); }
.choice[aria-pressed='true'] {
  border-color: var(--purple-500);
  background: color-mix(in srgb, var(--purple-900) 55%, var(--panel));
}

.choice__bars { display: flex; align-items: flex-end; gap: 3px; height: 22px; padding-top: 4px; }
.choice__bar { width: 5px; background: var(--line-strong); border-radius: 1px; }
.choice[aria-pressed='true'] .choice__bar--on { background: var(--purple-500); }
.choice__bar--on { background: var(--muted); }

.choice__name { font-weight: 700; }
.choice__desc { color: var(--muted); font-size: var(--step--1); }
.choice__pace {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--faint);
}

.switch {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  cursor: pointer;
  color: var(--muted);
  font-size: var(--step--1);
}
.switch input { accent-color: var(--purple-500); width: 18px; height: 18px; }
.switch:hover { color: var(--text); }

/* --- code pad ----------------------------------------------------------- */

.pad { display: grid; gap: var(--gap-3); justify-items: center; }

.pad__tiles {
  display: flex;
  gap: var(--gap-2);
}

.tile {
  width: clamp(2.7rem, 11vw, 3.2rem);
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  background: var(--sunken);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}

.tile--filled { border-color: var(--purple-700); background: var(--raised); }
.tile--empty { color: var(--faint); }

.tile--cursor {
  border-color: var(--purple-500);
  box-shadow: var(--glow-accent);
}

.tile--pop { animation: pop var(--fast) var(--ease); }

@keyframes pop {
  from { transform: scale(0.86); }
  to { transform: scale(1); }
}

.pad__keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-2);
  width: min(14.5rem, 100%);
}

.key {
  min-height: 44px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--step-1);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
              color var(--fast) var(--ease), opacity var(--fast) var(--ease);
}
.key:hover:not(:disabled) { background: var(--raised); border-color: var(--purple-700); }
.key:active:not(:disabled) { background: var(--purple-900); }
.key:disabled { opacity: 0.25; cursor: not-allowed; }

/* Digits the player has already ruled out stay clickable but read as spent. */
.key--out { color: var(--faint); border-style: dashed; }
.key--in { border-color: var(--position); color: var(--position); }
.key--maybe { border-color: var(--value); color: var(--value); }

/* Tools on one row, the commit action alone on the next: the primary button
   never has to share width with three others and so never wraps. */
.pad__tools {
  display: flex;
  gap: var(--gap-2);
  width: min(14.5rem, 100%);
}
.pad__tools .btn { flex: 1; padding-inline: 0.6rem; }
.pad__tools .btn--icon { flex: 0 0 3.2rem; }
/* Guessing has no Show/Random buttons, so backspace takes the whole row and
   lines up with the submit button beneath it. */
.pad__tools .btn--icon:only-child { flex: 1; }

.pad__commit { width: min(14.5rem, 100%); }
.pad__commit .btn { width: 100%; white-space: nowrap; }

.pad__hint {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--faint);
  text-align: center;
}

@media (pointer: coarse) {
  .pad__hint { display: none; }
}

/* --- notes tracker ------------------------------------------------------ */

.notes {
  display: grid;
  gap: var(--gap-2);
  padding: var(--gap-3);
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.notes__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap-2);
}

.notes__row {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 4px;
}

.pip-btn {
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--fast) var(--ease);
}
.pip-btn[data-state='in'] {
  border-color: var(--position);
  color: var(--position);
  background: var(--position-dim);
}
.pip-btn[data-state='maybe'] {
  border-color: var(--value);
  color: var(--value);
  background: var(--value-dim);
}
.pip-btn[data-state='out'] {
  color: var(--faint);
  text-decoration: line-through;
  border-style: dashed;
}

/* --- play --------------------------------------------------------------- */

.play { display: grid; gap: var(--gap-3); }

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-2) var(--gap-3);
  padding: var(--gap-2) var(--gap-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--step--1);
}

.hud__round {
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--muted);
}
.hud__round b { color: var(--text); }

.hud__turn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.hud__turn--you { border-color: var(--purple-500); color: var(--purple-300); background: var(--purple-900); }
.hud__turn--them { color: var(--muted); }

.hud__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.hud__turn--you .hud__dot { animation: breathe 1.8s var(--ease) infinite; }

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.hud__spacer { flex: 1; }

.hud__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--amber-700);
  background: var(--amber-900);
  color: var(--amber-300);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.hud__room {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: 0.2em;
  color: var(--text);
}

.boards {
  display: grid;
  gap: var(--gap-3);
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

.board {
  display: grid;
  gap: var(--gap-2);
  padding: var(--gap-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  min-height: 8rem;
}

.board--active { border-color: var(--purple-700); }

.board__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap-2);
  padding-bottom: var(--gap-2);
  border-bottom: 1px solid var(--line);
}

.board__who { font-weight: 700; letter-spacing: var(--track-tight); }
.board__who span { color: var(--muted); font-weight: 400; font-size: var(--step--1); }

.board__count { font-family: var(--font-mono); font-size: var(--step--1); color: var(--faint); }

.ledger { display: grid; gap: 2px; }

.ledger__empty {
  padding: var(--gap-3) 0;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: var(--step--1);
}

.row {
  display: grid;
  grid-template-columns: 1.6rem auto 1fr auto;
  align-items: center;
  gap: var(--gap-2);
  padding: 0.3rem 0.1rem;
  border-radius: var(--radius-sm);
}
.row + .row { border-top: 1px solid var(--line); }
.row--fresh { animation: slidein var(--slow) var(--ease); }
.row--crack { background: color-mix(in srgb, var(--position-dim) 70%, transparent); }

@keyframes slidein {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.row__no {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.row__code {
  display: flex;
  gap: 3px;
}

.row__digit {
  width: 1.55rem;
  height: 1.85rem;
  display: grid;
  place-items: center;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--step-0);
  font-variant-numeric: tabular-nums;
}

.row__pips { display: flex; gap: 3px; justify-content: flex-start; }

.pip {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
}
.pip--position { background: var(--position); border-color: var(--position); }
.pip--value { background: var(--value); border-color: var(--value); }

.row__score { display: flex; gap: var(--gap-1); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.chip b { color: var(--text); }
.chip--value { border-color: var(--amber-700); color: var(--value); }
.chip--value b { color: var(--value); }
.chip--position { border-color: var(--green-700); color: var(--position); }
.chip--position b { color: var(--position); }

.console {
  display: grid;
  gap: var(--gap-3);
  padding: var(--gap-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.console--live { border-color: var(--purple-700); box-shadow: 0 0 40px -26px var(--purple-500); }

.console__grid {
  display: grid;
  gap: var(--gap-4);
  grid-template-columns: minmax(0, 1fr) minmax(0, 20rem);
  align-items: start;
}

.console__status {
  display: grid;
  gap: var(--gap-1);
  place-items: center;
  padding: var(--gap-4) var(--gap-3);
  text-align: center;
}

.console__status-title {
  font-size: var(--step-2);
  font-weight: 700;
  letter-spacing: var(--track-tight);
}

/* Same shape as .overlay__actions but scoped to the console, so the two sets of
   end-of-match buttons stay independently styleable and unambiguous. */
.console__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap-2);
  width: 100%;
  max-width: 30rem;
  margin-top: var(--gap-2);
}
.console__actions .btn { flex: 1 1 9rem; }

.thinking {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  margin-top: var(--gap-2);
}
.thinking span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--purple-500);
  animation: bounce 1.1s var(--ease) infinite;
}
.thinking span:nth-child(2) { animation-delay: 0.14s; }
.thinking span:nth-child(3) { animation-delay: 0.28s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.segmented {
  display: none;
  gap: 2px;
  padding: 3px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.segmented button {
  flex: 1;
  min-height: 38px;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.segmented button[aria-pressed='true'] { background: var(--raised); color: var(--text); }

/* --- overlays (handoff + result) --------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: var(--gap-3);
  padding-top: max(var(--gap-3), env(safe-area-inset-top));
  padding-bottom: max(var(--gap-3), env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg-deep) 94%, transparent);
  backdrop-filter: blur(14px);
  animation: fade var(--slow) var(--ease);
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* The result overlay can be translucent — the match is over and there is nothing
   left to hide. The handoff gate cannot: someone is about to look at this screen
   who must not see what is behind it. */
.overlay--gate {
  background: var(--bg-deep);
  backdrop-filter: none;
}

.overlay__card {
  width: min(30rem, 100%);
  display: grid;
  gap: var(--gap-3);
  padding: var(--gap-4);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  text-align: center;
  justify-items: center;
}

.overlay__title {
  font-size: var(--step-3);
  font-weight: 700;
  letter-spacing: var(--track-tight);
  line-height: 1.1;
}
.overlay__title--win { color: var(--position); }
.overlay__title--loss { color: var(--value); }

.overlay__body { color: var(--muted); }

.overlay__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2);
  width: 100%;
}
.overlay__actions .btn { flex: 1 1 9rem; }

.reveal {
  display: grid;
  gap: var(--gap-2);
  width: 100%;
  padding: var(--gap-3);
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.reveal__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-3);
}

.reveal__label { font-size: var(--step--1); color: var(--muted); text-align: left; }
.reveal__code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--step-1);
  letter-spacing: 0.28em;
}

/* --- online lobby ------------------------------------------------------- */

.joinrow {
  display: flex;
  gap: var(--gap-2);
  align-items: stretch;
}
.joinrow .field { flex: 1; min-width: 0; }
.joinrow .btn { flex: 0 0 auto; padding-inline: 1.3rem; }

.roomcode {
  display: grid;
  gap: var(--gap-2);
  justify-items: center;
  padding: var(--gap-4);
  background: var(--sunken);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.roomcode__value {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 12vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  color: var(--purple-300);
}

.waiting {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-2);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
}

.spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--purple-500);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(1turn); } }

.offline-note {
  display: flex;
  gap: var(--gap-2);
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--sunken);
  color: var(--muted);
  font-size: var(--step--1);
}

/* --- responsive --------------------------------------------------------- */

@media (max-width: 60rem) {
  .console__grid { grid-template-columns: 1fr; }
  .console__grid > .notes { order: 2; }
}

@media (max-width: 34rem) {
  .topbar .eyebrow { display: none; }
}

@media (max-width: 46rem) {
  .boards { grid-template-columns: 1fr; }
  .segmented { display: flex; }
  .board[data-hidden='true'] { display: none; }
  .hero { padding-bottom: var(--gap-4); }

  .console, .board { padding: var(--gap-2); }
  .install { flex-direction: column; align-items: stretch; }
  .install__actions .btn { flex: 1; }
  .console__status { padding: var(--gap-3) var(--gap-2); }
  .overlay__card { padding: var(--gap-3); }
  /* Stack end-of-match buttons rather than squeezing three or four onto a row
     where the labels would truncate. */
  .overlay__actions .btn,
  .console__actions .btn { flex: 1 1 100%; }
}

@media (max-width: 26rem) {
  .row { grid-template-columns: 1.3rem auto 1fr auto; gap: var(--gap-1); }
  .row__digit { width: 1.4rem; font-size: var(--step--1); }
  .hud { padding: var(--gap-2); gap: var(--gap-1) var(--gap-2); }
}

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

/* --- daily ------------------------------------------------------------- */

.daily-card {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  width: 100%;
  padding: var(--gap-3);
  margin-bottom: var(--gap-3);
  text-align: left;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--purple-900) 55%, var(--panel)),
    var(--panel)
  );
  border: 1px solid var(--purple-700);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.daily-card:hover { border-color: var(--purple-500); transform: translateY(-2px); }
.daily-card__text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.daily-card__title {
  font-size: var(--step-2);
  font-weight: 700;
  letter-spacing: var(--track-tight);
}
.daily-card__sub { color: var(--muted); font-size: var(--step--1); }
.daily-card__streak {
  font-family: var(--font-mono);
  font-size: var(--step-1);
  color: var(--amber-300);
  flex: 0 0 auto;
}

.daily__head { display: grid; gap: var(--gap-1); margin-bottom: var(--gap-3); }
.daily__streak { font-family: var(--font-mono); color: var(--amber-300); }
.daily__play { display: grid; gap: var(--gap-3); margin-top: var(--gap-3); }
.daily__done { display: grid; gap: var(--gap-3); justify-items: center; text-align: center; }

/* The share grid, shown exactly as it will be pasted. */
.daily__grid {
  margin: 0;
  padding: var(--gap-3);
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--step-1);
  line-height: 1.35;
  letter-spacing: 2px;
  text-align: center;
}

.daily__countdown {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
}

.histogram { display: grid; gap: 3px; width: 100%; margin-top: var(--gap-3); }
.histogram__row { display: grid; grid-template-columns: 1.2rem 1fr; gap: var(--gap-2); align-items: center; }
.histogram__label { font-family: var(--font-mono); font-size: var(--step--1); color: var(--faint); }
.histogram__bar {
  background: var(--raised);
  border-radius: 3px;
  padding: 2px 6px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
}
.histogram__bar--current { background: var(--purple-700); color: var(--text); }

@media (max-width: 46rem) {
  .daily-card { flex-direction: row; }
}
