:root {
  color-scheme: light;
  --cream: #f6efe2;
  --paper: #fffdf8;
  --paper-warm: #fff7e9;
  --ink: #283632;
  --muted: #65736d;
  --line: rgba(47, 66, 59, .16);
  --green: #377a66;
  --green-dark: #285b4d;
  --berry: #d94f62;
  --berry-dark: #a92f47;
  --fizz: #f3c64e;
  --fizz-dark: #a77413;
  --shadow: rgba(65, 49, 30, .16);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  color: var(--ink);
  background: var(--cream);
  font-family: "Avenir Next", Avenir, "Nunito Sans", ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 4px solid #2375bb; outline-offset: 3px; }
[hidden] { display: none !important; }

.lesson { position: relative; width: 100%; height: 100dvh; min-height: 620px; isolation: isolate; overflow: hidden; }
.scene-shell, .scene-shell canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene-shell canvas { display: block; touch-action: none; }
.scene-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,253,247,.46), transparent 24%, transparent 64%, rgba(65,42,22,.13)),
    radial-gradient(circle at 50% 44%, transparent 35%, rgba(90,64,35,.07) 100%);
}

.top-hud {
  position: absolute;
  z-index: 5;
  top: max(18px, env(safe-area-inset-top));
  left: 22px;
  right: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}
.lesson-mark, .scoreboard {
  border: 1px solid rgba(255,255,255,.82);
  background: rgba(255,253,248,.88);
  box-shadow: 0 9px 30px rgba(65,49,30,.12), inset 0 1px rgba(255,255,255,.9);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}
