:root {
  --bg: #080d1a;
  --bg-glow: #12203f;
  --panel: #141e39;
  --panel-2: #1b2749;
  --line: #2a3a63;
  --line-soft: #223055;

  --tile-face: linear-gradient(180deg, #22335f 0%, #16224a 100%);
  --tile-face-sel: linear-gradient(180deg, #3f5a9e 0%, #263a72 100%);

  --gold: #f0b429;
  --gold-bright: #ffc94a;
  --gold-dim: #9c7318;

  --text: #eef2fb;
  --muted: #8ea0c8;
  --faint: #64769e;

  --good: #4ade80;
  --warn: #fb923c;
  --bad: #f87171;

  --radius-lg: 16px;
  --ring: 0 0 0 2px rgba(240, 180, 41, 0.4);
}

* {
  box-sizing: border-box;
}

/* the flat colour lives on html so nothing white shows past the body box */
html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse 120% 70% at 50% -10%, var(--bg-glow) 0%, var(--bg) 62%);
  background-repeat: no-repeat;
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  justify-content: center;
  padding: 22px 16px 40px;
}

.shell {
  width: 100%;
  max-width: 700px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- masthead ---------- */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.wordmark {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.wordmark span {
  color: var(--gold);
}

.scoreline {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.scoreline b {
  color: var(--text);
  font-weight: 650;
}

.ghost-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 9px;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  cursor: pointer;
}
.ghost-btn:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* ---------- panels & screens ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.screen {
  display: none;
}
.screen.is-active {
  display: block;
}

/* ---------- setup ---------- */
.field {
  margin-bottom: 20px;
}
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 9px;
}
.choices {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.choice {
  flex: 1 1 auto;
  min-width: 54px;
  padding: 11px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  font-weight: 650;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.choice:hover {
  border-color: var(--muted);
}
.choice[aria-pressed='true'] {
  background: var(--gold);
  border-color: var(--gold);
  color: #1d1300;
}
.note {
  font-size: 13px;
  color: var(--faint);
  margin: 8px 0 0;
}
.note--center {
  text-align: center;
}

.start-btn {
  width: 100%;
  padding: 15px;
  margin-top: 4px;
  background: var(--gold);
  color: #1d1300;
  border: none;
  border-radius: 11px;
  font: inherit;
  font-size: 16.5px;
  font-weight: 750;
  cursor: pointer;
}
.start-btn:hover {
  background: var(--gold-bright);
}

.stats-strip {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.stats-strip b {
  color: var(--muted);
  font-weight: 650;
}

/* ---------- board head: clock + target ---------- */
.board-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.clock-slot,
.head-slot {
  width: 96px;
  flex: 0 0 96px;
}
.head-slot {
  text-align: right;
}

.clock {
  position: relative;
  width: 96px;
  height: 96px;
}
.clock svg {
  display: block;
  width: 100%;
  height: 100%;
}
.clock__face {
  fill: rgba(8, 13, 26, 0.55);
  stroke: var(--line);
  stroke-width: 4;
}
.clock__arc {
  fill: none;
  stroke: var(--gold);
  stroke-width: 6;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
}
.clock__arc.is-low {
  stroke: var(--warn);
}
.clock__arc.is-out {
  stroke: var(--bad);
}
.clock__hand {
  stroke: var(--text);
  stroke-width: 4;
  stroke-linecap: round;
  transform-origin: 60px 60px;
}
.clock__count {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  pointer-events: none;
}
.clock__count.is-low {
  color: var(--warn);
}
.clock__count.is-out {
  color: var(--bad);
}
.clock.is-idle {
  opacity: 0.45;
}

.target {
  flex: 1;
  text-align: center;
}
.target__cap {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--muted);
  font-weight: 700;
}
.target__num {
  font-size: 60px;
  line-height: 1.05;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.target__num.is-rolling {
  color: var(--gold-dim);
}
.target__num.is-landed {
  animation: land 0.34s ease-out;
}
@keyframes land {
  0% {
    transform: scale(1.16);
    filter: brightness(1.5);
  }
  100% {
    transform: scale(1);
    filter: none;
  }
}

.opponent-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--faint);
  border: 1px solid var(--line-soft);
  border-radius: 99px;
  padding: 4px 9px;
}
.opponent-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 1;
  }
}

