:root {
  --bg: #fff4e0;
  --ink: #2b2140;
  --card: #ffffff;
  --pink: #ff5d8f;
  --orange: #ff9f1c;
  --yellow: #ffd60a;
  --teal: #2ec4b6;
  --blue: #3a86ff;
  --purple: #8338ec;
  --green: #35c759;
  --red: #ff3b5c;
  --lvl: var(--pink);
  --radius: 22px;
  --font: 'Fredoka', 'Arial Rounded MT Bold', 'Nunito', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}
button { font-family: inherit; font-size: inherit; cursor: pointer; border: 0; color: inherit; }
[hidden] { display: none !important; }
button:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }

/* background bubbles */
.bg-shapes { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-shapes span {
  position: absolute; border-radius: 50%; opacity: 0.18;
  animation: float 14s ease-in-out infinite alternate;
}
.bg-shapes span:nth-child(1) { width: 220px; height: 220px; background: var(--pink); top: -60px; left: -60px; }
.bg-shapes span:nth-child(2) { width: 160px; height: 160px; background: var(--teal); top: 30%; right: -40px; animation-delay: -3s; }
.bg-shapes span:nth-child(3) { width: 300px; height: 300px; background: var(--yellow); bottom: -120px; left: 10%; animation-delay: -6s; }
.bg-shapes span:nth-child(4) { width: 120px; height: 120px; background: var(--blue); top: 55%; left: -30px; animation-delay: -9s; }
.bg-shapes span:nth-child(5) { width: 180px; height: 180px; background: var(--purple); bottom: 10%; right: 5%; animation-delay: -2s; }
.bg-shapes span:nth-child(6) { width: 90px; height: 90px; background: var(--orange); top: 8%; right: 25%; animation-delay: -5s; }
@keyframes float { from { transform: translateY(0) scale(1); } to { transform: translateY(-40px) scale(1.12); } }

#app { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; padding: 12px 16px 40px; }
.screen { display: none; animation: screen-in 0.4s cubic-bezier(.2,.9,.3,1.3); }
.screen.active { display: block; }
@keyframes screen-in { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: none; } }

/* ---------- Home ---------- */
.home-top { display: flex; justify-content: flex-end; }
.title {
  text-align: center; font-size: clamp(2.4rem, 9vw, 4rem); margin: 0 0 8px; line-height: 1;
  letter-spacing: -0.02em; font-weight: 700;
}
.title span { display: inline-block; animation: bob 2.4s ease-in-out infinite; }
.title span:nth-child(1) { color: var(--pink); }
.title span:nth-child(2) { color: var(--teal); animation-delay: 0.2s; }
.title span:nth-child(3) { color: var(--blue); animation-delay: 0.4s; }
.title span:nth-child(4) { color: var(--orange); animation-delay: 0.6s; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }

.clock-wrap { display: flex; justify-content: center; }
.home-clock { width: min(52vw, 260px); margin: 0 auto; cursor: pointer; }
.home-clock .clock { width: 100%; }
.greeting { text-align: center; font-size: 1.25rem; margin: 10px 0 6px; font-weight: 600; }

.stats-row { display: flex; justify-content: center; gap: 14px; margin: 10px 0 18px; }
.stat { background: var(--card); border-radius: 18px; padding: 10px 22px; text-align: center; min-width: 120px; }
.stat-value { display: block; font-size: 2rem; font-weight: 700; color: var(--purple); line-height: 1; }
.stat-label { font-size: 0.9rem; opacity: 0.7; }

