/* Countdown Duel - mobile-first */

:root {
  --bg0: #070d1f;
  --bg1: #0c1733;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-line: rgba(255, 255, 255, 0.09);
  --ink: #f2f5ff;
  --ink-dim: rgba(226, 232, 250, 0.62);
  --ink-faint: rgba(226, 232, 250, 0.38);
  --tile1: #2447c5;
  --tile2: #16307f;
  --tile-edge: #4a6df0;
  --accent: #fbbf24;
  --accent-ink: #201503;
  --good: #34d399;
  --bad: #fb7185;
  --led: #ff4d42;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(120% 90% at 50% -10%, var(--bg1) 0%, var(--bg0) 62%) fixed, var(--bg0);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

/* Backstop: nothing may ever push the page sideways on a phone. */
#app { overflow-x: hidden; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(var(--sat) + 14px) 16px calc(var(--sab) + 22px);
  display: flex;
  flex-direction: column;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: 0.38; cursor: default; }

input {
  font: inherit;
  color: var(--ink);
}

h1, h2, h3 { margin: 0; font-weight: 800; }

.screen { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ---------- shared bits ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  padding: 16px;
  backdrop-filter: blur(8px);
}

.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 12px 18px;
  transition: transform 0.06s ease, filter 0.12s ease;
}
.btn:active:not(:disabled) { transform: scale(0.975); }

.btn-primary {
  background: linear-gradient(180deg, #ffd257, var(--accent) 55%, #eaa612);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(251, 191, 36, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-line);
}
.btn-danger {
  background: linear-gradient(180deg, #ff6b60, #e0362b);
  color: #fff;
  box-shadow: 0 6px 18px rgba(224, 54, 43, 0.3);
}
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-line);
  color: var(--ink-dim);
  white-space: nowrap;
}

.muted { color: var(--ink-dim); }
.tiny { font-size: 12.5px; }
.center { text-align: center; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sab) + 24px);
  transform: translate(-50%, 20px);
  background: #1c2a55;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--ink);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 600;
  max-width: 88vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 90;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- brand ---------- */

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 8vh 0 26px;
  text-align: center;
}
.brand svg { width: 84px; height: 84px; filter: drop-shadow(0 8px 24px rgba(36, 71, 197, 0.55)); }
.brand .word {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.16em;
}
.brand .word span { color: var(--accent); }
.brand .sub { color: var(--ink-dim); font-size: 14px; letter-spacing: 0.02em; }

.name-form { display: flex; flex-direction: column; gap: 14px; }
.name-form input {
  width: 100%;
  min-height: 54px;
  border-radius: 14px;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, 0.07);
  padding: 0 16px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  outline: none;
}
.name-form input:focus { border-color: var(--accent); }

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

.lobby-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.lobby-head .me {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.head-btns { display: flex; gap: 8px; flex: none; }
.lobby-title { font-size: 13px; font-weight: 800; letter-spacing: 0.14em; color: var(--ink-faint); margin: 18px 4px 10px; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--tile-edge), var(--tile2));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 17px;
  color: #fff;
  flex: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.player-list { display: flex; flex-direction: column; gap: 9px; }
.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
}
.player-row .nm { font-weight: 800; font-size: 16.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.player-row .btn { width: auto; min-height: 42px; padding: 8px 18px; font-size: 15px; }

.empty-lobby { padding: 26px 18px; text-align: center; color: var(--ink-dim); font-size: 14.5px; line-height: 1.55; }

.practice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 4px;
}
.practice .p-txt { flex: 1; min-width: 0; }
.practice .p-t { font-weight: 800; font-size: 15.5px; }
.practice .p-d { color: var(--ink-dim); font-size: 12.5px; margin-top: 2px; }
.practice .btn { width: auto; min-height: 42px; padding: 8px 18px; font-size: 15px; }

.waitbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.waitbar .grow { flex: 1; font-weight: 700; font-size: 14.5px; }
.waitbar .btn { width: auto; min-height: 40px; font-size: 14px; padding: 7px 14px; }