.lesson-mark { display: flex; align-items: center; gap: 11px; min-height: 58px; padding: 9px 16px 9px 11px; border-radius: 18px; }
.mark-dot { width: 36px; height: 36px; border-radius: 12px; background: radial-gradient(circle at 35% 30%, #f87987, var(--berry) 55%, var(--berry-dark)); box-shadow: inset 0 -4px rgba(111,22,39,.2), 0 3px 8px rgba(169,47,71,.23); }
.lesson-mark small, .lesson-mark strong { display: block; }
.lesson-mark small { color: var(--green); font-size: 10px; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
.lesson-mark strong { margin-top: 2px; font-size: 15px; line-height: 1.1; }

.scoreboard { min-height: 58px; display: flex; align-items: stretch; gap: 0; padding: 5px; border-radius: 18px; }
.scoreboard > div { min-width: 70px; display: grid; place-content: center; padding: 3px 14px; border-right: 1px solid var(--line); text-align: center; }
.scoreboard span, .scoreboard strong { display: block; }
.scoreboard span { color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.scoreboard strong { margin-top: 1px; font-size: 18px; line-height: 1; }
.sound-button { width: 48px; min-width: 48px; border: 0; border-radius: 13px; background: transparent; display: grid; place-items: center; }
.sound-button:hover { background: rgba(55,122,102,.1); }
.sound-button svg { width: 23px; height: 23px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sound-button .sound-off { display: none; }
.sound-button[aria-pressed="true"] .sound-on { display: none; }
.sound-button[aria-pressed="true"] .sound-off { display: block; }

.recipe-card {
  position: absolute;
  z-index: 4;
  left: clamp(22px, 4vw, 64px);
  top: clamp(104px, 16vh, 150px);
  width: 205px;
  min-height: 238px;
  padding: 27px 21px 20px;
  border: 1px solid rgba(119,83,31,.18);
  border-radius: 11px 11px 30px 11px;
  background: linear-gradient(155deg, #fffdf7, #fff4da);
  box-shadow: 0 16px 0 rgba(117,79,31,.08), 0 24px 44px rgba(78,52,24,.17);
  transform: rotate(-2deg);
  transform-origin: center;
}
.recipe-card::after { content: ""; position: absolute; right: 8px; bottom: 8px; width: 30px; height: 30px; border-radius: 0 0 19px 0; border-right: 2px solid rgba(169,118,32,.15); border-bottom: 2px solid rgba(169,118,32,.15); }
.pin { position: absolute; top: 9px; left: 50%; width: 13px; height: 13px; border-radius: 50%; background: #e16a58; box-shadow: inset 0 -3px rgba(110,36,27,.24), 0 3px 5px rgba(76,35,27,.22); }
.card-kicker { display: block; color: var(--green); font-size: 10px; font-weight: 950; letter-spacing: .13em; text-transform: uppercase; }
.recipe-card h2 { margin: 5px 0 15px; font-size: 24px; line-height: 1; letter-spacing: -.04em; }
.ratio-lockup { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.ratio-lockup > b { color: #8b7a62; font-size: 24px; }
.ratio-part { min-width: 0; text-align: center; }
.ratio-part i { display: block; width: 38px; height: 38px; margin: 0 auto 5px; border-radius: 50% 46% 52% 48%; }
.berry-part i { background: radial-gradient(circle at 35% 28%, #fb8590, var(--berry) 58%, var(--berry-dark)); box-shadow: inset 0 -5px rgba(112,19,42,.18); }
.fizz-part i { background: radial-gradient(circle at 35% 28%, #ffe895, var(--fizz) 60%, #d79f26); box-shadow: inset 0 -5px rgba(126,87,5,.14); }
.ratio-part strong { display: block; font-size: 28px; line-height: .9; }
.ratio-part span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 850; text-transform: uppercase; }
.recipe-card p { margin: 16px 0 0; padding-top: 13px; border-top: 1px dashed rgba(91,72,41,.23); color: #5d604d; font-size: 12px; font-weight: 650; line-height: 1.4; }

.batch-card {
  position: absolute;
  z-index: 4;
  top: clamp(118px, 18vh, 164px);
  right: clamp(22px, 4vw, 64px);
  width: 195px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 22px;
  background: rgba(255,253,248,.86);
  box-shadow: 0 14px 36px rgba(65,49,30,.13);
  -webkit-backdrop-filter: blur(13px);
  backdrop-filter: blur(13px);
}
.batch-card > span { display: block; color: var(--green); font-size: 10px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.batch-ratio { display: flex; align-items: center; gap: 9px; margin-top: 10px; }
.batch-ratio strong { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 15px; color: white; font-size: 23px; box-shadow: inset 0 -5px rgba(65,25,25,.13); }
.batch-ratio .berry-number { background: var(--berry); }
.batch-ratio .fizz-number { color: #664a0e; background: var(--fizz); }
.batch-ratio b { font-size: 22px; }
.batch-card p { margin: 10px 0 0; color: var(--muted); font-size: 11px; font-weight: 650; line-height: 1.35; }
.recipe-card.is-pulsing, .batch-card.is-pulsing { animation: card-pulse .72s ease-out 2; }

.mix-status {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: clamp(223px, 30vh, 260px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 999px;
  background: rgba(40,54,50,.83);
  box-shadow: 0 8px 24px rgba(40,34,25,.16);
  color: white;
  transform: translateX(-50%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  pointer-events: none;
}
.mix-status span { width: 9px; height: 9px; border-radius: 50%; background: #91d6bd; box-shadow: 0 0 0 4px rgba(145,214,189,.15); }
.mix-status strong { font-size: 11px; letter-spacing: .025em; }
.mix-status.is-pouring span { background: var(--fizz); animation: status-pop .6s ease-in-out infinite; }
.mix-status.is-correct { background: rgba(40,91,77,.9); }
.mix-status.is-wrong { background: rgba(135,48,65,.9); }

.action-dock {
  position: absolute;
  z-index: 6;
  left: 22px;
  right: 22px;
  bottom: max(18px, env(safe-area-inset-bottom));
  min-height: 188px;
  padding: 17px 20px 20px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 28px;
  background: rgba(255,253,248,.94);
  box-shadow: 0 20px 55px rgba(62,45,26,.2), inset 0 1px white;
  -webkit-backdrop-filter: blur(17px);
  backdrop-filter: blur(17px);
}
.goal-row { min-height: 27px; display: flex; align-items: center; gap: 14px; padding: 0 3px 12px; border-bottom: 1px solid var(--line); }
.goal-row > span { flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; color: white; background: var(--green); font-size: 9px; font-weight: 950; letter-spacing: .1em; text-transform: uppercase; }
.goal-row p { margin: 0; color: #4f625b; font-size: 12px; font-weight: 700; line-height: 1.3; }
.action-layout { min-height: 123px; display: grid; grid-template-columns: minmax(250px, .78fr) minmax(0, 1.75fr); align-items: center; gap: 28px; padding-top: 12px; }
.question-copy h1 { margin: 0; font-size: clamp(23px, 2.25vw, 31px); line-height: 1.05; letter-spacing: -.04em; }
.question-copy p { max-width: 380px; margin: 7px 0 0; color: var(--muted); font-size: 12px; font-weight: 620; line-height: 1.4; }
.action-content { min-width: 0; display: flex; align-items: center; justify-content: flex-end; }
.answer-grid { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.answer-button {
  min-height: 92px;
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 2px solid #ddd4c6;
  border-radius: 18px;
  background: #fffefa;
  box-shadow: 0 4px 0 #e8dfd2;
  text-align: left;
  transition: transform 150ms ease-out, border-color 150ms ease-out, box-shadow 150ms ease-out, background 150ms ease-out;
}
.answer-button:hover { transform: translateY(-3px); border-color: var(--green); box-shadow: 0 7px 0 #d8e1dc; background: #fbfffc; }
.answer-button:active { transform: translateY(2px); box-shadow: 0 2px 0 #d8e1dc; }
.answer-number { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 16px; color: #684a09; background: linear-gradient(145deg, #ffe48c, var(--fizz)); box-shadow: inset 0 -5px rgba(126,87,5,.13); font-size: 23px; font-weight: 950; }
.answer-button strong, .answer-button small { display: block; }
.answer-button strong { font-size: 15px; line-height: 1.15; }
.answer-button small { margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 650; line-height: 1.25; }

.primary-button {
  min-width: 220px;
  min-height: 62px;
  padding: 0 24px;
  border: 2px solid var(--green-dark);
  border-radius: 18px;
  color: white;
  background: linear-gradient(180deg, #438c75, var(--green));
  box-shadow: 0 7px 0 var(--green-dark), 0 12px 23px rgba(40,91,77,.2);
  font-size: 16px;
  font-weight: 900;
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 9px 0 var(--green-dark), 0 14px 26px rgba(40,91,77,.22); }
.primary-button:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--green-dark); }
.primary-button.is-berry { border-color: var(--berry-dark); background: linear-gradient(180deg, #eb6777, var(--berry)); box-shadow: 0 7px 0 var(--berry-dark), 0 12px 23px rgba(169,47,71,.2); }
.commit-panel, .result-panel { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.commit-ratio { display: flex; align-items: center; gap: 9px; }
.commit-ratio span { min-width: 58px; height: 58px; display: grid; place-items: center; padding: 0 10px; border-radius: 17px; color: white; background: var(--berry); font-size: 25px; font-weight: 950; box-shadow: inset 0 -5px rgba(92,25,39,.15); }
.commit-ratio span:last-child { color: #694b0b; background: var(--fizz); }
.commit-ratio b { font-size: 25px; }
.result-evidence { min-width: 0; display: flex; align-items: center; gap: 13px; }
.result-icon { flex: 0 0 auto; width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; color: white; background: var(--green); font-size: 24px; font-weight: 950; }
.result-panel.is-wrong .result-icon { background: var(--berry); }
.result-evidence strong, .result-evidence p { display: block; }
.result-evidence strong { font-size: 15px; line-height: 1.25; }
.result-evidence p { max-width: 410px; margin: 4px 0 0; color: var(--muted); font-size: 11px; font-weight: 620; line-height: 1.35; }
.explain-grid { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 11px; }
.explain-button {
  min-height: 76px;
  padding: 12px 15px;
  border: 2px solid #ddd4c6;
  border-radius: 17px;
  background: #fffefa;
  box-shadow: 0 4px 0 #e8dfd2;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
  transition: transform 150ms ease-out, border-color 150ms ease-out;
}
.explain-button:hover { transform: translateY(-2px); border-color: var(--green); }
.loading-dots { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 800; }
.loading-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--fizz); animation: bubble .75s ease-in-out infinite alternate; }
.loading-dots i:nth-child(2) { animation-delay: .12s; }
.loading-dots i:nth-child(3) { animation-delay: .24s; }

.toast { position: absolute; z-index: 20; left: 50%; top: 49%; max-width: min(520px, 80vw); padding: 11px 18px; opacity: 0; border-radius: 999px; color: white; background: rgba(40,54,50,.94); box-shadow: 0 10px 35px rgba(31,27,22,.24); transform: translate(-50%, 12px); pointer-events: none; font-size: 12px; font-weight: 850; text-align: center; transition: opacity 150ms ease-out, transform 150ms ease-out; }
.toast.is-showing { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@keyframes card-pulse { 50% { transform: rotate(-1deg) translateY(-4px) scale(1.035); box-shadow: 0 0 0 8px rgba(243,198,78,.2), 0 18px 38px rgba(65,49,30,.16); } }
@keyframes status-pop { 50% { transform: scale(1.35); } }
@keyframes bubble { to { transform: translateY(-7px); background: var(--berry); } }

@media (max-width: 900px) {
  .top-hud { left: 14px; right: 14px; top: max(12px, env(safe-area-inset-top)); }
  .lesson-mark { min-height: 52px; }
  .scoreboard { min-height: 52px; }
  .scoreboard > div { min-width: 58px; padding-inline: 9px; }
  .recipe-card { left: 18px; top: 94px; width: 174px; min-height: 208px; padding: 23px 16px 16px; }
  .recipe-card h2 { font-size: 21px; }
  .ratio-part i { width: 32px; height: 32px; }
  .batch-card { right: 18px; top: 102px; width: 170px; }
  .action-dock { left: 14px; right: 14px; bottom: max(12px, env(safe-area-inset-bottom)); padding: 14px 16px 17px; }
  .action-layout { grid-template-columns: minmax(210px,.65fr) minmax(0,1.75fr); gap: 16px; }
  .answer-grid { gap: 8px; }
  .answer-button { grid-template-columns: 42px 1fr; min-height: 84px; padding: 9px; gap: 8px; }
  .answer-number { width: 42px; height: 42px; border-radius: 13px; font-size: 20px; }
  .answer-button strong { font-size: 13px; }
}

@media (max-width: 700px) {
  .lesson { min-height: 680px; }
  .lesson-mark { max-width: 158px; padding-right: 10px; }
  .mark-dot { width: 30px; height: 30px; border-radius: 10px; }
  .lesson-mark small { font-size: 8px; }
  .lesson-mark strong { font-size: 12px; }
  .scoreboard > div { min-width: 48px; padding-inline: 6px; }
  .scoreboard span { font-size: 8px; }
  .scoreboard strong { font-size: 15px; }
  .sound-button { width: 42px; min-width: 42px; }
  .recipe-card { width: 156px; min-height: 180px; top: 82px; }
  .recipe-card h2 { margin-bottom: 10px; font-size: 18px; }
  .recipe-card p { margin-top: 10px; padding-top: 9px; font-size: 10px; }
  .ratio-part strong { font-size: 22px; }
  .batch-card { top: 82px; width: 145px; padding: 12px; }
  .batch-ratio strong { width: 42px; height: 42px; font-size: 19px; }
  .batch-card p { font-size: 9px; }
  .mix-status { bottom: 325px; }
  .action-dock { min-height: 288px; border-radius: 24px; }
  .goal-row { align-items: flex-start; }
  .action-layout { display: block; padding-top: 10px; }
  .question-copy h1 { font-size: 23px; }
  .question-copy p { margin-top: 4px; }
  .action-content { margin-top: 12px; justify-content: stretch; }
  .answer-button { display: block; min-height: 78px; text-align: center; }
  .answer-number { margin: 0 auto 5px; }
  .answer-button small { display: none; }
  .primary-button { width: 100%; min-height: 58px; }
  .commit-panel, .result-panel { align-items: stretch; flex-direction: column; gap: 10px; }
  .commit-ratio { justify-content: center; }
  .explain-grid { gap: 7px; }
  .explain-button { min-height: 92px; padding: 9px; font-size: 10px; }
}

@media (max-height: 720px) and (min-width: 701px) {
  .recipe-card { top: 82px; min-height: 190px; padding-top: 23px; }
  .recipe-card h2 { margin-bottom: 10px; }
  .recipe-card p { margin-top: 10px; padding-top: 8px; }
  .batch-card { top: 88px; }
  .action-dock { min-height: 170px; padding-top: 13px; padding-bottom: 14px; }
  .action-layout { min-height: 106px; padding-top: 9px; }
  .answer-button { min-height: 78px; }
  .mix-status { bottom: 205px; }
}

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