:root {
  --bg: #12121a;
  --fg: #f4f4fa;
  --muted: #8f8fa8;
  --card: #1e1e2c;
  --card-border: #2c2c3e;
  --accent: #ffb454;
  --accent-fg: #1a1206;
  --good: #4ade80;
  --bad: #f87171;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    max(16px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
}

/* ---------- screens ---------- */

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  text-align: center;
}

.screen[hidden] { display: none; }

.title {
  margin: 0;
  font-size: clamp(30px, 8vw, 42px);
  font-weight: 800;
  letter-spacing: -0.5px;
}

.subtitle {
  margin: -12px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.best-line {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.best-line[hidden] { display: none; }

/* ---------- game screen ---------- */

#screen-game { justify-content: flex-start; gap: 0; }

.topbar {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.streak-label {
  font-size: 18px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.streak-label span {
  color: var(--fg);
  font-size: 22px;
  font-weight: 800;
}

.stage {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
}

.badge {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}

.badge-icon, #badge-icon {
  font-size: 76px;
  font-weight: 800;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
}

.badge.playing { animation: pulse 1.2s ease-in-out infinite; }

.badge.correct {
  background: rgba(74, 222, 128, 0.15);
  border-color: var(--good);
}

.badge.correct #badge-icon { color: var(--good); }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* ---------- countdown ---------- */

.countdown-track {
  width: min(70%, 320px);
  height: 8px;
  border-radius: 4px;
  background: var(--card);
  overflow: hidden;
}

.countdown-track[hidden] { display: none; }

.countdown-bar {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(1);
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
  background: var(--card);
  min-height: 64px;
  padding: 0 28px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s, transform 0.05s;
}

.btn:active { transform: scale(0.98); }

.btn:disabled {
  opacity: 0.35;
  cursor: default;
}

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

.btn-big { width: min(100%, 360px); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}

.btn-secondary {
  background: transparent;
  border: 2px solid var(--card-border);
  color: var(--fg);
}

.answers {
  width: 100%;
  display: flex;
  gap: 14px;
  padding-bottom: 4px;
}

.answers .btn { flex: 1; }

.answers.stack {
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.btn-answer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 96px;
  font-size: 22px;
}

.btn-answer .emoji { font-size: 40px; line-height: 1; }

/* ---------- game over ---------- */

.over-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
}

.reason {
  margin: -12px 0 0;
  color: var(--muted);
  font-size: 16px;
  text-transform: capitalize;
}

.score {
  font-size: clamp(72px, 24vw, 110px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.new-best {
  margin: -8px 0 0;
  color: var(--accent);
  font-weight: 700;
}

.new-best[hidden] { display: none; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #2a2a3a;
  border: 1px solid var(--card-border);
  color: var(--fg);
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 90vw;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- a11y ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .badge.playing { animation: none; }
  .btn, .toast { transition: none; }
}