.section-heading { font-size: 1.3rem; margin: 18px 0 8px; }
.mode-row { display: flex; gap: 10px; flex-wrap: wrap; }
.mode-btn {
  flex: 1 1 140px; padding: 14px 10px; border-radius: 16px; background: var(--card);
  font-weight: 600; font-size: 1.05rem; transition: transform 0.15s, background 0.15s, color 0.15s;
  box-shadow: 0 4px 0 rgba(0,0,0,0.08);
}
.mode-btn:active { transform: translateY(3px); box-shadow: none; }
.mode-btn.active { background: var(--purple); color: #fff; }

.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.level-card {
  text-align: left; background: var(--card); border-radius: var(--radius); padding: 14px 16px 16px;
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center;
  border: 4px solid transparent; box-shadow: 0 6px 0 rgba(0,0,0,0.08);
  transition: transform 0.15s, box-shadow 0.15s;
}
.level-card:not(.locked):hover { transform: translateY(-3px); box-shadow: 0 9px 0 rgba(0,0,0,0.1); }
.level-card:not(.locked):active { transform: translateY(3px); box-shadow: none; }
.level-card.locked { opacity: 0.55; cursor: not-allowed; }
.level-num {
  grid-row: 1 / span 3; width: 56px; height: 56px; border-radius: 50%; background: var(--lvl); color: #fff;
  display: grid; place-items: center; font-size: 1.8rem; font-weight: 700;
}
.level-name { font-size: 1.25rem; font-weight: 700; color: var(--lvl); }
.level-blurb { font-size: 0.95rem; opacity: 0.75; }
.level-stars { color: var(--orange); font-size: 1.2rem; letter-spacing: 2px; }
.level-go { grid-column: 1 / -1; margin-top: 8px; font-weight: 600; font-size: 0.95rem; color: var(--purple); }
.level-card.locked .level-go { color: inherit; opacity: 0.8; }

.home-actions { display: flex; justify-content: center; margin-top: 20px; }

/* ---------- Buttons ---------- */
.btn {
  padding: 14px 24px; border-radius: 999px; font-weight: 700; font-size: 1.15rem;
  box-shadow: 0 5px 0 rgba(0,0,0,0.15); transition: transform 0.12s, box-shadow 0.12s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,0.15); }