.spin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  animation: rot 0.9s linear infinite;
  flex: none;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- picking a word at the end of a letters round ---------- */

.choose-count {
  text-align: center;
  font-size: 46px;
  font-weight: 900;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-bottom: 6px;
  text-shadow: 0 0 20px rgba(251, 191, 36, 0.35);
}
.pickwords { display: flex; flex-direction: column; gap: 7px; }
.pickword {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 16px;
  border-radius: 13px;
  border: 1.5px solid var(--panel-line);
  background: rgba(255, 255, 255, 0.055);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.1em;
}
.pickword span { flex: 1; text-align: left; }
.pickword b { font-size: 15px; color: var(--ink-dim); letter-spacing: 0; }
.pickword.sel {
  border-color: var(--accent);
  background: rgba(251, 191, 36, 0.15);
  color: #ffd76a;
}
.pickword.sel b { color: #ffd76a; }

/* ---------- lobby stats ---------- */

.stat-card { padding: 12px 14px; margin-bottom: 9px; }
.stat-head {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat { text-align: center; min-width: 0; }
.stat .n { font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat .k {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.stat .t { font-size: 10.5px; font-weight: 700; color: var(--accent); margin-top: 2px; }

/* ---------- sheets / modals ---------- */

.sheet-veil {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 15, 0.66);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%;
  max-width: 480px;
  background: #101c3f;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(var(--sab) + 20px);
  animation: rise 0.22s ease;
}
@keyframes rise { from { transform: translateY(40px); opacity: 0.4; } }
.sheet h3 { font-size: 19px; margin-bottom: 4px; }
.sheet .sub { color: var(--ink-dim); font-size: 14px; margin-bottom: 14px; }

.fmt-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.fmt-opt.danger {
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(251, 113, 133, 0.08);
}
.fmt-opt.danger .t { color: var(--bad); }
.fmt-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 13px;
  border: 1.5px solid var(--panel-line);
  background: rgba(255, 255, 255, 0.045);
}
.fmt-opt.sel { border-color: var(--accent); background: rgba(251, 191, 36, 0.09); }
.fmt-opt .t { font-weight: 800; font-size: 15.5px; }
.fmt-opt .d { color: var(--ink-dim); font-size: 12.5px; margin-top: 2px; }
.fmt-opt .radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--ink-faint);
  flex: none;
}
.fmt-opt.sel .radio { border-color: var(--accent); background: radial-gradient(circle at center, var(--accent) 0 45%, transparent 52%); }

.steppers { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 14px; }
.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--panel-line);
}
.stepper .lbl { flex: 1; font-weight: 700; font-size: 14.5px; }
.stepper button {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.09);
  font-size: 21px;
  font-weight: 800;
}
.stepper .val { width: 30px; text-align: center; font-weight: 900; font-size: 17px; }

/* ---------- game chrome ---------- */

.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.game-top .pill {
  max-width: calc(100% - 104px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-line);
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
}

.scorebar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.scorebar .side { min-width: 0; }
.scorebar .side.right { text-align: right; }
.scorebar .who {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.scorebar .side.right .who { justify-content: flex-end; }
.scorebar .pts { font-size: 30px; font-weight: 900; line-height: 1.15; font-variant-numeric: tabular-nums; }
.scorebar .pts.lead { color: var(--accent); }
.scorebar .vs { font-size: 12px; font-weight: 900; color: var(--ink-faint); letter-spacing: 0.1em; }
.scorebar.solo { grid-template-columns: 1fr auto; }
.scorebar.solo .pts { color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); flex: none; }
.dot.on { background: var(--good); }

/* ---------- clock ---------- */

