/* Strawberry Sprint: page shell, HUD, menus, touch controls.
   Layout modes:
   - desktop: the 16:9 game sits in a soft framed "screen" with an ambient glow
   - phone/tablet/small windows: the frame fills the whole (dynamic) viewport,
     safe areas respected, letterbox bars filled with light from the game. */

:root {
  --rose: #f36f9f;
  --rose-deep: #c92768;
  --berry: #b9134f;
  --berry-dark: #8f0e3e;
  --petal: #ffd6e4;
  --blush: #ffeef4;
  --cream: #fff7ea;
  --mint: #7ed9c4;
  --mint-soft: #c9f0e4;
  --mint-dark: #2f8c81;
  --gold: #f4b63f;
  --ink: #3b1830;
  --ink-soft: #6b3a58;
  --ink-faint: rgba(59, 24, 48, 0.55);
  --shadow: rgba(59, 24, 48, 0.2);
  --panel: rgba(255, 249, 251, 0.97);
  --panel-blur: blur(12px) saturate(1.15);
  --glass: rgba(255, 250, 252, 0.88);
  --bubble-mr: #ece8ef;
  --bubble-mrs: #ec4f87;
  --ui-font: Nunito, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino", Georgia, serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --edge: 14px;
  --hud-h: 40px;
  --spring: cubic-bezier(0.2, 0.9, 0.25, 1.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--ink);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html {
  background: #fbd3e2;
}

body {
  background:
    radial-gradient(1100px 760px at 50% 38%, rgba(255, 246, 250, 0.95) 0%, rgba(255, 223, 235, 0.6) 46%, rgba(255, 223, 235, 0) 72%),
    radial-gradient(900px 600px at 12% 100%, rgba(151, 219, 201, 0.55), rgba(151, 219, 201, 0) 70%),
    radial-gradient(900px 600px at 92% 0%, rgba(255, 190, 214, 0.7), rgba(255, 190, 214, 0) 70%),
    linear-gradient(180deg, #ffe4ef 0%, #f9c3d7 55%, #f3b5cc 100%);
}

/* Tiny strawberries + hearts scattered behind the frame (desktop). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg opacity='.38'%3E%3Cpath d='M38 30c7 0 11 5 10 11-1 6-6 11-10 13-4-2-9-7-10-13-1-6 3-11 10-11z' fill='%23f06d9a'/%3E%3Cpath d='M32 30c3 1 4-2 6-3 2 1 3 4 6 3' fill='none' stroke='%2364c3a2' stroke-width='2.4' stroke-linecap='round'/%3E%3Cpath d='M128 112c-3-5-11-4-11 2 0 6 11 12 11 12s11-6 11-12c0-6-8-7-11-2z' fill='%23ffffff'/%3E%3Ccircle cx='140' cy='40' r='3' fill='%23ffffff'/%3E%3Ccircle cx='60' cy='140' r='2.5' fill='%23ffffff'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 180px 180px;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

svg {
  fill: currentColor;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 7px;
  background: #fff;
  border: 1.5px solid rgba(201, 39, 104, 0.22);
  box-shadow: 0 2px 0 rgba(201, 39, 104, 0.22);
  color: var(--rose-deep);
  font: 900 13px/1 var(--ui-font);
}

kbd.wide {
  min-width: 52px;
}

/* ================================================================ ambient light */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.amb {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  opacity: 0;
  transition: opacity 600ms ease;
  image-rendering: auto;
}

.ambient.ready .amb {
  opacity: 0.62;
  filter: blur(46px) saturate(1.15);
}

/* ================================================================ frame */

.game-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 48px 32px 56px;
}

.game-frame {
  position: relative;
  width: min(calc(100vw - 64px), calc((100vh - 120px) * 16 / 9), 1360px);
  width: min(calc(100vw - 64px), calc((100dvh - 120px) * 16 / 9), 1360px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 22px;
  background: #ffd4e3;
  isolation: isolate;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.92),
    0 0 0 9px rgba(255, 255, 255, 0.28),
    0 30px 80px rgba(118, 25, 69, 0.28),
    0 8px 22px rgba(118, 25, 69, 0.16);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#game-root {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

#game-root canvas {
  display: block;
  touch-action: none;
}

.page-credit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  color: rgba(107, 58, 88, 0.72);
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
}

.page-credit > span:first-child {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 17px;
  color: var(--rose-deep);
}

.credit-keys {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  opacity: 0;
  transition: opacity 420ms ease;
}

/* The keyboard reminder belongs to playing, not to the title, map, results or ending. */
.game-frame.is-playing ~ .page-credit .credit-keys,
.game-frame[data-panel="intro"] ~ .page-credit .credit-keys {
  opacity: 1;
}

.page-credit kbd {
  height: 22px;
  min-width: 22px;
  font-size: 11px;
  border-radius: 6px;
}

.page-credit kbd.wide {
  min-width: 44px;
}

@media (max-height: 700px), (pointer: coarse) {
  .page-credit {
    display: none;
  }
}

/* Soft veil behind open panels, so text reads well over the game. */
.scrim {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  transition: opacity 320ms ease, background 320ms ease;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 241, 247, 0.55) 0%, rgba(255, 241, 247, 0.15) 55%, rgba(255, 241, 247, 0) 80%);
}

.game-frame[data-panel="title"] .scrim,
.game-frame[data-panel="map"] .scrim {
  opacity: 1;
}

.game-frame[data-panel="intro"] .scrim,
.game-frame[data-panel="result"] .scrim {
  opacity: 1;
  background: radial-gradient(ellipse at 50% 50%, rgba(59, 24, 48, 0.28) 0%, rgba(59, 24, 48, 0.12) 70%);
}

.game-frame[data-panel="pause"] .scrim,
.game-frame[data-panel="out"] .scrim {
  opacity: 1;
  background: rgba(59, 24, 48, 0.34);
}

.game-frame[data-panel="ending"] .scrim {
  opacity: 1;
  background: radial-gradient(ellipse 70% 80% at 22% 30%, rgba(14, 10, 38, 0.55) 0%, rgba(14, 10, 38, 0.18) 60%, rgba(14, 10, 38, 0) 85%);
}

/* ================================================================ HUD */

.hud {
  position: absolute;
  z-index: 5;
  top: max(var(--edge), var(--safe-t));
  left: max(var(--edge), var(--safe-l));
  right: max(var(--edge), var(--safe-r));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  animation: hud-in 420ms var(--spring) both;
}

@keyframes hud-in {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }
}