.btn.big { font-size: 1.4rem; padding: 18px 36px; }
.btn-primary { background: var(--green); color: #fff; }
.btn-accent { background: var(--pink); color: #fff; }
.btn-secondary { background: var(--card); color: var(--ink); }
.btn.small-btn { padding: 8px 16px; font-size: 1rem; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%; background: var(--card); font-size: 1.4rem; display: grid; place-items: center;
  box-shadow: 0 4px 0 rgba(0,0,0,0.1);
}
.icon-btn:active { transform: translateY(3px); box-shadow: none; }
.icon-btn.small { width: 40px; height: 40px; font-size: 1.1rem; }

/* ---------- Play ---------- */
.play-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.progress { flex: 1; display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: rgba(0,0,0,0.12); transition: transform 0.2s, background 0.2s; }
.dot.now { background: var(--lvl); transform: scale(1.35); animation: pulse 1s infinite; }
.dot.good { background: var(--green); }
.dot.bad { background: var(--red); }
@keyframes pulse { 50% { transform: scale(1.1); } }

.score-box { display: flex; align-items: center; gap: 10px; }
.score { background: var(--purple); color: #fff; border-radius: 999px; padding: 6px 16px; font-weight: 700; font-size: 1.2rem; min-width: 60px; text-align: center; }
.streak { display: flex; align-items: center; gap: 2px; font-weight: 700; font-size: 1.05rem; opacity: 0.5; transition: opacity 0.2s; }
.streak .flame { display: inline-block; transition: transform 0.2s; filter: grayscale(1); }
.streak.hot { opacity: 1; }
.streak.hot .flame { filter: none; animation: flicker 0.5s infinite alternate; }
.streak[data-mult="2"] .flame { transform: scale(1.2); }
.streak[data-mult="3"] .flame { transform: scale(1.45); }
.streak[data-mult="4"] .flame { transform: scale(1.7); }
@keyframes flicker { from { transform: scale(1.2) rotate(-6deg); } to { transform: scale(1.4) rotate(6deg); } }

.play-body { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.prompt { font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 700; margin: 6px 0 0; text-align: center; }
.prompt.small { font-size: 1rem; flex: 1; margin: 0; font-weight: 600; }
.play-clock { width: min(90vw, 390px); }
.play-clock .clock { width: 100%; }

.target {
  display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 999px; padding: 10px 14px 10px 22px;
  flex-wrap: wrap; justify-content: center;
}
.target-words { font-size: clamp(1.4rem, 5.5vw, 2rem); font-weight: 700; color: var(--lvl); }
.target-digital { font-size: 1.1rem; opacity: 0.7; font-weight: 600; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.option {
  background: var(--card); border-radius: 18px; padding: 14px 10px; display: flex; flex-direction: column; gap: 4px;
  box-shadow: 0 5px 0 rgba(0,0,0,0.1); border: 4px solid transparent; min-height: 84px; justify-content: center;
  animation: opt-in 0.35s cubic-bezier(.2,.9,.3,1.4) both; transition: transform 0.12s, box-shadow 0.12s, border-color 0.2s, background 0.2s;
}
.option:not(:disabled):hover { transform: translateY(-2px); border-color: var(--lvl); }
.option:not(:disabled):active { transform: translateY(4px); box-shadow: none; }
.option:disabled { cursor: default; opacity: 0.55; }
.option.right { opacity: 1; background: var(--green); color: #fff; animation: pop 0.4s; }
.option.wrong { opacity: 1; background: var(--red); color: #fff; animation: shake 0.4s; }
.opt-words { font-size: clamp(1.05rem, 4vw, 1.3rem); font-weight: 700; }
.opt-digital { font-size: 0.95rem; opacity: 0.8; font-weight: 600; }
@keyframes opt-in { from { opacity: 0; transform: scale(0.7) translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes pop { 30% { transform: scale(1.08); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.set-actions { margin-top: 4px; }

/* feedback card */
.feedback {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; pointer-events: none;
}
.feedback-card {
  pointer-events: auto; background: var(--card); border-radius: 28px; padding: 18px 22px; width: min(100%, 440px);
  text-align: center; box-shadow: 0 20px 60px rgba(43,33,64,0.25); border: 5px solid var(--green);
  animation: card-in 0.45s cubic-bezier(.2,.9,.3,1.4);
}
.feedback.bad .feedback-card { border-color: var(--orange); }
@keyframes card-in { from { transform: translateY(80px) scale(0.8); opacity: 0; } to { transform: none; opacity: 1; } }
.feedback-emoji { font-size: 3rem; line-height: 1; animation: bob 1.2s infinite; }
.feedback-title { font-size: 2rem; font-weight: 700; margin-top: 4px; }
.feedback.good .feedback-title { color: var(--green); }
.feedback.bad .feedback-title { color: var(--orange); }
.feedback-sub { font-size: 1.3rem; font-weight: 600; margin-top: 2px; }
.feedback-points { font-size: 1.1rem; color: var(--purple); font-weight: 700; margin: 6px 0 12px; }

.popup {
  position: fixed; top: 22%; left: 50%; z-index: 30; transform: translate(-50%, 0) scale(0.5); pointer-events: none;
  background: var(--yellow); color: var(--ink); font-weight: 700; font-size: 2rem; padding: 12px 28px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2); opacity: 0;
}
.popup.show { animation: popup 1.4s cubic-bezier(.2,.9,.3,1.3) forwards; }
@keyframes popup {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(0.5) rotate(-6deg); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1.15) rotate(3deg); }
  35% { transform: translate(-50%, 0) scale(1) rotate(0); }
  80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -30px) scale(0.9); }
}

/* ---------- Summary ---------- */
.summary-card { background: var(--card); border-radius: 32px; padding: 28px 20px; text-align: center; margin-top: 30px; }
.summary-title { font-size: clamp(2rem, 8vw, 3rem); margin: 0; color: var(--purple); }
.stars { font-size: clamp(3.5rem, 16vw, 6rem); line-height: 1; margin: 10px 0; color: #d9d2e9; display: flex; justify-content: center; gap: 8px; }
.stars span { display: inline-block; transition: color 0.2s; }
.stars span.lit { color: var(--yellow); animation: star-in 0.5s cubic-bezier(.2,.9,.3,1.6); text-shadow: 0 0 20px rgba(255,214,10,0.7); }
.stars span:nth-child(2) { transform: translateY(-14px); }
.stars span:nth-child(2).lit { animation-name: star-in-mid; }
@keyframes star-in { 0% { transform: scale(0) rotate(-180deg); } 70% { transform: scale(1.35) rotate(10deg); } 100% { transform: scale(1); } }
@keyframes star-in-mid { 0% { transform: translateY(-14px) scale(0) rotate(-180deg); } 70% { transform: translateY(-14px) scale(1.4) rotate(10deg); } 100% { transform: translateY(-14px) scale(1); } }
.summary-score { font-size: 1.6rem; font-weight: 600; }
.summary-score span { font-size: 2.6rem; font-weight: 700; color: var(--pink); }
.summary-line { margin-top: 4px; font-size: 1.15rem; opacity: 0.8; }
.summary-banner {
  margin: 16px auto 0; background: var(--teal); color: #fff; font-weight: 700; font-size: 1.25rem; padding: 12px 18px;
  border-radius: 999px; display: inline-block; animation: pop 0.6s;
}
.summary-actions { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: 22px; }

/* ---------- Explore ---------- */
.explore-readout { text-align: center; }
.explore-readout .target-words { display: block; font-size: clamp(1.8rem, 7vw, 2.6rem); color: var(--purple); }
.explore-readout .target-digital { font-size: 1.4rem; }
.explore-helpers { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; font-size: 1.05rem; font-weight: 600; }
.explore-helpers input { width: 22px; height: 22px; vertical-align: middle; accent-color: var(--purple); }

/* ---------- Clock (SVG) ---------- */
.clock { display: block; overflow: visible; touch-action: none; }
.clock-rim { fill: var(--lvl); }
.clock-face { fill: #fff; }
.tick { stroke: #c9c2d8; stroke-width: 1.5; stroke-linecap: round; }
.tick.major { stroke: var(--ink); stroke-width: 3; }
.hour-number { font-family: var(--font); font-size: 15px; font-weight: 700; fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.minute-number { font-family: var(--font); font-size: 7.5px; font-weight: 700; fill: var(--ink); dominant-baseline: central; opacity: 0; transition: opacity 0.3s; }
.minute-number.past { fill: #1a9c90; }
.minute-number.to { fill: #e0306a; }
.clock.show-minutes .minute-number { opacity: 1; }
.clock.show-minutes .clock-halves { opacity: 1; }
.clock-halves { opacity: 0; transition: opacity 0.3s; }
.clock.show-halves .clock-halves { opacity: 1; }
.half.past { fill: rgba(46,196,182,0.18); }
.half.to { fill: rgba(255,93,143,0.16); }
.half-label { font-family: var(--font); font-size: 9px; font-weight: 700; text-anchor: middle; fill: var(--ink); opacity: 0.55; }

.clock-mascot .eye { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.clock-mascot .pupil { fill: var(--ink); }
.clock-mascot .shine { fill: #fff; }
.clock-mascot .mouth { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; transition: d 0.2s; }
.clock[data-mood="big"] .mouth { fill: #ff7b9c; }
.clock-mascot .cheek { fill: #ffb3c6; opacity: 0.8; }
.clock[data-mood="sad"] .eye { transform: scaleY(0.6); transform-box: fill-box; transform-origin: center; }
.clock[data-mood="wow"] .eye { transform: scale(1.2); transform-box: fill-box; transform-origin: center; }
.clock-mascot .eye { transition: transform 0.2s; }

.hand .stick { stroke: var(--ink); stroke-linecap: round; }
.hand.hour .stick { stroke-width: 8; }
.hand.minute .stick { stroke-width: 5; }
.hand .tip { fill: var(--ink); }
.hand.hour .tip { fill: var(--pink); }
.hand.minute .tip { fill: var(--blue); }
.hand .grab { stroke: transparent; stroke-width: 28; stroke-linecap: round; }
.pivot { fill: var(--yellow); stroke: var(--ink); stroke-width: 2; }
.hand { transition: transform 0.45s cubic-bezier(.3,1.4,.5,1); }
.clock.dragging .hand { transition: none; }
.clock.interactive .hand { cursor: grab; }
.clock.dragging .hand { cursor: grabbing; }
.clock.interactive .hand.minute .stick { stroke: var(--blue); }
.clock.interactive .hand.hour .stick { stroke: var(--pink); }
.clock.interactive .hand .tip { animation: glow 1s infinite alternate; }
@keyframes glow { from { filter: drop-shadow(0 0 0 rgba(0,0,0,0)); } to { filter: drop-shadow(0 0 4px var(--yellow)); } }
.clock.drag-minute .hand.hour .tip, .clock.drag-hour .hand.minute .tip { animation: none; }

.clock.bounce { animation: clock-bounce 0.5s cubic-bezier(.2,.9,.3,1.4); }
@keyframes clock-bounce { 0% { transform: scale(0.92); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }
.clock.wobble { animation: clock-wobble 0.5s; }
@keyframes clock-wobble { 20% { transform: rotate(-5deg); } 40% { transform: rotate(5deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(3deg); } }

#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }

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