:root {
  font-family: 'Nunito', system-ui, sans-serif;
  color: #243047;
  background: #fff9e8;
  --ink: #243047;
  --honey: #fbbf24;
  --honey-dark: #b45309;
  --teal: #0f766e;
  --cream: #fffdf6;
  --line: rgba(36, 48, 71, 0.13);
  --shadow: 0 18px 48px rgba(82, 63, 19, 0.13);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #fff9e8; }
body { margin: 0; min-width: 320px; background:
  radial-gradient(circle at 8% 8%, rgba(251, 191, 36, .25), transparent 19rem),
  radial-gradient(circle at 92% 22%, rgba(45, 212, 191, .18), transparent 20rem),
  linear-gradient(180deg, #fff9e8, #eefdf8); }
button, input { font: inherit; }
button { touch-action: manipulation; }
.skip-link { position: fixed; left: 12px; top: 12px; z-index: 200; transform: translateY(-180%); padding: 10px 14px; border-radius: 12px; background: #111827; color: white; font-weight: 800; }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.game-root { width: 100%; min-height: 0; padding: clamp(14px, 3vw, 30px) max(12px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); overflow-x: clip; }
.shell { width: min(100%, 1100px); margin-inline: auto; }
.play-shell { width: min(100%, 760px); margin-inline: auto; }
.card { border: 1px solid var(--line); border-radius: 26px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.hero { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(250px, .7fr); gap: clamp(20px, 5vw, 54px); align-items: center; padding: clamp(24px, 5vw, 50px); overflow: hidden; }
.eyebrow { margin: 0 0 8px; color: var(--honey-dark); font-weight: 900; letter-spacing: .08em; text-transform: uppercase; font-size: .8rem; }
h1, h2, h3 { font-family: 'Fredoka', system-ui, sans-serif; color: #1f2937; line-height: 1.04; }
h1 { margin: 0; font-size: clamp(2.4rem, 8vw, 5.2rem); letter-spacing: -.04em; }
h2 { margin: 0; font-size: clamp(1.8rem, 5vw, 3rem); }
h3 { margin: 0; font-size: 1.28rem; }
.lead { max-width: 640px; margin: 18px 0 0; font-size: clamp(1.05rem, 2vw, 1.25rem); line-height: 1.65; color: #4b5563; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.btn { min-height: 48px; border: 0; border-radius: 999px; padding: 12px 20px; background: var(--teal); color: #fff; font-weight: 900; box-shadow: 0 5px 0 #115e59; cursor: pointer; transition: transform .14s ease, box-shadow .14s ease; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #115e59; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #115e59; }
.btn.secondary { background: #fff; color: #334155; border: 2px solid #d7dee8; box-shadow: 0 4px 0 #cbd5e1; }
.btn.honey { background: #f59e0b; color: #422006; box-shadow: 0 5px 0 #b45309; }
.btn:focus-visible, .level-btn:focus-visible, .key:focus-visible, input:focus-visible { outline: 4px solid rgba(14,165,233,.45); outline-offset: 3px; }
.btn:disabled, .level-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.bee-scene { position: relative; display: grid; place-items: center; min-height: 280px; isolation: isolate; }
.bee { width: min(58vw, 220px); aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: #fbbf24; border: 10px solid #f59e0b; box-shadow: inset 0 -18px 0 rgba(180,83,9,.14), 0 25px 45px rgba(180,83,9,.22); font-size: clamp(5rem, 16vw, 8rem); animation: hover 3s ease-in-out infinite; }
.bee-scene::before, .bee-scene::after { content: ''; position: absolute; width: 90px; height: 125px; border-radius: 50%; background: rgba(255,255,255,.85); border: 4px solid #bae6fd; z-index: -1; }
.bee-scene::before { transform: translate(-90px,-30px) rotate(-26deg); }
.bee-scene::after { transform: translate(90px,-30px) rotate(26deg); }
@keyframes hover { 50% { transform: translateY(-10px) rotate(2deg); } }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 24px; }
.stat { padding: 14px; border-radius: 18px; background: #fff8dc; border: 1px solid #fde68a; text-align: center; }
.stat strong { display: block; font-family: 'Fredoka'; font-size: 1.55rem; }
.stat span { font-size: .78rem; color: #6b7280; font-weight: 800; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 15px; background: #fff; color: var(--ink); font-size: 1.25rem; cursor: pointer; box-shadow: 0 4px 0 #e2e8f0; }
.level-grid { display: grid; gap: 20px; margin-top: 22px; }
.world-card { padding: clamp(18px, 3vw, 28px); }
.world-head { display: flex; justify-content: space-between; gap: 16px; align-items: start; margin-bottom: 14px; }
.world-head p { margin: 6px 0 0; color: #64748b; }
.world-lock { padding: 7px 11px; border-radius: 999px; background: #f1f5f9; font-weight: 900; font-size: .82rem; white-space: nowrap; }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.level-btn { min-height: 116px; display: grid; align-content: center; gap: 5px; border: 2px solid #fde68a; border-radius: 20px; background: #fffbeb; color: #334155; padding: 12px; cursor: pointer; text-align: left; }
.level-btn:hover:not(:disabled) { border-color: #f59e0b; transform: translateY(-2px); }
.level-btn .number { color: #b45309; font-size: .78rem; font-weight: 900; text-transform: uppercase; }
.level-btn .stars { letter-spacing: 2px; color: #f59e0b; }
.level-btn.locked { border-color: #e2e8f0; background: #f8fafc; }

.round-card { padding: clamp(18px, 4vw, 34px); }
.progress-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; margin-bottom: 18px; font-weight: 900; }
.progress { height: 12px; border-radius: 999px; overflow: hidden; background: #e2e8f0; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f59e0b, #facc15); transition: width .25s ease; }
.prompt { text-align: center; }
.listen { width: min(180px, 48vw); aspect-ratio: 1; margin: 22px auto 14px; display: grid; place-items: center; border: 0; border-radius: 50%; background: linear-gradient(145deg, #fcd34d, #f59e0b); box-shadow: 0 10px 0 #b45309, 0 22px 40px rgba(180,83,9,.22); color: #422006; cursor: pointer; }
.listen .speaker { font-size: clamp(3.5rem, 14vw, 5.4rem); }
.listen .listen-label { display: block; font-size: .9rem; font-weight: 900; }
.listen.playing { animation: pulse .8s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.04); box-shadow: 0 8px 0 #b45309, 0 22px 48px rgba(245,158,11,.38); } }
.sentence { min-height: 30px; margin: 12px 0; color: #475569; font-weight: 800; text-align: center; }
.answer-label { display: block; margin: 22px 0 8px; font-weight: 900; text-align: center; }
.sentence:empty { display: none; }
.answer-input { width: 100%; min-height: 58px; border: 3px solid #cbd5e1; border-radius: 18px; background: #fff; color: #1e293b; padding: 10px 18px; text-align: center; font-family: 'Fredoka'; font-size: clamp(1.35rem, 6vw, 2rem); letter-spacing: .08em; }
.feedback { min-height: 52px; display: grid; place-items: center; margin: 12px 0; padding: 10px; border-radius: 16px; font-weight: 900; text-align: center; }
.feedback.correct { background: #dcfce7; color: #166534; }
.feedback.try { background: #fff7ed; color: #9a3412; }
.feedback.error { background: #fee2e2; color: #991b1b; }
.context-btn { display: block; margin: 0 auto; border: 0; background: transparent; color: #0f766e; text-decoration: underline; font-weight: 900; cursor: pointer; min-height: 44px; }

.keyboard { display: grid; gap: 7px; margin-top: 16px; }
.key-row { display: flex; justify-content: center; gap: 6px; }
.key { min-width: 0; width: min(8.5vw, 46px); min-height: 46px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: #334155; box-shadow: 0 3px 0 #cbd5e1; font-weight: 900; cursor: pointer; }
.key.wide { width: auto; min-width: 78px; padding-inline: 12px; }
.submit-row { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
.teaching-word { margin: 16px 0 6px; font-family: 'Fredoka'; font-size: clamp(2.3rem, 10vw, 4.4rem); color: #b45309; letter-spacing: .06em; text-align: center; }
.pattern-chip { width: fit-content; margin: 0 auto 12px; border-radius: 999px; background: #fef3c7; color: #92400e; padding: 7px 12px; font-weight: 900; }

.result { padding: clamp(24px, 5vw, 48px); text-align: center; }
.big-stars { margin: 18px 0 10px; color: #f59e0b; font-size: clamp(3rem, 13vw, 6rem); letter-spacing: .08em; text-shadow: 0 4px 0 #fde68a; }
.result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; max-width: 480px; margin: 22px auto; }
.result-grid div { padding: 16px; border-radius: 18px; background: #f8fafc; }
.result-grid strong { display: block; font-family: 'Fredoka'; font-size: 1.7rem; }
.settings-panel { margin-top: 24px; padding: 18px; border-top: 1px solid var(--line); }
.toggle-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 300; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 999px; background: #1e293b; color: white; font-weight: 900; box-shadow: var(--shadow); }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; text-align: center; }
  .hero .lead { margin-inline: auto; }
  .hero .actions { justify-content: center; }
  .bee-scene { min-height: 220px; }
  .bee { width: 170px; }
  .levels { grid-template-columns: 1fr; }
  .level-btn { min-height: 92px; }
}
@media (max-width: 480px) {
  .game-root { padding-inline: 8px; }
  .card { border-radius: 20px; }
  .round-card { padding-inline: 12px; }
  .key-row { gap: 3px; }
  .key { width: 9vw; min-height: 42px; border-radius: 8px; font-size: .86rem; }
  .key.wide { min-width: 64px; }
  .stats { gap: 6px; }
  .stat { padding: 10px 5px; }

  /* Keep the complete answer action above mobile virtual keyboards. */
  .game-root { padding-block: 7px max(12px, env(safe-area-inset-bottom)); }
  .topbar { gap: 7px; margin-bottom: 8px; }
  .topbar .btn { min-height: 40px; padding: 7px 12px; }
  .topbar > strong { font-size: .9rem; }
  .icon-btn { width: 40px; height: 40px; border-radius: 13px; }
  .round-card { padding: 8px 12px 10px; }
  .progress-row { gap: 8px; margin-bottom: 5px; font-size: .88rem; }
  .progress { height: 10px; }
  .prompt .eyebrow { margin-bottom: 2px; font-size: .7rem; }
  .prompt h2 { font-size: clamp(1.35rem, 6.5vw, 1.65rem); }
  .listen { width: 82px; margin: 8px auto 7px; box-shadow: 0 6px 0 #b45309, 0 12px 24px rgba(180,83,9,.2); }
  .listen .speaker { font-size: 2.25rem; line-height: 1; }
  .listen .listen-label { margin-top: 2px; font-size: .72rem; }
  .context-btn { min-height: 32px; font-size: .9rem; }
  .sentence { min-height: 0; margin: 2px 0; font-size: .82rem; }
  .answer-label { margin: 5px 0 3px; font-size: .9rem; }
  .answer-input { min-height: 48px; border-radius: 14px; padding-block: 6px; font-size: 1.4rem; }
  .submit-row { margin-top: 6px; }
  .submit-row .btn { min-height: 44px; padding-block: 8px; }
  .feedback { min-height: 34px; margin: 7px 0 0; padding: 5px; font-size: .8rem; }
  .keyboard { display: none; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .listen { width: 110px; }
  .listen .speaker { font-size: 3rem; }
  .keyboard { margin-top: 8px; }
  .key { min-height: 38px; }
  .round-card { padding-block: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition-duration: .01ms !important; }
}
