:root {
  color-scheme: light;
  --ink: #40251e;
  --muted: #7b6258;
  --cream: #fff8e9;
  --paper: #fffdf5;
  --tomato: #e5482f;
  --tomato-dark: #a92c20;
  --basil: #397a46;
  --basil-dark: #24552f;
  --gold: #f5bd45;
  --cheese: #ffd96d;
  --wood: #92502f;
  --wood-dark: #552a20;
  font-family: ui-rounded, "Avenir Next Rounded", "Nunito Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 320px; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--ink); background: #3a1c18; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 4px solid #ffdc73; outline-offset: 3px; }
[hidden] { display: none !important; }
.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; }

.lesson,.parlor { width: 100%; height: 100%; }
.parlor { position: relative; min-height: 620px; overflow: hidden; background: #5d2c22 url("art/parlor-world-01.webp") center/cover no-repeat; isolation: isolate; }
.parlor::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg,rgba(45,18,13,.14),rgba(34,13,10,.46)); }
.world-light { position: absolute; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(circle at 18% 48%,rgba(255,174,63,.25),transparent 28%),radial-gradient(circle at 72% 75%,rgba(255,221,145,.12),transparent 35%); }

.lesson-hud { position: absolute; z-index: 12; top: 18px; left: 50%; width: min(1180px,calc(100% - 40px)); min-height: 62px; transform: translateX(-50%); display: grid; grid-template-columns: auto minmax(220px,1fr) auto; align-items: center; gap: 18px; }
.brand-plate,.goal-meter,.difficulty,.scores div { border: 2px solid rgba(71,35,26,.35); background: rgba(255,248,233,.96); box-shadow: 0 5px 0 rgba(64,28,20,.25),0 12px 24px rgba(39,14,10,.16); }
.brand-plate { display: flex; align-items: center; gap: 10px; min-width: 190px; padding: 8px 14px 8px 10px; border-radius: 18px; }
.brand-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: var(--tomato); box-shadow: inset 0 -4px rgba(112,31,22,.28); transform: rotate(-5deg); }
.brand-plate div { display: grid; }
.brand-plate span:not(.brand-icon),.goal-meter span,.scores span,.difficulty span { color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.brand-plate strong { font-size: 14px; }
.goal-meter,.difficulty { justify-self: center; width: min(390px,100%); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 13px; border-radius: 16px; }
.goal-meter i,.difficulty i { height: 12px; overflow: hidden; border: 2px solid #cba879; border-radius: 999px; background: #ead9bd; box-shadow: inset 0 2px 3px rgba(90,48,31,.14); }
.goal-meter i b,.difficulty i b { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--gold),#ff8c3b); transition: width 180ms ease-out; }
.goal-meter strong,.difficulty strong { font-size: 11px; white-space: nowrap; }
.difficulty span b { color: var(--tomato-dark); font-size: 14px; }
.difficulty i b { background: linear-gradient(90deg,var(--basil),var(--gold),var(--tomato)); }
.scores { justify-self: end; display: flex; gap: 8px; }
.scores div { min-width: 70px; padding: 7px 11px; border-radius: 16px; text-align: center; }
.scores strong { display: block; margin-top: 1px; font-size: 20px; line-height: 1; }
.scores strong i { font-size: 14px; font-style: normal; }
.scores .streak-score.is-hot { animation: hud-pop 340ms ease-out; border-color: var(--tomato); }

.game-card { position: absolute; z-index: 6; top: 94px; bottom: 24px; left: 50%; width: min(930px,calc(100% - 310px)); min-width: 680px; transform: translateX(-43%); display: grid; grid-template-rows: auto minmax(250px,1fr) auto auto 68px; padding: 22px 28px 20px; overflow: hidden; border: 4px solid #7b3c29; border-radius: 30px; background: rgba(255,250,237,.97); box-shadow: 0 10px 0 #4c241c,0 26px 55px rgba(26,9,6,.36),inset 0 0 0 3px #edc985; }
.game-card.is-miss { animation: card-shake 300ms ease-out; }
.order-ticket { position: relative; min-height: 90px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px; margin: -22px -28px 0; padding: 18px 30px 16px 34px; border-bottom: 3px dashed #d7b787; background: #fff4d9; }
.order-ticket::after { content: ""; position: absolute; right: -9px; bottom: -10px; left: -9px; height: 16px; background: radial-gradient(circle,#fffaf0 6px,transparent 7px) 0 0/18px 18px repeat-x; }
.ticket-pin { position: absolute; top: 13px; left: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--tomato); box-shadow: 0 2px 0 #8f2c20; }
.ticket-copy > span { color: var(--tomato-dark); font-size: 10px; font-weight: 1000; letter-spacing: .13em; text-transform: uppercase; }
.ticket-copy h1 { margin: 3px 0 2px; font-size: clamp(24px,2.7vw,36px); line-height: 1; letter-spacing: -.035em; }
.ticket-copy p { margin: 0; color: var(--muted); font-size: 13px; font-weight: 650; }
.ticket-fraction { width: 68px; min-width: 68px; display: grid; place-items: center; padding: 5px 9px; border: 2px solid #dfc18f; border-radius: 14px; background: #fffdfa; transform: rotate(2deg); box-shadow: 0 3px 0 #e0c18b; }
.ticket-fraction strong { font-size: 23px; line-height: .9; }
.ticket-fraction i { width: 34px; height: 3px; margin: 3px 0; border-radius: 2px; background: var(--ink); }

.chef-wrap { position: absolute; z-index: 7; right: max(6px,calc(50% - 640px)); bottom: -18px; width: 270px; pointer-events: none; transform-origin: bottom center; }
.chef-wrap img { display: block; width: 100%; max-height: 390px; object-fit: contain; object-position: bottom; filter: drop-shadow(0 12px 12px rgba(28,10,7,.32)); }
.chef-speech { position: absolute; z-index: 2; top: -54px; left: -28px; width: 205px; padding: 11px 14px; border: 3px solid var(--ink); border-radius: 18px 18px 6px 18px; background: var(--paper); box-shadow: 0 5px 0 rgba(50,23,17,.24); font-size: 12px; font-weight: 900; line-height: 1.25; text-align: center; }
.chef-wrap.is-cheering { animation: chef-cheer 520ms cubic-bezier(.2,1.7,.4,1); }
.chef-wrap.is-worried { animation: chef-worry 340ms ease-out; }
.chef-wrap.is-worried .chef-speech { color: var(--tomato-dark); }

.slice-stage { min-height: 0; display: grid; grid-template-columns: minmax(0,1.1fr) minmax(260px,.9fr); align-items: stretch; gap: 18px; padding: 20px 0 8px; }
.prep-panel { min-width: 0; display: grid; align-content: center; gap: 10px; padding: 15px 17px; border: 2px solid #dfc9a6; border-radius: 22px; background: #fffaf0; box-shadow: 0 5px 0 #ead6b6; }
.panel-label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.panel-label span { color: var(--muted); font-size: 10px; font-weight: 1000; letter-spacing: .1em; text-transform: uppercase; }
.panel-label strong { font-size: 13px; }
.food-choice { display: flex; justify-content: center; gap: 7px; }
.food-option { min-width: 74px; padding: 6px 11px; border: 2px solid #dbc39d; border-radius: 999px; background: #fff; font-size: 11px; font-weight: 900; box-shadow: 0 3px 0 #e2caa4; transition: transform 130ms ease-out,background 130ms ease-out; }
.food-option.is-selected { color: #fff; border-color: var(--tomato-dark); background: var(--tomato); box-shadow: 0 3px 0 var(--tomato-dark); }
.food-board { min-height: 185px; display: grid; place-items: center; border-radius: 18px; background: radial-gradient(ellipse at center,#d69b5e 0 52%,#b97741 53% 65%,transparent 66%); }
.source-pizza { width: min(180px,70%); aspect-ratio: 1; filter: drop-shadow(0 8px 2px rgba(76,36,19,.22)); }
.pizza-svg { width: 100%; height: 100%; overflow: visible; }
.pizza-slice { cursor: pointer; transform-box: fill-box; transform-origin: center; transition: transform 140ms ease-out,filter 140ms ease-out,opacity 140ms ease-out; stroke: #8b3d23; stroke-width: 2.6; }
.pizza-slice:hover { transform: translateY(-4px) scale(1.025); filter: brightness(1.06); }
.pizza-slice.is-taken { transform: translateY(-8px) scale(.91); opacity: .28; }
.pizza-slice:focus { outline: none; filter: drop-shadow(0 0 5px #fff) drop-shadow(0 0 4px var(--tomato)); }
.pizza-slice.is-cake { stroke: #683c34; }
.topping { pointer-events: none; }
.slice-pop { animation: slice-pop 190ms ease-out both; }
.slicer-control { display: grid; gap: 5px; }
.slicer-control label { display: flex; align-items: baseline; justify-content: space-between; font-size: 11px; font-weight: 900; }
.slicer-control label span { color: var(--muted); }
.slicer-control label strong { color: var(--tomato-dark); font-size: 13px; }
input[type="range"] { width: 100%; height: 22px; margin: 0; accent-color: var(--tomato); cursor: ew-resize; }
.slicer-ticks { display: flex; justify-content: space-between; color: #a68d79; font-size: 9px; font-weight: 900; }
.slicer-ticks i { font-style: normal; }
.tap-note { min-height: 15px; margin: 0; color: var(--muted); font-size: 10px; font-weight: 800; text-align: center; }

.order-panel { grid-template-rows: auto 1fr auto; }
.order-box { position: relative; min-height: 188px; display: grid; place-items: center; overflow: hidden; border: 3px solid #9b5c37; border-radius: 17px; background: #ead1a3; box-shadow: inset 0 0 0 6px #f6e5c3,0 5px 0 #744027; }
.order-lid { position: absolute; top: 0; right: 0; left: 0; height: 33px; display: grid; place-items: center; border-bottom: 2px dashed #c79962; color: #a3482f; background: #f5dfb7; font-size: 9px; font-weight: 1000; letter-spacing: .15em; text-transform: uppercase; }
.served-pizza { width: 128px; height: 128px; margin-top: 25px; border: 8px solid #b8612f; border-radius: 50%; background: conic-gradient(var(--cheese) var(--fill,0%),#ead7b0 0); box-shadow: inset 0 0 0 3px rgba(126,59,29,.22),0 7px 0 rgba(91,50,28,.18); transition: background 170ms ease-out,transform 170ms ease-out; }
.served-pizza.is-cake { border-radius: 16px; border-color: #9e5b4d; background: linear-gradient(90deg,#ffb7aa var(--fill,0%),#ead7b0 0); box-shadow: inset 0 -13px rgba(121,55,48,.15),0 7px 0 rgba(91,50,28,.18); }
.served-pizza.is-exact { transform: scale(1.06) rotate(-2deg); box-shadow: 0 0 0 8px rgba(57,122,70,.18),0 7px 0 rgba(91,50,28,.18); }
.served-pizza.is-over { animation: order-shake 290ms ease-out; }
.fraction-progress { display: grid; gap: 5px; }
.progress-copy { display: flex; align-items: baseline; justify-content: space-between; }
.progress-copy span { color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.progress-copy strong { font-size: 23px; }
.fraction-bar { position: relative; height: 19px; overflow: hidden; border: 2px solid var(--ink); border-radius: 999px; background: #eadfc9; box-shadow: inset 0 2px 3px rgba(65,34,25,.15); }
.gap-needed { position: absolute; inset: 0 auto 0 0; border-right: 2px dashed var(--ink); background: repeating-linear-gradient(135deg,rgba(57,122,70,.12) 0 6px,transparent 6px 12px); }
.gap-fill { position: absolute; z-index: 2; inset: 0 auto 0 0; width: 0; background: var(--gold); border-right: 2px solid rgba(64,37,30,.4); transition: width 180ms ease-out,background 160ms ease-out; }
.gap-edge { position: absolute; z-index: 4; top: -3px; bottom: -3px; width: 3px; background: var(--ink); }
.fraction-bar.is-exact { border-color: var(--basil-dark); box-shadow: 0 0 0 5px rgba(57,122,70,.14); }
.fraction-bar.is-exact .gap-fill { background: var(--basil); }
.fraction-bar.is-over { border-color: var(--tomato-dark); }
.fraction-bar.is-over .gap-fill { background: var(--tomato); }
.fit-readout { min-height: 17px; color: var(--muted); font-size: 11px; font-weight: 900; text-align: right; }
.fraction-bar.is-exact + .fit-readout { color: var(--basil-dark); }

.compare-stage { min-height: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 22px; padding: 28px 40px 12px; }
.compare-card { min-width: 0; display: grid; justify-items: center; padding: 18px; border: 2px solid #dfc9a6; border-radius: 22px; background: #fffaf0; box-shadow: 0 5px 0 #ead6b6; }
.compare-card button { width: 100%; min-height: 52px; margin-top: 14px; border: 2px solid var(--tomato-dark); border-radius: 15px; color: #fff; background: var(--tomato); box-shadow: 0 5px 0 var(--tomato-dark); font-size: 20px; font-weight: 1000; }
.compare-card button:hover { transform: translateY(-2px); }
.compare-card button:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--tomato-dark); }
.compare-card button:disabled { cursor: default; opacity: .58; transform: none; }
.mini-pizza { width: 145px; aspect-ratio: 1; }
.compare-vs { width: 50px; height: 50px; display: grid; place-items: center; border: 3px solid var(--ink); border-radius: 50%; background: var(--gold); box-shadow: 0 4px 0 rgba(70,36,26,.24); font-size: 12px; font-weight: 1000; text-transform: uppercase; }

.equation-strip { min-height: 33px; display: grid; place-items: center; font-size: 22px; font-weight: 1000; }
.feedback { min-height: 23px; display: grid; place-items: center; color: var(--basil-dark); font-size: 12px; font-weight: 900; text-align: center; }
.feedback.is-error { color: var(--tomato-dark); }
.actions { min-height: 62px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.choice-grid { width: min(650px,100%); display: grid; grid-template-columns: repeat(var(--columns,3),1fr); gap: 10px; }
.choice,.primary,.secondary { min-height: 54px; border: 2px solid #b98556; border-radius: 16px; background: #fff; box-shadow: 0 5px 0 #dfbd91; font-weight: 1000; transition: transform 130ms ease-out,box-shadow 130ms ease-out; }
.choice { padding: 7px 10px; font-size: 17px; }
.choice small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 800; }
.choice:hover,.primary:hover,.secondary:hover { transform: translateY(-2px); }
.choice:active,.primary:active,.secondary:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(81,38,27,.3); }
.primary { min-width: 220px; padding: 0 25px; border-color: var(--basil-dark); color: #fff; background: var(--basil); box-shadow: 0 6px 0 var(--basil-dark); font-size: 16px; letter-spacing: .02em; }
.primary.is-hot { border-color: #23602d; background: #45a64f; box-shadow: 0 6px 0 #23602d,0 9px 20px rgba(57,122,70,.2); }
.secondary { min-width: 100px; padding: 0 18px; color: var(--tomato-dark); background: #fff7eb; font-size: 13px; }

.peel-prop { position: absolute; z-index: 3; left: -45px; bottom: -35px; width: 230px; transform: rotate(18deg); filter: drop-shadow(0 8px 8px rgba(31,11,7,.28)); pointer-events: none; }
.ingredient-prop { position: absolute; z-index: 4; left: 10px; bottom: -18px; width: 205px; filter: drop-shadow(0 8px 8px rgba(31,11,7,.25)); pointer-events: none; }
.toast { position: absolute; z-index: 30; left: 50%; bottom: 28px; max-width: 76%; padding: 11px 18px; opacity: 0; transform: translate(-50%,12px); border: 3px solid #fff4d4; border-radius: 999px; color: #fff; background: var(--ink); box-shadow: 0 5px 0 rgba(31,12,8,.28); pointer-events: none; font-size: 12px; font-weight: 900; transition: opacity 150ms ease-out,transform 150ms ease-out; }
.toast.is-showing { opacity: 1; transform: translate(-50%,0); }
.celebration-burst { position: absolute; z-index: 24; top: 46%; left: 52%; pointer-events: none; }
.celebration-burst i { position: absolute; width: 14px; height: 20px; opacity: 0; border-radius: 5px; background: var(--gold); }
.celebration-burst i:nth-child(2n) { background: var(--tomato); }
.celebration-burst i:nth-child(3n) { background: var(--basil); }
.celebration-burst strong { position: absolute; opacity: 0; transform: translate(-50%,-50%) scale(.4) rotate(-4deg); padding: 12px 23px; border: 4px solid var(--ink); border-radius: 19px; color: var(--tomato-dark); background: #fff5c8; box-shadow: 0 7px 0 rgba(65,30,22,.24); font-size: 28px; }
.parlor.is-celebrating .celebration-burst i { animation: confetti 720ms ease-out both; }
.parlor.is-celebrating .celebration-burst strong { animation: perfect-pop 700ms ease-out both; }
.celebration-burst i:nth-child(1){--x:-210px;--y:-110px;--r:140deg}.celebration-burst i:nth-child(2){--x:-170px;--y:130px;--r:240deg;animation-delay:30ms}.celebration-burst i:nth-child(3){--x:-90px;--y:-170px;--r:190deg;animation-delay:70ms}.celebration-burst i:nth-child(4){--x:-30px;--y:160px;--r:320deg;animation-delay:110ms}.celebration-burst i:nth-child(5){--x:70px;--y:-180px;--r:220deg;animation-delay:50ms}.celebration-burst i:nth-child(6){--x:150px;--y:125px;--r:170deg;animation-delay:120ms}.celebration-burst i:nth-child(7){--x:220px;--y:-80px;--r:290deg;animation-delay:80ms}.celebration-burst i:nth-child(8){--x:235px;--y:55px;--r:210deg;animation-delay:140ms}.celebration-burst i:nth-child(9){--x:-250px;--y:25px;--r:310deg;animation-delay:90ms}.celebration-burst i:nth-child(10){--x:35px;--y:190px;--r:170deg;animation-delay:150ms}

@keyframes slice-pop { 45% { transform: scale(.94); } }
@keyframes order-shake { 25% { transform: translateX(-6px) rotate(-2deg); } 55% { transform: translateX(6px) rotate(2deg); } 80% { transform: translateX(-3px); } }
@keyframes card-shake { 25% { margin-left: -5px; } 55% { margin-left: 5px; } 80% { margin-left: -2px; } }
@keyframes chef-cheer { 45% { transform: translateY(-17px) rotate(-3deg) scale(1.05); } }
@keyframes chef-worry { 30% { transform: rotate(-3deg); } 65% { transform: rotate(3deg); } }
@keyframes hud-pop { 50% { transform: scale(1.14) rotate(-2deg); } }
@keyframes confetti { 0% { opacity: 0; transform: translate(0,0) rotate(0) scale(.4); } 25% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--x),var(--y)) rotate(var(--r)) scale(1.1); } }
@keyframes perfect-pop { 0%,100% { opacity: 0; } 18%,70% { opacity: 1; transform: translate(-50%,-50%) scale(1) rotate(-4deg); } }

@media (max-width: 1050px) {
  .game-card { width: calc(100% - 210px); min-width: 620px; transform: translateX(-46%); }
  .chef-wrap { right: -5px; width: 220px; }
  .chef-speech { left: -15px; width: 180px; }
  .peel-prop,.ingredient-prop { opacity: .7; }
}
@media (max-width: 820px) {
  html,body { overflow: auto; }
  .parlor { min-height: 100%; overflow: auto; background-attachment: fixed; }
  .lesson-hud { position: relative; top: 10px; grid-template-columns: 1fr auto; width: calc(100% - 20px); }
  .goal-meter,.difficulty { grid-column: 1/-1; grid-row: 2; width: 100%; }
  .scores div { min-width: 57px; padding-inline: 7px; }
  .game-card { position: relative; top: 30px; bottom: auto; left: 0; width: calc(100% - 20px); min-width: 0; min-height: 690px; margin: 0 10px 90px; transform: none; padding-inline: 18px; }
  .order-ticket { margin-inline: -18px; padding-inline: 24px; }
  .slice-stage { grid-template-columns: 1fr; }
  .food-board { min-height: 175px; }
  .chef-wrap { display: none; }
  .peel-prop,.ingredient-prop { display: none; }
  .compare-stage { padding-inline: 0; gap: 8px; }
  .mini-pizza { width: 115px; }
}
@media (max-height: 720px) and (min-width: 821px) {
  .lesson-hud { top: 9px; min-height: 54px; }
  .game-card { top: 73px; bottom: 12px; padding-top: 16px; padding-bottom: 12px; }
  .order-ticket { margin-top: -16px; min-height: 76px; padding-block: 12px; }
  .food-board,.order-box { min-height: 145px; }
  .source-pizza { width: 142px; }
  .served-pizza { width: 105px; height: 105px; }
  .chef-wrap { width: 225px; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
