:root {
  --bg: #fff8ef;
  --ink: #2d2a4a;
  --muted: #6e6a8c;
  --primary: #7c5cff;
  --primary-dark: #5a3ee0;
  --secondary: #ffb547;
  --secondary-dark: #e8952a;
  --right: #2fbf71;
  --wrong: #ff5d73;
  --card: #ffffff;
  --radius: 24px;
  --shadow: 0 6px 0 rgba(45, 42, 74, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg) radial-gradient(circle at 15% 10%, #ffe3f0 0, transparent 35%),
    radial-gradient(circle at 85% 90%, #e2f0ff 0, transparent 40%);
  color: var(--ink);
  font-family: "Fredoka", "Comic Sans MS", system-ui, sans-serif;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.screen { text-align: center; animation: pop 0.25s ease-out; }
[hidden] { display: none !important; }

.title { font-size: clamp(2.2rem, 9vw, 3.2rem); line-height: 1.05; margin: 16px 0 8px; }
.title span { color: var(--primary); }
.subtitle { color: var(--muted); font-size: 1.1rem; margin: 8px 0 24px; }

.actions { display: flex; flex-direction: column; gap: 14px; margin: 24px 0; }

.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  padding: 14px 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.08s, box-shadow 0.08s;
  color: var(--ink);
  background: var(--card);
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(45, 42, 74, 0.12); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-big { font-size: 1.4rem; padding: 20px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 0 var(--primary-dark); }
.btn-secondary { background: var(--secondary); box-shadow: 0 6px 0 var(--secondary-dark); }
.btn-right { background: var(--right); color: #fff; box-shadow: 0 6px 0 #1f9456; }
.btn-wrong { background: var(--wrong); color: #fff; box-shadow: 0 6px 0 #d63d53; }
.btn-sound { font-size: 1.1rem; flex: 1; }

.btn-link {
  font: inherit;
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

.badge {
  display: inline-block;
  min-width: 1.8em;
  padding: 2px 8px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 1rem;
}

.stats p { color: var(--muted); }
.history { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0 32px; }
.chip { white-space: pre; padding: 6px 12px; border-radius: 999px; font-weight: 600; background: var(--card); box-shadow: var(--shadow); }
.chip-pass { color: var(--right); }
.chip-fail { color: var(--wrong); }

/* exam */
.exam-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pill { background: var(--card); padding: 6px 12px; border-radius: 999px; font-weight: 600; box-shadow: var(--shadow); }
.counter { font-weight: 700; font-size: 1.3rem; }
.progress { height: 12px; background: #ece6ff; border-radius: 999px; margin: 16px 0 24px; overflow: hidden; }
.progress-bar { height: 100%; width: 100%; background: var(--primary); transform: scaleX(0); transform-origin: left; transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1); }

.card {
  background: var(--card);
  border-radius: 32px;
  padding: 28px 20px;
  box-shadow: 0 10px 0 rgba(45, 42, 74, 0.1);
}
.mystery {
  width: 140px;
  height: 140px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 5rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #ff7ac6);
  animation: wobble 2.5s ease-in-out infinite;
}
.hint { font-size: 1.2rem; color: var(--muted); }
.sound-buttons, .answer-buttons { display: flex; gap: 12px; margin: 20px 0; }
.answer-buttons .btn { flex: 1; font-size: 1.4rem; padding: 18px; }

.label { color: var(--muted); margin: 0; font-size: 1.1rem; }
.word { font-size: clamp(2.6rem, 13vw, 4rem); font-weight: 700; color: var(--primary); margin: 8px 0; word-break: break-word; }
.sentence { color: var(--muted); font-style: italic; }
.question { font-size: 1.3rem; font-weight: 600; margin-top: 24px; }

/* results */
.grade {
  font-size: 7rem;
  font-weight: 700;
  line-height: 1;
  width: 180px;
  height: 180px;
  margin: 8px auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  animation: pop 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.grade-pass { background: var(--right); box-shadow: 0 8px 0 #1f9456; }
.grade-fail { background: var(--wrong); box-shadow: 0 8px 0 #d63d53; }
.grade-message { font-size: 1.8rem; font-weight: 700; margin: 20px 0 4px; }

.result-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  text-align: left;
}
.result-list li { white-space: pre; background: var(--card); padding: 10px 14px; border-radius: 16px; font-weight: 600; box-shadow: var(--shadow); }
.result-list li.ko { color: var(--wrong); }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span { position: absolute; top: -40px; font-size: 1.8rem; animation: fall 3s linear forwards; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 16px;
}

@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes wobble { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