.clockwrap { display: flex; justify-content: center; margin: 2px 0 12px; }
.clock { width: 148px; height: 148px; }
.clock .face { fill: #f4f6ff; }
.clock .rim { fill: none; stroke: #21335f; stroke-width: 7; }
.clock .tick { stroke: #22315c; stroke-width: 2; stroke-linecap: round; }
.clock .quarter { stroke: #22315c; stroke-width: 4; }
.clock .hand { stroke: #d43a2f; stroke-width: 5; stroke-linecap: round; }
.clock .hub { fill: #22315c; }
.clock.urgent .hand { stroke: #ff2617; }

/* ---------- round content ---------- */

.round-title {
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
  margin-bottom: 10px;
}
.round-title .tiebreak { color: var(--accent); }
.round-title.callnow {
  color: var(--accent);
  font-size: 15px;
  animation: callpulse 0.7s ease-in-out infinite alternate;
}
@keyframes callpulse { from { opacity: 0.55; } to { opacity: 1; } }

.tilerow {
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: nowrap;
  margin-bottom: 12px;
}
.tile {
  width: min(8.6vw, 44px);
  height: min(11.4vw, 56px);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: min(5.6vw, 27px);
  font-weight: 900;
  color: #fff;
  background: linear-gradient(180deg, var(--tile1), var(--tile2));
  border: 1px solid rgba(120, 150, 255, 0.5);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.28), inset 0 -3px 6px rgba(0, 0, 20, 0.35), 0 4px 10px rgba(0, 0, 0, 0.35);
  text-shadow: 0 2px 3px rgba(0, 0, 30, 0.5);
  flex: none;
}
.tile.empty {
  background: rgba(255, 255, 255, 0.045);
  border: 1.5px dashed rgba(255, 255, 255, 0.16);
  box-shadow: none;
}
.tile.used { opacity: 0.28; }
button.tile { transition: transform 0.05s; }
button.tile:active:not(:disabled) { transform: scale(0.92); }

.numrow { display: flex; justify-content: center; gap: 5px; margin-bottom: 12px; }
.numtile {
  min-width: min(13.5vw, 52px);
  height: 52px;
  padding: 0 4px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(180deg, var(--tile1), var(--tile2));
  border: 1px solid rgba(120, 150, 255, 0.5);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.28), 0 4px 10px rgba(0, 0, 0, 0.35);
  font-variant-numeric: tabular-nums;
}
.numtile.used { opacity: 0.28; }
/* A number made by the player, as opposed to one of the six drawn. */
.numtile.made {
  background: linear-gradient(180deg, #2f8f6b, #17614a);
  border-color: rgba(120, 230, 180, 0.5);
}
.numtile.sel {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
  transform: translateY(-2px);
}
.oprow button.sel {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* the working: one line per step, tap one to declare it */
.working { display: flex; flex-direction: column; gap: 5px; margin: 4px 0 8px; }
.workline {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1.5px solid var(--panel-line);
  background: rgba(255, 255, 255, 0.05);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.workline span:first-child { flex: 1; color: var(--ink-dim); font-weight: 700; }
.workline b { font-size: 17px; font-weight: 900; }
.workline .away, .workline .hit {
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-dim);
}
.workline .hit { background: rgba(52, 211, 153, 0.18); color: var(--good); }
.workline.sel { border-color: var(--accent); background: rgba(251, 191, 36, 0.13); }
.workline.sel b { color: #ffd76a; }

.target {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.target .bezel {
  background: #05070f;
  border: 1px solid #26304f;
  border-radius: 14px;
  padding: 8px 26px;
  box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.9), 0 4px 16px rgba(0, 0, 0, 0.4);
}
.target .digits {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--led);
  text-shadow: 0 0 14px rgba(255, 77, 66, 0.75), 0 0 40px rgba(255, 77, 66, 0.4);
}

.pickbar { display: flex; gap: 10px; margin-top: 4px; }
.pickbar .btn { flex: 1; }

.waiting-note {
  text-align: center;
  color: var(--ink-dim);
  font-size: 15px;
  padding: 18px 10px;
  line-height: 1.5;
}

.entry {
  min-height: 58px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--panel-line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 0.14em;
  margin-bottom: 10px;
  padding: 6px 12px;
  text-align: center;
  word-break: break-all;
}
.entry.expr { letter-spacing: 0.03em; font-size: 22px; font-variant-numeric: tabular-nums; }
.entry .ph { color: var(--ink-faint); font-size: 15px; letter-spacing: 0.02em; font-weight: 600; }
.entry-status {
  text-align: center;
  font-size: 13px;
  min-height: 19px;
  margin-bottom: 8px;
  font-weight: 700;
}
.entry-status.ok { color: var(--good); }
.entry-status.err { color: var(--bad); }
.entry-status.dim { color: var(--ink-faint); font-weight: 600; }

.oprow { display: flex; justify-content: center; gap: 7px; margin-bottom: 10px; }
.oprow button {
  width: 50px;
  height: 46px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--panel-line);
  font-size: 21px;
  font-weight: 800;
}
.editrow { display: flex; gap: 8px; }
.editrow button {
  flex: 1;
  min-height: 44px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-line);
  font-size: 15px;
  font-weight: 700;
}

.opp-chip { display: flex; justify-content: center; margin-top: 12px; }

/* scratchpad tries */
.tries {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 10px 0 2px;
}
.try-chip {
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1.5px solid var(--panel-line);
  font-weight: 800;
  font-size: 13.5px;
  color: var(--ink-dim);
}
.try-chip.sel {
  border-color: var(--accent);
  background: rgba(251, 191, 36, 0.13);
  color: #ffd76a;
}
.editrow .try {
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.42);
  color: #ffd76a;
}

/* ---------- typed word entry ---------- */

.entry-input {
  display: block;
  width: 100%;
  color: var(--ink);
  font-family: inherit;
  text-transform: uppercase;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.entry-input::placeholder {
  color: var(--ink-faint);
  font-size: 15px;
  letter-spacing: 0.02em;
  font-weight: 600;
  text-transform: none;
}
.entry-input:focus { border-color: rgba(120, 150, 255, 0.55); }
.entry-input.reject { animation: shake 0.3s; border-color: var(--bad); }
@keyframes shake {
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ---------- numbers: face-down card decks ---------- */

.deck-label {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  margin: 8px 0 5px;
}
.deck {
  display: grid;
  gap: 5px;
  margin: 0 auto;
}
/* Sized so all twenty-four cards fit a phone screen without scrolling. */
.deck.large { grid-template-columns: repeat(4, 1fr); max-width: min(58vw, 216px); }
.deck.small { grid-template-columns: repeat(5, 1fr); max-width: min(72vw, 270px); }
/* Deliberately not called .card: that class is already a panel. */
.numcard {
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 4px, transparent 4px 8px),
    linear-gradient(180deg, #23366f, #16204a);
  border: 1px solid rgba(120, 150, 255, 0.35);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.16), 0 3px 8px rgba(0, 0, 0, 0.35);
  color: var(--ink-faint);
  font-size: 16px;
  font-weight: 900;
  padding: 0;
  transition: transform 0.08s;
}
.numcard:active:not(:disabled) { transform: scale(0.93); }
.numcard.sel {
  background: linear-gradient(180deg, var(--accent), #d99b06);
  border-color: rgba(255, 220, 130, 0.7);
  color: var(--accent-ink);
}
.numcard:disabled { opacity: 0.4; }

.numtile.facedown {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 4px, transparent 4px 8px),
    linear-gradient(180deg, #23366f, #16204a);
  color: var(--ink-faint);
}
.numtile.pop { animation: flipin 0.32s ease-out; }
@keyframes flipin {
  from { transform: rotateY(90deg) scale(0.85); opacity: 0.2; }
  to { transform: none; opacity: 1; }
}

/* ---------- help ---------- */

.help-veil {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 15, 0.72);
  z-index: 80;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  animation: fade 0.18s ease;
}
.help-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: #101c3f;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  animation: rise 0.22s ease;
}
.help-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--panel-line);
}
.help-title { flex: 1; font-size: 19px; font-weight: 800; }
.help-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 18px 10px;
  user-select: text;
  -webkit-user-select: text;
}
.help-body h4 {
  margin: 16px 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.help-body p {
  margin: 0 0 8px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-dim);
}
.help-body b { color: var(--ink); }
.help-foot {
  padding: 10px 18px calc(var(--sab) + 16px);
  border-top: 1px solid var(--panel-line);
  font-size: 12px;
  color: var(--ink-faint);
  text-align: center;
}
.menu-btn.off { opacity: 0.4; }

/* ---------- winner's screen ---------- */

.gameover.winner { position: relative; }
.go-badge.win {
  animation: trophy 1.4s ease-in-out 2;
  filter: drop-shadow(0 0 18px rgba(251, 191, 36, 0.55));
}
@keyframes trophy {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.14) rotate(-7deg); }
  60% { transform: scale(1.14) rotate(7deg); }
}
.win-title {
  color: var(--accent);
  line-height: 1.2;
  text-shadow: 0 2px 18px rgba(251, 191, 36, 0.35);
}
.confetti {
  position: absolute;
  inset: -10px 0 auto 0;
  height: 60vh;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.confetti i {
  position: absolute;
  top: -14px;
  width: 7px;
  height: 13px;
  border-radius: 1px;
  opacity: 0.9;
  animation-name: fall;
  animation-timing-function: linear;
  animation-iteration-count: 3;
}
@keyframes fall {
  from { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  to { transform: translateY(58vh) rotate(540deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .confetti, .go-badge.win { animation: none; display: none; }
  .go-badge.win { display: block; }
}

/* ---------- conundrum ---------- */

.buzz-zone { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 6px; }
.buzzer {
  width: 138px;
  height: 138px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, #ff8d84, #e0362b 58%, #9c1810);
  color: #fff;
  font-size: 23px;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow: 0 10px 30px rgba(224, 54, 43, 0.5), inset 0 3px 0 rgba(255, 255, 255, 0.4), inset 0 -8px 16px rgba(80, 5, 0, 0.55);
  transition: transform 0.07s;
}
.buzzer:active:not(:disabled) { transform: scale(0.94); }

/* ---------- reveal ---------- */

.reveal { display: flex; flex-direction: column; gap: 10px; }
.rv-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}
.rv-row .side { flex: 1; min-width: 0; }
.rv-row .who { font-size: 12.5px; font-weight: 700; color: var(--ink-dim); margin-bottom: 3px; }
.rv-row .what { font-size: 20px; font-weight: 900; letter-spacing: 0.06em; word-break: break-all; }
.rv-row .why { font-size: 12.5px; color: var(--bad); font-weight: 600; margin-top: 2px; }
.rv-row .what.invalid { color: var(--ink-faint); text-decoration: line-through; text-decoration-thickness: 2px; }
.rv-row .got {
  font-size: 21px;
  font-weight: 900;
  flex: none;
  min-width: 52px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.rv-row .got.zero { color: var(--ink-faint); }
.rv-row .got:not(.zero) { color: var(--good); }
.rv-best { text-align: center; color: var(--ink-dim); font-size: 14px; padding: 4px 0 2px; }
.rv-best b { color: var(--accent); letter-spacing: 0.08em; }
.rv-best b.sol { letter-spacing: 0.02em; white-space: nowrap; }

/* ---------- game over ---------- */

.gameover { text-align: center; padding-top: 4vh; }
.go-badge { font-size: 54px; margin-bottom: 6px; }
.gameover h2 { font-size: 28px; margin-bottom: 6px; }
.gameover .final { font-size: 42px; font-weight: 900; font-variant-numeric: tabular-nums; margin: 8px 0 4px; }
.gameover .final span { color: var(--accent); }
.go-log { margin: 18px 0; text-align: left; font-size: 13.5px; }
.go-log .lrow {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.go-log .lrow:last-child { border-bottom: 0; }
.go-log .lrow b { color: var(--ink); }

.notice {
  padding: 11px 14px;
  border-radius: 13px;
  background: rgba(251, 113, 133, 0.12);
  border: 1px solid rgba(251, 113, 133, 0.3);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 12px;
}
.notice .btn { margin-top: 10px; }

@media (min-height: 760px) {
  .clock { width: 168px; height: 168px; }
}
