:root {
  --grass-1: #4ade80;
  --grass-2: #22c55e;
  --grass-deep: #15803d;
  --cream: #fffdf5;
  --ink: #1f2937;
  --sun: #fcd34d;
  --coral: #fb7185;
  --sky: #38bdf8;
  --shadow: 0 18px 40px -12px rgba(20, 83, 45, 0.45);
  --radius: 28px;
  --bg: #2d7a3a;
}
[data-theme="dark"] {
  --bg: #0a0f1e;
  --shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: var(--bg);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

#bg-balls {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.card {
  position: relative;
  z-index: 1;
  width: min(540px, 100%);
  background: var(--cream);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 30px 30px;
  border: 3px solid #fff;
  overflow: hidden;
}

/* ---------- screens ---------- */
.screen { display: none; animation: pop 0.45s cubic-bezier(.2,.8,.2,1.2); }
.screen.is-active { display: block; }

@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* ---------- start ---------- */
.screen--start { text-align: center; }

.ball-bounce {
  font-size: 64px;
  display: inline-block;
  animation: bounce 1.4s ease-in-out infinite;
  filter: drop-shadow(0 8px 6px rgba(0,0,0,.18));
}
@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50%      { transform: translateY(-16px) rotate(8deg); }
}

.title {
  font-family: "Baloo 2", cursive;
  font-size: clamp(30px, 8vw, 42px);
  line-height: 1.05;
  margin: 12px 0 14px;
  color: var(--grass-deep);
  letter-spacing: -0.5px;
}
.wiggle {
  display: inline-block;
  color: var(--coral);
  animation: wiggle 1.6s ease-in-out infinite;
}
@keyframes wiggle {
  0%,100% { transform: rotate(-4deg); }
  50%     { transform: rotate(4deg); }
}

.subtitle {
  font-size: 16px;
  line-height: 1.5;
  color: #4b5563;
  max-width: 38ch;
  margin: 0 auto 26px;
  font-weight: 600;
}

