/* Crown Trouble: HulaGames candy brand (coral, gold, teal, glossy). Portrait, phone first.
   Every UI piece has a CSS-drawn look; when its PNG from assets/ loads, art.js adds an art-<name>
   class to <html> and the rules at the bottom switch that piece to the image. */
@font-face { font-family: 'Fredoka'; font-weight: 600; font-display: swap; src: url(./fonts/fredoka-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Outfit'; font-weight: 600; font-display: swap; src: url(./fonts/outfit-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-display: swap; src: url(./fonts/fredoka-latin-700-normal.woff2) format('woff2'); }

:root {
  --coral: #ff7a5c; --coral-hi: #ffb09a; --coral-lo: #e8553a; --coral-lip: #b53a22;
  --gold: #ffc94a; --gold-hi: #fff0a8; --gold-lo: #f0a000; --gold-lip: #b87400;
  --teal: #19a7a1; --teal-hi: #7fe6df; --teal-lo: #10827d; --teal-lip: #0b5c58;
  --cream: #fff8ea; --cream-2: #fdebd0; --ink: #4a2a1a; --ink-teal: #0d5f5c;
  --font: 'Fredoka', ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: 'Outfit', system-ui, -apple-system, "Segoe UI", sans-serif;   /* sentences; Fredoka stays for titles, buttons and numbers */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  font-family: var(--font); font-weight: 600; color: var(--ink); }
html { background: #ffe1c8; }
body { background: #ffe1c8; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#loading { position: fixed; inset: 0; display: grid; place-content: center; background: linear-gradient(#fff1e0, #ffd2b8); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 6px solid rgba(25,167,161,.2); border-top-color: var(--teal); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; overflow: hidden;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(env(safe-area-inset-bottom) + 14px); }

/* ---------- shared pieces ---------- */
.panel { background: linear-gradient(#fffdf6, var(--cream) 45%, var(--cream-2)); border: 3px solid #f5c95c; border-radius: 18px;
  box-shadow: inset 0 2px 0 #fff, inset 0 -3px 0 rgba(214,160,60,.25), 0 3px 0 #d9a23a, 0 8px 18px rgba(110,60,20,.18); }
.pill { display: flex; align-items: center; gap: 6px; padding: 4px 14px 4px 8px; border-radius: 999px; font-size: 20px; font-weight: 700; }
.ico-star { display: inline-block; width: 26px; height: 26px; background: url(./ui/star.svg) center / contain no-repeat; flex: none; }
.ico-star.big { width: 84px; height: 84px; }
.ico-x { display: block; width: 18px; height: 18px; margin: auto; background: url(./ui/x.svg) center / contain no-repeat; }
.map-title { white-space: nowrap; font-size: 20px; font-weight: 700; color: #fff; letter-spacing: .5px;
  -webkit-text-stroke: 5px var(--ink-teal); paint-order: stroke fill; text-shadow: 0 3px 0 rgba(13,95,92,.4); }

/* Candy buttons: glossy jelly with a gold outline and a thick lip. */
.btn { position: relative; border: 3px solid #ffe08a; border-radius: 999px; padding: 12px 26px; font-weight: 700; font-size: 18px;
  letter-spacing: .4px; color: #fff; isolation: isolate;
  text-shadow: 0 2px 0 rgba(120,30,10,.45), 0 0 1px rgba(120,30,10,.6); transition: transform .08s; }
.btn::before { content: ''; position: absolute; left: 12%; right: 12%; top: 4px; height: 42%; border-radius: 999px; z-index: -1;
  background: linear-gradient(rgba(255,255,255,.8), rgba(255,255,255,.08)); }
.btn.primary { background: linear-gradient(var(--coral-hi), var(--coral) 48%, var(--coral-lo));
  box-shadow: inset 0 -5px 0 rgba(150,40,20,.25), 0 6px 0 var(--coral-lip), 0 12px 20px rgba(150,50,20,.35); }
.btn.secondary { background: linear-gradient(var(--teal-hi), var(--teal) 50%, var(--teal-lo)); text-shadow: 0 2px 0 rgba(10,70,70,.5);
  box-shadow: inset 0 -5px 0 rgba(10,70,70,.25), 0 5px 0 var(--teal-lip), 0 10px 18px rgba(10,80,80,.3); }
.btn:active { transform: translateY(4px); }
.btn.primary:active { box-shadow: inset 0 -3px 0 rgba(150,40,20,.25), 0 2px 0 var(--coral-lip); }
.btn.secondary:active { box-shadow: inset 0 -3px 0 rgba(10,70,70,.25), 0 1px 0 var(--teal-lip); }
.btn.big { min-width: 230px; min-height: 64px; font-size: 28px; }
.btn.small { padding: 7px 16px; font-size: 16px; border-width: 2px; }
/* One line, no wrapping: long labels grow the pill instead of making it tall. */
.btn { white-space: nowrap; }
.btn.pulse { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); } }
.round-btn { width: 44px; height: 44px; border-radius: 50%; flex: none; border: 3px solid #fff; padding: 0;
  background: radial-gradient(circle at 35% 30%, #fff, #dff6f3 70%); box-shadow: 0 3px 0 rgba(13,95,92,.35), 0 6px 12px rgba(0,0,0,.12); }
.round-btn:active { transform: translateY(2px); }

/* ---------- title ---------- */
#title { justify-content: space-between; padding-top: calc(env(safe-area-inset-top) + 48px); padding-bottom: calc(env(safe-area-inset-bottom) + 36px); }
.scene { position: absolute; inset: -12px; z-index: -1; background: linear-gradient(#ffcfae, #ffe9d4 50%, #f7b9a0) center / cover no-repeat;
  filter: blur(3px) saturate(1.05); }
/* Warm wash: darker at the top so the logo pops, soft cream at the bottom behind the buttons. */
.scene::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(rgba(70,25,10,.55), rgba(255,170,120,.1) 38%, rgba(255,214,180,.2) 62%, rgba(255,236,215,.92) 88%); }
.logo { text-align: center; line-height: .86; animation: drop-in .7s cubic-bezier(.2,.9,.3,1.3); }
@keyframes drop-in { from { transform: translateY(-60px) scale(.8); opacity: 0; } }
.logo img { width: min(330px, 84vw); height: auto; display: block; filter: drop-shadow(0 8px 10px rgba(80,30,10,.25)); }
.logo span { display: block; font-weight: 700; paint-order: stroke fill; }
.logo-a { font-size: 62px; color: var(--gold); -webkit-text-stroke: 9px #a0451f; text-shadow: 0 7px 0 #7a2f12, 0 12px 18px rgba(80,30,10,.35); }
.logo-b { font-size: 78px; color: #fff; -webkit-text-stroke: 10px var(--teal-lip); text-shadow: 0 7px 0 #073f3c, 0 12px 18px rgba(10,60,60,.35); margin-top: -4px; }
.title-cast { position: relative; flex: 1; min-height: 0; width: 100%; max-width: 440px; margin: 8px 0 -10px; }
.title-cast::before { content: ''; position: absolute; left: 60%; width: 36%; bottom: 2%; height: 8%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(60,30,10,.35), transparent); }
.title-cast .pet { position: absolute; left: 54%; bottom: 0; height: 50%; width: 46%; animation: bob-y 3.2s ease-in-out infinite; }
.title-cast .who img, .title-cast .who svg { object-position: bottom; filter: drop-shadow(0 10px 14px rgba(60,20,5,.35)); }
@keyframes bob-y { 50% { transform: translateY(-5px); } }
.who img, .who svg, .art img, .art svg { width: 100%; height: 100%; object-fit: contain; display: block; filter: drop-shadow(0 6px 6px rgba(60,30,10,.25)); }
.title-buttons { display: flex; flex-direction: column; align-items: center; gap: 16px; }

/* ---------- map ---------- */
#map { background: linear-gradient(#bfeef0 0%, #d8f5d2 22%, #9fdc8a 60%, #7ccb6c 100%); padding-left: 0; padding-right: 0; }
#map .bar { padding: 0 14px; flex-wrap: wrap; row-gap: 4px; }
/* The room name gets its own row under the stars, sound and Castle buttons, so nothing crowds it. */
#map .map-title { order: 3; flex-basis: 100%; text-align: center; }
.bar { position: relative; z-index: 2; width: 100%; max-width: 480px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; }
.path { flex: 1; width: 100%; overflow-y: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.path::-webkit-scrollbar { display: none; }
.path-inner { position: relative; margin: 0 auto; width: 100%; max-width: 420px; }
.path-inner svg.trail { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.deco { position: absolute; border-radius: 50%; pointer-events: none; }
.lvl { position: absolute; width: 76px; height: 76px; margin: -38px 0 0 -38px; border-radius: 50%; border: 0; padding: 0;
  background: radial-gradient(circle at 50% 38%, #8ff0e9, var(--teal) 55%, var(--teal-lo));
  box-shadow: inset 0 0 0 5px #ffe08a, inset 0 0 0 7px #d49a2a, inset 0 -8px 0 7px rgba(0,0,0,.12), 0 6px 0 var(--teal-lip), 0 10px 16px rgba(10,60,40,.35);
  color: #fff; font-size: 30px; font-weight: 700; isolation: isolate; }
.lvl::before { content: ''; position: absolute; left: 20%; right: 20%; top: 12%; height: 30%; border-radius: 50%; z-index: -1;
  background: linear-gradient(rgba(255,255,255,.85), rgba(255,255,255,0)); }
.lvl b { position: relative; top: 2px; -webkit-text-stroke: 5px rgba(10,60,60,.55); paint-order: stroke fill; }
.lvl .ico-star { position: absolute; right: -8px; bottom: -8px; width: 32px; height: 32px; }
.lvl .lock { position: absolute; inset: 22px; background: url(./ui/lock.svg) center / contain no-repeat; }
.lvl.won { background: radial-gradient(circle at 50% 38%, #fff3a6, var(--gold) 55%, var(--gold-lo)); box-shadow: inset 0 0 0 5px #fff6cf, inset 0 0 0 7px #c58a10, inset 0 -8px 0 7px rgba(0,0,0,.1), 0 6px 0 var(--gold-lip), 0 10px 16px rgba(10,60,40,.35); }
.lvl.won b { -webkit-text-stroke-color: rgba(140,80,0,.65); }
.lvl.locked { background: radial-gradient(circle at 50% 38%, #e8edf4, #c3ccd9 60%, #a3aec0); cursor: default;
  box-shadow: inset 0 0 0 5px #eef1f6, inset 0 0 0 7px #8f9bb0, 0 6px 0 #7a869b, 0 10px 14px rgba(10,40,40,.25); }
.lvl.locked b { display: none; }
.lvl.next { width: 88px; height: 88px; margin: -44px 0 0 -44px; font-size: 34px;
  background: radial-gradient(circle at 50% 38%, #ffd0c2, var(--coral) 55%, var(--coral-lo));
  box-shadow: inset 0 0 0 5px #ffe08a, inset 0 0 0 7px #d49a2a, inset 0 -8px 0 7px rgba(0,0,0,.1), 0 6px 0 var(--coral-lip), 0 0 0 8px rgba(255,255,255,.55), 0 12px 22px rgba(150,40,20,.4);
  animation: node-bob 1.3s ease-in-out infinite; }
.lvl.next b { -webkit-text-stroke-color: rgba(140,30,10,.6); }
@keyframes node-bob { 50% { transform: translateY(-6px); } }
.lvl.next { z-index: 1; }

/* ---------- level ---------- */
#play { padding: calc(env(safe-area-inset-top) + 8px) 0 calc(env(safe-area-inset-bottom) + 8px);
  background: radial-gradient(70% 40% at 20% 15%, rgba(255,255,255,.55), transparent 70%),
              radial-gradient(60% 35% at 85% 80%, rgba(255,214,140,.5), transparent 70%),
              linear-gradient(#ffe6cf, #ffc9b0 45%, #8fd6cc); }
.hud { width: 100%; max-width: 540px; padding: 0 12px; display: flex; align-items: center; gap: 10px; flex: none; }
.hud-goals { position: relative; flex: 1; min-width: 0; padding: 18px 10px 8px; }
.tag { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: linear-gradient(var(--coral-hi), var(--coral) 55%, var(--coral-lo)); color: #fff; font-size: 14px; font-weight: 700;
  padding: 3px 14px; border-radius: 999px; border: 2px solid #ffe08a; box-shadow: 0 2px 0 var(--coral-lip); text-shadow: 0 1px 0 rgba(120,30,10,.5); }
.collect { text-align: center; font-size: 13px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--teal-lo); margin: 5px 0 0; }
.goals { display: flex; justify-content: center; gap: 14px; }
.goal { position: relative; display: flex; align-items: center; gap: 4px; }
.goal canvas { filter: drop-shadow(0 2px 2px rgba(0,0,0,.15)); }
.goal b { font-size: 30px; font-weight: 700; min-width: 30px; color: var(--ink); }
.goal .done-mark { display: none; width: 26px; height: 26px; background: url(./ui/check.svg) center / contain no-repeat; }
.goal.done b { display: none; }
.goal.done .done-mark { display: block; animation: pop .35s cubic-bezier(.2,.9,.3,1.6); }
.goal.bump { animation: bump .3s cubic-bezier(.2,.9,.3,1.4); }
@keyframes bump { 35% { transform: scale(1.38); filter: brightness(1.25); } }
.flyer { position: fixed; z-index: 20; pointer-events: none; filter: drop-shadow(0 4px 6px rgba(80,40,10,.35)); }
@keyframes pop { from { transform: scale(0); } }
.moves-badge { position: relative; flex: none; width: 82px; height: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding-top: 6px; color: #fff; background: linear-gradient(var(--teal-hi), var(--teal) 45%, var(--teal-lo));
  border: 4px solid #ffd76a; border-radius: 20px 20px 42px 42px / 20px 20px 56px 56px;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.5), inset 0 -6px 0 rgba(0,0,0,.12), 0 4px 0 #c08a1e, 0 10px 16px rgba(10,60,60,.3); }
.moves-badge small { font-size: 12px; font-weight: 700; letter-spacing: .5px; opacity: .95; text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.moves-badge b { font-size: 38px; line-height: 1; font-weight: 700; -webkit-text-stroke: 5px var(--teal-lip); paint-order: stroke fill; }
.moves-badge.low { background: linear-gradient(var(--coral-hi), var(--coral) 45%, var(--coral-lo)); animation: pulse .8s infinite; }
.moves-badge.low b { -webkit-text-stroke-color: var(--coral-lip); }
/* Coach line: sits under the board (top is set by game.js), ignores touches so it never blocks play. */
.coach { position: absolute; left: 50%; transform: translateX(-50%); width: min(calc(100% - 32px), 360px); z-index: 2; pointer-events: none;
  text-align: center; padding: 9px 16px;
  font-size: 1.0625rem; line-height: 1.3; color: var(--ink); background: linear-gradient(#fffdf6, var(--cream) 50%, var(--cream-2));
  border: 3px solid #f5c95c; border-radius: 18px; box-shadow: inset 0 2px 0 #fff, 0 3px 0 #d9a23a, 0 8px 16px rgba(110,60,20,.2); }
.coach.narrow { width: min(calc(100% - 128px), 360px); }
.coach canvas { vertical-align: middle; margin: -4px 2px; }
.coach.pop { animation: coach-in .3s cubic-bezier(.2,.9,.3,1.3); }
@keyframes coach-in { from { opacity: 0; margin-top: 8px; } }
#board { flex: 1; width: 100%; min-height: 0; touch-action: none; display: block; }

/* ---------- win / lose card ---------- */
.overlay.entering .btn { pointer-events: none; }   /* buttons move while the card slides in (DEX-10) */
.overlay { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 50% 45%, rgba(255,240,200,.25), rgba(40,20,10,.55)); animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }
.card { width: min(100%, 350px); padding: 46px 22px 24px; border-radius: 30px; text-align: center; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 14px; border-width: 4px; animation: rise .4s cubic-bezier(.2,.9,.3,1.3); }
@keyframes rise { from { transform: translateY(50px) scale(.85); opacity: 0; } }
.ribbon { position: absolute; top: -26px; left: -18px; right: -18px; height: 58px; display: grid; place-items: center;
  background: linear-gradient(var(--coral-hi), var(--coral) 50%, var(--coral-lo)); border: 3px solid #ffe08a; border-radius: 14px;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.4), 0 5px 0 var(--coral-lip), 0 10px 18px rgba(120,30,10,.3); }
.ribbon::before, .ribbon::after { content: ''; position: absolute; top: 14px; width: 30px; height: 50px; z-index: -1; background: var(--coral-lip); }
.ribbon::before { left: -12px; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); }
.ribbon::after { right: -12px; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); }
.ribbon span { color: #fff; font-size: 24px; font-weight: 700; -webkit-text-stroke: 5px var(--coral-lip); paint-order: stroke fill; white-space: nowrap; }
/* The finale title wraps onto two lines in a taller ribbon (T28); the card gets the extra headroom. */
.ribbon.finale { height: 76px; top: -34px; }
.ribbon.finale span { font-size: 21px; line-height: 1.05; -webkit-text-stroke-width: 4px; white-space: normal; text-align: center; text-wrap: balance; max-width: 230px; }
.card:has(.ribbon.finale) { padding-top: 56px; }
.ribbon.lose { background: linear-gradient(#b9c6d8, #8a9bb5 50%, #70819c); box-shadow: inset 0 3px 0 rgba(255,255,255,.4), 0 5px 0 #4f5d75, 0 10px 18px rgba(20,30,50,.3); }
.ribbon.lose span { -webkit-text-stroke-color: #4f5d75; }
.ribbon.lose::before, .ribbon.lose::after { background: #4f5d75; }
.card p { margin: 0; font-size: 1.0625rem; color: #6a4630; line-height: 1.35; }
/* Lose card: "2 [star tile]" stays on one line, the icon sitting on the text's middle (T18). */
.card p .need { white-space: nowrap; font-weight: 700; color: var(--ink); }
.card p .need canvas { vertical-align: -6px; }
.card-star { position: relative; display: grid; place-items: center; width: 150px; height: 120px; }
.card-star .ico-star { position: relative; animation: star-in .7s cubic-bezier(.2,.9,.3,1.5); filter: drop-shadow(0 6px 6px rgba(160,90,0,.35)); }
.card-star b { position: absolute; right: 0; bottom: 6px; font-size: 30px; color: #fff; -webkit-text-stroke: 6px var(--gold-lip); paint-order: stroke fill; animation: pop .5s .35s both; }
/* Lose card: an empty Moves badge in the star's slot (same height), so the text clears the ribbon. */
.card-lose { display: grid; place-items: center; width: 150px; height: 120px; }
.card-lose .moves-badge { transform: scale(1.15); filter: saturate(.7); }
.rays { position: absolute; inset: -30px; border-radius: 50%; animation: spin 9s linear infinite;
  background: repeating-conic-gradient(rgba(255,214,90,.5) 0 10deg, transparent 10deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%); mask: radial-gradient(circle, #000 30%, transparent 70%); }
@keyframes star-in { from { transform: scale(0) rotate(-200deg); } }

/* ---------- castle ---------- */
#castle { gap: 10px; background: radial-gradient(80% 50% at 50% 0%, #fff4e4, transparent 70%), linear-gradient(#ffe2cc, #f9c7b2 50%, #a7ddd3); }
/* Landscape phones are short: let the castle scroll and give the room a real height (Tyler, R5). */
@media (orientation: landscape) and (max-height: 500px) {
  #castle { overflow-y: auto; justify-content: flex-start; }
  #castle .room-wrap { flex: none; height: 78vh; }
  #castle .cast, #castle .tasks { flex: none; }
}
/* Room tabs under the castle header: the shown room is the gold one, a locked room is grey with a lock. */
.room-tabs { width: 100%; max-width: 480px; display: flex; gap: 8px; flex: none; }
.room-tab { flex: 1; min-width: 0; min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 4px 10px;
  border-radius: 999px; border: 2px solid #fff; font-size: 16px; font-weight: 700; color: var(--ink-teal); white-space: nowrap;
  background: linear-gradient(#f3fffd, #cdeee9); box-shadow: 0 3px 0 rgba(13,95,92,.35); }
.room-tab span { overflow: hidden; text-overflow: ellipsis; }
/* A locked tab's reason sits under its name (T21), small enough for 360-wide phones. */
.room-tab span small { display: block; font-size: 11px; line-height: 1.1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.room-tab.locked { line-height: 1.15; padding: 5px 7px; gap: 4px; }
.room-tab.locked .lock { width: 16px; height: 16px; }
/* With the Room 3 teaser there are three tabs: tighter type so full names fit at 360. The teaser drops its lock
   ("Coming soon" says it) and its SOON badge sits above the name. */
.room-tabs:has(.soon) { gap: 6px; }
.room-tabs:has(.soon) .room-tab { font-size: 13.5px; padding: 4px 6px; }
.room-tab.soon { flex: .75; }
.room-tab.soon .lock { display: none; }
.room-tab.soon.glow::after { content: 'SOON'; top: -15px; right: -2px; font-size: 10px; padding: 1px 6px; }
.room-tab.on { color: var(--ink); background: linear-gradient(var(--gold-hi), var(--gold) 60%, var(--gold-lo)); border-color: #fff3c4; box-shadow: 0 3px 0 var(--gold-lip); }
.room-tab.locked { color: #4a566d; background: linear-gradient(#eef1f6, #cfd6e2); box-shadow: 0 3px 0 #8e9ab0; }
/* The Room 3 teaser tab looks selected while its teaser is showing (BH-3); otherwise it keeps the locked grey. */
.room-tab.soon.on { color: var(--ink); background: linear-gradient(var(--gold-hi), var(--gold) 60%, var(--gold-lo)); border-color: #fff3c4; box-shadow: 0 3px 0 var(--gold-lip); }
.room-tab .lock { width: 18px; height: 18px; flex: none; background: url(./ui/lock.svg) center / contain no-repeat; }
.room-tab .ico-star { width: 20px; height: 20px; animation: pulse 1.2s ease-in-out infinite; }
.room-tab:active { transform: translateY(2px); }
/* A tab that just unlocked glows and pulses for a few seconds (T26). */
.room-tab.glow { position: relative; overflow: visible; animation: tab-glow .9s ease-in-out infinite; border-color: #ffd76a;
  box-shadow: 0 0 0 3px rgba(255,201,74,.55), 0 0 16px 4px rgba(255,201,74,.7), 0 3px 0 rgba(13,95,92,.35); }
.room-tab.glow::after { content: 'NEW'; position: absolute; top: -9px; right: -4px; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 700;
  color: #fff; background: linear-gradient(var(--coral-hi), var(--coral)); border: 2px solid #fff; box-shadow: 0 2px 0 var(--coral-lip); letter-spacing: .5px; }
@keyframes tab-glow { 50% { transform: scale(1.06); box-shadow: 0 0 0 4px rgba(255,201,74,.6), 0 0 22px 6px rgba(255,201,74,.85), 0 3px 0 rgba(13,95,92,.35); } }
.room-wrap { flex: 1; min-height: 0; width: 100%; display: flex; justify-content: center; position: relative; }
/* Room finished (T20): a coral ribbon banner over the room and confetti falling through it. Taps pass through. */
.celebrate { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; transition: opacity .4s; }
.celebrate.out { opacity: 0; }
/* The banner is a ribbon like the win card's: a band with folded tails, near the top so the key art stays clear (T24). */
.celebrate .banner { position: absolute; z-index: 2; left: 50%; top: 4%; transform: translateX(-50%); white-space: nowrap;   /* above the confetti */
  animation: banner .5s cubic-bezier(.2,.9,.3,1.3) backwards; }
.celebrate .banner::before, .celebrate .banner::after { content: ''; position: absolute; top: 12px; width: 28px; height: 100%; background: var(--coral-lip);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); }
.celebrate .banner::before { left: -14px; }
.celebrate .banner::after { right: -14px; }
.celebrate .banner span { position: relative; z-index: 1; display: block; padding: 7px 26px; border-radius: 14px; border: 3px solid #ffe08a;
  background: linear-gradient(var(--coral-hi), var(--coral) 50%, var(--coral-lo));
  box-shadow: inset 0 3px 0 rgba(255,255,255,.4), 0 5px 0 var(--coral-lip), 0 10px 18px rgba(120,30,10,.3);
  color: #fff; font-size: 24px; font-weight: 700; -webkit-text-stroke: 5px var(--coral-lip); paint-order: stroke fill; }
.celebrate.big .banner span { background: linear-gradient(var(--coral-hi), var(--coral) 50%, var(--coral-lo)); font-size: 26px; }
@keyframes banner { 0% { transform: translateX(-50%) scale(0); opacity: 0; } 60% { transform: translateX(-50%) scale(1.1); opacity: 1; } }
.confetti { position: absolute; top: -14px; width: 9px; height: 13px; border-radius: 2px; box-shadow: 0 1px 0 rgba(0,0,0,.12);
  animation: confetti 1.6s ease-in both; }
.celebrate.big .confetti { animation-duration: 1.9s; }
@keyframes confetti { from { top: -14px; transform: translateX(0) rotate(0); } to { top: 105%; transform: translateX(var(--dx)) rotate(var(--spin)); opacity: .7; } }
.room { position: relative; height: 100%; max-width: 100%; aspect-ratio: 9 / 16; border-radius: 22px; overflow: hidden; background: #9c8878;
  border: 5px solid #ffd76a; box-shadow: inset 0 0 0 2px #b98320, 0 4px 0 #c08a1e, 0 12px 26px rgba(80,40,10,.3); }
.room-bg { position: absolute; inset: 0; }
.room-bg img, .room-bg svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.spot { position: absolute; }
.spot img, .spot svg { width: 100%; height: 100%; object-fit: contain; display: block; }
.spot.fixed img, .spot.fixed svg { filter: drop-shadow(0 4px 4px rgba(40,20,10,.3)); }
.spot.flat img, .spot.flat svg { filter: none; }   /* a floor patch lies in the floor: no shadow, or its edges read as a loose slab */
.spot.pending { background: radial-gradient(closest-side, rgba(255,240,170,.75), rgba(255,214,90,.35) 55%, transparent); animation: glow 1.8s ease-in-out infinite; }
@keyframes glow { 50% { opacity: .55; } }
.spot.appear { animation: appear .55s cubic-bezier(.2,.9,.3,1.5); }
@keyframes appear { from { transform: scale(.3); opacity: 0; filter: brightness(2); } }
.sparkle { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; pointer-events: none;
  background: radial-gradient(circle, #fff 0 18%, rgba(255,230,120,.9) 30%, transparent 62%);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%); animation: sparkle .9s ease-out forwards; }
.art-fx-sparkle .sparkle { background: url(./assets/fx-sparkle.webp) center / contain no-repeat; clip-path: none; }
@keyframes sparkle { 0% { transform: scale(0) rotate(0); opacity: 1; } 50% { transform: scale(1.5) rotate(60deg); } 100% { transform: scale(0) rotate(120deg) translateY(-24px); opacity: 0; } }
.cast { width: 100%; max-width: 480px; display: flex; align-items: center; gap: 12px; flex: none; min-height: 88px; }
/* The castle caption: no speaker, just a warm line about the player's castle, centered. */
.speech { flex: 1; align-self: center; text-align: center; padding: 9px 13px; font-size: 0.9375rem; line-height: 1.3; position: relative; border-radius: 18px; border-width: 2px; }
.speech.pop { animation: speech-pop .3s ease-out; }   /* a gentle pop: a 1.18 bump pushed the wide bubble past the screen edge (MARCUS-20) */
@keyframes speech-pop { 40% { transform: scale(1.03); } }
.tasks { list-style: none; margin: 0; padding: 0; width: 100%; max-width: 480px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; flex: none; }
/* Jobs are picture chips: the fixed item, its name, a price tag or a check. */
.task { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 3px 6px;
  border-radius: 14px; border: 2px solid #f5c95c; background: linear-gradient(#fffdf6, var(--cream) 50%, var(--cream-2));
  box-shadow: inset 0 2px 0 #fff, 0 3px 0 #d9a23a, 0 6px 12px rgba(110,60,20,.16); font-weight: 700; }
.task:active:not(:disabled) { transform: translateY(2px); }
.chip-pic { width: 100%; aspect-ratio: 1; display: block; }
.chip-pic img, .chip-pic svg { width: 100%; height: 100%; object-fit: contain; display: block; filter: grayscale(1) opacity(.55); }
.task.afford .chip-pic img, .task.afford .chip-pic svg { filter: grayscale(.35) drop-shadow(0 2px 2px rgba(40,20,10,.25)); }
.task.done .chip-pic img, .task.done .chip-pic svg { filter: drop-shadow(0 2px 2px rgba(40,20,10,.25)); }
.chip-name { font-size: 11.5px; line-height: 1.1; text-align: center; min-height: 2.2em; display: flex; align-items: center; }
.task .cost { position: absolute; top: -8px; right: -5px; display: flex; align-items: center; gap: 1px; padding: 1px 7px 1px 3px; border-radius: 999px;
  color: #fff; font-size: 14px; font-style: normal; background: linear-gradient(#c5ccd8, #9aa6ba); box-shadow: 0 2px 0 #6f7c93; text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.task .cost .ico-star { width: 16px; height: 16px; }
.task.afford { border-color: var(--coral); box-shadow: inset 0 2px 0 #fff, 0 3px 0 var(--coral-lip), 0 0 0 3px rgba(255,122,92,.25), 0 6px 12px rgba(110,60,20,.16); }
.task.afford .cost { background: linear-gradient(var(--coral-hi), var(--coral) 50%, var(--coral-lo)); box-shadow: 0 2px 0 var(--coral-lip); animation: pulse 1.2s ease-in-out infinite; }
.task.done { cursor: default; background: linear-gradient(#f2fbf7, #dff3ec); border-color: #9ed9c8; box-shadow: 0 2px 0 #8ccab8; color: #3f6b62; }
.task .done-mark { position: absolute; top: -8px; right: -5px; width: 24px; height: 24px; background: url(./ui/check.svg) center / contain no-repeat; }
/* The smallest phones (320 wide): a long job name like "Light the fireplace" must fit its chip (bug hunt BH-1). */
@media (max-width: 359px) { .tasks { gap: 4px; } .task { padding: 6px 1px; min-width: 0; } .chip-name { font-size: 10px; } }
.task { min-width: 0; }
/* The inner layer zooms; the frame stays put and clips it. */
.room-inner { position: absolute; inset: 0; }
.room-inner.zoom { animation: room-zoom 1.7s cubic-bezier(.3,.8,.3,1); }
@keyframes room-zoom { 0% { transform: scale(1); } 30%, 62% { transform: scale(1.55); } 100% { transform: scale(1); } }

/* ---------- PNG art, when delivered (orders CM-018 to CM-029) ---------- */
.art-panel .panel { border: 18px solid transparent; border-image: url(./assets/panel.webp) 80 fill / 18px; background: none; box-shadow: none;
  filter: drop-shadow(0 4px 6px rgba(90,45,10,.18)); }
.art-panel .hud-goals { padding: 10px 2px 0; }
.art-panel .pill { padding: 0 4px; border-width: 10px; border-image-width: 10px; }
.art-panel .speech { padding: 0 2px; }
.art-panel .art-panel .card { padding: 30px 6px 8px; border-width: 24px; border-image-width: 24px; }
.art-btn-coral .btn.primary, .art-btn-teal .btn.secondary { border: 0 solid transparent; border-width: 0 34px; background: none; box-shadow: none;
  border-image-slice: 0 80 fill; border-image-width: 0 34px; border-image-repeat: stretch; filter: drop-shadow(0 6px 8px rgba(80,30,10,.25)); }
.art-btn-coral .btn.primary { border-image-source: url(./assets/btn-coral.webp); }
.art-btn-teal .btn.secondary { border-image-source: url(./assets/btn-teal.webp); }
.art-btn-coral .btn.primary::before, .art-btn-teal .btn.secondary::before { display: none; }
.art-btn-coral .btn.big, .art-btn-teal .btn.big { min-width: 0; padding: 0 6px; min-height: 64px; }
.art-btn-coral .btn.small, .art-btn-teal .btn.small { min-height: 46px; border-width: 0 22px; border-image-width: 0 22px; padding: 0 8px; }
.art-btn-coral .btn:not(.big):not(.small), .art-btn-teal .btn:not(.big):not(.small) { min-height: 54px; padding: 0 18px; }
.art-moves-badge .moves-badge { background: url(./assets/moves-badge.webp) center / contain no-repeat; border: 0; box-shadow: none; border-radius: 0; }
.art-bg-map #map { background: url(./assets/bg-map.webp) center / cover no-repeat; }
.art-bg-map .deco { display: none; }
.art-bg-title .scene { background: url(./assets/bg-title.webp) center / cover no-repeat; filter: none; inset: 0; }
.art-bg-title .scene::after { display: none; }
.art-bg-board #play, .art-bg-board #castle { background: url(./assets/bg-board.webp) center / cover no-repeat; }
.art-win-ribbon .ribbon:not(.lose) { background: url(./assets/win-ribbon.webp) center / contain no-repeat; border: 0; box-shadow: none; height: 96px; top: -48px; }
.art-win-ribbon .ribbon:not(.lose)::before, .art-win-ribbon .ribbon:not(.lose)::after { display: none; }
/* Art audit (orders CM-039 to CM-043): each switches on when its PNG arrives. */
.art-reward-star .ico-star { background-image: url(./assets/reward-star.webp); }
.art-lose-ribbon .ribbon.lose { background: url(./assets/lose-ribbon.webp) center / contain no-repeat; border: 0; box-shadow: none; height: 96px; top: -48px; }
.art-lose-ribbon .ribbon.lose::before, .art-lose-ribbon .ribbon.lose::after { display: none; }
.art-finale-crown #card-star.finale .ico-star.big { background-image: url(./assets/finale-crown.webp); width: 112px; height: 112px; }
.lvl .marker { position: absolute; top: 50%; width: 48px; height: 48px; margin-top: -30px; pointer-events: none; animation: node-bob 1.3s ease-in-out infinite; }
.lvl .marker.side-r { left: calc(100% + 6px); }
.lvl .marker.side-l { right: calc(100% + 6px); }
.art-level-node .lvl, .art-level-node .lvl.next { background: url(./assets/level-node.webp) center / contain no-repeat; box-shadow: none; }
.art-level-node .lvl::before { display: none; }
.art-level-node .lvl.won { filter: hue-rotate(25deg) saturate(1.2) brightness(1.08); }
.art-level-node .lvl.locked { filter: grayscale(1) brightness(1.1); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; }
  .confetti { display: none; }
  .celebrate .banner { transform: translateX(-50%); } }

/* Title: Play is the primary action, so it's the widest button (MARCUS-14). Placed last so it wins over the
   art-button rules that zero min-width. */
.title-buttons .btn.big { min-width: min(260px, 72vw); }
.title-buttons .btn.secondary { min-width: min(200px, 56vw); }

/* ---------- sound switch (title corner, map bar, under the board) ---------- */
.sound-btn { width: 44px; height: 44px; }   /* 44 pt: best-practice tap target */
.ico-sound { display: block; width: 22px; height: 22px; margin: auto; background: url(./ui/sound-on.svg) center / contain no-repeat; }
.sound-btn[aria-pressed="false"] .ico-sound { background-image: url(./ui/sound-off.svg); }
.sound-btn.corner { position: absolute; z-index: 3; right: 14px; top: calc(env(safe-area-inset-top) + 12px); }
.sound-btn.corner.low { top: auto; bottom: calc(env(safe-area-inset-bottom) + 12px); left: 14px; right: auto; }
.bar-end { display: flex; align-items: center; gap: 8px; }

/* Sentences in the body face (brand kit: Fredoka for display, Outfit for body). */
.speech, .coach, #card-text, .room-tab span small { font-family: var(--body); font-weight: 600; }

/* ---------- turn the phone upright (short landscape screens) ---------- */
#rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  #rotate { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center;
    background: linear-gradient(#fff1e0, #ffd2b8); color: var(--ink); font-size: 22px; font-weight: 700; padding: 20px; }
  #rotate i { width: 54px; height: 86px; border: 6px solid var(--teal); border-radius: 12px; background: #fff; animation: tilt 1.8s ease-in-out infinite; }
}
@keyframes tilt { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0); } }

/* ---------- age label and About (Best Practices ruling 2; How to play) ---------- */
/* Pinch zoom is allowed again (the zoom lock is gone); double-tap zoom stays off so fast taps never zoom. */
html { touch-action: manipulation; }
.title-buttons .age { margin: -4px 0 0; font: 600 0.8125rem var(--body); color: #fff; text-shadow: 0 1px 3px rgba(60,20,10,.6); letter-spacing: .3px; }
.about-btn { position: absolute; z-index: 3; left: 14px; top: calc(env(safe-area-inset-top) + 12px); }
.ico-about { display: block; font: 700 22px/38px var(--font); font-style: normal; color: var(--ink-teal); }
.card .about { text-align: left; font-size: 0.9375rem; }
.card .about b { color: var(--ink); }
.card-alt-hidden #card-alt { display: none; }

/* ---------- Today's Daily, "Up next", toast ---------- */
.title-row { display: flex; gap: 10px; justify-content: center; }
.title-row .btn.secondary { min-width: 0; flex: 1; max-width: 170px; padding-left: 10px; padding-right: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
#btn-daily small { display: block; font: 600 0.6875rem var(--body); opacity: .92; margin-top: 2px; }
#btn-daily.done small::before { content: "¹3  "; }
.card-next { margin: 10px 0 2px; text-align: center; }
.card-next .next-goal { margin: 0; font: 700 1rem var(--font); color: var(--teal-lo); }
.card-next .next-game { display: inline-block; margin-top: 6px; padding: 8px 4px; font: 600 0.8125rem var(--body); color: #8a6a55; text-decoration: underline; text-underline-offset: 3px; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translateX(-50%); padding: 10px 18px; border-radius: 999px;
  background: rgba(40,25,15,.88); color: #fff; font: 600 0.9375rem var(--body); animation: fade .2s; pointer-events: none; }

/* The title row fits two buttons side by side down to 320 wide: slimmer art caps, a little smaller type. */
.title-buttons { width: 100%; }
.title-row { width: 100%; max-width: 360px; gap: 8px; }
.title-row .btn.secondary { flex: 1 1 0; min-width: 0; max-width: none; font-size: 17px; border-width: 0 18px; border-image-width: 0 18px; padding: 6px 2px; min-height: 52px; }
@media (max-width: 359px) { .title-row .btn.secondary { font-size: 15px; } #btn-daily small { font-size: 0.625rem; } }

/* ---------- the job builds while you play (signature twist) ---------- */
.job { flex: none; width: min(calc(100% - 24px), 420px); margin: 6px auto 0; display: flex; align-items: center; gap: 10px;
  padding: 4px 14px 4px 4px; border-radius: 16px; border: 2px solid #f5c95c; background: linear-gradient(#fffdf6, var(--cream) 55%, var(--cream-2));
  box-shadow: inset 0 2px 0 #fff, 0 3px 0 #d9a23a, 0 6px 12px rgba(110,60,20,.16); }
.job-pic { position: relative; flex: none; width: clamp(52px, 11vh, 104px); aspect-ratio: 1; }
.job-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.job-base { filter: grayscale(1) brightness(1.15) opacity(.38); }
/* The repaired piece fills in from the bottom as goal tiles land. */
.job-fill { clip-path: inset(calc((1 - var(--f, 0)) * 100%) 0 0 0); transition: clip-path .45s ease-out; filter: drop-shadow(0 2px 3px rgba(60,30,10,.25)); }
.job-text { flex: 1; min-width: 0; }
.job-text small { display: block; font: 600 0.6875rem var(--body); color: #8a6a55; letter-spacing: .2px; }
.job-text b { display: block; font: 700 1rem/1.15 var(--font); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-bar { display: block; height: 7px; margin-top: 5px; border-radius: 4px; background: #efdcc0; overflow: hidden; }
.job-bar i { display: block; height: 100%; width: calc(var(--f, 0) * 100%); border-radius: 4px; background: linear-gradient(var(--gold-hi), var(--gold) 60%, var(--gold-lo)); transition: width .45s ease-out; }
.job.bump .job-pic { animation: bump .3s cubic-bezier(.2,.9,.3,1.4); }
.job.done { border-color: var(--gold); box-shadow: inset 0 2px 0 #fff, 0 3px 0 var(--gold-lip), 0 0 0 4px rgba(255,201,74,.45), 0 0 22px 6px rgba(255,201,74,.55); }
.job.done .job-pic { animation: job-settle .7s cubic-bezier(.2,.9,.3,1.5); }
.job.done .job-text small { color: var(--teal-lo); font-weight: 700; }
@keyframes job-settle { 0% { transform: scale(1); filter: brightness(1); } 40% { transform: scale(1.25); filter: brightness(1.6); } 100% { transform: scale(1); filter: brightness(1); } }
/* Short phones: a compact strip, so the board keeps 44 pt tiles and the level 1 line still fits under it. */
@media (max-height: 740px) { .job { margin-top: 4px; padding: 2px 12px 2px 2px; border-radius: 14px; } .job-pic { width: 46px; } .job-text b { font-size: 0.9375rem; } .job-bar { margin-top: 3px; height: 6px; } }

/* ---------- settings button (live-ops kit sheet: Music, Sound effects, Vibration, Reduced motion) ---------- */
.ico-gear { display: block; width: 24px; height: 24px; margin: auto; background: url(./ui/gear.svg) center / contain no-repeat; }
/* The in-game Reduced motion switch does what the system setting does. */
[data-hula-reduced-motion] *, [data-hula-reduced-motion] *::before, [data-hula-reduced-motion] *::after { animation: none !important; }