.hud-cluster {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-chip,
.icon-button {
  height: var(--hud-h);
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  background: var(--glass);
  box-shadow:
    0 6px 16px rgba(118, 25, 69, 0.16),
    inset 0 -3px 0 rgba(201, 39, 104, 0.07);
}

.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px 0 10px;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.hud-icon {
  flex: none;
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
}

.berry-icon {
  width: 22px;
  height: 25px;
  margin-top: -2px;
}

.clock-icon {
  width: 18px;
  height: 18px;
  color: var(--rose-deep);
}

.berry-chip.bump,
.berry-chip.catch {
  animation: chip-bump 360ms var(--spring);
}

.berry-chip.bump .berry-icon,
.berry-chip.catch .berry-icon {
  animation: berry-spin 420ms ease-out;
}

.berry-chip.crown {
  animation: chip-bump 520ms var(--spring) 2;
}

.berry-chip.complete {
  background: linear-gradient(180deg, #fff6d8, #ffe7a8);
  border-color: #fff4cf;
  box-shadow:
    0 0 0 2px rgba(244, 182, 63, 0.5),
    0 6px 18px rgba(244, 182, 63, 0.35);
}

@keyframes chip-bump {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.16);
    background: #fff;
  }
  100% {
    transform: scale(1);
  }
}

@keyframes berry-spin {
  0% {
    transform: rotate(0) scale(1);
  }
  40% {
    transform: rotate(-18deg) scale(1.35);
  }
  100% {
    transform: rotate(0) scale(1);
  }
}

/* Hearts are drawn as icons by shell.js; the number stays for screen readers. */
.heart-chip {
  gap: 3px;
  padding: 0 12px;
  color: var(--berry);
}

.heart-icons {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.heart-icons svg {
  width: 21px;
  height: 21px;
  fill: var(--berry);
  filter: drop-shadow(0 1px 0 rgba(143, 14, 62, 0.25));
  transition: transform 200ms var(--spring);
}

.heart-icons svg.empty {
  fill: rgba(185, 19, 79, 0.16);
  filter: none;
  transform: scale(0.82);
}

.heart-icons svg.lost {
  animation: heart-lost 520ms ease-out;
}

.heart-icons svg.gain {
  animation: heart-gain 420ms var(--spring);
}

@keyframes heart-lost {
  0% {
    fill: var(--berry);
    transform: scale(1.35);
  }
  30% {
    transform: scale(1.4) rotate(-12deg);
  }
  100% {
    transform: scale(0.82);
  }
}

@keyframes heart-gain {
  from {
    transform: scale(0.2);
  }
}

.heart-fallback {
  font-size: 15px;
}

.heart-chip.has-icons .heart-fallback,
.heart-chip.has-icons #heart-count {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.heart-chip.hurt {
  animation: chip-shake 420ms ease-out;
  background: #ffe1ea;
}

@keyframes chip-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-5px) rotate(-2deg);
  }
  40% {
    transform: translateX(5px) rotate(2deg);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(2px);
  }
}

.power-chip {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.9);
  background: linear-gradient(135deg, #ff8fb8, #c92768);
  box-shadow: 0 6px 18px rgba(201, 39, 104, 0.35);
  animation: power-in 380ms var(--spring);
}

.power-chip .power-icon {
  font-size: 15px;
  animation: twinkle 1.4s ease-in-out infinite;
}

.power-chip.idle {
  display: none;
}

/* shell.js redraws the power text as unbreakable pieces (#power-state stays for screen readers) */
.power-text {
  display: none;
}

.power-chip.has-text .power-text {
  display: inline-block;
  white-space: nowrap;
}

.power-chip.has-text #power-state {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.power-text .pw {
  white-space: nowrap;
}

.power-chip.ending {
  animation: power-ending 520ms ease-in-out infinite;
}

@keyframes power-ending {
  50% {
    opacity: 0.55;
    transform: scale(0.96);
  }
}

@keyframes power-in {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

@keyframes twinkle {
  50% {
    transform: rotate(45deg) scale(1.25);
  }
}

.timer {
  min-width: 82px;
  justify-content: center;
  padding: 0 14px 0 11px;
}

.icon-button {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--rose-deep);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

.icon-button svg {
  width: 22px;
  height: 22px;
}

/* a slightly larger, invisible hit area (comfortable thumbs at 42px) */
.icon-button::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
}

/* ---------------------------------------------------------------- sound toggle off the HUD */

/* Same corner as the HUD's pause button; shown on every screen without the HUD. */
.menu-mute {
  position: absolute;
  z-index: 9;
  top: max(var(--edge), var(--safe-t));
  right: max(var(--edge), var(--safe-r));
  display: none;
}

.game-frame:not(.is-playing) .menu-mute {
  display: grid;
  animation: hud-in 420ms var(--spring) both;
}

/* docked inside a card (shell.js): a white chip like the map's total */
.game-frame:not(.is-playing) .menu-mute[data-dock] {
  position: relative;
  top: auto;
  right: auto;
  z-index: 2;
  flex: none;
  border-color: rgba(201, 39, 104, 0.14);
  background: #fff;
  box-shadow: 0 4px 12px rgba(118, 25, 69, 0.08);
  animation: rise-in 420ms ease both;
}

.game-frame:not(.is-playing) .menu-mute[data-dock="result"] {
  position: absolute;
  top: 12px;
  right: 14px;
}

.map-head > .map-total {
  margin-left: auto;
}

#mute-glyph {
  display: grid;
  place-items: center;
}

#mute-glyph svg {
  grid-area: 1 / 1;
}

.icon-button .icon-off,
.icon-button.muted .icon-on {
  display: none;
}

.icon-button.muted .icon-off {
  display: block;
}

.icon-button.muted {
  color: rgba(59, 24, 48, 0.42);
}

.icon-button:active {
  transform: scale(0.9);
  background: #fff;
}

@media (hover: hover) {
  .icon-button:hover {
    background: #fff;
    transform: translateY(-1px);
  }
}

/* ---------------------------------------------------------------- progress */

.progress-track {
  position: relative;
  flex: 1 1 auto;
  min-width: 70px;
  max-width: 480px;
  height: 12px;
  margin: 0 18px 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow:
    inset 0 2px 3px rgba(118, 25, 69, 0.16),
    0 4px 12px rgba(118, 25, 69, 0.12);
}

.progress-fill {
  position: relative;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8fe3cf, #f5a3c3 60%, var(--rose));
  transition: width 140ms linear;
}

.progress-bear {
  position: absolute;
  z-index: 3; /* above the checkpoint flags */
  right: -15px;
  top: 50%;
  width: 30px;
  height: 30px;
  transform: translateY(-54%);
  filter: drop-shadow(0 2px 3px rgba(118, 25, 69, 0.3));
}

.progress-bear svg {
  width: 100%;
  height: 100%;
}

.progress-bear.hop {
  animation: bear-hop 520ms var(--spring);
}

@keyframes bear-hop {
  40% {
    transform: translateY(-110%) scale(1.15);
  }
}

/* short screens: the hop would leave the screen, so she pops in place */
@keyframes bear-pop {
  40% {
    transform: translateY(-54%) scale(1.38);
  }
}

