:root {
  --bg: #ffffff; --fg: #1a202c; --muted: #4a5568; --card: #f7fafc; --line: #cbd5e0;
  --accent: #2b6cb0; --accent-fg: #ffffff; --ok: #276749; --ok-bg: #f0fff4;
  --bad: #9b2c2c; --bad-bg: #fff5f5; --star: #b7791f; --emoji-bg: #edf2f7;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121820; --fg: #edf2f7; --muted: #a0aec0; --card: #1c2532; --line: #3a4658;
    --accent: #63b3ed; --accent-fg: #0b1220; --ok: #9ae6b4; --ok-bg: #1c3326;
    --bad: #feb2b2; --bad-bg: #3b1f1f; --star: #f6e05e; --emoji-bg: #e2e8f0;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
/* viewport-fit=cover: keep the bar and content out of the iPhone status bar, notch and home indicator */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: calc(8px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 8px calc(16px + env(safe-area-inset-left)); border-bottom: 1px solid var(--line); }
#app { max-width: 640px; margin: 0 auto; padding: 16px calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); outline: none; }
h1 { font-size: 1.6rem; margin: 8px 0 16px; }
h2 { font-size: 1.2rem; margin: 0 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.tile, .btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 12px 16px; border: 2px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--fg); font: inherit; cursor: pointer; text-align: center;
}
.tile { flex-direction: column; }
.btn { width: 100%; margin: 8px 0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 700; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.tile:focus-visible, .btn:focus-visible, .link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.link { background: none; border: 0; color: var(--accent); font: inherit; min-height: 48px; padding: 0 4px; cursor: pointer; text-decoration: underline; }
.top .link { text-decoration: none; font-weight: 700; }
.big { font-size: 3rem; line-height: 1.1; }
.tile .big, div.big { display: flex; align-items: center; justify-content: center; width: 4.5rem; height: 4.5rem; margin: 0 auto 8px; border-radius: 50%; background: var(--emoji-bg); }
.small { color: var(--muted); font-size: .9rem; }
.chip { display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem; margin-right: 10px; border-radius: 50%; background: var(--emoji-bg); font-size: 1.4rem; vertical-align: middle; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 20px; text-align: center; margin-bottom: 8px; overflow-wrap: anywhere; }
.card.ok { background: var(--ok-bg); border-color: var(--ok); }
.card.bad { background: var(--bad-bg); border-color: var(--bad); }
.lt { font-size: 1.3rem; font-weight: 700; }
.prompt { font-size: 1.8rem; font-weight: 700; text-align: center; margin: 8px 0 16px; overflow-wrap: anywhere; }
.answer { font: 700 1.8rem/1.3 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .15em; text-align: center; overflow-wrap: anywhere; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.options .btn { margin: 0; overflow-wrap: anywhere; }
.options.emoji .btn { font-size: 2.4rem; background: var(--emoji-bg); }
.options.letters { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
.levels { list-style: none; padding: 0; margin: 0; }
.stars { font-size: 2.6rem; color: var(--star); text-align: center; margin: 8px 0; }
.note { background: var(--card); border-left: 4px solid var(--accent); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: no-preference) {
  .btn, .tile { transition: transform .08s ease; }
  .btn:active, .tile:active { transform: scale(.97); }
}
