:root {
  --bg: #1b1420;
  --ink: #fff8ef;
  --muted: #c9b9c4;
  --accent: #ffb547;
  --card: #2a2030;
  --good: #6fe3c1;
  --bad: #ff6b8b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; }
body { font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }

#app { position: relative; height: 100%; max-width: 480px; margin: 0 auto; user-select: none; -webkit-user-select: none; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; padding: max(14px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.screen.active { display: flex; }

.home { color: var(--muted); text-decoration: none; font-size: 14px; }
.primary, .ghost { display: block; width: 100%; padding: 14px; border-radius: 999px; font-weight: 800; font-size: 17px; text-align: center; text-decoration: none; }
.primary { background: var(--accent); color: #3b1d05; box-shadow: 0 4px 0 #b86b12; }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #b86b12; }
.ghost { margin-top: 10px; background: rgba(255,255,255,.1); color: var(--ink); }
.best { color: var(--accent); min-height: 1.2em; }

/* intro */
.intro-body { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.disc { font-size: 72px; }
.intro-body h1 { margin: 8px 0; font-size: 34px; letter-spacing: 4px; color: var(--accent); text-shadow: 0 3px 0 #7a3a1a; }
.intro-body p { color: var(--muted); line-height: 1.6; }
.intro-body .primary { margin-top: 20px; }

/* quiz */
.hud { display: flex; align-items: center; gap: 12px; }
.hud .home { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.1); color: var(--ink); display: grid; place-items: center; font-size: 22px; }
.hud small { font-size: 12px; color: var(--muted); }
.hud b { font-size: 22px; margin: 0 3px; font-variant-numeric: tabular-nums; }
.round { flex: 1; }
.score { text-align: right; }

.player { margin: 18px 0 14px; text-align: center; }
.wave { display: inline-flex; align-items: center; gap: 6px; height: 84px; padding: 0 28px; border-radius: 999px; background: var(--card); box-shadow: 0 4px 0 rgba(0,0,0,.35); }
.wave i { display: block; width: 7px; height: 16px; border-radius: 4px; background: var(--accent); }
.wave.playing i { animation: eq .8s ease-in-out infinite; }
.wave.playing i:nth-child(2) { animation-delay: -.6s; }
.wave.playing i:nth-child(3) { animation-delay: -.2s; }
.wave.playing i:nth-child(4) { animation-delay: -.7s; }
.wave.playing i:nth-child(5) { animation-delay: -.4s; }
.wave.playing i:nth-child(6) { animation-delay: -.1s; }
.wave.playing i:nth-child(7) { animation-delay: -.5s; }
@keyframes eq { 0%, 100% { height: 14px; } 50% { height: 52px; } }
.timer { height: 6px; margin: 16px 8px 0; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; }
.timer span { display: block; height: 100%; width: 100%; background: var(--good); transform-origin: left; }
.reveal { min-height: 2.8em; margin: 10px 0 0; color: var(--muted); font-size: 15px; line-height: 1.4; }
.reveal b { color: var(--ink); }

.options { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 12px; }
.options button {
  position: relative; width: 100%; height: 100%; padding: 0; border-radius: 18px; overflow: hidden; background: var(--card);
  box-shadow: 0 4px 0 rgba(0,0,0,.35); display: flex; flex-direction: column;
}
.options button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.options img { flex: 1; min-height: 0; width: 100%; object-fit: cover; object-position: 50% 28%; }
.options span { padding: 8px 6px; font-weight: 800; font-size: 16px; }
.options button.right { box-shadow: 0 0 0 4px var(--good), 0 4px 0 rgba(0,0,0,.35); }
.options button.wrong { box-shadow: 0 0 0 4px var(--bad); animation: shake .35s; }
.options button.dim { opacity: .35; }
.options button.right::after, .options button.wrong::after {
  position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; color: #1b1420;
}
.options button.right::after { content: "✓"; background: var(--good); }
.options button.wrong::after { content: "✕"; background: var(--bad); }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* result */
#result { justify-content: center; overflow-y: auto; }
.card { text-align: center; }
.card h2 { margin: 0; color: var(--accent); }
.big { margin: 6px 0; font-size: 52px; font-weight: 900; font-variant-numeric: tabular-nums; }
.sub { margin: 0; color: var(--muted); }
.res-list { list-style: none; margin: 14px 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.res-list li { position: relative; }
.res-list img { display: block; width: 100%; aspect-ratio: 1; border-radius: 50%; object-fit: cover; object-position: 50% 28%; border: 3px solid var(--good); }
.res-list li.miss img { border-color: var(--bad); filter: grayscale(.7); }
.res-list span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 6; }
.loading.hide { display: none; }