.progress-goal {
  position: absolute;
  right: -13px;
  top: 50%;
  width: 24px;
  height: 24px;
  transform: translateY(-50%);
  color: var(--berry);
  filter: drop-shadow(0 2px 2px rgba(118, 25, 69, 0.3));
  animation: goal-beat 1.6s ease-in-out infinite;
}

.progress-goal svg {
  width: 100%;
  height: 100%;
  stroke: #fff;
  stroke-width: 2px;
  paint-order: stroke;
}

@keyframes goal-beat {
  0%,
  60%,
  100% {
    transform: translateY(-50%) scale(1);
  }
  70% {
    transform: translateY(-50%) scale(1.22);
  }
  80% {
    transform: translateY(-50%) scale(1);
  }
  88% {
    transform: translateY(-50%) scale(1.14);
  }
}

.progress-flag {
  position: absolute;
  z-index: 1;
  top: -7px;
  width: 4px;
  height: 22px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--mint-dark);
  pointer-events: none;
  animation: flag-in 420ms var(--spring);
}

.progress-flag::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 11px;
  height: 8px;
  border-radius: 0 3px 3px 0;
  background: var(--mint);
}

@keyframes flag-in {
  from {
    transform: scaleY(0);
    transform-origin: bottom;
  }
}

/* ---------------------------------------------------------------- controls hint (keyboard) */

.controls-hint {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: calc(max(var(--edge), var(--safe-t)) + var(--hud-h) + 26px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 250, 252, 0.94);
  border: 2px solid #fff;
  box-shadow: 0 14px 34px rgba(118, 25, 69, 0.24);
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -12px) scale(0.96);
  transition: opacity 360ms ease, transform 420ms var(--spring);
}

.controls-hint.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.hint-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hint-dot {
  color: rgba(201, 39, 104, 0.45);
}

html.input-touch .controls-hint {
  display: none;
}

/* ================================================================ panels */

.menu-panel {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: calc(50% + (var(--safe-t) - var(--safe-b)) / 2);
  width: min(470px, calc(100% - 32px - var(--safe-l) - var(--safe-r)));
  max-height: calc(100% - 24px - var(--safe-t) - var(--safe-b));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  transform: translate(-50%, -50%);
  padding: 28px 30px;
  border: 2px solid rgba(255, 255, 255, 0.96);
  border-radius: 26px;
  background: var(--panel);
  /* Frosted glass: whatever busy world art sits behind a panel melts into a
     soft wash, so the text on top always reads cleanly. */
  -webkit-backdrop-filter: var(--panel-blur);
  backdrop-filter: var(--panel-blur);
  box-shadow:
    0 30px 70px rgba(81, 20, 50, 0.26),
    0 6px 16px rgba(81, 20, 50, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -4px 0 rgba(201, 39, 104, 0.05);
  text-align: center;
  animation: panel-in 420ms var(--spring) both;
  scrollbar-width: thin;
}

/* No frosted glass available: lean on opacity instead. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root {
    --panel: rgba(255, 249, 251, 0.985);
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root {
    --panel: #fff9fb;
    --panel-blur: none;
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translate(-50%, -44%) scale(0.94);
  }
}

/* Just shown (ui.js, ~350ms): the second click of a quick double-tap must not
   press whatever this panel put under the finger. Keyboard is unaffected. */
.menu-panel.arming,
.menu-panel.arming * {
  pointer-events: none !important;
}

.menu-panel > * {
  animation: rise-in 460ms ease both;
}

.menu-panel > :nth-child(2) {
  animation-delay: 50ms;
}

.menu-panel > :nth-child(3) {
  animation-delay: 100ms;
}

.menu-panel > :nth-child(4) {
  animation-delay: 150ms;
}

.menu-panel > :nth-child(5) {
  animation-delay: 200ms;
}

.menu-panel > :nth-child(n + 6) {
  animation-delay: 240ms;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--rose-deep);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow-script {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 2px;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 24px;
  letter-spacing: 0.01em;
  text-transform: none;
}

.eyebrow-script::before,
.eyebrow-script::after {
  content: "";
  width: 34px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(201, 39, 104, 0), rgba(201, 39, 104, 0.5));
}

.eyebrow-script::after {
  transform: scaleX(-1);
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(38px, min(8vw, 12.5vh), 78px);
  line-height: 0.95;
}

