@font-face{font-family:"Barlow Condensed";font-weight:700;font-display:swap;src:url("../fonts/barlow-condensed-latin-700-normal.woff2") format("woff2")}
@font-face{font-family:"Barlow Condensed";font-weight:800;font-display:swap;src:url("../fonts/barlow-condensed-latin-800-normal.woff2") format("woff2")}
@font-face{font-family:"Barlow Condensed";font-weight:900;font-display:swap;src:url("../fonts/barlow-condensed-latin-900-normal.woff2") format("woff2")}
@font-face{font-family:"Barlow Condensed";font-weight:900;font-style:italic;font-display:swap;src:url("../fonts/barlow-condensed-latin-900-italic.woff2") format("woff2")}
@font-face{font-family:"DM Sans";font-weight:100 1000;font-display:swap;src:url("../fonts/dm-sans-latin-wght-normal.woff2") format("woff2")}
@font-face{font-family:"Nunito";font-weight:200 1000;font-display:swap;src:url("assets/fonts/nunito-latin.woff2") format("woff2")}
:root {
  color-scheme: dark;
  --bg: #140c28;
  --surface: #2a1458;
  --line: #ffffff18;
  --ink: #fcf6ff;
  --muted: #b9adca;
  --gold: #ffd456;
  --chocolate: #4a2812;
  --candy-pink: #ff6dad;
  --candy-orange: #ff8a3a;
  --panel: #2a1458;
  --panel-deep: #1a0a3c;
  --heading: "Barlow Condensed", Impact, sans-serif;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { overflow: hidden; overscroll-behavior: none; }
body { margin: 0; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; background: radial-gradient(ellipse at 50% 0%, #261838 0%, #141023 67%); }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, canvas:focus-visible { outline: 3px solid #fff5ba; outline-offset: 4px; }
button:disabled { cursor: default; }
.icon { display: inline-block; flex: none; width: 1em; height: 1em; background-color: currentColor; mask: var(--icon) center/contain no-repeat; vertical-align: -.1em; }
.local-game .icon { background: var(--icon) center/contain no-repeat; mask: none; }
.local-game :is(.primary, .brand-icon, .result-icon, .selected-mark) .icon { filter: brightness(.19); }
.local-game .hearts .spent { opacity: .4; }
[data-icon="note"] { --icon: url("assets/ui-note.png"); }
[data-icon="play"] { --icon: url("assets/ui-play.png"); }
[data-icon="pad"] { --icon: url("assets/ui-pad.png"); }
[data-icon="volume"] { --icon: url("assets/ui-volume.png"); }
[data-icon="muted"] { --icon: url("assets/ui-muted.png"); }
[data-icon="check"] { --icon: url("assets/ui-check.png"); }
[data-icon="left"] { --icon: url("assets/ui-left.png"); }
[data-icon="right"] { --icon: url("assets/ui-right.png"); }
[data-icon="up"] { --icon: url("assets/ui-up.png"); }
[data-icon="burst"] { --icon: url("assets/ui-burst.png"); }
[data-icon="water"] { --icon: url("assets/water-balloon.webp"); }
[data-icon="close"] { --icon: url("assets/ui-close.png"); }
[data-icon="pause"] { --icon: url("assets/ui-pause.png"); }
[data-icon="lock"] { --icon: url("assets/ui-lock.png"); }
[data-icon="heart"] { --icon: url("assets/ui-heart.png"); }
[data-icon="music-off"] { --icon: url("assets/ui-music-off.png"); }
.topbar { background: linear-gradient(#3a1d72f2, #1a0a3cf2); border-bottom: 3px solid var(--chocolate); box-shadow: 0 6px 16px #0006; }
.topbar-inner, .shell { width: min(1240px, calc(100% - 64px)); margin: auto; }
.topbar-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wordmark, .top-actions { display: flex; align-items: center; gap: 10px; }
.wordmark { border: 0; background: none; padding: 0; font: 900 30px/.9 var(--heading); font-style: italic; letter-spacing: .025em; white-space: nowrap; }
.wordmark-accent { color: var(--gold); }
.brand-icon { display: grid; place-items: center; width: 32px; height: 32px; transform: rotate(-7deg); background: radial-gradient(circle at 30% 25%, #fff3a8, #ffd456 55%, #f0a020); color: #3a1408; border-radius: 10px; font-size: 19px; border: 2px solid var(--chocolate); box-shadow: inset 0 2px 0 #fff8, 0 2px 0 #2a1408; }
.utility { min-height: 40px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 0 13px; border: 3px solid var(--chocolate); background: linear-gradient(#8a5bff, #4a1fa8); color: #fff8ef; border-radius: 999px; font-size: 13px; font-weight: 800; box-shadow: inset 0 2px 0 #ffffff66, 0 3px 0 #2a1048; }
.utility .icon { font-size: 17px; }
.utility:hover { background: linear-gradient(#9b70ff, #5a2cc0); transform: translateY(-1px); }
.utility:active { transform: translateY(2px); box-shadow: inset 0 2px 0 #ffffff44, 0 1px 0 #2a1048; }
.utility-square { width: 40px; padding: 0; border-radius: 14px; }
.shell { flex: 1; min-height: 0; padding: 26px 0 38px; overflow: auto; overscroll-behavior: contain; }
.hero { isolation: isolate; position: relative; display: grid; align-items: center; min-height: clamp(390px, 38vw, 488px); border: 1px solid #896e9e62; overflow: hidden; border-radius: 24px; box-shadow: 0 17px 50px #0c071b75; background: #241a42; }
.hero-visual { position: absolute; z-index: -2; inset: 0; background: url("assets/rescue-key-art.webp") center center/cover no-repeat; }
.hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, #160f30bb 0%, #160f3042 34%, transparent 61%), linear-gradient(0deg, #1b102754, transparent 32%); }
.hero-content { padding: 32px 0 35px clamp(30px, 5.4vw, 76px); }
.hero-kicker { display: flex; gap: 8px; align-items: center; font-size: 11px; font-weight: 800; color: #ffe186; letter-spacing: .20em; margin: 0 0 12px; }
.hero-kicker .icon { font-size: 16px; }
h1 { width: fit-content; margin: 0 0 18px; font: italic 900 clamp(84px, 9.1vw, 136px)/.82 var(--heading); letter-spacing: -.035em; transform: translateX(-.032em); filter: drop-shadow(0 .05em 0 #7e3b40) drop-shadow(0 .035em .075em #120b29b0); }
h1 > span { display: block; }
h1 > span:first-child { padding-inline-end: .15em; color: #ffe58b; background: linear-gradient(#fff2b5 10%, #ffd052 86%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
h1 > span:last-child { position: relative; width: max-content; color: #ffc344; }
.title-spark { position: absolute; left: calc(100% + .28em); top: 14%; transform: rotate(12deg); color: #fff1a3; font-size: .25em; }
.hero p { max-width: 305px; margin: 23px 0 22px; color: #f5eaf9; font-size: 15px; line-height: 1.5; text-shadow: 0 2px 12px #170f2f; }
.primary { position: relative; isolation: isolate; display: inline-flex; justify-content: center; align-items: center; min-height: 51px; gap: 8px; padding: 0 22px; border: 3px solid var(--chocolate); border-radius: 999px; background:
    radial-gradient(circle at 22% 22%, #ffffffaa 0 16%, transparent 42%),
    linear-gradient(#ffb3d6 0%, #ff6dad 42%, #ff8a3a 100%);
  color: #3a1408; box-shadow: inset 0 3px 0 #ffffff88, inset 0 -4px 0 #c33a2a55, 0 4px 0 var(--chocolate), 0 8px 18px #0f092458; font-size: 14px; font-weight: 900; }
.primary .icon { font-size: 19px; }
.primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.primary:active { transform: translateY(2px); box-shadow: inset 0 3px 0 #ffffff66, 0 2px 0 var(--chocolate); }
.load-error { color: #ffcfde; margin-top: 10px; font-size: 12px; font-weight: 800; }
.roster { margin-top: 23px; }
.world-map { margin-top: 23px; }
.section-heading { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.section-heading h2 { margin: 0; color: #fff5fb; font: 800 27px/.95 var(--heading); letter-spacing: .05em; }
.selection-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.roster-grid, .stage-grid { display: grid; gap: 11px; }
.roster-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.character { isolation: isolate; position: relative; height: 104px; overflow: hidden; display: flex; align-items: flex-end; padding: 13px; text-align: left; background: radial-gradient(ellipse at 80% 22%, var(--glow) 0%, transparent 67%), var(--card); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 14px; transition: transform .16s ease, border .16s ease; }
.character::before { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(85deg, color-mix(in srgb, var(--card) 80%, transparent), transparent 73%); pointer-events: none; }
.character:hover { transform: translateY(-3px); border-color: var(--accent); }
.character[aria-pressed="true"] { border: 2px solid var(--accent); padding: 12px; box-shadow: 0 0 15px color-mix(in srgb, var(--accent) 23%, transparent); }
.doo { --accent: #ffdf73; --glow: #966b2d; --card: #463022; }
.moo { --accent: #ff995a; --glow: #a64c36; --card: #492733; }
.lou { --accent: #6de9db; --glow: #258b88; --card: #183e50; }
.pee { --accent: #d9a2ff; --glow: #7747a0; --card: #362050; }
.character-copy { z-index: 2; display: grid; gap: 4px; }
.character-copy strong { font: 900 clamp(21px, 2.45vw, 33px)/.9 var(--heading); color: #fff8fc; letter-spacing: .025em; text-shadow: 0 2px 7px var(--card); white-space: nowrap; }
.character-copy > span { color: var(--accent); font-size: 11px; font-weight: 750; }
.character img { position: absolute; width: clamp(85px, 9vw, 106px); height: auto; right: 14px; top: 1px; filter: drop-shadow(0 7px 13px #1b0c2ba0); pointer-events: none; }
.selected-mark { display: none; position: absolute; top: 8px; right: 8px; z-index: 3; width: 21px; height: 21px; place-items: center; border-radius: 50%; background: var(--accent); color: #221432; font-size: 14px; }
.character[aria-pressed="true"] .selected-mark { display: grid; }
.stage-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stage { display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px 12px; min-height: 55px; border: 1px solid var(--line); border-radius: 12px; background: #251c36; }
.stage:not(:disabled):hover { border-color: var(--stage-accent); }
.stage:disabled { opacity: .65; }
.grove { --stage-accent: #e7dc71; --stage-bg: #3e3b31; }
.caverns { --stage-accent: #b5a4fa; --stage-bg: #3f3456; }
.summit { --stage-accent: #ffa1b6; --stage-bg: #553346; }
.stage-icon { flex: none; display: grid; place-items: center; width: 33px; height: 33px; border-radius: 8px; background: var(--stage-bg); color: var(--stage-accent); font: 800 14px/1 var(--heading); }
.stage-icon img { width: 23px; height: 23px; object-fit: contain; }
.stage-copy { display: grid; gap: 1px; }
.stage-copy strong { font-size: 13px; }
.stage-copy small { color: var(--muted); font-size: 11px; }
.stage-status { margin-left: auto; color: var(--stage-accent); font-size: 15px; }
.stage:disabled .stage-status { color: var(--muted); }

.game-top { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.game-top > :first-child { justify-self: start; }
.game-top > :last-child { justify-self: end; }
.game-top-actions { display: flex; align-items: center; gap: 8px; }
.level-name { justify-self: center; padding: 5px 16px 7px; border-radius: 18px; background: linear-gradient(#3b1d72f0, #1a0a3cf0); border: 3px solid var(--chocolate); box-shadow: inset 0 2px 0 #ffffff44, 0 3px 0 #12061f; text-align: center; }
.level-name small { color: var(--gold); font-size: 10px; letter-spacing: .18em; font-weight: 800; }
.level-name h2 { margin: 1px 0 0; font: 900 25px/.9 var(--heading); }
.game-screen[data-flooding] .level-name small { color: #ffb4a8; }
.game-screen[data-area="underwater"] .level-name small { color: #9ff6f0; }
.game-frame { position: relative; background: #25193a url("assets/rescue-key-art.webp") center/cover; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
canvas:focus-visible { outline-offset: -4px; }
.game-hud { position: absolute; inset: 12px 12px auto; display: flex; gap: 7px; pointer-events: none; z-index: 4; }
.stat { display: flex; align-items: center; gap: 5px; padding: 5px 10px; border: 3px solid var(--chocolate); border-radius: 999px; background: linear-gradient(#3b1d72ee, #1a0a3cee); color: #fff8ef; font-size: 13px; font-weight: 800; white-space: nowrap; box-shadow: inset 0 2px 0 #ffffff55, 0 3px 0 #12061f; }
.stat .icon { font-size: 17px; }
.hearts { border-color: #7a2038; background: linear-gradient(#5a1a48ee, #2a0a28ee); }
.hearts .icon { color: #ff6dad; filter: drop-shadow(0 1px 0 #3a1020); }
.hearts .spent { color: #6a4a68; filter: grayscale(.4); }
.notes { border-color: #c9a227; background: linear-gradient(#5a3a10ee, #2a1808ee); }
.notes .icon { color: #ffd456; }
.blocks { border-color: #7a4dff; }
.blocks #rescue-type { color: #ffd456; font-weight: 900; }
.stage-progress { position: absolute; bottom: 0; left: 0; right: 0; height: 8px; background: #17102b90; pointer-events: none; border-top: 2px solid var(--chocolate); }
.stage-progress > span { display: block; width: 0%; height: 100%; background: linear-gradient(90deg, #ff6dad, #ff8a3a, #ffe786); box-shadow: 0 0 8px #ffd45688; }
.announcement { position: absolute; top: 16px; right: 14px; max-width: min(42vw, 340px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 3px solid #c9a227; border-radius: 999px; padding: 5px 12px; background: linear-gradient(#3b1d72ee, #1a0a3cee); color: #ffe68d; font-size: 12px; font-weight: 800; pointer-events: none; z-index: 4; box-shadow: inset 0 2px 0 #ffffff44, 0 3px 0 #12061f; }
.note-cheer {
  position: absolute;
  left: 50%;
  top: calc(var(--top-edge, 10px) + 44px);
  transform: translateX(-50%);
  z-index: 5;
  pointer-events: none;
  display: grid;
  place-items: center;
  width: min(70vw, 520px);
  margin: 0;
}
.note-cheer[hidden] { display: none; }
.note-cheer-canvas {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 10px 14px #0007);
  transform-origin: 50% 60%;
}
.note-cheer.is-in .note-cheer-canvas {
  animation: note-cheer-pop 1.75s cubic-bezier(0.2, 1.4, 0.35, 1) both;
}
.note-cheer-sparks {
  position: absolute;
  inset: -12% -6%;
  pointer-events: none;
}
.note-cheer-sparks span {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px;
  background: radial-gradient(circle at 35% 30%, #fff, #ffe56a 45%, #ff8a3a 70%, transparent 75%);
  border-radius: 50%;
  animation: note-cheer-spark 0.7s ease-out both;
  animation-delay: var(--d, 0s);
}
@keyframes note-cheer-pop {
  0% { transform: scale(0.38) rotate(-10deg) translateY(-8px); opacity: 0; }
  14% { transform: scale(1.16) rotate(4deg) translateY(0); opacity: 1; }
  22% { transform: scale(0.94) rotate(-2deg); opacity: 1; }
  30% { transform: scale(1.04) rotate(1deg); opacity: 1; }
  38% { transform: scale(1) rotate(0deg); opacity: 1; }
  68% { transform: scale(1) rotate(0deg); opacity: 1; }
  100% { transform: scale(0.86) translateY(-6px); opacity: 0; }
}
@keyframes note-cheer-spark {
  0% { transform: scale(0.2); opacity: 0; }
  25% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.2) translate(var(--tx, 0), var(--ty, -16px)); opacity: 0; }
}
@media (max-height: 400px) {
  .note-cheer { top: calc(var(--top-edge, 8px) + 40px); width: min(68vw, 460px); }
}

.result { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; background: #130e2bc7; padding: 7px; overflow: auto; }
.result[data-state="ready"] { background: #130e2b42; }
.result-card { display: grid; gap: 12px; justify-items: center; width: min(100%, 355px); border: 3px solid var(--chocolate); background: linear-gradient(#3b1d72, #1a0a3c); border-radius: 24px; text-align: center; padding: 19px 18px 13px; box-shadow: inset 0 3px 0 #ffffff33, 0 8px 0 #2a1408, 0 16px 28px #110a24ad; }
.result-icon { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 11px; background: var(--gold); color: #271739; font-size: 26px; transform: rotate(-7deg); }
.result-card h2 { margin: 0; font: 900 48px/.85 var(--heading); color: #ffe592; }
.result-card p { margin: 0; color: var(--muted); font-size: 13px; }
.text-button { min-height: 30px; padding: 0 8px; border: none; background: transparent; color: #e8d8fa; font-weight: 750; font-size: 13px; }
.text-button:hover { color: var(--gold); }
.touch-controls { display: none; touch-action: none; justify-content: space-between; gap: 8px; margin: 10px 0 0; }
.touch-controls > div { display: flex; gap: 7px; }

/* iOS long-press on the game or touch buttons was selecting HUD text
   and showing the Copy / Look Up / Translate callout mid-play. */
#game-screen,
#game-screen *,
.game-frame,
#game,
.game-hud,
.touch-controls,
.touch-controls * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
#game-screen, .game-frame, #game, .touch-controls {
  touch-action: none;
}
#game-screen .game-top,
#game-screen .game-top button,
#game-screen .celebrate-panel,
#game-screen #celebrate-continue,
#game-screen .result-card button {
  touch-action: manipulation;
  pointer-events: auto;
}

.touch-controls button { touch-action: none; user-select: none; -webkit-user-select: none; border: 3px solid var(--chocolate); border-radius: 16px; min-width: 54px; height: 51px; padding: 0 8px; background: linear-gradient(#8a5bff, #4a1fa8); color: #fff8ef; display: grid; gap: 2px; justify-items: center; align-content: center; font-size: 10px; font-weight: 800; box-shadow: inset 0 2px 0 #ffffff66, 0 3px 0 #2a1048; }
.touch-controls button .icon { font-size: 20px; }
.touch-controls button[data-input="jump"] { background: linear-gradient(#ffe08a, #ff8a3a); color: #3a1408; box-shadow: inset 0 2px 0 #ffffff88, 0 3px 0 var(--chocolate); }
.touch-controls button:active { filter: brightness(1.08); }
.rescue-list { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 8px; padding: 0; color: #fff7ee; text-shadow: 0 1px 3px #160e28, 0 0 6px #11081ccc; background: none; border: 0; border-radius: 0; box-shadow: none; }
.rescue-list h3 { margin: 0; display: block; width: 100%; text-align: center; font: 800 8px/1 var(--heading); letter-spacing: .16em; color: #ffe584; text-shadow: 0 1px 2px #160e28, 0 0 5px #160e28cc; }
.rescue-list ul { display: flex; flex-wrap: nowrap; gap: 0 3px; align-items: flex-end; justify-content: center; padding: 0; margin: 0; list-style: none; width: max-content; max-width: 100%; }
.rescue-list li { flex: none; min-width: auto; min-height: 0; display: grid; place-items: center; padding: 0 1px; font: 800 13px/1 var(--heading); color: #efe6d6; text-shadow: 0 1px 2px #000c, 0 0 4px #0009; background: none; border: 0; box-shadow: none; }
.rescue-list li.rescued { color: #ffe584; text-shadow: 0 0 8px #ffe584dd, 0 1px 2px #160e28; box-shadow: none; }
.rescue-list li img { width: 16px; height: 18px; flex-shrink: 0; object-fit: contain; filter: drop-shadow(0 1px 2px #000c) drop-shadow(0 0 3px #0008) grayscale(.6) opacity(.78); transition: filter .25s ease, transform .25s ease; }
.rescue-list li.rescued img { filter: drop-shadow(0 0 4px #ffe584cc) drop-shadow(0 1px 2px #160e28) grayscale(0) opacity(1) brightness(1.06); }
.rescue-list li.is-pop img { animation: rescue-pop .42s ease-out; }
@keyframes rescue-pop { 0% { transform: scale(.7); } 55% { transform: scale(1.38); } 100% { transform: scale(1); } }
.key-guide { position: absolute; inset: auto 12px var(--bottom-edge); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; color: #fff6ee; font-size: 12px; text-shadow: 0 1px 4px #160e28; pointer-events: none; }
kbd { display: inline-grid; place-items: center; min-width: 22px; padding: 2px 5px; border: 1px solid #ffffff2b; border-radius: 5px; background: #322547; color: #f7ecff; font: 750 11px/1.25 "DM Sans", system-ui, sans-serif; }
.help-dialog { width: min(440px, calc(100% - 28px)); padding: 22px; border: 3px solid var(--chocolate); border-radius: 24px; color: var(--ink); background: linear-gradient(#3b1d72, #1a0a3c); box-shadow: inset 0 3px 0 #ffffff33, 0 8px 0 #2a1408, 0 16px 40px #0f091cd6; }
.help-dialog::backdrop { background: #100b21b8; }
.help-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.help-head h2 { margin: 0; color: #ffe38a; font: 900 34px/.9 var(--heading); letter-spacing: .03em; }
.help-dialog p { font-size: 14px; color: #e9def2; line-height: 1.5; }
.help-keys { margin: 16px 0; }
.help-keys > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 37px; border-bottom: 1px solid var(--line); font-size: 13px; }
.help-keys dt { font-weight: 800; }
.help-keys dd { margin: 0; color: var(--muted); }
.help-dialog .help-tip { margin-bottom: 0; }

@media (max-width: 950px) {
  .topbar-inner, .shell { width: calc(100% - 40px); }
  .hero { min-height: 390px; }
  .character img { right: 0; }
}
@media (max-width: 680px) {
  .topbar-inner, .shell { width: calc(100% - 24px); }
  .topbar-inner { min-height: 57px; }
  .shell { padding-top: 13px; }
  .wordmark { font-size: 26px; }
  .hero { min-height: 458px; align-items: end; border-radius: 18px; }
  .hero-visual { background-size: auto 63%; background-position: 80% top; }
  .hero::after { background: linear-gradient(0deg, #211538 0%, #211538 32%, #21153810 62%, transparent 83%); }
  .hero-content { padding: 175px 20px 21px; }
  .hero-kicker { margin-bottom: 9px; font-size: 10px; }
  h1 { font-size: clamp(68px, 16vw, 96px); margin-bottom: 0; }
  .hero p { margin: 13px 0; max-width: 285px; font-size: 13px; }
  .primary { min-height: 44px; }
  .roster, .world-map { margin-top: 19px; }
  .section-heading h2 { font-size: 23px; }
  .roster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .character { height: 83px; padding: 10px; }
  .character[aria-pressed="true"] { padding: 9px; }
  .character img { width: 82px; top: 1px; }
  .stage-grid { grid-template-columns: 1fr; gap: 6px; }
  .game-hud { inset: 6px 6px auto; gap: 4px; }
  .stat { padding: 3px 5px; gap: 3px; font-size: 10px; }
  .stat .icon { font-size: 12px; }
  .announcement { top: 6px; right: 6px; padding: 3px 5px; font-size: 9px; }
  .result-card { gap: 7px; padding: 8px; }
  .result-icon { width: 26px; height: 26px; font-size: 17px; border-radius: 6px; }
  .result-card h2 { font-size: 31px; }
  .result-card p { font-size: 11px; }
  .result-card .primary { min-height: 33px; font-size: 12px; }
  .result-card .text-button { min-height: 22px; font-size: 11px; }
  .rescue-list { gap: 1px; padding: 0; }
  .rescue-list h3 { font-size: 7px; }
  .rescue-list li { font-size: 10px; }
  .rescue-list li img { width: 14px; height: 16px; }
}
@media (pointer: coarse) {
  .touch-controls { display: flex; }
  .key-guide { display: none; }
}

@media (pointer: coarse) and (max-height: 540px) and (orientation: landscape) {
  body { --menu-inset: max(12px, env(safe-area-inset-left), env(safe-area-inset-right)); }
  .topbar-inner, .shell { width: calc(100% - 2 * var(--menu-inset)); }
  .topbar-inner { min-height: 48px; }
  .shell { padding: 8px 0 max(10px, env(safe-area-inset-bottom)); }
  .hero { min-height: 0; align-items: center; border-radius: 14px; }
  .hero-content { padding: 12px 0 14px 22px; }
  .hero-visual { background-size: cover; background-position: center; }
  .hero::after { background: linear-gradient(90deg, #160f30dc, #160f3042 45%, transparent 66%); }
  .hero-kicker { margin-bottom: 6px; }
  #title { margin: 0; font-size: clamp(44px, 15dvh, 76px); }
  .hero p { max-width: 245px; margin: 8px 0; font-size: 12px; line-height: 1.32; }
  .primary { min-height: 42px; }
  .roster, .world-map { margin-top: 10px; }
  .section-heading { margin-bottom: 6px; }
  .section-heading h2 { font-size: 20px; }
  .roster-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .character { height: 62px; border-radius: 9px; }
  .character-copy strong { font-size: clamp(16px, 3vw, 25px); }
  .character img { width: 65px; right: 0; }
  .stage-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .stage { min-height: 43px; padding: 5px 7px; gap: 6px; }
}

  body:has(.game-screen:not([hidden])) { background: #0c0a12; }
  body:has(.game-screen:not([hidden])) .topbar { display: none; }
  body:has(.game-screen:not([hidden])) .shell { padding: 0; overflow: hidden; }
  .game-screen {
    --left-edge: max(20px, calc(env(safe-area-inset-left, 0px) + 12px));
    --right-edge: max(20px, calc(env(safe-area-inset-right, 0px) + 12px));
    --top-edge: max(10px, env(safe-area-inset-top, 0px));
    --bottom-edge: max(14px, calc(env(safe-area-inset-bottom, 0px) + 6px));
    --touch-size: clamp(60px, 18dvh, 84px);
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    isolation: isolate;
  }
  .game-frame { width: 100%; height: 100%; }
  .game-top {
    position: absolute;
    inset: var(--top-edge) var(--right-edge) auto var(--left-edge);
    margin: 0;
    z-index: 6;
    pointer-events: none;
    grid-template-columns: 1fr 1fr;
  }
  .game-top button {
    width: 48px;
    min-width: 48px;
    min-height: 48px;
    height: 48px;
    padding: 0;
    touch-action: manipulation;
    pointer-events: auto;
    position: relative;
    z-index: 7;
  }
  .game-top .level-name {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: min(72vw, 420px);
    height: auto;
    padding: 3px 12px 4px;
    overflow: visible;
    clip-path: none;
    z-index: 2;
    pointer-events: none;
    transition: opacity .55s ease;
  }
  .game-top .level-name h2 { font-size: clamp(15px, 2.3vw, 20px); }
  .game-top .level-name small { font-size: 9px; letter-spacing: .16em; }
  .game-top .level-name.is-settled { opacity: 0; }
  .game-back > span:not(.icon) { display: none; }
  .game-hud { inset: calc(var(--top-edge) + 8px) auto auto calc(var(--left-edge) + 56px); z-index: 4; }
  .stat { padding: 5px 7px; font-size: 12px; }
  .stat .icon { font-size: 15px; }
  .announcement { top: calc(var(--top-edge) + 8px); right: calc(var(--right-edge) + 120px); max-width: min(34vw, 260px); }
  .touch-controls {
    position: absolute;
    inset: auto var(--right-edge) var(--bottom-edge) var(--left-edge);
    margin: 0;
    z-index: 5;
    pointer-events: none;
  }
  .touch-controls > div { gap: 10px; }
  .touch-controls .direction-pad { display: grid; grid-template-columns: repeat(3, var(--touch-size)); grid-template-rows: repeat(2, var(--touch-size)); gap: 6px; }
  .direction-pad [data-input="left"] { grid-column: 1; grid-row: 1 / 3; align-self: center; }
  .direction-pad .climb-buttons { display: flex; flex-direction: column; grid-column: 2; grid-row: 1 / 3; gap: 6px; }
  .direction-pad [data-input="right"] { grid-column: 3; grid-row: 1 / 3; align-self: center; }
  [data-input="down"] .icon { transform: rotate(180deg); }
  .touch-controls > div:not(.direction-pad) { align-self: end; }
  .touch-controls button {
    width: var(--touch-size);
    min-width: var(--touch-size);
    height: var(--touch-size);
    padding: 0;
    pointer-events: auto;
  }
  :is(.game-top, .touch-controls) button,
  .touch-controls button:is([data-input="jump"], :active) {
    position: relative;
    isolation: isolate;
    border: 0;
    background: transparent;
    color: #fffaf4;
    -webkit-tap-highlight-color: transparent;
  }
  :is(.game-top, .touch-controls) button::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 3px;
    border: 3px solid var(--chocolate);
    border-radius: 50%;
    background: radial-gradient(ellipse at 31% 15%, #ffffff90, transparent 44%),
      linear-gradient(155deg, #9b70ff, #4a1fa8 70%);
    box-shadow: inset 0 2px 2px #ffffff9c, inset 0 -3px 4px #2117368c, 0 3px 0 #2a1408, 0 5px 8px #1a132f80;
    pointer-events: none;
  }
  .touch-controls button[data-input="jump"]::before {
    background: radial-gradient(ellipse at 31% 15%, #ffffffaa, transparent 44%),
      linear-gradient(155deg, #ffe08a, #ff8a3a 70%);
  }
  .touch-controls button[data-input="throw"]::before {
    background: radial-gradient(ellipse at 31% 15%, #ffffffaa, transparent 44%),
      linear-gradient(155deg, #ffb3d6, #ff6dad 70%);
  }
  :is(.game-top, .touch-controls) button:is(:active, [data-held])::before {
    transform: scale(.91);
    box-shadow: inset 0 2px 6px #160e28a6, inset 0 0 5px #fff6cc66, 0 1px 2px #1a132f80;
  }
  :is(.game-top, .touch-controls) button .icon { font-size: 22px; filter: drop-shadow(0 1px 1px #160e28); pointer-events: none; }
  .touch-controls button .icon[data-icon="water"] { font-size: 30px; background: var(--icon) center/contain no-repeat; mask: none; }
  .touch-controls button > span:not(.icon) { display: none; }
  .rescue-list {
    position: absolute;
    inset: auto 12px calc(var(--bottom-edge) + 26px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0;
    margin: 0;
    background: none;
    border: 0;
    box-shadow: none;
    z-index: 1;
    pointer-events: none;
  }
  .rescue-list h3 { font-size: 8px; }
  .rescue-list ul { justify-content: center; gap: 0 2px; }
  .rescue-list li { flex: none; min-width: auto; min-height: 0; padding: 0; font-size: 11px; background: none; box-shadow: none; }
  .rescue-list li img { width: 16px; height: 18px; }

@media (pointer: coarse), (max-width: 680px) {
  .game-top { grid-template-columns: 1fr 1fr; }
  .game-top .level-name {
    top: calc(100% + 6px);
    left: 50%;
    width: max-content;
    height: auto;
    padding: 3px 10px 4px;
    overflow: visible;
    clip-path: none;
    transform: translateX(-50%);
  }
  .game-top .level-name h2 { font-size: 16px; }
}

@media (pointer: coarse) {
  /* Bottom center, in the gap between the D-pad and the action buttons. */
  .rescue-list {
    inset: auto calc(var(--right-edge) + 2 * var(--touch-size) + 16px)
      var(--bottom-edge)
      calc(var(--left-edge) + 3 * var(--touch-size) + 16px);
    z-index: 3;
  }
  .rescue-list ul { max-width: 100%; }
  .rescue-list ul.is-wrap {
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    row-gap: 1px;
  }
}

@media (pointer: coarse) and (orientation: portrait) {
  .game-screen {
    --left-edge: max(10px, env(safe-area-inset-left));
    --right-edge: max(10px, env(safe-area-inset-right));
    --touch-size: clamp(44px, 14vw, 66px);
  }
  .touch-controls > div { gap: 6px; }
  .rescue-list {
    inset: auto var(--right-edge) calc(var(--bottom-edge) + 2 * var(--touch-size) + 12px) var(--left-edge);
  }
  .rescue-list ul { flex-wrap: wrap; row-gap: 2px; }
  body.pad-connected .rescue-list { bottom: var(--bottom-edge); }
}

@media (max-width: 440px) {
  .game-hud { inset: calc(var(--top-edge) + 48px) auto auto var(--left-edge); }
  .announcement { top: calc(var(--top-edge) + 82px); right: var(--right-edge); }
  .key-guide { display: none; }
  .game-top .level-name { top: calc(100% + 48px); }
  .game-screen:not([data-area="surface"]) .announcement { top: calc(var(--top-edge) + 118px); }
}

@media (max-height: 360px) {
  .result-card { gap: 6px; padding: 10px 12px; }
  .result-card h2 { font-size: clamp(26px, 10dvh, 36px); }
  .result-icon { width: 30px; height: 30px; font-size: 19px; }
  .result-card .primary { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

.rescue-list li[data-voice] { pointer-events: auto; cursor: pointer; touch-action: manipulation; }

body.pad-connected .touch-controls { display: none !important; }
.pad-focus {
  outline: 3px solid #ffe179;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px #ffe17955, 0 8px 18px #160e28aa;
  position: relative;
  z-index: 2;
}
.pad-toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translate(-50%, 8px);
  z-index: 80;
  padding: 8px 16px;
  border-radius: 999px;
  background: #241833f0;
  color: #fff6d8;
  font: 800 13px/1.3 "DM Sans", system-ui, sans-serif;
  letter-spacing: .02em;
  box-shadow: 0 8px 24px #160e28aa;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.pad-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}


/* Menu pages: title and character select each fit in the viewport, no scrolling. */
body:has(#menu:not([hidden])) .shell {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#menu:not([hidden]) {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
#menu[data-page="title"] .hero {
  flex: 1;
  min-height: 0;
  max-height: 100%;
}
.menu-actions {
  display: none;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 2vw, 16px);
}
#menu[data-page="select"] {
  gap: clamp(6px, 1.6dvh, 14px);
}
#menu[data-page="select"] .menu-actions { display: flex; }
#menu[data-page="select"] .roster,
#menu[data-page="select"] .world-map {
  margin-top: 0;
  min-height: 0;
}
#menu[data-page="select"] .roster {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1dvh, 10px);
}
#menu[data-page="select"] .section-heading {
  flex: none;
  margin-bottom: 0;
}
#menu[data-page="select"] .section-heading h2 {
  font-size: clamp(18px, 6dvh, 27px);
}
#menu[data-page="select"] .roster-grid {
  flex: 0 0 auto;
  height: clamp(72px, 36dvh, 170px);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 1.4dvh, 11px);
  align-items: stretch;
}
#menu[data-page="select"] .character {
  height: 100%;
  min-height: 0;
  max-height: 170px;
  padding: clamp(6px, 1.6dvh, 13px);
  align-self: stretch;
}
#menu[data-page="select"] .character[aria-pressed="true"] {
  padding: clamp(5px, 1.4dvh, 12px);
}
#menu[data-page="select"] .character-copy {
  gap: 2px;
}
#menu[data-page="select"] .character-copy strong {
  font-size: clamp(14px, 2.4vw, 33px);
}
#menu[data-page="select"] .character-copy > span {
  font-size: clamp(9px, 2.4dvh, 11px);
}
#menu[data-page="select"] .character img {
  width: auto;
  max-width: 46%;
  height: 86%;
  max-height: 86%;
  object-fit: contain;
  object-position: right top;
  right: 4px;
  top: 2px;
}
#menu[data-page="select"] .world-map {
  flex: none;
}
#menu[data-page="select"] .stage-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
#menu[data-page="select"] .stage {
  min-height: clamp(40px, 12dvh, 55px);
  padding: clamp(5px, 1.2dvh, 9px) 10px;
}
#menu[data-page="select"] #menu-play {
  min-height: clamp(40px, 12dvh, 51px);
  margin-left: auto;
}
#menu[data-page="select"] #menu-back {
  min-height: clamp(36px, 11dvh, 44px);
}

@media (max-width: 680px) and (orientation: portrait) {
  #menu[data-page="select"] .roster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #menu[data-page="select"] .stage-grid { grid-template-columns: 1fr; }
}
@media (max-height: 400px) {
  #menu[data-page="select"] .character-copy > span { display: none; }
  #menu[data-page="select"] .stage-copy small { display: none; }
}


/* Bonus slide intro and end-of-round celebration */
.slide-banner,
.celebrate {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: auto;
}
.slide-banner[hidden],
.celebrate[hidden] { display: none; }
.slide-banner {
  background: linear-gradient(180deg, #1a103acc, #0e1a28d9);
}
.slide-banner-card {
  text-align: center;
  color: #fffdf6;
  font-family: "Nunito", system-ui, sans-serif;
  text-shadow: 0 1px 0 #5b321b, 0 4px 12px #23160bb5;
  padding: clamp(8px, 3dvh, 22px) clamp(14px, 4vw, 36px);
  max-width: min(640px, 92%);
}
.slide-kicker {
  margin: 0;
  letter-spacing: 0.18em;
  font-weight: 800;
  font-size: clamp(10px, 2.4dvh, 14px);
  color: #ffe56a;
  text-transform: uppercase;
}
.slide-banner-card h2 {
  margin: 0.15em 0 0.2em;
  font-size: clamp(28px, 9dvh, 64px);
  line-height: 0.95;
  font-weight: 1000;
  letter-spacing: 0.01em;
  color: #ffdb67;
  filter: drop-shadow(0 .055em 0 #713809) drop-shadow(0 .08em .075em #211309);
}
@supports (background-clip: text) {
  .slide-banner-card h2 {
    color: transparent;
    background: linear-gradient(#fff7ba 10%, #ffdc64 49%, #ffad31 88%);
    background-clip: text;
    text-shadow: none;
  }
}
@media (forced-colors: active) {
  .slide-banner-card h2 { color: CanvasText; background: none; filter: none; }
}
.slide-banner-card p:last-child {
  margin: 0;
  font-size: clamp(13px, 3.4dvh, 20px);
}
#slide-guide, .game-screen[data-area="slide"] .announcement { font-family: "Nunito", system-ui, sans-serif; }
#slide-guide kbd { font-family: inherit; }
.celebrate-bg {
  position: absolute;
  inset: 0;
  background-color: #142056;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}
.celebrate-fx,
#celebrate-fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.celebrate-scene {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  padding: 0;
  box-sizing: border-box;
  min-height: 0;
}
.celebrate-top {
  position: relative;
  z-index: 4;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.3dvh, 12px);
  padding: clamp(4px, 1.4dvh, 12px) clamp(10px, 3vw, 24px) 0;
  box-sizing: border-box;
  pointer-events: none;
}
.celebrate-top > * { pointer-events: auto; }
.celebrate-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: 28%;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 2dvh, 16px);
  padding: 0 clamp(10px, 3vw, 24px);
  box-sizing: border-box;
  pointer-events: none;
}
.celebrate-panel > * { pointer-events: auto; }
.celebrate-caption {
  margin: 0;
  max-width: min(920px, 94%);
  flex: 0 0 auto;
  text-align: center;
  font-weight: 900;
  font-size: clamp(15px, 5.2dvh, 36px);
  line-height: 1.15;
  color: #fffce9;
  text-shadow: 0 2px 0 #3b1a6a, 0 0 14px #ffef8a, 0 8px 18px #0008;
}
.celebrate-stage {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--ground-from-bottom, 8%);
  width: 100%;
  height: auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  pointer-events: none;
  z-index: 2;
}
.celebrate-cast {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 0;
  height: 100%;
  pointer-events: none;
}
.celebrate-hero {
  position: relative;
  display: block;
  height: clamp(120px, 48dvh, 280px);
  max-height: 100%;
  width: auto;
  aspect-ratio: 1 / 1;
  image-rendering: auto;
  transform-origin: 50% 100%;
  animation: cele-bounce 0.5s ease-in-out infinite;
  filter: drop-shadow(0 10px 0 #0003);
}
.celebrate-letters {
  position: static;
  left: auto;
  top: auto;
  transform: none;
  width: min(94%, 820px);
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-wrap: nowrap;
  gap: clamp(2px, 0.6vw, 6px);
  /* Leave headroom so the letter bob/rotate never eats the caption. */
  padding-top: 12px;
  box-sizing: border-box;
  z-index: 3;
  pointer-events: none;
}
.celebrate-letters-inner {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-wrap: nowrap;
  gap: clamp(2px, 0.6vw, 6px);
  width: max-content;
  max-width: none;
  transform-origin: top center;
}
.celebrate-friend {
  height: clamp(30px, 9.4dvh, 56px);
  min-width: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  background: none;
  color: #fff8ef;
  font-weight: 900;
  font-size: clamp(14px, 4dvh, 24px);
  box-shadow: none;
  padding: 0;
  animation: cele-bob 0.7s ease-in-out infinite;
}
.celebrate-friend-num {
  min-width: 0.85em;
  font-family: inherit;
  text-shadow: 0 2px 0 #3b1a6a, 0 0 10px #ffef8a;
  filter: drop-shadow(0 3px 0 #0005);
}
.celebrate-friend img { height: 100%; width: auto; filter: drop-shadow(0 3px 0 #0005); }
.celebrate-friend:nth-child(even) { animation-delay: 0.15s; }
.celebrate-grade-wrap {
  display: none;
}
.celebrate-stamp {
  width: clamp(64px, 18dvh, 120px);
  height: clamp(64px, 18dvh, 120px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: clamp(36px, 12dvh, 84px);
  color: #fffdf3;
  background: radial-gradient(circle at 35% 30%, #ffd36a, #e23d6a 62%, #8e1848);
  border: 5px solid #fff6c8;
  box-shadow: 0 0 0 4px #d6284acc, 0 8px 0 #6a1238, 0 16px 24px #0006;
  text-shadow: 0 3px 0 #6a1238;
  transform: scale(0);
  animation: cele-stamp 0.55s 0.25s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}
.celebrate-stamp[data-grade="S"] { background: radial-gradient(circle at 35% 30%, #fff4a8, #ffbf1f 58%, #d06a00); }
.celebrate-stamp[data-grade="A"] { background: radial-gradient(circle at 35% 30%, #d8ffb0, #4cce4a 58%, #1b7a32); }
.celebrate-stamp[data-grade="B"] { background: radial-gradient(circle at 35% 30%, #c8e8ff, #3d8dff 58%, #1c4a9a); }
.celebrate-stamp[data-grade="C"] { background: radial-gradient(circle at 35% 30%, #ffe3b0, #ff8a3d 58%, #b04810); }
.celebrate-cheer {
  margin: 4px 0 0;
  text-align: center;
  font-weight: 800;
  font-size: clamp(11px, 3dvh, 18px);
  color: #fff8d8;
  text-shadow: 0 2px 0 #3b1a6a;
  max-width: 18ch;
}
.celebrate-stats {
  margin: 0;
  flex: 0 0 auto;
  font-weight: 800;
  font-size: clamp(12px, 3.2dvh, 18px);
  color: #fffaf0;
  text-shadow: 0 1px 0 #3b1a6a;
  text-align: center;
  background: linear-gradient(#3b1d72ee, #1a0a3cee);
  border: 3px solid var(--chocolate);
  border-radius: 999px;
  padding: 4px 16px;
  max-width: min(92%, 560px);
  line-height: 1.25;
  z-index: 2;
  box-shadow: inset 0 2px 0 #ffffff44, 0 3px 0 #12061f;
}
#celebrate-continue {
  min-height: clamp(36px, 11dvh, 50px);
  padding: 0 18px;
  flex: 0 0 auto;
}
@keyframes cele-dance {
  0%, 100% { transform: translateY(0) rotate(-6deg) scale(1, 1); }
  50% { transform: translateY(-10px) rotate(6deg) scale(1.04, 0.96); }
}
@keyframes cele-bounce {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.03, 0.96); }
}
@keyframes cele-bob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-5px) rotate(6deg); }
}
@keyframes cele-stamp {
  0% { transform: scale(1.6) rotate(-18deg); opacity: 0; }
  60% { transform: scale(0.9) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(-6deg); opacity: 1; }
}
@media (max-height: 400px) {
  .celebrate-top { gap: 6px; padding-top: 4px; }
  .celebrate-caption { font-size: clamp(12px, 4.6dvh, 18px); line-height: 1.12; }
  .celebrate-hero { height: clamp(88px, 42dvh, 150px); }
  .celebrate-letters { width: min(96%, 800px); gap: 0; padding-top: 8px; }
  .celebrate-letters-inner { gap: 2px; }
  .celebrate-friend { height: clamp(20px, 7dvh, 30px); min-width: 0; font-size: clamp(11px, 5dvh, 16px); }
  .celebrate-panel { gap: 8px; }
  .celebrate-stats { font-size: clamp(10px, 3.2dvh, 13px); padding: 2px 10px; }
  #celebrate-continue { min-height: 36px; padding: 0 14px; }
  .celebrate-cheer { display: none; }
}
@media (max-height: 360px) {
  .celebrate-top { gap: 6px; padding-top: 3px; }
  .celebrate-caption { font-size: clamp(11px, 4.4dvh, 16px); }
  .celebrate-hero { height: clamp(80px, 38dvh, 120px); }
  .celebrate-letters { padding-top: 8px; }
  .celebrate-friend { height: clamp(18px, 6.6dvh, 26px); }
  .celebrate-panel { gap: 8px; }
}

.celebrate-dancer {
  position: relative;
  display: block;
  height: clamp(60px, 24dvh, 140px);
  max-height: 52%;
  width: auto;
  aspect-ratio: 1 / 1;
  image-rendering: auto;
  transform-origin: 50% 100%;
  animation: cele-bounce 0.5s ease-in-out infinite;
  filter: drop-shadow(0 6px 0 #0003);
  margin: 0 -4px;
}
.celebrate-hero .dance-layer,
.celebrate-dancer .dance-layer {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  height: 100%;
  width: auto;
  object-fit: contain;
  object-position: 50% 100%;
  pointer-events: none;
  image-rendering: auto;
}
.celebrate-cast .celebrate-hero { z-index: 1; margin: 0 2px; }
@media (max-height: 360px) {
  .celebrate-dancer { height: clamp(44px, 22dvh, 72px); }
}

.home-screen-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  min-height: 44px;
  padding: 0 18px;
  border: 3px solid var(--chocolate);
  border-radius: 999px;
  background:
    radial-gradient(circle at 22% 22%, #ffffff88 0 16%, transparent 42%),
    linear-gradient(#8a5bff, #4a1fa8);
  color: #fff8e8;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: inset 0 2px 0 #ffffff66, 0 4px 0 #2a1048, 0 8px 18px #0f092466;
  cursor: pointer;
}
.home-screen-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.home-screen-btn:active { transform: translateY(2px); box-shadow: inset 0 2px 0 #ffffff44, 0 2px 0 #2a1048; }
.home-screen-btn[hidden] { display: none !important; }
.home-screen-glyph {
  width: 22px;
  height: 22px;
  display: inline-block;
  background:
    linear-gradient(#fff8e8, #fff8e8) 9px 3px / 4px 10px no-repeat,
    linear-gradient(#fff8e8, #fff8e8) 6px 3px / 10px 4px no-repeat,
    linear-gradient(#fff8e8, #fff8e8) 4px 12px / 14px 8px no-repeat;
  border: 2px solid #fff8e8;
  border-radius: 5px;
  box-sizing: border-box;
}

.add-home-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(92vw, 460px);
}
.add-home-dialog::backdrop { background: #140f26cc; }
.add-home-card {
  background: linear-gradient(#fff7e4, #ffe7b8);
  color: #2a1840;
  border-radius: 22px;
  padding: 22px 22px 20px;
  box-shadow: 0 12px 0 #c48a3a, 0 22px 40px #0008;
  text-align: center;
}
.add-home-card h2 {
  margin: 0 0 6px;
  font-size: clamp(22px, 4.4vw, 30px);
  color: #5b2d86;
}
.add-home-lead { margin: 0 0 16px; font-weight: 700; }
.add-home-steps {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 12px;
  text-align: left;
}
.add-home-steps li {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  background: #fffdf8;
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 3px 0 #efc48a;
  font-size: 15px;
  font-weight: 700;
}
.add-home-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffd24d;
  color: #3a1d08;
  font-weight: 900;
}
.share-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: #efe7ff;
  border-radius: 14px;
  border: 2px solid #3a2a6b;
}
.add-home-mini {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: #efe7ff;
  border-radius: 14px;
  border: 2px solid #3a2a6b;
  font-size: 30px;
  color: #3a2a6b;
  font-weight: 900;
}
.add-home-card .primary { width: 100%; }

.homescreen-tip {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #2a1840f2;
  color: #fff8e8;
  box-shadow: 0 8px 24px #0006;
  font-weight: 700;
}
.homescreen-tip[hidden] { display: none !important; }
.homescreen-tip p { margin: 0; font-size: 14px; }
.homescreen-tip .primary { min-height: 40px; flex: 0 0 auto; }

@media (max-height: 390px) {
  .home-screen-btn { margin-top: 8px; min-height: 38px; font-size: 13px; }
  .homescreen-tip { padding: 8px 10px; }
  .homescreen-tip p { font-size: 12px; }
}
@media (max-width: 540px) and (max-height: 390px) {
  .hero-content .home-screen-btn { min-height: 34px; padding: 0 12px; font-size: 12px; }
}


/* Candy-jelly + purple kit: compact HUD tweaks */
@media (max-width: 680px), (max-height: 400px) {
  .stat { border-width: 2px; }
  .announcement { border-width: 2px; }
  .rescue-list { border: 0; padding: 0; background: none; box-shadow: none; }
  .level-name { border-width: 2px; }
  .stage-progress { height: 6px; }
}
@media (max-height: 360px) {
  .game-hud { gap: 4px; }
  .stat { padding: 2px 6px; font-size: 10px; }
  .rescue-list li img { width: 13px; height: 15px; }
}

/* Short landscape: keep Play + Add to Home Screen on screen */
@media (max-height: 500px) {
  .topbar-inner { min-height: 48px; }
  .shell { padding: 8px 0 10px; }
  .hero { min-height: 0 !important; max-height: calc(100dvh - 58px); align-items: center; }
  .hero-content { padding: 10px 0 12px clamp(16px, 4vw, 48px); }
  .hero p { margin: 6px 0 8px; font-size: 12px; line-height: 1.3; max-width: 260px; }
  .title-logo { width: min(100%, 320px); }
  .title-logo img { max-height: 26dvh; }
  .hero-content .primary,
  .hero-content .home-screen-btn {
    display: inline-flex;
    vertical-align: middle;
    min-height: 38px;
  }
  .hero-content .home-screen-btn { margin-top: 0; margin-left: 8px; }
}
@media (max-height: 360px) {
  .hero p { display: none; }
  .title-logo img { max-height: 22dvh; }
  .hero-kicker { margin-bottom: 4px; }
}
@media (min-height: 600px) and (min-width: 1100px) {
  .rescue-list li img { width: 18px; height: 20px; }
  .rescue-list h3 { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  .rescue-list li.is-pop img { animation: none; }
}
