/* Ring Sort game screen, storybook-bakery look (task #68; owner art in references/owner-art/,
   layout C3/C4). Painted pieces come from public/art/bakery/ (tools/art/build_bakery.py);
   every label is live text. */
:root {
  /* teal tokens: only the rotate-your-phone card still uses them */
  --bg-deep: #0A3A41; --bg-mid: #12545A; --bg-glow: #2B7372;
  --hud-ink: #FFF5D2; --hud-shadow: #0B3036;
  /* bakery tokens, sampled from 01-style-master.png */
  --cream: #FFF7EA; --cream-2: #F8E8CF; --cream-edge: #EBC98E;
  --blush: #F6D9D2; --pink: #EE8A98; --pink-deep: #C9586E;
  --mint-paint: #8CCBA4; --butter: #F9D77A; --honey-paint: #F2B54A;
  --ink: #5A3A2E; --ink-soft: #8A6250; --ink-shadow: #FFF7EA;
  --paper: #FFF6DF; --paper-2: #F3DFB4; --paper-edge: #FFF0C2;
  --honey-hi: #FFE7A0; --honey: #F6BC55; --honey-lip: #B97A2E; --honey-icon: #7A4416;
  --mint-hi: #BDEBD0; --mint: #6FBF94; --mint-lip: #3F8A62;
  --go-hi: #BDEBD0; --go: #6FBF94; --go-lip: #3F8A62;
  --off-hi: #EFE6D2; --off: #D6C7A6; --off-lip: #A8977A;
  --alert: #D9483B;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --font: "Nunito", "Fredoka", "Baloo 2", ui-rounded, "SF Pro Rounded", "Avenir Next", "Inter", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--blush); }
body {
  font-family: var(--font); color: var(--ink);
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%; touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus { outline: none; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 6px #FFFFFFCC; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
img { -webkit-user-drag: none; }

/* ------------------------------------------------------------ phone frame */
.phone { position: fixed; inset: 0; overflow: hidden; isolation: isolate; contain: layout paint; background: var(--blush); }
.inset-probe { position: absolute; visibility: hidden; pointer-events: none; padding-top: var(--sat); padding-bottom: var(--sab); }
@media (min-width: 700px) and (min-height: 600px) {
  body { display: grid; place-items: center; background: #EBC7BE url("art/bakery/lobby-bg.webp") center / cover no-repeat; }
  .phone {
    position: relative; inset: auto; height: min(932px, calc(100dvh - 48px)); width: auto; aspect-ratio: 430 / 932;
    border-radius: 40px; border: 10px solid #FFF3E4; box-shadow: 0 30px 80px #5A2A2A55, 0 0 0 1px #C98A7A55;
  }
}

/* ------------------------------------------------------------------ scene */
.scene { position: absolute; inset: 0; z-index: 0; }
.play-bg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; user-select: none; pointer-events: none; }
.hc .play-bg { filter: saturate(.4) brightness(1.05) contrast(.85); }
.pegs { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.peg-svg { position: absolute; left: 0; top: 0; overflow: visible; }
.peg-svg use, .peg-svg g, .peg-svg image { transform-box: view-box; }

/* peg states (drawn in game-art.mjs) */
.peg-svg .sel-glow, .peg-svg .done-glow, .peg-svg .valid-ring, .peg-svg .bad-ring,
.peg-svg .cap, .peg-svg .chip { display: none; }
.peg-svg.selected .sel-glow { display: inline; }
/* the selected plate gets a steady honey ring (the glow alone is too faint on the light counter) */
.peg-svg.selected .valid-ring { display: inline; stroke: #F2A93B; stroke-width: 3; animation: none; filter: drop-shadow(0 0 3px #FFE7A0); }
.peg-svg.valid .valid-ring { display: inline; stroke: #FFFFFF; stroke-width: 2.6; animation: pulse 1.1s ease-in-out infinite; filter: drop-shadow(0 0 3px #F2A7B8); }
.peg-svg.bad .bad-ring { display: inline; stroke: var(--alert); stroke-width: 3.2; animation: none; }
.peg-svg.bad .valid-ring { display: none; }
.peg-svg.bad .chip-bad { display: inline; }
.peg-svg .chip circle { fill: var(--alert); stroke: #FFF7EA; stroke-width: 2; }
.peg-svg .chip use { color: #FFFFFF; fill: none; stroke: #FFFFFF; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.peg-svg .chip-ok circle { fill: #2E7D4F; }
.peg-svg.done .cap, .peg-svg.done .done-glow { display: inline; }
.peg-svg.done .base-rim { stroke: #F7C86A; stroke-opacity: 1; stroke-width: 2.2; }
.peg-svg.selected .base-rim { stroke: #FFFFFF; stroke-opacity: 1; stroke-width: 2.6; }
.peg-svg.selected .base-top { filter: brightness(1.04); }
.hc .peg-svg.valid .valid-ring { stroke: #1A1A1A; stroke-width: 3; animation: none; filter: none; }
.hc .peg-svg.valid .chip-ok { display: inline; }
.hc .peg-svg.bad .bad-ring { stroke-width: 3.5; }
@keyframes pulse { 0%, 100% { stroke-opacity: .5; } 50% { stroke-opacity: 1; } }
.reduced .peg-svg.valid .valid-ring { animation: none; stroke-opacity: .95; }

/* hit boxes */
.board { position: absolute; inset: 0; z-index: 8; pointer-events: none; margin: 0; }
.hit { position: absolute; pointer-events: auto; background: transparent; border: 0; padding: 0; margin: 0; border-radius: 18px; }
.hit:focus-visible { outline-offset: -3px; box-shadow: none; }

/* lifted / flying donuts and particles */
.fx, .fx-top { position: absolute; inset: 0; pointer-events: none; }
.fx { z-index: 6; }
.fx-top { z-index: 30; overflow: hidden; }
.lift, .flight { position: absolute; inset: 0; }
.ring-sprite { position: absolute; overflow: visible; filter: drop-shadow(-2px 7px 5px #6A341844); }
.particle, .confetti { position: absolute; }

/* ------------------------------------------------------------------- HUD */
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20; height: calc(var(--sat) + 70px);
  padding: calc(var(--sat) + 8px) 10px 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 6px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.short .hud { height: calc(var(--sat) + 62px); padding-top: calc(var(--sat) + 5px); }
.hud-pills { display: grid; justify-items: start; gap: 4px; }
/* bar.webp is 298 x 74: both pills keep that ratio (never stretched) */
.moves-pill, .coins-pill {
  display: flex; align-items: center; justify-content: center; gap: 5px; aspect-ratio: 298 / 74;
  background: url("art/bakery/bar.webp") center / contain no-repeat; color: var(--ink);
  filter: drop-shadow(0 2px 2px #8A4E3A33);
}
.moves-pill, .coins-pill { width: 112px; padding-left: 24px; justify-content: flex-start; gap: 6px; }
.coins-pill { position: relative; margin-left: 8px; }
/* both numbers sit in the same right-aligned column so the digits line up */
.pill-num { display: inline-block; width: 32px; text-align: right; font-size: 17px; line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums; }
.moves-pill span:not(.pill-num) { font-size: 11px; line-height: 1; font-weight: 800; color: var(--ink-soft); letter-spacing: .04em; text-transform: uppercase; }
.coins-pill .pill-num { width: auto; min-width: 32px; flex: 1; padding-right: 14px; white-space: nowrap; }
.coins-pill img { position: absolute; left: -10px; top: 50%; width: 26px; height: 26px; transform: translateY(-50%); }
/* ribbon.webp is 551 x 151: live LEVEL text sits on the banner's centre band */
.level-ribbon {
  position: relative; width: clamp(150px, 46vw, 196px); aspect-ratio: 551 / 151; margin-top: 2px;
  background: url("art/bakery/ribbon.webp") center / contain no-repeat; text-align: center;
  filter: drop-shadow(0 3px 3px #8A4E3A33);
}
.level-ribbon p {
  position: absolute; left: 0; right: 0; top: 19%; margin: 0; font-size: clamp(16px, 5vw, 20px); line-height: 1.1; font-weight: 900;
  letter-spacing: .06em; color: #8A4A3A; text-shadow: 0 1px 0 #FFF8EC;
}
.level-ribbon h1 {
  position: absolute; left: 50%; top: calc(100% + 1px); transform: translateX(-50%); max-width: 100%; margin: 0;
  font-size: 11.5px; line-height: 1.25; font-weight: 800; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 1px 8px; border-radius: 8px; background: #FFF7EACC;
}
.round-btn { display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; background: none; }
.round-btn img, .round-face { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 2px #8A4E3A40); transition: transform 80ms ease-out; }
.hud-gear { justify-self: end; }
/* Home: round cream button with a house icon, 48 px touch target */
.home-btn, .home-face { color: #8A4A3A; background: linear-gradient(#FFF9EE, #FFE9C4); border: 2.5px solid var(--cream-edge); box-shadow: 0 3px 0 #E2B98A, 0 5px 8px #8A4E3A33; }
.home-btn .icon { width: 26px; height: 26px; stroke-width: 2.6; }
.home-btn:active { transform: translateY(2px); }
.home-face { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; box-shadow: none; }
.home-face .icon { width: 20px; height: 20px; }
.stuck-home { margin: 12px auto 0; }
.round-btn:active img, .bar-btn:active:not(:disabled):not(.soon) .round-face { transform: translateY(2px) scale(.96); }

/* ------------------------------------------------------------- bottom bar */
.bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 18px 8px calc(var(--sab) + 14px); display: flex; justify-content: space-evenly; align-items: flex-end;
  background: linear-gradient(#FFF7EA00 0%, #FFF7EA99 40%, #FBE9DDE6 100%);
  pointer-events: none;
}
.bar-btn { position: relative; pointer-events: auto; display: grid; justify-items: center; gap: 4px; min-width: 64px; padding: 0; border: 0; background: none; color: var(--ink); }
.bar-btn .round-face { width: 58px; height: 58px; }
.cap-text { font-size: 12px; line-height: 1.1; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; text-shadow: 0 1px 0 #FFFFFF, 0 0 6px #FFF7EA; }
.bar-btn:disabled { cursor: default; }
.bar-btn:disabled .round-face { filter: grayscale(.7) opacity(.5); }
.bar-btn:disabled .cap-text { opacity: .5; }
.bar-btn.soon .round-face { filter: grayscale(.55) opacity(.6); }
.bar-btn.soon .cap-text { opacity: .6; }
.soon-tag {
  position: absolute; top: -6px; right: -2px; padding: 2px 6px; border-radius: 8px; background: var(--cream); color: var(--pink-deep);
  font-size: 9.5px; line-height: 1; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; box-shadow: 0 1px 3px #8A4E3A55;
}
.bar-btn:focus-visible { box-shadow: none; outline-offset: 4px; border-radius: 18px; }
.short .bar { padding-bottom: calc(var(--sab) + 8px); padding-top: 14px; }
.short .bar-btn .round-face { width: 52px; height: 52px; }
.tiny .cap-text { display: none; }

/* ------------------------------------------------------------ hint bubble */
.bubble {
  position: absolute; z-index: 5; left: 12px; top: 0; max-width: 300px; display: flex; align-items: flex-end; gap: 4px;
  transition: opacity 120ms ease, top 180ms cubic-bezier(.2,.8,.2,1);
}
.bubble-chef { flex: none; width: 54px; height: auto; aspect-ratio: 239 / 600; filter: drop-shadow(0 3px 3px #8A4E3A33); }
.bubble p {
  position: relative; margin: 0 0 18px; padding: 9px 13px 10px; border-radius: 16px; border: 2px solid var(--cream-edge);
  background: #FFF7EAF5; color: var(--ink); font-size: 13.5px; line-height: 1.3; font-weight: 800;
  box-shadow: 0 3px 0 #E9C79A88, 0 8px 18px #8A4E3A33;
}
.bubble p::before {
  content: ""; position: absolute; left: -8px; bottom: 12px; width: 12px; height: 12px;
  background: #FFF7EA; border-left: 2px solid var(--cream-edge); border-bottom: 2px solid var(--cream-edge); transform: rotate(45deg); border-radius: 0 0 0 3px;
}
.bubble.ghost { opacity: 0; }
.reduced .bubble { transition: opacity 120ms ease; }
.short .bubble p { font-size: 12.5px; padding: 7px 11px 8px; }
.hc .bubble p { background: var(--paper); border-color: var(--ink); }

/* reason caption under a refused peg (shown with the red ring and ✕ chip) */
.reject-cap {
  position: absolute; z-index: 9; transform: translateX(-50%); padding: 4px 10px; border-radius: 10px; pointer-events: none;
  background: var(--cream); border: 2px solid var(--alert); color: #8E2414; font-size: 12px; font-weight: 900; white-space: nowrap;
  box-shadow: 0 3px 8px #8A4E3A55; animation: capin 1.7s ease both;
}
@keyframes capin { 0% { opacity: 0; transform: translate(-50%, 4px); } 8%, 82% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.reduced .reject-cap { animation: capfade 1.7s linear both; }
@keyframes capfade { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }

/* level 1 pointer */
.guide { position: absolute; z-index: 7; width: 40px; height: 44px; pointer-events: none; animation: guide 900ms ease-in-out infinite; filter: drop-shadow(0 3px 2px #8A4E3A55); }
.guide-arrow { width: 40px; height: 44px; }
@keyframes guide { 0%, 100% { transform: translateY(-4px); } 50% { transform: translateY(5px); } }
.reduced .guide { animation: none; }

/* ------------------------------------------------------------------ note */
.note {
  position: absolute; z-index: 22; left: 12px; right: 12px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px;
  padding: 8px 6px 8px 12px; border-radius: 14px; background: var(--cream); border: 2px solid var(--cream-edge); box-shadow: 0 6px 16px #8A4E3A44;
  font-size: 12.5px; font-weight: 700; color: var(--ink);
}
.note p { margin: 0; grid-column: 1; }
.note-action { grid-column: 1; justify-self: start; min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--mint); color: #fff; font-weight: 800; box-shadow: 0 3px 0 var(--mint-lip); }
.note-close { grid-column: 2; grid-row: 1 / span 2; width: 44px; height: 44px; border: 0; border-radius: 12px; background: none; color: var(--ink-soft); display: grid; place-items: center; }
.toast {
  position: absolute; z-index: 25; left: 16px; right: 16px; bottom: calc(var(--sab) + 112px); margin: 0 auto; max-width: 340px;
  padding: 10px 14px; border-radius: 14px; background: #5A3A2EF0; color: var(--cream); font-size: 13px; font-weight: 800; text-align: center; box-shadow: 0 6px 16px #5A3A2E55;
}

/* --------------------------------------------------------------- dialogs */
dialog {
  position: fixed; inset: auto; margin: 0; padding: 0; border: 0; max-width: none; max-height: none;
  background: transparent; color: var(--ink); overflow: hidden; font-family: var(--font);
}
dialog::backdrop { background: transparent; }
dialog[open] { display: block; }
.panel[open] { display: grid; place-items: center; }
.sheet[open] { display: flex; flex-direction: column; justify-content: flex-end; }
.stuck-sheet { background: #5A3A2E22; }
.confirm-sheet, .settings-sheet { background: #5A3A2E55; }
.hc dialog.sheet { background: #2A1A12CC; }
h2 { margin: 0; }

.wide-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 56px; padding: 0 18px;
  border: 0; border-radius: 28px; font-size: 18px; font-weight: 900; letter-spacing: .01em;
  --hi: var(--honey-hi); --face: var(--honey); --lip: var(--honey-lip); color: var(--honey-icon);
  background: linear-gradient(var(--hi), var(--face) 65%);
  box-shadow: 0 4px 0 var(--lip), 0 8px 12px #8A4E3A33, inset 0 2px 0 #FFFFFFAA;
  transition: transform 80ms ease-out, box-shadow 80ms ease-out;
}
.wide-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--lip), 0 3px 6px #8A4E3A33, inset 0 2px 0 #FFFFFFAA; }
.wide-btn.go, .wide-btn.mint { --hi: var(--mint-hi); --face: var(--mint); --lip: var(--mint-lip); color: #fff; text-shadow: 0 1px 1px #2E6A4A; }
.wide-btn .icon { width: 22px; height: 22px; stroke-width: 3; }
.text-btn { min-height: 44px; min-width: 120px; margin-top: 4px; border: 0; background: none; color: var(--ink-soft); font-size: 15px; font-weight: 800; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }

/* --------------------------------------------------------------- win screen */
.win-screen { background: #FBE3C8 url("art/bakery/win-bg.webp") center / cover no-repeat; }
.win-screen .card {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  width: 100%; height: 100%; padding: calc(var(--sat) + 12px) 16px calc(var(--sab) + 14px);
}
/* ribbon.webp 551 x 151 */
.win-ribbon { position: relative; z-index: 2; width: min(92%, 340px); aspect-ratio: 551 / 151; background: url("art/bakery/ribbon.webp") center / contain no-repeat; filter: drop-shadow(0 4px 4px #8A4E3A44); }
.win-ribbon h2 {
  position: absolute; left: 12%; right: 12%; top: 16%; text-align: center; font-size: clamp(21px, 6.6vw, 27px); line-height: 1.1; font-weight: 900;
  color: #8A4A3A; white-space: nowrap; text-shadow: 0 1px 0 #FFF8EC;
}
.win-chef { position: relative; z-index: 1; width: auto; height: clamp(130px, 24vh, 230px); aspect-ratio: 348 / 600; margin: -6px 0 6px; filter: drop-shadow(0 8px 10px #8A4E3A44); }
/* panel.webp 456 x 279 */
.win-panel {
  position: relative; z-index: 2; width: min(86%, 320px); aspect-ratio: 456 / 279; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 6% 8% 7%; background: url("art/bakery/panel.webp") center / contain no-repeat; filter: drop-shadow(0 8px 10px #8A4E3A40);
}
.win-panel p { margin: 0; }
.win-stars { display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.win-stars .star { width: 50px; height: auto; aspect-ratio: 113 / 109; }
.win-stars .s2 { width: 60px; transform: translateY(-6px); }
.win-stars .off { filter: grayscale(1) brightness(1.25) opacity(.45); }
.win-moves { font-size: 15px; font-weight: 800; color: var(--ink-soft); }
.win-coins { display: flex; align-items: center; gap: 6px; font-size: 19px; font-weight: 900; color: #B7792A; text-shadow: 0 1px 0 #FFF8EC; }
.win-coins img { width: 28px; height: 28px; }
.win-kept { font-size: 12px; font-weight: 700; color: var(--ink-soft); text-align: center; }
/* pill-mint.webp 411 x 151: the NEXT button keeps that ratio */
.pill-btn {
  position: relative; z-index: 2; width: min(62%, 230px); aspect-ratio: 411 / 151; margin-top: 12px; padding: 0 0 4px; border: 0; border-radius: 40px;
  background: url("art/bakery/pill-mint.webp") center / contain no-repeat; color: #FFFFFF;
  font-size: 24px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; text-shadow: 0 2px 0 #3F8A62, 0 0 8px #3F8A6288;
  filter: drop-shadow(0 6px 6px #3F8A6244); transition: transform 80ms ease-out;
}
.pill-btn:active { transform: translateY(3px) scale(.98); }
.pill-btn:focus-visible, .wide-btn:focus-visible { outline: 3px solid #FFFFFF; outline-offset: -7px; box-shadow: none; }
.win-row { position: relative; z-index: 2; display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.win-row .soft-btn { padding-right: 12px; font-size: 14px; }
.soft-btn {
  display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 4px 16px 4px 6px; border: 2px solid var(--cream-edge); border-radius: 26px;
  background: #FFF7EAF0; color: var(--ink); font-size: 15px; font-weight: 900; box-shadow: 0 3px 0 #E2B98A, 0 6px 10px #8A4E3A33;
}
.soft-btn img { width: 34px; height: 34px; }
.soft-btn:active { transform: translateY(2px); }
.short .win-chef { height: clamp(110px, 21vh, 180px); }
.short .win-stars .star { width: 42px; }
.short .win-stars .s2 { width: 50px; }

/* bottom sheets */
.sheet .card {
  position: relative; margin: 0 10px calc(var(--sab) + 10px); padding: 20px 18px 18px; border-radius: 28px;
  background: linear-gradient(var(--cream), var(--cream-2)); border: 3px solid var(--cream-edge);
  box-shadow: 0 6px 0 #E2B98A, 0 18px 40px #8A4E3A55;
}
.chef-pop { position: absolute; top: -96px; left: 50%; transform: translateX(-50%); width: auto; height: 120px; aspect-ratio: 249 / 600; filter: drop-shadow(0 6px 6px #8A4E3A44); pointer-events: none; }
.stuck-sheet .card, .confirm-sheet .card { text-align: center; padding-top: 30px; margin-top: 100px; }
.stuck-sheet h2, .confirm-sheet h2 { font-size: 23px; font-weight: 900; color: var(--ink); }
.stuck-sheet p, .confirm-sheet p { margin: 6px 0 16px; font-size: 14.5px; line-height: 1.4; font-weight: 700; color: var(--ink-soft); }
.sheet-actions { display: flex; gap: 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-head h2 { font-size: 24px; font-weight: 900; }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 18px; height: 18px; }
.close-btn { width: 44px; height: 44px; border: 0; border-radius: 14px; display: grid; place-items: center; background: #8A4E3A14; color: var(--ink-soft); }
.settings-list { display: grid; gap: 2px; margin-bottom: 14px; }
.cloud-status { margin: -4px 4px 14px; font-size: 14px; font-weight: 800; line-height: 1.3; color: var(--ink-soft); overflow-wrap: anywhere; }
.toggle {
  display: grid; grid-template-columns: 28px 1fr 52px; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 4px 4px;
  border: 0; border-bottom: 1.5px solid #E2C68D88; background: none; color: var(--ink); text-align: left; font-size: 16px; font-weight: 800;
}
.toggle:last-child { border-bottom: 0; }
.toggle-icon { color: var(--pink-deep); width: 24px; height: 24px; }
.toggle:disabled { opacity: .55; cursor: default; }
.track { position: relative; width: 52px; height: 32px; border-radius: 16px; background: var(--off); box-shadow: inset 0 2px 3px #0003; transition: background 160ms; }
.track span { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #FFFDF5; box-shadow: 0 2px 3px #0004; transition: transform 160ms cubic-bezier(.3,1.4,.5,1); }
.toggle[aria-checked="true"] .track { background: var(--mint); box-shadow: inset 0 2px 3px #0002, inset 0 0 0 2px var(--mint-lip); }
.toggle[aria-checked="true"] .track span { transform: translateX(20px); }
.reduced .track, .reduced .track span { transition: none; }

/* level map: three painted maps stacked bottom to top (see renderMap in game.mjs) */
.map-screen[open] { display: flex; }
.map-screen .card { position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; background: #DCEBB8; }
.map-head {
  position: absolute; z-index: 5; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px;
  padding: calc(var(--sat) + 10px) 12px 22px; pointer-events: none;
  background: linear-gradient(#FFF1E2F2 55%, #FFF1E200);
}
.map-head > * { pointer-events: auto; }
.map-title-pill, .map-star-total {
  margin: 0; border: 2px solid var(--cream-edge); border-radius: 22px; background: #FFF7EAF2; color: var(--ink);
  box-shadow: 0 3px 0 #E2B98A, 0 6px 10px #8A4E3A33;
}
.map-title-pill { flex: 1; padding: 5px 14px 6px; text-align: left; }
.map-title-pill h2 { font-size: 20px; line-height: 1.1; font-weight: 900; }
.map-title-pill p { margin: 1px 0 0; font-size: 12.5px; line-height: 1.2; font-weight: 800; color: var(--ink-soft); }
.map-star-total { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px 6px 8px; font-size: 14px; font-weight: 900; font-variant-numeric: tabular-nums; }
.map-star-total img { width: 22px; height: auto; }
.map-head .close-btn { width: 46px; height: 46px; border-radius: 50%; background: #FFF7EA; color: var(--ink); border: 2px solid var(--cream-edge); box-shadow: 0 3px 0 #E2B98A; }
.map-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.map-path { position: relative; margin: 0 auto; overflow: hidden; }
.map-art { position: absolute; max-width: none; user-select: none; -webkit-user-drag: none; pointer-events: none; }
/* a short gradient overlap hides the seam: the lower edge of each upper map fades into the map below */
.map-art.fade-bottom { -webkit-mask-image: linear-gradient(to top, transparent 0, #000 var(--fade)); mask-image: linear-gradient(to top, transparent 0, #000 var(--fade)); }
.chapter-tag {
  position: absolute; z-index: 2; transform: translate(-50%, -50%); margin: 0; display: flex; align-items: baseline; gap: 6px; padding: 4px 14px 5px;
  border-radius: 16px; background: #FFF7EAF0; border: 2px solid var(--cream-edge); box-shadow: 0 3px 0 #E2B98A, 0 5px 8px #8A4E3A33; white-space: nowrap; pointer-events: none;
}
.chapter-tag small { font-size: 10px; line-height: 1; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: var(--pink-deep); }
.chapter-tag b { font-size: 14px; line-height: 1.1; font-weight: 900; color: var(--ink); }
.node { position: absolute; z-index: 3; transform: translate(-50%, -50%); width: 44px; height: 44px; padding: 0; border: 0; background: none; display: grid; place-items: center; }
.node.current { width: 50px; height: 50px; z-index: 4; }
.node-face {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-size: 17px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums;
  background: radial-gradient(circle at 40% 30%, #FFFDF5, var(--cream-2) 80%); border: 2.5px solid var(--cream-edge);
  color: var(--ink); box-shadow: 0 3px 0 #D9AE76, 0 6px 8px #8A4E3A40, inset 0 2px 0 #FFFFFF;
}
.node.done .node-face { background: radial-gradient(circle at 40% 30%, #FFE3E6, #F7B8C3 80%); border-color: #E98FA0; color: #8A3348; box-shadow: 0 3px 0 #C9586E, 0 6px 8px #8A4E3A40, inset 0 2px 0 #FFFFFFAA; }
.node.current .node-face { width: 46px; height: 46px; background: radial-gradient(circle at 40% 30%, var(--mint-hi), var(--mint) 80%); border-color: var(--mint-lip); color: #fff; font-size: 21px; text-shadow: 0 2px 0 var(--mint-lip); box-shadow: 0 3px 0 var(--mint-lip), 0 0 0 4px #FFFFFFB0, 0 7px 10px #3F8A6255, inset 0 2px 0 #E4FFF0; }
.node.current::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 3px solid #FFFFFFE0; animation: ping 1.6s ease-out infinite; }
.node.locked .node-face { background: radial-gradient(circle at 40% 30%, #F1ECF7, #D5CCE3 80%); border-color: #B8ABCB; color: #7C6D93; box-shadow: 0 3px 0 #9D90B3, 0 5px 7px #5A3A2E30, inset 0 2px 0 #FFFFFFAA; }
.node.locked .icon { width: 19px; height: 19px; stroke-width: 2.6; }
.node.locked { cursor: default; }
.node:focus-visible { border-radius: 50%; }
.node-stars { position: absolute; left: 50%; bottom: -3px; transform: translateX(-50%); display: flex; gap: 0; padding: 1px 4px; border-radius: 9px; background: #FFF7EAF2; box-shadow: 0 2px 3px #8A4E3A44; }
.node-stars img { width: 11px; height: 11px; }
.node-stars .off { filter: grayscale(1) brightness(1.3) opacity(.5); }
.pin { position: absolute; bottom: -2px; width: 26px; margin-left: -13px; height: auto; filter: drop-shadow(0 3px 2px #5A3A2E55); pointer-events: none; animation: pin-bob 1.6s ease-in-out infinite; }
@keyframes pin-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes ping { from { transform: scale(.85); opacity: .9; } to { transform: scale(1.25); opacity: 0; } }
.reduced .node.current::before { animation: none; opacity: .6; }
.reduced .pin { animation: none; }

/* ------------------------------------------------------------------ lobby */
.lobby { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; overflow: hidden; background: var(--blush); }
.lobby-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; }
.lobby-top { position: relative; z-index: 2; width: 100%; display: flex; align-items: center; justify-content: space-between; padding: calc(var(--sat) + 10px) 12px 0; }
.lobby-ribbon { z-index: 2; flex: none; margin-top: 4px; width: clamp(180px, 58vw, 240px); }
.lobby-ribbon p { font-size: clamp(18px, 5.6vw, 24px); top: 20%; }
.lobby-stage { position: relative; z-index: 1; flex: 1; width: 100%; min-height: 0; margin-bottom: clamp(4px, 2.4vh, 22px); }
.lobby-chef {
  position: absolute; left: 50%; bottom: 0; height: min(100%, 440px); width: auto; aspect-ratio: 364 / 600; transform: translateX(-50%); transform-origin: 50% 100%;
  filter: drop-shadow(0 10px 10px #8A4E3A44); animation: chef-bob 3.4s ease-in-out infinite;
}
@keyframes chef-bob { 0%, 100% { transform: translateX(-50%) translateY(0) scale(1, 1); } 50% { transform: translateX(-50%) translateY(-7px) scale(1.012, .994); } }
.sparkles { position: absolute; inset: 0; pointer-events: none; }
.sparkles i {
  position: absolute; bottom: 20%; width: 14px; height: 14px; background: #FFF6C8; opacity: 0;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 4px #FFE9A0); animation: sparkle-drift 5.2s ease-in-out infinite;
}
.sparkles i:nth-child(1) { left: 12%; animation-delay: 0s; }
.sparkles i:nth-child(2) { left: 24%; bottom: 40%; width: 10px; height: 10px; animation-delay: 1.1s; }
.sparkles i:nth-child(3) { left: 76%; animation-delay: 2s; }
.sparkles i:nth-child(4) { left: 86%; bottom: 44%; width: 11px; height: 11px; animation-delay: .6s; }
.sparkles i:nth-child(5) { left: 34%; bottom: 62%; width: 9px; height: 9px; animation-delay: 3.1s; }
.sparkles i:nth-child(6) { left: 66%; bottom: 58%; width: 12px; height: 12px; animation-delay: 1.8s; }
.sparkles i:nth-child(7) { left: 50%; bottom: 76%; width: 9px; height: 9px; animation-delay: 4s; }
@keyframes sparkle-drift { 0% { opacity: 0; transform: translateY(0) scale(.5) rotate(0); } 25% { opacity: 1; } 100% { opacity: 0; transform: translateY(-70px) scale(1.1) rotate(60deg); } }
.lobby-actions { position: relative; z-index: 2; display: grid; justify-items: center; gap: 8px; width: 100%; padding: 0 16px calc(var(--sab) + clamp(14px, 4vh, 36px)); }
.lobby-play { margin-top: 0; width: min(72%, 280px); font-size: 30px; }
.lobby-levels { min-width: 148px; justify-content: center; }
.reduced .lobby-chef { animation: none; }
.reduced .sparkles i { animation: none; opacity: .7; }
@media (prefers-reduced-motion: reduce) { .lobby-chef, .sparkles i, .pin { animation: none; } .sparkles i { opacity: .7; } }

/* ----------------------------------------------------------------- splash */
.splash {
  position: fixed; inset: 0; z-index: 1000; display: grid; align-items: end; justify-items: center; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 7vh);
  background: #F6D9D2 url("art/bakery/splash.webp") 50% 40% / cover no-repeat; transition: opacity 300ms ease-out;
}
.splash.gone { opacity: 0; pointer-events: none; }
.splash-text {
  margin: 0; padding: 6px 18px; border-radius: 20px; background: #FFF7EACC; color: var(--ink); font: 800 15px/1.2 var(--font); letter-spacing: .02em;
}
.dots i { font-style: normal; animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; } .splash { transition: none; } }

/* ---------------------------------------------------------- rotate card */
.rotate { display: none; position: fixed; inset: 0; z-index: 100; place-items: center; background: var(--bg-deep); color: var(--hud-ink); text-align: center; }
.rotate-card { display: grid; justify-items: center; gap: 14px; font-size: 18px; font-weight: 800; max-width: 320px; }
.rotate-card p { margin: 0; }
.rotate-icon { color: var(--honey); }
.rotate-glyph { width: 72px; height: 72px; stroke-width: 1.8; animation: turn 2.2s ease-in-out infinite; }
@keyframes turn { 0%, 30% { transform: rotate(90deg); } 60%, 100% { transform: rotate(0deg); } }
@media (orientation: landscape) and (max-height: 500px) {
  .rotate { display: grid; }
}

/* reduced motion: no CSS transitions beyond fades */
.reduced .round-face, .reduced .wide-btn, .reduced .pill-btn { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .guide, .rotate-glyph, .node.current::before { animation: none; }
}
html:not(.ready) .scene, html:not(.ready) .board { opacity: 0; }
.scene, .board { transition: opacity 200ms ease; }

/* ------------------------------------------------- economy screens (chest, daily gift, welcome back) */
.econ-panel { gap: 3px; }
.econ-panel .win-coins { font-size: 22px; }
.econ-unit { font-size: 14px; font-weight: 800; color: var(--ink-soft); }
.econ-note { font-size: 13.5px; line-height: 1.25; font-weight: 800; color: var(--ink-soft); text-align: center; }
.hint-line { color: #2E7D5B; }
.gift-days { display: flex; gap: 5px; margin-top: 2px; }
.gift-days i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--cream-edge); background: #FFF7EA; font-weight: 900; font-size: 11px; line-height: 18px; font-style: normal; text-align: center; color: var(--ink-soft); }
.gift-days i.done { background: #B7E3C9; border-color: #6CBF93; }
.gift-days i.today { background: #FFD36A; border-color: #D9A23A; color: #7A4416; transform: scale(1.18); }
.welcome-lines { list-style: none; margin: 0 0 2px; padding: 0; display: grid; gap: 1px; font-size: 12.5px; line-height: 1.25; font-weight: 800; color: var(--ink-soft); text-align: center; }
.welcome-lines b { color: #B7792A; }
.econ-screen .pill-btn { margin-top: 14px; }

/* ------------------------------------------------ Task B: stuck sheet, pay sheet, hint marks */
.stuck-sheet .card { position: relative; max-height: 50%; padding: 22px 56px 12px; margin-top: 110px; }
.stuck-sheet .stuck-actions { margin: 0 -42px; }
.stuck-sheet .chef-pop { left: 12px; top: -86px; height: 104px; transform: none; }
.stuck-sheet h2 { font-size: 21px; }
.stuck-sheet p { margin: 2px 0 8px; font-size: 16px; line-height: 1.3; }
.stuck-home { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; }
.stuck-actions, .pay-actions { display: flex; flex-direction: column; gap: 8px; }
.stuck-actions .wide-btn, .pay-actions .wide-btn { min-height: 48px; justify-content: space-between; padding: 0 16px; font-size: 16px; text-align: left; }
.wide-btn .price { display: inline-flex; align-items: center; gap: 4px; flex: none; margin-left: 8px; padding: 2px 10px; border-radius: 14px; background: #FFFFFF66; font-size: 16px; font-weight: 900; white-space: nowrap; }
.wide-btn .price img { width: 18px; height: 18px; }
.wide-btn:disabled { filter: grayscale(.7) opacity(.6); box-shadow: none; }
.pay-balance { display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 900; color: #B7792A; }
.pay-balance[hidden] { display: none; }
.pay-balance .text-btn { margin: 0 0 0 6px; min-width: 0; color: var(--pink-deep); }
.pay-sheet .card { padding-top: 28px; }
.pay-sheet p { font-size: 16px; }
.pay-actions .wide-btn.quiet, .cloud-sheet .wide-btn.quiet { --hi: #FFF7EA; --face: #FFE9C4; --lip: #E2B98A; color: var(--ink); }
/* hint and ghost marks on pegs (drawn as a glow around the whole peg) */
.peg-svg.mark-from { filter: drop-shadow(0 0 7px #FFD36A) drop-shadow(0 0 3px #FFFFFF); }
.peg-svg.mark-to { filter: drop-shadow(0 0 7px #6FBF94) drop-shadow(0 0 3px #FFFFFF); }
.peg-svg.mark-bad-from, .peg-svg.mark-bad-to { filter: drop-shadow(0 0 7px #E5484D) drop-shadow(0 0 3px #FFFFFF); opacity: .92; }
.hc .peg-svg.mark-from, .hc .peg-svg.mark-to { filter: drop-shadow(0 0 0 #000) drop-shadow(0 0 2px #000) drop-shadow(0 0 2px #000); }
.spinner-note { font-weight: 800; color: var(--ink-soft); }
.tool-badge { position: absolute; top: -6px; right: -4px; min-width: 22px; padding: 2px 6px; border-radius: 10px; background: var(--cream); color: var(--ink); border: 1.5px solid var(--cream-edge); font-size: 11px; line-height: 1.1; font-weight: 900; text-align: center; box-shadow: 0 1px 3px #8A4E3A55; }
.tool-badge:empty { display: none; }
.tool-badge.token { background: var(--mint); color: #fff; border-color: var(--mint-lip); }
.bar-btn:disabled .tool-badge { opacity: .5; }

/* ---- cloud save dialog and legal links (P1-D) ---- */
.cloud-open { min-height: 52px; margin: 0 0 8px; font-size: 16px; }
.legal-links { margin: 0 0 12px; text-align: center; font-size: 14px; font-weight: 800; }
.legal-links a { display: inline-block; min-height: 32px; line-height: 32px; color: var(--ink-soft); text-underline-offset: 3px; }
.cloud-sheet .card { margin-top: 24px; padding-top: 20px; }
.cloud-sheet h2 { font-size: 22px; }
.cloud-sheet .cloud-body { text-align: left; }
.cloud-sheet .cloud-body p { margin: 8px 0 10px; font-size: 14.5px; line-height: 1.35; }
.cloud-sheet .sheet-actions { flex-direction: column; gap: 10px; }
.cloud-sheet .wide-btn { min-height: 52px; font-size: 16px; }
.cloud-sheet .wide-btn[disabled] { opacity: .55; }
.cloud-code { margin: 10px 0 8px; padding: 12px 6px; border-radius: 16px; background: #fff8e2; border: 2px dashed var(--cream-edge); text-align: center;
  font: 900 24px/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; color: var(--ink); user-select: all; overflow-wrap: anywhere; }
.cloud-input { width: 100%; min-height: 52px; margin: 6px 0; padding: 0 12px; box-sizing: border-box; border-radius: 16px; border: 2px solid var(--cream-edge);
  background: #fff8e2; color: var(--ink); text-align: center; font: 900 20px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; }
.cloud-check { display: flex; align-items: center; gap: 10px; min-height: 48px; font-size: 14.5px; font-weight: 800; color: var(--ink); }
.cloud-check input { width: 24px; height: 24px; flex: none; }
.cloud-msg { min-height: 20px; margin: 4px 0 0; font-weight: 800; color: #B0413E; }

/* Ask a friend (AF-7): stuck-sheet button, friend note and the link sheet */
.stuck-sheet .stuck-friend { margin: 0 0 6px; font-size: 14px; }
.stuck-sheet .stuck-friend .text-btn { min-height: 44px; margin: 0; min-width: 64px; }
.stuck-actions .wide-btn:disabled { opacity: .7; }
.help-sheet .card { position: relative; text-align: center; padding-top: 30px; margin-top: 100px; max-height: 80%; overflow: visible; }
.help-body { max-height: 60vh; overflow-y: auto; }
.help-link { width: 100%; min-height: 44px; margin: 0 0 12px; padding: 0 12px; box-sizing: border-box; border: 2px solid #E2B98A; border-radius: 14px; background: #FFF7EA; color: var(--ink); font: 700 14px/1.2 inherit; text-align: center; }
.help-watch { margin: 0 0 12px; padding: 0 0 0 28px; max-height: 30vh; overflow-y: auto; text-align: left; font-size: 14.5px; font-weight: 700; color: var(--ink-soft); }
.help-sheet .pay-actions .wide-btn { min-height: 48px; }

/* Ask a friend, helper side (AF-9): the friend's board uses the normal play screen without Hint, +Peg or coins */
html.helping .coins-pill, html.helping #hint, html.helping #add-peg { display: none; }
html.helper-card .hud, html.helper-card .bar, html.helper-card #board { visibility: hidden; }
.help-banner .note-action { min-width: 44px; }

/* helper banner: 44 px close target; no motion beyond the shared dialog fade (which game.mjs already skips to a short fade when reduced) */
.help-banner .note-close { min-width: 44px; min-height: 44px; }
.reduced .help-banner, .reduced .help-sheet .card { transition: none; animation: none; }