.title-word {
  display: inline-block;
  padding: 0 0.04em 0.08em;
  background: linear-gradient(180deg, #f2669a 0%, #c92768 70%, #a8124e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #fff) drop-shadow(0 10px 16px rgba(185, 19, 79, 0.22));
}

.title-word.w2 {
  background-image: linear-gradient(180deg, #56c9ad 0%, #2f8c81 75%, #24706a 100%);
  filter: drop-shadow(0 3px 0 #fff) drop-shadow(0 10px 16px rgba(47, 140, 129, 0.24));
}

h2 {
  font-size: clamp(24px, min(4.4vw, 8vh), 38px);
}

.panel-copy {
  margin: 14px auto 0;
  max-width: 34ch;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.5;
  font-weight: 700;
  text-wrap: pretty;
}

.panel-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- buttons */

.primary-button,
.secondary-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease, background 140ms ease;
}

.primary-button {
  border: 0;
  color: #fff;
  background: linear-gradient(180deg, #f35b93 0%, #d3336f 55%, #c22463 100%);
  box-shadow:
    0 4px 0 var(--berry-dark),
    0 12px 26px rgba(185, 19, 79, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 0 rgba(143, 14, 62, 0.35);
}

.primary-button.big {
  min-height: 56px;
  padding: 0 38px 0 42px;
  font-size: 21px;
}

.btn-icon {
  width: 18px;
  height: 18px;
  margin-right: -4px;
}

.big .btn-icon {
  width: 21px;
  height: 21px;
}

.secondary-button {
  border: 2px solid rgba(201, 39, 104, 0.2);
  background: #fff;
  color: var(--rose-deep);
  box-shadow: 0 3px 0 rgba(201, 39, 104, 0.16), 0 8px 18px rgba(118, 25, 69, 0.08);
}

@media (hover: hover) {
  .primary-button:hover {
    transform: translateY(-2px);
    filter: brightness(1.06);
    box-shadow:
      0 6px 0 var(--berry-dark),
      0 16px 30px rgba(185, 19, 79, 0.34),
      inset 0 2px 0 rgba(255, 255, 255, 0.35);
  }

  .secondary-button:hover {
    transform: translateY(-2px);
    border-color: rgba(201, 39, 104, 0.4);
    box-shadow: 0 5px 0 rgba(201, 39, 104, 0.18), 0 12px 22px rgba(118, 25, 69, 0.12);
  }
}

.primary-button:active {
  transform: translateY(3px);
  filter: brightness(0.97);
  box-shadow:
    0 1px 0 var(--berry-dark),
    0 4px 10px rgba(185, 19, 79, 0.26),
    inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

.secondary-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(201, 39, 104, 0.16);
  background: var(--blush);
}

.icon-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.control-button:focus-visible,
.tip-close:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 3px;
}

.primary-button:focus-visible {
  box-shadow:
    0 4px 0 var(--berry-dark),
    0 0 0 6px rgba(126, 217, 196, 0.35),
    0 12px 26px rgba(185, 19, 79, 0.3);
}

/* ---------------------------------------------------------------- title */

.title-panel {
  width: min(520px, calc(100% - 32px - var(--safe-l) - var(--safe-r)));
  padding: 26px 34px 24px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.95), rgba(255, 249, 251, 0.9) 60%),
    var(--panel);
}

.title-panel .panel-copy {
  font-size: 16.5px;
}

.title-progress {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.title-progress b {
  color: var(--rose-deep);
}

.a2hs-tip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 14px auto 0;
  padding: 6px 6px 6px 14px;
  border-radius: 999px;
  background: rgba(126, 217, 196, 0.22);
  color: var(--mint-dark);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.a2hs-tip b {
  font-weight: 900;
}

.inline-icon {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  fill: none;
  color: var(--mint-dark);
}

.inline-icon use {
  fill: none;
}

.reload-button.big {
  padding: 0 28px;
  font-size: 18px;
}

.tip-close {
  position: relative;
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: var(--mint-dark);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

/* 44px hit area around the small dismiss button */
.tip-close::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
}

/* ---------------------------------------------------------------- map */

.map-panel {
  --scene-h: 112px;
  --gap: 18px;
  width: min(900px, calc(100% - 28px - var(--safe-l) - var(--safe-r)));
  padding: 24px 26px 22px;
  text-align: left;
}

.map-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.map-total {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid rgba(201, 39, 104, 0.14);
  box-shadow: 0 4px 12px rgba(118, 25, 69, 0.08);
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.map-total.all {
  background: linear-gradient(180deg, #fff6d8, #ffe7a8);
  border-color: rgba(244, 182, 63, 0.5);
}

.world-list {
  position: relative;
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px var(--gap);
}

.world-list > li {
  position: relative;
  min-width: 0;
  animation: rise-in 420ms ease both;
}

.world-list > li:nth-child(2) {
  animation-delay: 70ms;
}

.world-list > li:nth-child(3) {
  animation-delay: 140ms;
}

.world-list > li:nth-child(4) {
  animation-delay: 210ms;
}

/* The trail between stops: dotted while ahead of her, solid mint once walked. */
.world-list > li:not(:last-child)::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: 50%;
  top: calc(var(--scene-h) - 2px);
  width: calc(100% + var(--gap));
  height: 5px;
  border-radius: 3px;
  background-image: radial-gradient(circle, rgba(201, 39, 104, 0.4) 2.2px, transparent 2.8px);
  background-size: 11px 5px;
  background-position: 0 50%;
  pointer-events: none;
}

.world-list > li.walked:not(:last-child)::after {
  background: linear-gradient(90deg, var(--mint), #a7e8d8);
}

.world-card {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0 0 4px;
  border: 0;
  border-radius: 18px;
  background: none;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}

.world-scene {
  position: relative;
  display: block;
  width: 100%;
  height: var(--scene-h);
  border-radius: 18px;
  overflow: hidden;
  background: var(--petal);
  border: 3px solid #fff;
  box-shadow: 0 8px 20px rgba(118, 25, 69, 0.18);
  transition: transform 180ms var(--spring), box-shadow 180ms ease, filter 200ms ease;
}

.world-scene > svg {
  display: block;
  width: 100%;
  height: 100%;
}

@media (hover: hover) {
  .world-card:not(:disabled):hover .world-scene {
    transform: translateY(-4px) rotate(-1deg);
    box-shadow: 0 14px 28px rgba(118, 25, 69, 0.24);
  }
}

.world-card:not(:disabled):active .world-scene {
  transform: scale(0.97);
}

.world-card:focus {
  outline: none;
}

.world-card:focus-visible .world-scene {
  box-shadow:
    0 0 0 4px var(--mint),
    0 0 0 8px rgba(126, 217, 196, 0.3),
    0 12px 26px rgba(118, 25, 69, 0.22);
  transform: translateY(-3px);
}

.world-card:focus-visible .world-title {
  color: var(--rose-deep);
}

.world-num {
  position: relative;
  z-index: 2;
  flex: none;
  width: 32px;
  height: 32px;
  margin-top: -17px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--petal);
  color: var(--rose-deep);
  font-weight: 900;
  font-size: 15px;
  box-shadow: 0 3px 8px rgba(118, 25, 69, 0.18);
}

.world-card.done .world-num {
  background: var(--mint);
  color: #fff;
}

.world-card.current .world-num,
.world-card.next .world-num {
  background: var(--rose-deep);
  color: #fff;
}

.world-text {
  display: grid;
  gap: 1px;
  width: 100%;
  min-width: 0;
  margin-top: 3px;
}

.world-title {
  font-weight: 900;
  font-size: 16px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.world-quote {
  color: var(--ink-soft);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.world-meta {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: 3px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.world-meta > span:empty {
  display: none;
}

.world-card.perfect .world-meta > span:first-child,
.world-card.all-berries:not(.locked) .world-meta > span:first-child {
  padding: 0 7px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff6d8, #ffe39b);
  color: #8a5a00;
}

/* corner badges on the scene (top-left: the cave's moon lives top-right) */
.scene-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--mint);
  color: #fff;
  box-shadow: 0 2px 6px rgba(47, 140, 129, 0.35);
}

.scene-badge svg {
  width: 15px;
  height: 15px;
}

.scene-lock {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 245, 250, 0.5);
}

.scene-lock span {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-soft);
  box-shadow: 0 4px 12px rgba(118, 25, 69, 0.18);
}

.scene-lock svg {
  width: 20px;
  height: 20px;
}

.world-card.locked {
  cursor: not-allowed;
}

.world-card.locked .world-scene > svg {
  filter: grayscale(0.75) blur(1.2px) brightness(1.08);
}

.world-card.locked .world-title,
.world-card.locked .world-quote,
.world-card.locked .world-meta {
  opacity: 0.55;
}

/* "you are here" pin */
.world-pin {
  position: absolute;
  z-index: 3;
  top: -10px;
  left: 50%;
  width: 42px;
  height: 46px;
  margin-left: -21px;
  pointer-events: none;
  filter: drop-shadow(0 4px 4px rgba(118, 25, 69, 0.3));
  animation: pin-bob 1.6s ease-in-out infinite;
}

.world-pin svg {
  width: 42px;
  height: 42px;
}

@keyframes pin-bob {
  50% {
    transform: translateY(-6px);
  }
}

/* all worlds walked: the two of them, cheek to cheek, on the cave */
.world-pin.pair {
  width: 78px;
  margin-left: -39px;
}

.world-pin.pair svg {
  position: absolute;
  top: 0;
  width: 40px;
  height: 42px;
}

.world-pin.pair .pin-mrs {
  z-index: 1; /* in front, as in the hug, so his head never hides her face */
  left: 0;
  transform: rotate(9deg);
  transform-origin: 70% 90%;
}

.world-pin.pair .pin-mr {
  left: 35px;
  transform: rotate(-9deg);
  transform-origin: 30% 90%;
}

/* "Watch the ending" with a note still unread (engine adds .has-secret) */
#ending-replay-button.has-secret {
  animation: secret-glow 2.4s ease-in-out infinite;
}

#ending-replay-button.has-secret::after {
  content: "";
  position: absolute;
  top: -3px;
  right: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  background: #ffcf6e;
  box-shadow: 0 2px 6px rgba(185, 19, 79, 0.3);
}

