:root {
  --bg: #050913;
  --ink: #eaf2ff;
  --ink-dim: #9fb3d1;
  --accent: #4cc9ff;
  --accent-2: #7c5cff;
  --ok: #4ade80;
  --bad: #ff7a7a;
  --card: rgba(12, 22, 44, 0.66);
  --border: rgba(120, 170, 255, 0.22);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, "SF Pro Text", "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }

.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px;
  background: linear-gradient(to bottom, rgba(5,9,19,0.9), rgba(5,9,19,0));
}
.crumb { color: var(--ink-dim); font-size: 14px; }
.crumb a { color: var(--ink-dim); }
.crumb a:hover { color: var(--accent); }
.progress { display: flex; align-items: center; gap: 10px; color: var(--ink-dim); font-size: 13px; font-weight: 600; }
.progress-bar { width: 140px; height: 8px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0%; transition: width .35s ease; }

.stage { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 90px 20px 40px; }
.stage-inner { width: 100%; max-width: 760px; text-align: center; }

/* visualization area */
.viz {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(20px, 5vw, 60px);
  margin: 0 auto 36px;
  flex-wrap: wrap;
  min-height: 180px;
}
.token-group { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 280px; }
.token {
  font-size: clamp(36px, 6vw, 52px); line-height: 1;
  animation: pop .3s ease both;
}
.token:nth-child(n) { animation-delay: calc(var(--i, 0) * 40ms); }
.token.eaten { opacity: 0.28; text-decoration: line-through; text-decoration-color: var(--bad); text-decoration-thickness: 3px; }
@keyframes pop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.op-sign { font-size: clamp(40px, 7vw, 72px); font-weight: 800; color: var(--accent); line-height: 1; }

/* problem expression */
.problem {
  font-size: clamp(40px, 6vw, 72px); font-weight: 800; letter-spacing: -0.02em;
  margin: 0 0 28px;
  display: flex; align-items: center; justify-content: center;
  gap: 16px; flex-wrap: wrap;
}
.problem .eq { color: var(--ink-dim); }

.answer {
  display: inline-block; width: clamp(140px, 22vw, 200px);
  font: 800 clamp(48px, 8vw, 80px)/1 -apple-system, "SF Pro Text", system-ui, sans-serif;
  text-align: center;
  background: rgba(255,255,255,0.04);
  border: 2px solid var(--border);
  border-radius: 22px;
  padding: 18px 8px;
  color: var(--ink); outline: none;
  transition: border-color .2s, background .2s, transform .2s;
  -moz-appearance: textfield;
}
.answer::-webkit-outer-spin-button, .answer::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.answer:focus { border-color: var(--accent); background: rgba(76,201,255,0.08); }
.answer.ok  { border-color: var(--ok); background: rgba(74,222,128,0.10); animation: bump .35s ease; }
.answer.bad { border-color: var(--bad); background: rgba(255,122,122,0.10); animation: shake .35s ease; }
@keyframes bump { 0%,100% {transform:scale(1);} 40% {transform:scale(1.08);} }
@keyframes shake { 0%,100% {transform:translateX(0);} 25% {transform:translateX(-8px);} 75% {transform:translateX(8px);} }

/* multiple choice */
.choices { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 0 0 16px; }
.choice {
  background: rgba(255,255,255,0.04);
  border: 2px solid var(--border); border-radius: 22px;
  padding: 18px 32px;
  font-size: clamp(28px, 4vw, 40px); font-weight: 800; color: var(--ink);
  min-width: 110px;
  transition: border-color .2s, background .2s, transform .2s;
}
.choice:hover { border-color: var(--accent); background: rgba(76,201,255,0.08); transform: translateY(-2px); }
.choice.ok  { border-color: var(--ok); background: rgba(74,222,128,0.15); animation: bump .35s ease; }
.choice.bad { border-color: var(--bad); background: rgba(255,122,122,0.15); animation: shake .35s ease; }
.choice:disabled { cursor: not-allowed; }

.hint { margin-top: 22px; min-height: 32px; font-size: 18px; font-weight: 700; }
.hint.ok  { color: var(--ok); }
.hint.bad { color: var(--bad); }

/* Крупная цифра-бейдж на варианте ответа — чтобы ребёнок жал по цифре */
.choice-num {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #07101f; font-weight: 800; font-size: 26px; line-height: 1;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}

/* Большая кнопка «Слушать» — главный способ для не умеющего читать */
.listen {
  display: inline-flex; align-items: center; gap: 9px;
  background: rgba(255,255,255,0.06);
  border: 2px solid var(--border); color: var(--ink);
  padding: 11px 24px; border-radius: 999px;
  font-weight: 800; font-size: 17px; cursor: pointer;
  margin: 0 0 20px;
  transition: border-color .2s, background .2s, transform .15s;
  animation: listenPulse 2.4s ease-in-out infinite;
}
.listen:hover { border-color: var(--accent); background: rgba(255,255,255,0.12); }
.listen:active { transform: scale(0.96); }
.listen.playing { animation: none; border-color: var(--accent); background: rgba(255,255,255,0.12); }
.listen .li-emoji { font-size: 20px; line-height: 1; }
@keyframes listenPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.0); }
  50%      { box-shadow: 0 0 0 7px rgba(255,255,255,0.05); }
}
@media (max-width: 480px) {
  .choice-num { width: 40px; height: 40px; font-size: 22px; }
}

/* кнопка озвучки */
.speak {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; margin-left: 6px;
  font-size: 18px; line-height: 1;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border); border-radius: 999px;
  color: inherit; cursor: pointer;
  vertical-align: middle;
  transition: background .15s, transform .15s, border-color .15s;
}
.speak:hover { background: rgba(255,255,255,0.16); transform: scale(1.08); border-color: var(--accent); }
.speak:active { transform: scale(0.95); }
.qtext .speak { width: 32px; height: 32px; font-size: 16px; }

.actions { margin-top: 28px; }
.btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #001022; border: 0; padding: 16px 40px; border-radius: 999px;
  font-weight: 800; font-size: 17px; letter-spacing: 0.03em;
  box-shadow: 0 12px 32px rgba(76,201,255,0.35);
  transition: transform .2s;
}
.btn:hover { transform: translateY(-2px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--border); padding: 16px 32px; border-radius: 999px; font-weight: 700; font-size: 16px; }
.btn-ghost:hover { background: rgba(255,255,255,0.05); }

/* finish screen */
.finish { display: none; }
.finish.show { display: block; }
.finish-emoji { font-size: 96px; margin-bottom: 14px; }
.finish h2 { font-size: clamp(32px, 5vw, 48px); margin: 0 0 12px; letter-spacing: -0.02em; }
.finish p { color: var(--ink-dim); font-size: 18px; margin: 0 0 30px; }
.finish-stats {
  display: inline-flex; gap: 40px; padding: 20px 32px;
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  margin-bottom: 30px;
}
.stat-num { font-size: 36px; font-weight: 800; color: var(--accent); }
.stat-lbl { font-size: 12px; color: var(--ink-dim); letter-spacing: 0.18em; text-transform: uppercase; margin-top: 4px; }
.finish-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 640px) {
  .nav { padding: 12px 14px; }
  .progress-bar { width: 90px; }
  .stage { padding: 80px 16px 30px; }
  .viz { gap: 14px; min-height: 140px; margin-bottom: 24px; }
  .token-group { max-width: 200px; gap: 6px; }
  .finish-stats { gap: 24px; padding: 16px 22px; }
  .choice { padding: 14px 22px; min-width: 90px; }
}