.footnote { margin-top: 16px; font-size: 12.5px; color: #9ca3af; font-weight: 700; }

/* ---------- buttons ---------- */
.btn {
  font-family: "Baloo 2", cursive;
  font-size: 18px;
  border: none;
  border-radius: 999px;
  padding: 15px 30px;
  cursor: pointer;
  font-weight: 700;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  color: #fff;
  background: linear-gradient(135deg, var(--coral), #f43f5e);
  box-shadow: 0 10px 0 -2px #be123c, 0 14px 22px -8px rgba(244,63,94,.6);
  touch-action: manipulation;
}
.btn:hover { transform: translateY(-2px); filter: saturate(1.1); }
.btn:active { transform: translateY(4px); box-shadow: 0 6px 0 -2px #be123c; }
.btn:disabled { opacity: .6; cursor: progress; transform: none; }

.btn--big { font-size: 22px; padding: 17px 44px; }

.btn--share {
  background: linear-gradient(135deg, var(--sky), #0ea5e9);
  box-shadow: 0 10px 0 -2px #0369a1, 0 14px 22px -8px rgba(14,165,233,.6);
}
.btn--ghost {
  background: #fff;
  color: var(--grass-deep);
  box-shadow: 0 10px 0 -2px #d1d5db, 0 14px 22px -8px rgba(0,0,0,.15);
  border: 2px solid #e5e7eb;
}
.btn--save {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  box-shadow: 0 10px 0 -2px #166534, 0 14px 22px -8px rgba(34,197,94,.5);
}
#retry-btn { grid-column: 1 / -1; }

/* ---------- quiz ---------- */
.quiz-head { margin-bottom: 22px; }
.progress {
  height: 14px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.12);
}
.progress__bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: repeating-linear-gradient(45deg, var(--sun), var(--sun) 10px, #fbbf24 10px, #fbbf24 20px);
  transition: width .4s cubic-bezier(.2,.8,.2,1);
}
.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}
.qcount { font-weight: 800; color: #6b7280; font-size: 14px; }
.back-btn {
  background: none; border: none; cursor: pointer;
  font-family: "Nunito"; font-weight: 800; font-size: 14px;
  color: #9ca3af; padding: 6px 8px; visibility: hidden;
}
.back-btn:hover { color: var(--grass-deep); }

.question {
  font-family: "Baloo 2", cursive;
  font-size: clamp(21px, 5vw, 27px);
  line-height: 1.2;
  color: var(--grass-deep);
  margin-bottom: 20px;
}
.options { display: grid; gap: 11px; }
.option {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: #fff;
  border: 2.5px solid #eef0f2;
  border-radius: 18px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
  touch-action: manipulation;
}
@media (hover: hover) {
  .option:hover {
    transform: translateX(4px) scale(1.01);
    border-color: var(--coral);
    background: #fff5f7;
  }
}
.option:active { transform: scale(0.99); }
.option.selected {
  border-color: #22c55e;
  background: #f0fdf4;
  transform: translateX(4px) scale(1.02);
  color: #15803d;
}
.option .emoji { font-size: 26px; flex-shrink: 0; }

/* ---------- result ---------- */
.screen--result { text-align: center; }
.result-card {
  border-radius: 24px;
  padding: 26px 22px 24px;
  color: #fff;
  background: linear-gradient(150deg, var(--sky), #6366f1);
  box-shadow: 0 16px 30px -10px rgba(99,102,241,.55);
  position: relative;
  overflow: hidden;
}
.result-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% -10%, rgba(255,255,255,.35), transparent 40%);
  pointer-events: none;
}
.result-badge {
  position: absolute;
  top: 14px; left: 16px;
  font-size: 26px;
  opacity: .9;
}
.result-emoji {
  font-size: 84px;
  line-height: 1;
  filter: drop-shadow(0 8px 8px rgba(0,0,0,.25));
  animation: bounce 1.6s ease-in-out infinite;
}
.result-kicker { font-weight: 800; opacity: .85; letter-spacing: .5px; text-transform: uppercase; font-size: 12px; margin-top: 10px; }
.result-name {
  font-family: "Baloo 2", cursive;
  font-size: clamp(30px, 8vw, 40px);
  margin: 2px 0 4px;
}
.result-style { font-weight: 800; font-size: 16px; opacity: .95; margin-bottom: 12px; }
.result-desc { font-size: 15px; line-height: 1.5; font-weight: 600; opacity: .96; max-width: 36ch; margin: 0 auto; }

.result-stats {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.stat {
  background: rgba(255,255,255,.18);
  border: 1.5px solid rgba(255,255,255,.3);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 800;
}
.result-family {
  margin-top: 16px;
  font-size: 12.5px;
  font-weight: 700;
  opacity: .9;
  line-height: 1.4;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}
.result-actions .btn {
  font-size: 15px;
  padding: 13px 10px;
}


.share-hint {
  margin-top: 14px;
  font-size: 13px;
  font-weight: 800;
  color: var(--grass-deep);
  min-height: 18px;
  transition: opacity .2s;
}

.page-footer {
  position: relative;
  z-index: 1;
  margin-top: 18px;
  color: rgba(255,255,255,.9);
  font-weight: 700;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0,0,0,.2);
}

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.sound-toggle,
.theme-toggle {
  position: fixed;
  z-index: 60;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(255, 255, 255, 0.9);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 6px 16px -4px rgba(0, 0, 0, 0.3);
  transition: transform .12s ease, background .12s ease;
  line-height: 1;
  touch-action: manipulation;
  bottom: max(16px, env(safe-area-inset-bottom));
}
.sound-toggle { right: 16px; }
.theme-toggle { right: 72px; }
.sound-toggle:hover, .theme-toggle:hover { transform: scale(1.1); }
.sound-toggle:active, .theme-toggle:active { transform: scale(0.94); }
.sound-toggle.is-muted { background: rgba(255, 255, 255, 0.55); filter: grayscale(1); }

/* ---------- mobile ---------- */
@media (max-width: 480px) {
  .card { padding: 26px 18px 22px; border-radius: 24px; }
  .ball-bounce { font-size: 56px; }
  .subtitle { font-size: 15px; }
  .option { padding: 13px 14px; font-size: 15.5px; }
  .result-actions .btn { font-size: 13px; padding: 13px 8px; }
  .sound-toggle { bottom: 12px; right: 12px; }
  .theme-toggle { bottom: 12px; right: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