@keyframes secret-glow {
  0%,
  100% {
    box-shadow:
      0 4px 0 var(--berry-dark),
      0 12px 26px rgba(185, 19, 79, 0.3),
      0 0 0 0 rgba(255, 158, 196, 0),
      inset 0 2px 0 rgba(255, 255, 255, 0.35);
  }
  50% {
    box-shadow:
      0 4px 0 var(--berry-dark),
      0 12px 26px rgba(185, 19, 79, 0.3),
      0 0 0 7px rgba(255, 158, 196, 0.32),
      inset 0 2px 0 rgba(255, 255, 255, 0.35);
  }
}

/* ---------------------------------------------------------------- chat (iMessage-ish) */

.chat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 16px auto 0;
  max-width: 360px;
  min-height: 40px;
  text-align: left;
}

.chat-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-bottom: 8px;
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 800;
  animation: rise-in 300ms ease both;
}

.chat-head .avatar {
  width: 42px;
  height: 42px;
}

.chat-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

.chat-row.from-mr {
  justify-content: flex-start;
}

.chat-row.from-mrs {
  justify-content: flex-end;
}

.chat-row + .chat-row:not(.cont) {
  margin-top: 6px;
}

.avatar {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff3e6, #fbe1c8);
  box-shadow: 0 1px 3px rgba(118, 25, 69, 0.16);
}

.avatar svg {
  width: 86%;
  height: 86%;
  margin-top: 8%;
}

.chat-row .avatar {
  visibility: hidden;
}

.chat-row.tail .avatar {
  visibility: visible;
}

