:root {
  --bg: #111214;
  --panel: #1c1d21;
  --line: #2e3036;
  --text: #ecedef;
  --muted: #9a9ca3;
  --accent: #f5c518;
  --good: #3fb950;
  --bad: #e5534b;
  --skip: #5c5f66;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
button {
  font: inherit; cursor: pointer; border: 0; border-radius: 8px;
  padding: 10px 16px; background: var(--accent); color: #111; font-weight: 600;
}
button:disabled { opacity: .4; cursor: default; }
button.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.muted { color: var(--muted); }

.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 20px; margin: 0; letter-spacing: .5px; }
.bar h1 span { color: var(--muted); font-weight: 400; font-size: 15px; }
.icon {
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  background: transparent; color: var(--text); border: 1px solid var(--line);
}

main { max-width: 640px; margin: 0 auto; padding: 16px; }

.screen { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; }
.screen video { width: 100%; height: 100%; display: block; object-fit: contain; }
.overlay {
  position: absolute; inset: 0; width: 100%; background: rgba(0,0,0,.35);
  border-radius: 0; display: grid; place-items: center;
}
.overlay span {
  width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: #111;
  display: grid; place-items: center; font-size: 26px; padding-left: 4px;
}
.overlay[hidden] { display: none; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.15); }
#progress-fill { height: 100%; width: 0; background: var(--accent); }

.tabs { display: flex; gap: 6px; margin-top: 10px; }
.tabs button {
  flex: 1; padding: 8px 0; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); font-weight: 500;
}
.tabs button[aria-selected="true"] { border-color: var(--accent); color: var(--accent); }
.tabs button.wrong { box-shadow: inset 0 -3px 0 var(--bad); }
.tabs button.skipped { box-shadow: inset 0 -3px 0 var(--skip); }
.tabs button.right { box-shadow: inset 0 -3px 0 var(--good); }

.guess { margin-top: 16px; }
.combo { position: relative; }
#guess-input {
  width: 100%; font: inherit; padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
}
#guess-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#suggestions {
  position: absolute; left: 0; right: 0; bottom: 100%; margin: 0 0 4px; padding: 4px 0;
  list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  max-height: 260px; overflow-y: auto; z-index: 5;
}
#suggestions li { padding: 8px 14px; cursor: pointer; }
#suggestions .year { color: var(--muted); }
#suggestions li[aria-selected="true"], #suggestions li:hover { background: var(--line); }
.actions { display: flex; gap: 8px; margin-top: 8px; }
.actions button { flex: 1; }

.history { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 6px; }
.history li {
  padding: 10px 14px; border-radius: 8px; background: var(--panel); border-left: 4px solid var(--skip);
}
.history li.wrong { border-color: var(--bad); }
.history li.right { border-color: var(--good); }
.history li.skipped { color: var(--muted); }

.result { text-align: center; margin-top: 16px; padding: 16px; background: var(--panel); border-radius: 10px; }
.result-msg { margin: 0; color: var(--muted); }
.answer { font-size: 22px; font-weight: 700; margin: 6px 0; }
.grid { font-size: 22px; letter-spacing: 2px; margin: 8px 0 12px; }

.error { color: var(--bad); text-align: center; }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; max-width: min(420px, calc(100vw - 32px)); padding: 20px;
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin-top: 0; }
dialog form { text-align: right; margin-top: 12px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.stat-row strong { display: block; font-size: 28px; }
.stat-row span { font-size: 12px; color: var(--muted); }
.dist { display: grid; gap: 4px; }
.dist div { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.dist .barfill { background: var(--skip); padding: 2px 6px; text-align: right; min-width: 20px; border-radius: 3px; }
.dist .barfill.today { background: var(--good); }

.toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-weight: 600; z-index: 10;
}
