/* Any element carrying the hidden attribute stays hidden, full stop. The UA's
   own [hidden] rule loses on specificity to .gate{display:grid} and
   #app{display:flex}, which left the leaderboard painted over everything. */
[hidden] { display: none !important; }

:root {
  --bg: #15171c;
  --panel: #1e2128;
  --line: #2e323c;
  --text: #eef0f4;
  --muted: #8f97a6;
  --idle: #2f6df6;
  --rec: #e0393e;
  --confirm: #1f9d55;
  --dock-h: 152px;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

button, select, input { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- gate ---- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.gate-box { width: 100%; max-width: 320px; text-align: center; }
.gate-box h1 { margin: 0 0 4px; font-size: 22px; }
.gate-box p { margin: 0 0 20px; color: var(--muted); }

.gate-box input {
  width: 100%;
  padding: 14px;
  margin-bottom: 12px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.gate-box button {
  width: 100%;
  padding: 14px;
  background: var(--idle);
  border: 0;
  border-radius: 10px;
  font-weight: 600;
}

.error { min-height: 1.5em; margin: 12px 0 0; color: #ff8b8f; font-size: 14px; }

/* ----------------------------------------------------------------- app ---- */

/* Fixed-height rows mean the main button lands on the exact same pixels in
   every state, so a thumb can just rest there. dvh keeps mobile browser
   chrome from shifting it. */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.topbar {
  flex: 0 0 auto;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

/* Two selects plus the trophy; the selects share whatever width is left. */
.pickers { display: flex; align-items: center; gap: 8px; }

.pickers select {
  flex: 1 1 0;
  min-width: 0;                /* so long topic names can't widen the row */
  padding: 8px 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.trophy {
  flex: 0 0 auto;
  width: 42px;
  height: 38px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 17px;
  line-height: 1;
}

.progress {
  margin-top: 7px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}

.prompt-area {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  min-height: 0;             /* lets a long prompt scroll instead of pushing */
  overflow-y: auto;
  padding: 20px 22px;
}

.prompt {
  margin: 0;
  max-width: 34ch;
  text-align: center;
  font-size: clamp(21px, 5.4vw, 30px);
  font-weight: 500;
  line-height: 1.38;
}

.prompt.done  { color: var(--muted); }
.prompt.empty { color: var(--muted); font-size: 19px; }

.monitor {
  flex: 0 0 auto;
  padding: 0 16px 10px;
  text-align: center;
}

.meter {
  display: block;
  width: 100%;
  height: 56px;
}

.readout {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--muted);
  min-height: 1.4em;
}

/* ---------------------------------------------------------------- dock ---- */

.dock {
  flex: 0 0 auto;
  height: calc(var(--dock-h) + env(safe-area-inset-bottom));
  padding: 0 14px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.secondary {
  display: flex;
  gap: 8px;
  padding: 12px 0;
}

.secondary button {
  flex: 1;
  padding: 12px 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
}

.secondary button:disabled { opacity: .38; }

.main {
  display: block;
  width: 100%;
  height: 76px;
  border: 0;
  border-radius: 14px;
  background: var(--idle);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .04em;
}

.main[data-state="recording"] { background: var(--rec); }
.main[data-state="review"]    { background: var(--confirm); }
.main:disabled                { background: #3a3f4a; color: var(--muted); }

@media (hover: hover) {
  .secondary button:not(:disabled):hover { border-color: #4a5060; }
  .main:not(:disabled):hover { filter: brightness(1.08); }
}

.main:not(:disabled):active { transform: translateY(1px); }

/* --------------------------------------------------------- leaderboard ---- */

.board-box { max-width: 300px; }
.board-box h1 { margin-bottom: 16px; }

.board { width: 100%; border-collapse: collapse; margin-bottom: 14px; }

.board td {
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.board td.count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.board tr.me td { color: #8fb4ff; }
.board td.unlabeled { color: var(--muted); font-style: italic; }

.board-total { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
