:root {
  --bg: #0f1220;
  --card: #1b1f33;
  --accent: #6ee7b7;
  --wrong: #f87171;
  --text: #eef0f7;
  --muted: #9aa0b4;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, #0f1220, #171b2e);
  color: var(--text);
  min-height: 100vh;
}
.app { max-width: 640px; margin: 0 auto; padding: 24px 16px 60px; }
header h1 { text-align: center; margin: 8px 0 0; font-size: 2rem; }
.subtitle { text-align: center; color: var(--muted); margin-top: 4px; }
.topbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center;
  margin: 16px 0 24px;
}
.topbar label { font-size: 0.85rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.topbar select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid #333a55;
  background: #11142c; color: var(--text); min-width: 200px;
}
.topbar button {
  padding: 9px 16px; border-radius: 8px; border: none; background: var(--accent);
  color: #06231a; font-weight: 600; cursor: pointer; align-self: flex-end;
}
.topbar button:hover { filter: brightness(1.05); }
.badge {
  font-size: 0.8rem; background: #2b3a2f; color: var(--accent);
  padding: 6px 10px; border-radius: 999px; align-self: flex-end;
}
.card {
  background: var(--card); border-radius: 16px; padding: 28px 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.progress { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.85rem; margin-bottom: 8px; }
.hanzi { font-size: 5rem; text-align: center; margin: 8px 0 24px; }
.question h2 { font-size: 1rem; color: var(--muted); margin: 0 0 12px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.opt {
  padding: 14px; border-radius: 10px; border: 1px solid #333a55; background: #11142c;
  color: var(--text); cursor: pointer; font-size: 1.05rem; text-align: center; transition: background 0.15s;
}
.opt:hover:not(:disabled) { background: #191d38; }
.opt:disabled { cursor: default; }
.opt.correct { background: #16311f; border-color: var(--accent); color: var(--accent); }
.opt.wrong { background: #351a1a; border-color: var(--wrong); color: var(--wrong); }

.opt.celebrate {
  animation: correctPop 0.5s ease;
}
@keyframes correctPop {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(110, 231, 183, 0); }
  40% { transform: scale(1.08); box-shadow: 0 0 24px rgba(110, 231, 183, 0.65); }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(110, 231, 183, 0); }
}

.card.finish-celebrate {
  animation: finishPop 0.9s ease;
}
@keyframes finishPop {
  0% { transform: scale(1) rotate(0deg); box-shadow: 0 10px 30px rgba(0,0,0,0.35); }
  30% { transform: scale(1.05) rotate(-1deg); box-shadow: 0 0 40px rgba(110, 231, 183, 0.7); }
  60% { transform: scale(1.03) rotate(1deg); box-shadow: 0 0 50px rgba(253, 230, 138, 0.6); }
  100% { transform: scale(1) rotate(0deg); box-shadow: 0 10px 30px rgba(0,0,0,0.35); }
}

.confetti-piece {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 999;
  animation: confettiBurst 0.7s ease-out forwards;
}
@keyframes confettiBurst {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(360deg) scale(0.4); opacity: 0; }
}
#nextBtn {
  width: 100%; padding: 12px; border-radius: 10px; border: none; background: var(--accent);
  color: #06231a; font-weight: 700; font-size: 1rem; cursor: pointer;
}
.status { text-align: center; color: var(--muted); margin-top: 16px; min-height: 1.2em; }