/* ---------- tiles ---------- */
.tiles {
  display: flex;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
  margin: 18px 0 16px;
  min-height: 74px;
}
.tile {
  position: relative;
  width: 74px;
  height: 74px;
  background: var(--tile-face);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  font: inherit;
  font-size: 23px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: transform 0.14s, border-color 0.12s, background 0.12s, opacity 0.24s;
}
.tile:hover {
  transform: translateY(-2px);
  border-color: var(--muted);
}
.tile[aria-pressed='true'] {
  background: var(--tile-face-sel);
  border-color: var(--gold);
  box-shadow: var(--ring), inset 0 1px 0 rgba(255, 255, 255, 0.11);
}
.tile.is-derived {
  border-style: dashed;
  border-color: var(--gold-dim);
}
.tile.is-hit {
  border-color: var(--good);
  border-style: solid;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
}
.tile.is-new {
  animation: pop 0.3s ease-out;
}
@keyframes pop {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
.tile.is-pending {
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  pointer-events: none;
}
.tile__key {
  position: absolute;
  top: 3px;
  left: 6px;
  font-size: 9.5px;
  font-weight: 650;
  color: var(--faint);
}
.tile__flag {
  position: absolute;
  bottom: 2px;
  right: 6px;
  font-size: 11px;
  color: var(--good);
}

/* ---------- operators ---------- */
.ops {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-bottom: 14px;
}
.op {
  width: 56px;
  height: 46px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 19px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.op:hover {
  border-color: var(--muted);
}
.op[aria-pressed='true'] {
  background: var(--gold);
  border-color: var(--gold);
  color: #1d1300;
}

/* ---------- status ---------- */
.status {
  text-align: center;
  min-height: 24px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 14px;
  font-variant-numeric: tabular-nums;
}
.status.is-error {
  color: var(--bad);
}
.status.is-good {
  color: var(--good);
}
.status b {
  color: var(--text);
  font-weight: 650;
}

/* ---------- working ---------- */
.working {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13.5px;
}
.working li {
  display: flex;
  gap: 10px;
  padding: 7px 12px;
  background: var(--panel-2);
  border-radius: 8px;
  margin-bottom: 5px;
}
.working li .idx {
  color: var(--faint);
  min-width: 16px;
}
.working li .res {
  color: var(--gold);
  font-weight: 650;
}
.working-empty {
  padding: 13px;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
  border: 1px dashed var(--line-soft);
  border-radius: 8px;
  margin-bottom: 16px;
}

/* ---------- actions ---------- */
.actions {
  display: flex;
  gap: 7px;
}
.btn {
  flex: 1;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.btn:hover:not(:disabled) {
  border-color: var(--muted);
}
.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.btn.is-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #1d1300;
}
.btn.is-primary:hover:not(:disabled) {
  background: var(--gold-bright);
}

.keyhints {
  margin: 15px 0 0;
  font-size: 11.5px;
  color: var(--faint);
  text-align: center;
}
.keyhints kbd {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, monospace;
  font-size: 10.5px;
}

/* ---------- result ---------- */
.verdict {
  text-align: center;
  margin-bottom: 18px;
}
.verdict__points {
  font-size: 42px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.verdict__points.p10 {
  color: var(--good);
}
.verdict__points.p7,
.verdict__points.p5 {
  color: var(--gold);
}
.verdict__points.p0 {
  color: var(--bad);
}
.verdict__line {
  font-size: 14.5px;
  color: var(--muted);
  margin-top: 3px;
}
.verdict__line b {
  color: var(--text);
}

.declarations {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}
.declarations.is-versus {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 520px) {
  .declarations.is-versus {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--panel-2);
  border-radius: 11px;
  padding: 14px;
  border: 1px solid transparent;
}
.card.is-winner {
  border-color: var(--gold);
}
.card__who {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.card__who .pts {
  color: var(--gold);
}
.card__value {
  font-size: 27px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  margin: 4px 0 2px;
}
.card__gap {
  font-size: 13px;
  color: var(--faint);
  margin-bottom: 9px;
}
.card ol {
  margin: 0;
  padding-left: 19px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--muted);
}
.card ol li {
  margin-bottom: 2px;
}
.card .plain {
  font-size: 13px;
  color: var(--faint);
}

.best-box {
  background: rgba(240, 180, 41, 0.07);
  border: 1px solid rgba(240, 180, 41, 0.25);
  border-radius: 11px;
  padding: 14px;
  margin-bottom: 16px;
}
.best-box h3 {
  margin: 0 0 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gold);
  font-weight: 700;
}
.best-box ol {
  margin: 0;
  padding-left: 19px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}
.best-box .plain {
  font-size: 13px;
  color: var(--muted);
}

.seedline {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--faint);
}
.seedline code {
  background: var(--panel-2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11.5px;
}

/* ---------- footer ---------- */
.footer {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--faint);
}
.footer a {
  color: var(--muted);
}

/* ---------- narrow screens ---------- */
@media (max-width: 460px) {
  .target__num {
    font-size: 46px;
  }
  .tile {
    width: 60px;
    height: 60px;
    font-size: 19px;
  }
  .op {
    width: 46px;
  }
  .clock-slot,
  .head-slot {
    width: 68px;
    flex: 0 0 68px;
  }
  .clock {
    width: 68px;
    height: 68px;
  }
  .clock__count {
    font-size: 18px;
  }
}

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