.bubble {
  position: relative;
  max-width: 76%;
  padding: 8px 14px 9px;
  border-radius: 20px;
  font-size: 16.5px;
  font-weight: 700;
  line-height: 1.28;
  text-align: left;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.from-mr .bubble {
  background: var(--bubble-mr);
  color: var(--ink);
}

.from-mrs .bubble {
  background: linear-gradient(180deg, #f6689c, var(--bubble-mrs));
  color: #fff;
}

.bubble.pop {
  animation: bubble-pop 300ms var(--spring);
}

.from-mr .bubble.pop {
  transform-origin: 0% 100%;
}

.from-mrs .bubble.pop {
  transform-origin: 100% 100%;
}

@keyframes bubble-pop {
  from {
    transform: scale(0.6);
    opacity: 0.4;
  }
}

/* tails (only on the last bubble of a run, like iMessage) */
.chat-row.tail .bubble::before {
  content: "";
  position: absolute;
  z-index: -1;
  bottom: 0;
  width: 20px;
  height: 20px;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M20 0V20H0C6 19 11 15 12 5Z'/%3E%3C/svg%3E") no-repeat 0 0 / 100% 100%;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M20 0V20H0C6 19 11 15 12 5Z'/%3E%3C/svg%3E") no-repeat 0 0 / 100% 100%;
}

.chat-row.tail.from-mr .bubble::before {
  left: -6px;
  background: var(--bubble-mr);
}

.chat-row.tail.from-mrs .bubble::before {
  right: -6px;
  background: var(--bubble-mrs);
  transform: scaleX(-1);
}

.bubble.typing {
  display: inline-flex;
  gap: 5px;
  padding: 13px 15px;
}

.bubble .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9d90a6;
  animation: typing 1.1s infinite ease-in-out;
}

.bubble .dot:nth-child(2) {
  animation-delay: 160ms;
}

.bubble .dot:nth-child(3) {
  animation-delay: 320ms;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.chat-status {
  align-self: flex-end;
  margin: 2px 4px 0 0;
  color: var(--ink-faint);
  font-size: 11.5px;
  font-weight: 800;
  animation: rise-in 300ms ease both;
}

.chat-status.read {
  animation: status-read 420ms ease both;
}

@keyframes status-read {
  from {
    opacity: 0.2;
  }
}

/* ---------------------------------------------------------------- pause / out */

.panel-actions.stacked {
  flex-direction: column;
  align-items: stretch;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

.pause-tip {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: 14px 0 0;
  color: var(--ink-faint);
  font-size: 13px;
  font-weight: 800;
}

html.input-touch .keys-only {
  display: none;
}

.pause-goose {
  margin: 12px 0 0;
  color: var(--ink-faint);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
}

.out-panel h2 {
  color: var(--rose-deep);
}

/* ---------------------------------------------------------------- results */

.result-panel {
  width: min(580px, calc(100% - 28px - var(--safe-l) - var(--safe-r)));
}

/* The results thread with a compact contact line (the story card had the big one). */
.result-panel .chat-head {
  flex-direction: row;
  justify-content: center;
  gap: 7px;
  margin-bottom: 6px;
}

.result-panel .chat-head .avatar {
  width: 26px;
  height: 26px;
}

/* Short frames (phones in landscape, laptop windows; shell.js sets the class
   from the frame's height): chat on the left, numbers on the right, buttons
   underneath, so the card never has to scroll. */
.game-frame.compact-result .result-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "eyebrow eyebrow"
    "title title"
    "chat stats"
    "actions actions";
  column-gap: 20px;
  align-items: center;
}

.game-frame.compact-result .result-panel > .eyebrow {
  grid-area: eyebrow;
}

.game-frame.compact-result .result-panel > h2 {
  grid-area: title;
}

.game-frame.compact-result .result-panel > .chat {
  grid-area: chat;
  width: 100%;
  margin-top: 10px;
}

.game-frame.compact-result .result-panel > .result-stats {
  grid-area: stats;
  margin-top: 10px;
  grid-auto-flow: row;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: none;
  row-gap: 6px;
  column-gap: 0;
}

.game-frame.compact-result .result-panel > .panel-actions {
  grid-area: actions;
  margin-top: 12px;
  flex-wrap: nowrap;
}

.game-frame.compact-result .result-stats dt,
.game-frame.compact-result .result-stats dd {
  grid-row: auto;
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  box-shadow: none;
}

.game-frame.compact-result .result-stats dt {
  grid-column: 1;
  border-radius: 12px 0 0 12px;
  font-size: 12px;
}

.game-frame.compact-result .result-stats dd {
  grid-column: 2;
  justify-content: flex-end;
  border-radius: 0 12px 12px 0;
  font-size: 15px;
  text-align: right;
}

/* Short desktop windows (1280x720, 1024x768): a slightly wider card, still
   clear of the hugging pair the engine frames on the right. */
@media (min-width: 1000px) and (min-height: 521px) {
  .game-frame.compact-result .result-panel {
    width: min(620px, calc(100% - 28px - var(--safe-l) - var(--safe-r)));
  }
}

/* One line per stat on cards wide enough for it (phones in landscape from
   640px, and the wider desktop card above): the numbers column is exactly as
   wide as its longest row and the thread takes the rest. Narrower cards keep
   the even split, which leaves the thread more room. */
@media (min-width: 640px) and (max-height: 520px), (min-width: 1000px) and (min-height: 521px) {
  .game-frame.compact-result .result-panel {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .game-frame.compact-result .result-stats dd {
    white-space: nowrap;
  }
}

/* the two of them, cheek to cheek, in the corner of the results card
   (wide screens show the real hug beside the card instead) */
.result-pair {
  position: absolute;
  top: 12px;
  left: 16px;
  width: 68px;
  height: 44px;
  pointer-events: none;
}

.rp-bear {
  position: absolute;
  bottom: 0;
  width: 36px;
  height: 38px;
  filter: drop-shadow(0 2px 2px rgba(118, 25, 69, 0.2));
}

.rp-emilia {
  z-index: 1; /* in front, as in the hug, so his head never hides her face */
  left: 0;
  transform: rotate(9deg);
  transform-origin: 70% 90%;
}

.rp-elijah {
  left: 31px;
  transform: rotate(-9deg);
  transform-origin: 30% 90%;
}

.rp-heart {
  position: absolute;
  z-index: 2;
  top: -2px;
  left: 27px;
  width: 14px;
  height: 14px;
  color: var(--rose);
  stroke: #fff;
  stroke-width: 2.5px;
  paint-order: stroke;
  animation: pair-heart 1.6s ease-in-out infinite;
}

@keyframes pair-heart {
  0%,
  60%,
  100% {
    transform: scale(1);
  }
  72% {
    transform: scale(1.25);
  }
  84% {
    transform: scale(1);
  }
}

/* Wide screens: nudge the card left; the engine frames the hugging pair on the right. */
@media (min-width: 900px) and (min-height: 521px) {
  .result-panel {
    left: 40%;
  }

  .result-pair {
    display: none;
  }
}

.result-stats {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 0;
  margin: 18px 0 0;
  font-variant-numeric: tabular-nums;
}

.result-stats dt {
  grid-row: 1;
  padding: 9px 8px 0;
  border-radius: 14px 14px 0 0;
  background: #fff;
  color: var(--ink-faint);
  font-weight: 900;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}

.result-stats dd {
  grid-row: 2;
  margin: 0;
  padding: 3px 8px 10px;
  border-radius: 0 0 14px 14px;
  background: #fff;
  font-weight: 900;
  font-size: 16px;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 6px 12px rgba(118, 25, 69, 0.06);
}

/* ---------------------------------------------------------------- ending */

.ending-panel {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  /* --cv-*: where the game picture sits inside the frame (shell.js) */
  padding:
    max(calc(var(--cv-t, 0px) + var(--cv-h, 0px) * 0.09), calc(var(--safe-t) + 18px))
    max(calc(var(--cv-r, 0px) + 24px), var(--safe-r))
    max(calc(var(--cv-b, 0px) + 18px), calc(var(--safe-b) + 10px))
    max(calc(var(--cv-l, 0px) + var(--cv-w, 0px) * 0.065), calc(var(--safe-l) + 18px));
  pointer-events: none;
  text-align: left;
}

.ending-lines {
  display: grid;
  gap: 3px;
  max-width: min(calc(var(--cv-w, 1000px) * 0.58), 640px);
}

.ending-line {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(18px, min(3vw, 5.6vh), 33px);
  font-weight: 500;
  line-height: 1.22;
  color: #fff7ea;
  text-shadow: 0 2px 14px rgba(14, 10, 38, 0.75), 0 0 2px rgba(14, 10, 38, 0.5);
  animation: line-in 1400ms ease both;
}

.ending-line.big {
  margin: 2px 0 4px;
  font-size: clamp(28px, min(5.4vw, 10vh), 60px);
  font-weight: 600;
  line-height: 1.05;
}

.ending-line.mrs {
  font-style: italic;
  color: #ffd6e4;
}

.ending-line.secret {
  color: #ffe2a8;
  text-shadow: 0 0 18px rgba(255, 206, 120, 0.45), 0 2px 12px rgba(14, 10, 38, 0.7);
}

.ending-line.hint {
  margin-top: 8px;
  font-family: var(--ui-font);
  font-size: clamp(12px, min(1.6vw, 3.4vh), 15px);
  font-weight: 800;
  color: rgba(255, 247, 234, 0.78);
}

.ending-line.sig {
  margin-top: 8px;
  font-style: italic;
  font-size: clamp(20px, min(3.2vw, 6vh), 36px);
}

.ending-panel .panel-actions {
  margin-top: 18px;
  pointer-events: auto;
  animation: rise-in 600ms ease both;
}

@keyframes line-in {
  from {
    opacity: 0;
    transform: translateY(10px);
    filter: blur(5px);
  }
}

/* ================================================================ touch controls */

.mobile-controls {
  position: absolute;
  z-index: 7;
  inset: 0;
  display: none;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html.touch .mobile-controls {
  display: block;
}

/* Hidden while a menu panel is up, so stray taps never reach the game. */
.game-frame:not([data-panel=""]) .mobile-controls {
  visibility: hidden;
}

.touch-zone {
  position: absolute;
  top: calc(max(var(--edge), var(--safe-t)) + var(--hud-h) + 16px);
  bottom: 0;
  width: 50%;
  pointer-events: auto;
  touch-action: none;
}

.zone-move {
  left: 0;
}

.zone-jump {
  right: 0;
}

.dpad {
  position: absolute;
  left: max(18px, calc(var(--safe-l) + 6px));
  bottom: max(16px, calc(var(--safe-b) + 6px));
  display: flex;
  gap: 8px;
  padding: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 10px 26px rgba(81, 20, 50, 0.12);
  pointer-events: auto;
  touch-action: none;
  transition:
    transform 120ms ease,
    background-color 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease;
}

.dpad[data-dir="-1"] {
  transform: rotate(-3deg);
}

.dpad[data-dir="1"] {
  transform: rotate(3deg);
}

.jump-wrap {
  position: absolute;
  right: max(20px, calc(var(--safe-r) + 8px));
  bottom: max(18px, calc(var(--safe-b) + 8px));
  pointer-events: auto;
  touch-action: none;
}

.control-button {
  position: relative;
  width: 70px;
  height: 70px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 2.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.7), rgba(255, 240, 246, 0.45));
  color: var(--rose-deep);
  box-shadow:
    0 8px 18px rgba(81, 20, 50, 0.2),
    inset 0 -4px 0 rgba(201, 39, 104, 0.1);
  opacity: 0.82;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  transition: transform 90ms ease, background 90ms ease, opacity 220ms ease, box-shadow 90ms ease;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.control-button svg {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.8));
  pointer-events: none;
}

.control-button[data-action="left"] svg {
  transform: scaleX(-1);
}

.control-button.jump {
  width: 92px;
  height: 92px;
  color: var(--mint-dark);
  opacity: 0.74; /* hazards arriving bottom-right read through it */
}

.control-button.jump svg {
  width: 38px;
  height: 38px;
}

.control-button.pressed {
  opacity: 1;
  transform: scale(0.9);
  transition: transform 90ms ease, background 90ms ease, opacity 90ms ease, box-shadow 90ms ease;
  background: radial-gradient(circle at 50% 40%, #fff, rgba(255, 214, 228, 0.95));
  box-shadow:
    0 0 0 7px rgba(255, 255, 255, 0.32),
    0 3px 8px rgba(81, 20, 50, 0.22),
    inset 0 3px 6px rgba(201, 39, 104, 0.18);
}

.control-button.jump.pressed {
  background: radial-gradient(circle at 50% 40%, #fff, rgba(201, 240, 228, 0.95));
}

/* The bear is behind this control (shell.js): fade it so she stays in view.
   Only the buttons fade, so a first-run tip above them stays readable. */
.dpad.see-through {
  background-color: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.see-through .control-button {
  opacity: 0.35;
}

.see-through .control-button.pressed {
  opacity: 0.55;
}

.touch-ripple {
  position: absolute;
  width: 84px;
  height: 84px;
  margin: -42px 0 0 -42px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  pointer-events: none;
  animation: ripple 460ms ease-out forwards;
}

@keyframes ripple {
  from {
    transform: scale(0.3);
    opacity: 0.9;
  }
  to {
    transform: scale(1.25);
    opacity: 0;
  }
}

.touch-tip {
  position: absolute;
  bottom: calc(100% + 14px);
  padding: 7px 12px;
  border-radius: 14px;
  background: rgba(255, 250, 252, 0.96);
  box-shadow: 0 10px 24px rgba(81, 20, 50, 0.22);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px) scale(0.92);
  transition: opacity 320ms ease, transform 380ms var(--spring);
}

.touch-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-top-color: rgba(255, 250, 252, 0.96);
}

.tip-move {
  left: 6px;
}

.tip-move::after {
  left: 54px;
}

.tip-jump {
  right: 0;
}

.tip-jump::after {
  right: 38px;
}

.mobile-controls.show-hint .touch-tip {
  opacity: 1;
  transform: none;
  animation: tip-nudge 1.4s ease-in-out 400ms infinite;
}

@keyframes tip-nudge {
  50% {
    transform: translateY(-4px);
  }
}

/* ================================================================ rotate card */

.rotate-hint {
  display: none;
}

@media (orientation: portrait) and (pointer: coarse) {
  .rotate-hint {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: max(24px, var(--safe-t)) 28px max(24px, var(--safe-b));
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 120' preserveAspectRatio='none'%3E%3Cpath d='M0 60 Q100 20 200 50 T400 40 V120 H0Z' fill='%23f6b2cb'/%3E%3Cpath d='M0 86 Q110 58 220 80 T400 74 V120 H0Z' fill='%23a3dfc9'/%3E%3Crect y='104' width='400' height='16' fill='%2362c0a7'/%3E%3C/svg%3E") bottom / 100% 22vh no-repeat,
      radial-gradient(520px 420px at 50% 40%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 70%),
      linear-gradient(180deg, #ffe7f0 0%, #ffd6e4 60%, #fbc9dc 100%);
    text-align: center;
    pointer-events: auto;
    touch-action: none;
  }

  .mobile-controls,
  .hud {
    visibility: hidden;
  }
}

.rotate-art {
  width: 150px;
  height: 150px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}

.rotate-phone {
  width: 74px;
  height: 128px;
  display: grid;
  place-items: center;
  border: 6px solid var(--rose-deep);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(118, 25, 69, 0.25);
  animation: rotate-phone 2.6s var(--spring) infinite;
}

.rotate-bear {
  width: 52px;
  height: 54px;
  animation: rotate-bear 2.6s var(--spring) infinite;
}

.rotate-title {
  margin: 0;
  color: var(--rose-deep);
  font-size: 24px;
  font-weight: 900;
}

.rotate-sub {
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 19px;
}

/* Phones with Portrait Orientation Lock never turn: say how, after a moment. */
.rotate-lock {
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: 330px;
  margin: 24px 0 0;
  padding: 11px 16px 11px 12px;
  border-radius: 18px;
  border: 1.5px solid rgba(201, 39, 104, 0.14);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 24px rgba(118, 25, 69, 0.1);
  color: var(--ink-soft);
  font-size: 14.5px;
  font-weight: 800;
  line-height: 1.35;
  text-align: left;
  text-wrap: pretty;
  animation: rotate-lock-in 700ms ease 3s both;
}

.rotate-lock-icon {
  flex: none;
  width: 28px;
  height: 28px;
  color: var(--rose-deep);
}

@keyframes rotate-lock-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes rotate-phone {
  0%,
  18% {
    transform: rotate(0deg);
  }
  45%,
  82% {
    transform: rotate(-90deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

@keyframes rotate-bear {
  0%,
  18% {
    transform: rotate(0deg);
  }
  45%,
  82% {
    transform: rotate(90deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

/* ================================================================ phones, tablets, small windows:
   the frame becomes the whole (dynamic) viewport. */

@media (pointer: coarse), (max-width: 900px), (max-height: 560px) {
  html,
  body {
    position: fixed;
    inset: 0;
  }

  body::before {
    display: none;
  }

  .game-shell {
    position: fixed;
    inset: 0;
    min-height: 0;
    padding: 0;
    display: block;
  }

  .game-frame {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .ambient.ready .amb {
    opacity: 1;
    filter: saturate(0.92) brightness(1.03);
  }

  /* a whisper of a veil so the letterbox reads as light, not as level */
  /* a soft falloff at the very screen edges so the bars read as light, not level */
  .ambient::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(40, 12, 32, 0.12), rgba(40, 12, 32, 0) 7%, rgba(40, 12, 32, 0) 93%, rgba(40, 12, 32, 0.12));
  }

  .page-credit {
    display: none;
  }
}

/* phone landscape & other short screens */
@media (max-height: 520px) {
  :root {
    --edge: 10px;
    --hud-h: 36px;
  }

  .hud {
    gap: 8px;
  }

  .hud-cluster {
    gap: 6px;
  }

  .hud-chip {
    font-size: 15px;
    padding: 0 12px 0 9px;
  }

  .berry-icon {
    width: 20px;
    height: 23px;
  }

  .heart-icons svg {
    width: 19px;
    height: 19px;
  }

  .timer {
    min-width: 74px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  /* Several powers at once fold onto two compact lines (between powers,
     never inside a timer) instead of squeezing the progress bar. */
  .power-chip {
    height: auto;
    min-height: var(--hud-h);
    padding-top: 3px;
    padding-bottom: 3px;
  }

  .power-chip.has-text .power-text {
    max-width: 10.6em;
    white-space: normal;
    font-size: 13px;
    line-height: 1.08;
  }

  .progress-track {
    min-width: 110px;
    margin: 0 16px 0 8px;
    height: 11px;
  }

  .progress-bear.hop {
    animation-name: bear-pop;
  }

  .menu-panel {
    padding: 18px 22px;
    border-radius: 22px;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 12px;
  }

  .eyebrow-script {
    font-size: 21px;
    margin-bottom: 0;
  }

  h2 {
    font-size: clamp(22px, 7.4vh, 32px);
  }

  .panel-copy {
    margin-top: 8px;
    font-size: 14.5px;
    line-height: 1.38;
  }

  .panel-actions {
    margin-top: 14px;
  }

  .primary-button,
  .secondary-button {
    min-height: 44px;
    padding: 0 20px;
    font-size: 16px;
  }

  .primary-button.big {
    min-height: 50px;
    font-size: 19px;
  }

  .title-panel {
    width: min(600px, calc(100% - 32px - var(--safe-l) - var(--safe-r)));
    padding: 16px 28px 16px;
  }

  .title-panel .panel-copy {
    max-width: 46ch;
    font-size: 15px;
  }

  h1 {
    font-size: clamp(34px, 12vh, 58px);
  }

  .title-progress,
  .a2hs-tip {
    margin-top: 10px;
  }

  .map-panel {
    --scene-h: clamp(62px, 19vh, 96px);
    --gap: 14px;
    width: min(860px, calc(100% - 20px - var(--safe-l) - var(--safe-r)));
    padding: 14px 18px 14px;
  }

  .map-total {
    padding: 6px 12px;
    font-size: 15px;
  }

  .world-list {
    margin-top: 12px;
  }

  .world-num {
    width: 28px;
    height: 28px;
    margin-top: -15px;
    font-size: 13px;
  }

  .world-title {
    font-size: 14px;
  }

  .world-quote {
    font-size: 15px;
  }

  .world-meta {
    font-size: 12px;
    margin-top: 1px;
  }

  .world-pin,
  .world-pin svg {
    width: 34px;
    height: 34px;
  }

  .world-pin {
    margin-left: -17px;
    top: -8px;
  }

  .scene-badge {
    top: 5px;
    left: 5px;
    width: 22px;
    height: 22px;
  }

  .scene-lock span {
    width: 32px;
    height: 32px;
  }

  .chat {
    margin-top: 10px;
  }

  .chat-head {
    flex-direction: row;
    justify-content: center;
    gap: 7px;
    margin-bottom: 6px;
  }

  .chat-head .avatar {
    width: 24px;
    height: 24px;
  }

  .bubble {
    font-size: 15.5px;
    padding: 7px 13px 8px;
  }

  .chat-status {
    font-size: 12px;
  }

  .result-pair {
    top: 10px;
    left: 14px;
  }

  .world-pin.pair {
    width: 66px;
    margin-left: -33px;
  }

  .world-pin.pair svg {
    width: 34px;
    height: 35px;
  }

  .world-pin.pair .pin-mr {
    left: 30px;
  }

  .pause-goose {
    margin-top: 8px;
    font-size: 15px;
  }

  .intro-panel {
    width: min(460px, calc(100% - 32px - var(--safe-l) - var(--safe-r)));
  }

  .result-panel {
    width: min(700px, calc(100% - 24px - var(--safe-l) - var(--safe-r)));
  }

  .pause-tip {
    margin-top: 10px;
  }

  .control-button {
    width: 66px;
    height: 66px;
  }

  .control-button.jump {
    width: 86px;
    height: 86px;
  }

  .controls-hint {
    font-size: 14px;
  }
}

/* very short (iPhone SE landscape with toolbars, etc.) */
@media (max-height: 400px) {
  .chat-head {
    display: none;
  }

  .panel-actions {
    margin-top: 12px;
  }

  .title-panel .panel-copy {
    font-size: 14px;
  }

  .world-quote {
    font-size: 14px;
  }

  .map-panel {
    --scene-h: clamp(56px, 18vh, 80px);
  }

  .control-button {
    width: 64px;
    height: 64px;
  }

  .control-button.jump {
    width: 82px;
    height: 82px;
  }
}

@media (max-height: 380px) {
  .ending-line {
    font-size: clamp(16px, min(3vw, 5.1vh), 30px);
  }

  .ending-line.big {
    font-size: clamp(24px, min(5vw, 9vh), 52px);
  }

  .ending-line.sig {
    margin-top: 4px;
  }

  .ending-panel .panel-actions {
    margin-top: 10px;
  }
}

/* narrow windows (non-touch portrait browsers, split screen) */
@media (max-width: 620px) {
  .world-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .world-list > li:nth-child(2)::after {
    display: none;
  }

  .hud-chip.timer {
    display: none;
  }

  .result-stats dd,
  .game-frame.compact-result .result-stats dd {
    font-size: 14px;
  }
}

@media (max-width: 720px) {
  .progress-track {
    margin: 0 14px 0 6px;
  }
}

/* small phones in landscape (iPhone SE): the power chip drops its sparkle and
   folds a little tighter, so the pause button never leaves the screen */
@media (max-width: 720px) and (max-height: 520px) {
  .power-chip.has-text {
    padding-left: 12px;
  }

  .power-chip.has-text .power-icon {
    display: none;
  }

  .power-chip.has-text .power-text {
    max-width: 9em;
    font-size: 12.5px;
  }

  .progress-track {
    min-width: 100px;
  }
}

/* big desktop screens: a touch more generous */
@media (min-width: 1500px) and (min-height: 900px) {
  .menu-panel {
    padding: 34px 36px;
  }

  .map-panel {
    --scene-h: 132px;
    width: min(980px, calc(100% - 48px));
  }

  .hud-chip {
    font-size: 17px;
  }
}

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

  #ending-replay-button.has-secret {
    animation: none;
    box-shadow:
      0 4px 0 var(--berry-dark),
      0 12px 26px rgba(185, 19, 79, 0.3),
      0 0 0 6px rgba(255, 158, 196, 0.3),
      inset 0 2px 0 rgba(255, 255, 255, 0.35);
  }
}
