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

:root {
  --bg: #0a0b0d;
  --panel: #131519;
  --panel-alt: #191c21;
  --border: #262a31;
  --border-bright: #383e47;
  --text: #dde1e6;
  --text-dim: #8b93a0;
  --text-faint: #545b66;
  --accent: #e0a531;
  --accent-bright: #f2bd4f;
  --accent-dim: #6b551f;
  --good: #4fbf82;
  --good-dim: #1c3728;
  --bad: #e4574f;
  --bad-dim: #3a201e;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", "Menlo", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

html, body {
  min-height: 100%;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(224, 165, 49, 0.07), transparent 60%);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
}

a { color: inherit; }

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 20px 60px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ── */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--text);
}

.brand .dot { color: var(--accent); }

.topnav {
  display: flex;
  gap: 4px;
}

.topnav button {
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.topnav button:hover {
  color: var(--text);
  background: var(--panel);
  border-color: var(--border);
}

.topnav button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Shared view ── */

.hidden { display: none !important; }

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 8px;
}

h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}

h2.stats-h2 {
  font-size: 15px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 28px 0 12px;
}

.btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s, background 0.15s;
}

.btn:hover { background: var(--panel-alt); border-color: var(--text-faint); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  color: #171003;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-bright); border-color: var(--accent-bright); }

.btn-big { padding: 13px 26px; font-size: 15px; }

.btn-danger {
  background: transparent;
  color: var(--bad);
  border-color: var(--bad-dim);
}
.btn-danger:hover { background: var(--bad-dim); border-color: var(--bad); }

kbd {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border-bright);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text);
}

.empty-note {
  color: var(--text-faint);
  font-size: 14px;
  padding: 16px 0;
}

/* ── Start view ── */

#view-start {
  flex: 1;
  display: flex;
  align-items: center;
}

.start-card { max-width: 560px; }

.lede {
  color: var(--text-dim);
  font-size: 15px;
  margin-bottom: 20px;
}

.rules {
  list-style: none;
  margin-bottom: 26px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rules li {
  font-size: 14px;
  color: var(--text-dim);
  padding-left: 18px;
  position: relative;
}

.rules li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--text-faint);
}

.pool-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--mono);
}

/* ── Game view ── */

.hud {
  display: flex;
  gap: 24px;
  margin-bottom: 12px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.hud-value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
}

.hud-lives .hud-value {
  color: var(--accent);
  letter-spacing: 2px;
}

.timer-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 20px;
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
}

.timer-fill.timer-danger {
  background: var(--bad);
}

.snippet-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}

.snippet-chrome {
  display: flex;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px dashed var(--border-bright);
  background: var(--panel-alt);
}

.snippet-tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.snippet-tag.muted { color: var(--text-faint); }

.snippet-code {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  padding: 20px;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
  min-height: 140px;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.choice-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent-dim);
  background: var(--panel-alt);
}

.choice-btn:active:not(:disabled) { transform: scale(0.98); }

.choice-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.choice-btn:disabled { cursor: default; }

.choice-num {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.choices.locked .choice-btn { opacity: 0.55; }
.choices.locked .choice-btn.correct,
.choices.locked .choice-btn.wrong { opacity: 1; }

.choice-btn.correct {
  border-color: var(--good);
  background: var(--good-dim);
}
.choice-btn.correct .choice-num { border-color: var(--good); color: var(--good); }

.choice-btn.wrong {
  border-color: var(--bad);
  background: var(--bad-dim);
}
.choice-btn.wrong .choice-num { border-color: var(--bad); color: var(--bad); }

.reveal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.reveal-verdict {
  font-weight: 700;
  font-size: 14.5px;
}
.reveal-verdict.good { color: var(--good); }
.reveal-verdict.bad { color: var(--bad); }

.reveal-tell {
  color: var(--text-dim);
  font-size: 13px;
  flex: 1 1 260px;
}

/* ── Game over ── */

#view-gameover { flex: 1; display: flex; align-items: center; }

.gameover-card { max-width: 560px; width: 100%; }

.go-stats {
  display: flex;
  gap: 28px;
  margin: 20px 0;
}

.go-stat { display: flex; flex-direction: column; }

.go-num {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.go-label {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.go-confusion {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 20px;
}

.go-qualify {
  background: var(--panel);
  border: 1px solid var(--accent-dim);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 22px;
}

.go-qualify-label {
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 10px;
}

.initials-row { display: flex; gap: 8px; }

#initials-input {
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  width: 90px;
  background: var(--bg);
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  text-align: center;
}

#initials-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.go-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Leaderboard ── */

.board-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0 24px;
  font-family: var(--mono);
  font-size: 13.5px;
}

.board-table th, .board-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}

.board-table th {
  color: var(--text-faint);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.board-initials { color: var(--accent); font-weight: 700; }

/* ── Stats ── */

.stats-summary { color: var(--text-dim); font-size: 14px; }

.accuracy-list { display: flex; flex-direction: column; gap: 8px; }

.acc-row {
  display: grid;
  grid-template-columns: 110px 1fr 90px;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
}

.acc-lang { font-weight: 600; }

.acc-bar {
  height: 8px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.acc-bar-fill {
  height: 100%;
  background: var(--accent);
}

.acc-pct {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
  text-align: right;
}

.acc-n { color: var(--text-faint); }

.confusion-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 24px; }

.conf-row {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.conf-arrow { color: var(--text-faint); font-weight: 400; }

.conf-n {
  font-family: var(--mono);
  color: var(--bad);
}

#reset-stats-btn { margin-right: 10px; margin-bottom: 20px; }

/* ── Footer ── */

footer {
  margin-top: auto;
  padding-top: 30px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}

footer a { color: var(--text-dim); text-decoration: none; }
footer a:hover { color: var(--accent); text-decoration: underline; }

/* ── Mobile ── */

@media (max-width: 520px) {
  .app { padding: 16px 14px 40px; }
  h1 { font-size: 24px; }
  .choices { grid-template-columns: 1fr; }
  .go-stats { gap: 18px; }
  .go-num { font-size: 22px; }
  .hud { gap: 16px; }
  .acc-row { grid-template-columns: 84px 1fr 70px; gap: 8px; }
  .board-table { display: block; overflow-x: auto; white-space: nowrap; }
}
