:root {
  --bg: #ffffff; --panel: #ffffff; --text: #1a1a1b; --muted: #5f6368; --line: #d3d6da;
  --key: #e1e4e8; --key-text: #1a1a1b;
  --accent: #d6001c; --correct: #2e7d4f; --absent: #6b7075;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121213; --panel: #1f1f21; --text: #f2f2f2; --muted: #a8abaf; --line: #3a3a3c;
    --key: #3a3a3c; --key-text: #ffffff;
    --accent: #ff4d5e; --absent: #3a3a3c;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex; flex-direction: column; align-items: center; min-height: 100dvh;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }

header {
  width: 100%; max-width: 500px; display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line);
}
.head-left { display: flex; gap: 2px; }
.head-right { display: flex; justify-content: flex-end; gap: 2px; }
.icon {
  background: none; border: 0; border-radius: 6px; font-size: 19px; width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: inherit;
}
.icon:hover { background: var(--line); }
.title { text-align: center; line-height: 1.1; }
h1 { margin: 0; font-size: 23px; font-weight: 800; letter-spacing: .02em; }
h1 span { color: var(--accent); }
.subtitle { font-size: 11px; color: var(--muted); }

main { flex: 1; min-height: 0; width: 100%; max-width: 500px; display: flex; flex-direction: column; padding: 8px; gap: 8px; }

.toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 20; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 6px; font-weight: 600; font-size: 14px;
  opacity: 0; transition: opacity .15s; max-width: calc(100vw - 24px); text-align: center;
}
.toast.show { opacity: 1; }

dialog {
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text);
  width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 20px; position: relative;
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h2 { margin: 0 0 12px; font-size: 20px; outline: none; }
dialog h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
dialog p, dialog li { font-size: 14px; line-height: 1.45; }
dialog ul { padding-left: 20px; margin: 8px 0; }
.close { position: absolute; top: 10px; right: 10px; }
.fine { color: var(--muted); font-size: 12px !important; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.stats-row b { display: block; font-size: 26px; }
.stats-row span { font-size: 11px; color: var(--muted); }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.action { flex: 1; border: 0; border-radius: 6px; padding: 11px; font-weight: 700; background: var(--correct); color: #fff; }
.action.alt { background: var(--key); color: var(--key-text); }
.next { text-align: center; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; color: var(--accent); }

.pill {
  background: none; border: 1px solid var(--tile-line, var(--muted)); border-radius: 999px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; touch-action: manipulation;
}
.pill:hover:not(:disabled) { background: var(--line); }
.pill:disabled { opacity: .4; cursor: default; }
.controls { display: flex; justify-content: center; gap: 8px; flex: none; }
