@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("assets/fonts/fredoka-500-700-latin.woff2?v=fd7ead9100b0") format("woff2");
}

:root {
  --ink: #183547;
  --cream: #fff7dd;
  --pink: #ef4f8b;
  --pink-dark: #a9265d;
  --aqua: #28c8df;
  --blue: #167caa;
  --sand: #f4cc78;
  --panel: rgba(255, 250, 230, 0.9);
  /* Extra breathing room above the device safe area for bottom overlays. */
  --bottom-safe-zone: 12px;
}

* {
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

img, video, canvas {
  -webkit-user-drag: none;
  user-drag: none;
}

html, body {
  min-height: 100%;
  /* The game owns touch gestures; zooming would move controls off screen. */
  touch-action: none;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Fredoka", "Avenir Next", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 14% 12%, #fff29a 0 46px, #ffd95c 47px 70px, transparent 72px),
    linear-gradient(160deg, #8ceaff 0%, #28bddd 50%, #067da5 100%);
  overflow: hidden;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page {
  width: 100vw;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.arcade {
  position: relative;
  width: 100%;
  height: 100%;
}

.game-loader {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 28px;
  color: #17425a;
  background:
    radial-gradient(circle at 50% 38%, rgba(255,255,255,.42), transparent 30%),
    linear-gradient(180deg, #75bdf0 0%, #61afea 56%, #f4d28d 100%);
  transition: opacity 320ms ease, visibility 320ms ease;
}

.game-loader.is-ready {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-content {
  display: grid;
  justify-items: center;
  width: min(260px, 82vw);
  padding: 28px 26px 24px;
  border: 3px solid rgba(255,255,255,.88);
  border-radius: 26px;
  background: rgba(255, 248, 222, .9);
  box-shadow: 0 14px 0 rgba(33, 113, 140, .16), 0 24px 48px rgba(19, 83, 112, .18);
}

.loader-bone {
  display: block;
  width: 132px;
  margin: 2px 0 17px;
  filter: drop-shadow(0 5px 3px rgba(111, 72, 29, .18));
  animation: loader-hop 900ms ease-in-out infinite alternate;
  will-change: transform;
}

.loader-bone img {
  display: block;
  width: 100%;
  height: auto;
}

.loader-copy {
  margin: 0 0 13px;
  color: var(--pink-dark);
  font-size: .78rem;
  font-weight: 1000;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.loader-track {
  width: 100%;
  height: 11px;
  overflow: hidden;
  border: 2px solid #b78346;
  border-radius: 999px;
  background: #ead7a8;
}

.loader-progress {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ef4f8b, #ff83ac);
  transform: scaleX(.04);
  transform-origin: left center;
  transition: transform 180ms ease;
}

@keyframes loader-hop {
  from { transform: translateY(0) rotate(-3deg); }
  to { transform: translateY(-9px) rotate(3deg); }
}

.asset-picture { display: contents; }

.help-links { display: none; }
.overlay[data-kind="help"] .help-links { display: flex; justify-content: center; gap: 24px; margin-top: 16px; grid-column: 2; font-size: 14px; }
.help-links a { color: #754029; text-underline-offset: 3px; }
.info-dialog { width: min(740px, 94vw); height: 85dvh; max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 32px); padding: 0; border: 3px solid white; border-radius: 20px; background: #fff8e9; }
.info-dialog::backdrop { background: #10283ab3; }
.info-dialog[open] { display: flex; flex-direction: column; }
.info-dialog header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; color: #493638; }
.info-dialog button { font: inherit; padding: 8px 18px; border: 0; border-radius: 12px; color: white; background: #b92a67; cursor: pointer; }
.info-dialog iframe { flex: 1; min-height: 0; width: 100%; border: 0; }

.start-screen {
  --intro-scene-height: 1080;
  --intro-sky-height: 800;
  --intro-media-height: 2280;
  position: absolute;
  inset: 0;
  z-index: 10;
  overflow: clip;
  padding: 0;
  background: linear-gradient(180deg, #73cdec 0%, #64c7e7 48%, #f0cf91 72%, #d7a45e 100%);
  transition: opacity 420ms ease, visibility 420ms ease, transform 420ms cubic-bezier(.2,.8,.2,1);
}

.start-background-poster,
.start-background-video {
  position: absolute;
  inset: calc(-1 * max(100% * var(--intro-sky-height) / var(--intro-scene-height), 100vw * var(--intro-sky-height) / 1920)) 0 auto;
  z-index: 0;
  width: 100%;
  height: calc(100% * var(--intro-media-height) / var(--intro-scene-height));
  border: 0;
  object-fit: cover;
  object-position: center top;
  transform: translateY(min(0px, calc((100svh - 100vw * .5625) / 2)));
  transform-origin: center;
  transition: opacity 280ms ease;
  pointer-events: none;
}

.start-background-video {
  opacity: 0;
  transition: opacity 200ms ease;
  will-change: opacity;
}

.start-screen.video-playing.intro-video-started .start-background-video {
  opacity: 1;
}

.start-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(1.025);
}

.start-screen::before,
.start-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transition: opacity 1000ms cubic-bezier(.4, 0, .2, 1);
}
.start-screen::before {
  background: linear-gradient(
    180deg,
    rgba(115, 205, 236, .98) 0%,
    rgba(115, 205, 236, .42) 7%,
    transparent 15%,
    transparent 80%,
    rgba(231, 191, 124, .34) 90%,
    rgba(215, 164, 94, .96) 100%
  );
}
.start-screen::after {
  background: linear-gradient(110deg, rgba(255, 237, 188, .07), transparent 48%);
}

.start-scene {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: block;
  padding:
    max(20px, env(safe-area-inset-top))
    max(26px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(26px, env(safe-area-inset-left));
  opacity: 1;
  transition: opacity 260ms ease, visibility 260ms ease;
}

.start-screen.video-playing .start-scene {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-loading-stage {
  z-index: 4;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  animation: none;
  transition: opacity 160ms ease, visibility 160ms ease, transform 220ms cubic-bezier(.2, .8, .2, 1);
  transform: translateY(8px);
}

.start-screen.video-loading .intro-loading-stage {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.intro-loading-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 17px 12px;
  border: 3px solid rgba(169, 33, 91, .82);
  border-radius: 20px;
  color: #6f2948;
  background: rgba(255, 250, 230, .94);
  box-shadow: 0 5px 0 rgba(143, 30, 80, .7), 0 10px 22px rgba(82, 44, 34, .18);
  font-size: clamp(1rem, 2vw, 1.22rem);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.intro-loading-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 14px;
}

.intro-loading-dots i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4f8b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45);
  animation: intro-loading-hop 720ms ease-in-out infinite alternate;
}

.intro-loading-dots i:nth-child(2) { animation-delay: 120ms; }
.intro-loading-dots i:nth-child(3) { animation-delay: 240ms; }

@keyframes intro-loading-hop {
  from { transform: translateY(3px); opacity: .58; }
  to { transform: translateY(-3px); opacity: 1; }
}

/* Every video caption uses the same compact background, over the intro and ending. */
.intro-subtitle.caption-overlay,
.ending-scene p {
  left: 50%;
  right: auto;
  width: max-content;
  max-width: min(84%, 920px);
  padding: .28em .8em .34em;
  border-radius: 16px;
  background: rgba(40, 24, 16, .74);
  color: #fff8e6;
  text-shadow: none;
  translate: -50% 0;
}
.intro-subtitle {
  display: none;
}

/* Timed intro captions overlay the video in every orientation. */
.intro-subtitle.caption-overlay {
  position: absolute;
  bottom: calc(max(28px, calc(env(safe-area-inset-bottom, 0px) + 18px)) + var(--bottom-safe-zone));
  z-index: 4;
  display: block;
  margin: 0;
  font-size: clamp(1.05rem, 2.2vw, 1.8rem);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-wrap: balance;
  opacity: 0;
  visibility: hidden;
  transition: opacity 140ms ease, visibility 140ms ease;
  pointer-events: none;
}

.intro-subtitle.caption-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* Top controls share one alignment and safe-area spacing. */
.arcade {
  --control-top: 18px;
  --control-side: 18px;
}
.hud,
.screen-actions,
.intro-skip-stage {
  position: absolute;
  top: max(var(--control-top), env(safe-area-inset-top));
}
.hud,
.intro-skip-stage { right: max(var(--control-side), env(safe-area-inset-right)); }
.screen-actions { left: max(var(--control-side), env(safe-area-inset-left)); }
@media (max-width: 780px) {
  .arcade {
    --control-top: 14px;
    --control-side: 12px;
  }
}

/* Skip shares the sound/help controls' treatment, with a text-sized shape. */
.intro-skip-stage {
  z-index: 4;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 140ms ease, visibility 140ms ease;
}
.start-screen.video-playing .intro-skip-stage {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.icon-button.intro-skip-button,
.icon-button.ending-replay-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  min-width: 64px;
  padding: 0 14px;
  border-radius: 12px;
  font-weight: 700;
}

.start-logo-art {
  position: absolute;
  left: 50%;
  top: 22%;
  display: block;
  width: min(58vw, 760px);
  max-width: calc(100% - 36px);
  max-height: 38vh;
  object-fit: contain;
  translate: -50% -50%;
  filter: drop-shadow(0 13px 14px rgba(72, 42, 26, .2));
  animation: logo-arrive 700ms cubic-bezier(.2,.9,.25,1.15) both;
}

.start-stage {
  position: absolute;
  left: 50%;
  width: auto;
  max-width: calc(100% - 36px);
  display: flex;
  align-items: center;
  justify-content: center;
  translate: -50% 0;
}

.start-button-art,
.play-button {
  border-style: solid;
  border-color: #a9215b;
  color: #fff7e7;
  background: linear-gradient(180deg, #ff72aa 0%, #ed4387 56%, #d52c70 100%);
  font-weight: 1000;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(136, 31, 74, .34);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}
.start-button-art:hover,
.play-button:hover {
  filter: brightness(1.04);
  transform: translateY(-2px);
}

.start-button-art {
  min-width: var(--button-min-width, 238px);
  min-height: var(--button-min-height, auto);
  padding-block: var(--button-padding-block, 14px 15px);
  padding-inline: var(--button-padding-inline, 38px);
  border-width: var(--button-border-width, 5px);
  border-radius: var(--button-radius, 28px);
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, .34),
    inset 0 -5px 0 rgba(151, 22, 79, .25),
    0 7px 0 #8f1e50,
    0 12px 22px rgba(82, 44, 34, .22);
  font-size: var(--button-font-size, clamp(1.7rem, 2.8vw, 2.45rem));
  letter-spacing: .035em;
}

.start-button-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
}

.start-button-rays {
  position: absolute;
  top: 50%;
  width: 58px;
  height: 58px;
  translate: 0 -50%;
  pointer-events: none;
}
.start-button-rays-left { right: calc(100% + 5px); }
.start-button-rays-right {
  left: calc(100% + 5px);
  transform: scaleX(-1);
}
.start-button-rays i {
  position: absolute;
  right: 0;
  width: 31px;
  height: 8px;
  border: 2px solid #a9215b;
  border-radius: 999px;
  background: #f65394;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35);
}
.start-button-rays i:nth-child(1) {
  top: 4px;
  transform: rotate(38deg);
  transform-origin: right center;
}
.start-button-rays i:nth-child(2) {
  top: 25px;
  right: 8px;
}
.start-button-rays i:nth-child(3) {
  bottom: 4px;
  transform: rotate(-38deg);
  transform-origin: right center;
}

/* Announce the action once the loader reveals it; replay when Home is shown. */
.start-announcing .start-button-wrap {
  animation: start-ta-da 850ms 360ms cubic-bezier(.2, .8, .25, 1) both;
}
.start-announcing .start-button-rays i {
  --ray-angle: 0deg;
  --ray-open-angle: 0deg;
  --ray-lift: 0px;
  transform-origin: right center;
  animation: start-ray-fan 850ms 360ms ease-in-out both;
}
.start-announcing .start-button-rays i:nth-child(1) {
  --ray-angle: 38deg;
  --ray-open-angle: 44deg;
  --ray-lift: -2px;
}
.start-announcing .start-button-rays i:nth-child(3) {
  --ray-angle: -38deg;
  --ray-open-angle: -44deg;
  --ray-lift: 2px;
}

@keyframes start-ta-da {
  0%, 100% { transform: translateY(0) scale(1) rotate(0); }
  20% { transform: translateY(3px) scale(.94, .9) rotate(-2deg); }
  45% { transform: translateY(-10px) scale(1.1, 1.08) rotate(2deg); }
  68% { transform: translateY(1px) scale(.98, .96) rotate(-1deg); }
  84% { transform: translateY(-3px) scale(1.025) rotate(0); }
}

@keyframes start-ray-fan {
  0%, 100% { transform: translateX(0) rotate(var(--ray-angle)); }
  45% { transform: translate(-5px, var(--ray-lift)) rotate(var(--ray-open-angle)); }
}

@media (prefers-reduced-motion: reduce) {
  .start-announcing .start-button-wrap,
  .start-announcing .start-button-rays i { animation: none !important; }
}

.start-button-art:hover {
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, .36),
    inset 0 -5px 0 rgba(151, 22, 79, .25),
    0 9px 0 #8f1e50,
    0 15px 24px rgba(82, 44, 34, .24);
}

.start-button-art:active {
  transform: translateY(5px);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, .25),
    inset 0 -3px 0 rgba(151, 22, 79, .18),
    0 2px 0 #8f1e50,
    0 7px 14px rgba(82, 44, 34, .2);
}

.start-button-art:focus-visible {
  outline: 5px solid #fff;
  outline-offset: 5px;
}

@keyframes prop-float {
  from { translate: 0 0; }
  to { translate: 0 -7px; }
}

@keyframes logo-arrive { from { opacity: 0; transform: translateY(-24px) scale(.9) rotate(-2deg); } }

.cabinet {
  position: relative;
  width: 100%;
  height: 100%;
}

.cabinet::before {
  content: none;
}

.screen {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  background: #74e0f5;
  contain: layout paint;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hud,
.icon-button {
  height: 36px;
  border: 1px solid rgba(255,255,255,.58);
}

.hud {
  z-index: 2;
  width: min(230px, calc(100% - 36px));
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(17, 54, 74, .5);
  box-shadow: 0 8px 26px rgba(8, 48, 68, .18);
  backdrop-filter: blur(14px) saturate(1.1);
  pointer-events: none;
}

.score-card, .best-card {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3px 10px;
  color: #fff;
  background: transparent;
  text-align: center;
}

.best-card { border-left: 1px solid rgba(255,255,255,.3); }

.score-card small, .best-card small {
  display: block;
  white-space: nowrap;
  color: #ffe08d;
  font-size: 9px;
  line-height: 1;
  font-weight: 1000;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.score-card strong, .best-card strong {
  display: block;
  margin-top: 1px;
  white-space: nowrap;
  font-family: "Fredoka", "Avenir Next", sans-serif;
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.screen-actions {
  z-index: 14;
  display: flex;
  gap: 6px;
}

.arcade.modal-open .screen-actions {
  pointer-events: none;
}

.arcade:not(.playing) #pauseButton { display: none; }

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  padding: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(15, 55, 76, .36);
  box-shadow: 0 4px 14px rgba(8, 48, 68, .11);
  font-size: .88rem;
  backdrop-filter: blur(9px);
  cursor: pointer;
}

.icon-button svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button .icon-state-sound path:first-child,
.icon-button .icon-state-muted path:first-child {
  fill: currentColor;
  stroke: none;
}

#soundButton[data-icon="sound"] .icon-state-muted,
#soundButton[data-icon="muted"] .icon-state-sound,
#pauseButton[data-icon="pause"] .icon-state-play,
#pauseButton[data-icon="play"] .icon-state-pause {
  display: none;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: rgba(255,255,255,.92);
  background: rgba(15, 55, 76, .58);
  outline: 0;
}

.icon-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(255, 224, 141, .72), 0 4px 14px rgba(8, 48, 68, .18);
}

.icon-button.ending-replay-button:focus-visible {
  box-shadow: 0 4px 14px rgba(8, 48, 68, .18);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  padding: 28px;
  /* The modal is a fixed, non-scrolling interaction surface. Safari can
     still smart-zoom its card after rapid taps unless the modal itself
     explicitly owns every touch gesture. */
  touch-action: none;
  background: linear-gradient(180deg, rgba(19, 80, 113, .1), rgba(4, 64, 92, .38));
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  overflow-y: auto;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.card {
  width: min(320px, 100%);
  padding: 26px 24px 22px;
  border: 6px solid #fff;
  border-radius: 34px;
  text-align: center;
  background: #fffae6;
  box-shadow: 0 5px 0 rgba(121, 204, 235, .65), 0 18px 32px rgba(1, 42, 61, .28);
  transform: none;
}

/* Confetti sits above the dimmer, below the opaque record card. */
.celebration-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.celebration-confetti i {
  position: absolute;
  top: 0;
  left: 0;
  width: 9px;
  height: 15px;
  border-radius: 2px;
}
.overlay .card { position: relative; z-index: 1; }
.result-ruby { display: none; }
.overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) {
  padding-top: 90px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}
.overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) .card {
  width: min(360px, 100%);
  padding: 20px 24px 22px;
  margin: auto;
}
.overlay[data-kind="pause"] .paused-ruby,
.overlay[data-kind="record"] .record-trophy,
.overlay[data-kind="result"] .retry-ruby {
  display: block;
  width: min(250px, 34vh);
  height: auto;
  margin: -94px auto 8px;
}

.card .kicker {
  margin: 0 0 14px;
  color: var(--pink-dark);
  font-size: .7rem;
  font-weight: 1000;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.card h2 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .03em;
  margin: 0;
  color: #17425a;
  font-family: "Fredoka", "Avenir Next", sans-serif;
  font-weight: 700;
  font-size: clamp(2.3rem, 10vw, 4.2rem);
  line-height: .9;
  letter-spacing: -.06em;
}

.help-visuals { display: none; }

.overlay[data-kind="help"] .card {
  width: min(400px, 100%);
  padding: 24px 24px 26px;
  margin: auto;
  transform: none;
}

.overlay[data-kind="help"] .card h2 {
  color: #ef3f83;
  font-size: clamp(1.8rem, 7.5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.1;
  text-transform: uppercase;
}

.overlay[data-kind="help"] .help-visuals {
  display: grid;
  place-items: center;
  height: clamp(160px, 23vh, 218px);
  margin: 0 auto 22px;
}

.help-phone-ruby { position: relative; display: block; width: min(280px, 100%); aspect-ratio: 1; filter: drop-shadow(0 8px 6px #0d3a731c); }
.help-phone-base { display: block; width: 100%; height: 100%; background: url("assets/images/ruby-help-phone.png?v=fd7ead9100b0") 0 0 / 100% 100% no-repeat; background-image: image-set(url("assets/images/ruby-help-phone.webp?v=fd7ead9100b0") type("image/webp"), url("assets/images/ruby-help-phone.png?v=fd7ead9100b0") type("image/png")); }
.help-phone-screen { position: absolute; left: 38.6%; top: 50%; width: 22.3%; height: 42.1%; display: flex; align-items: center; pointer-events: none; }
.help-phone-cue { display: grid; place-items: center; width: 50%; color: #fff; font: 700 clamp(15px, 4.5vw, 23px)/1 sans-serif; opacity: .2; text-shadow: 0 1px 3px #124f7370; }
.help-demonstrating .help-phone-cue { animation: help-phone-arrow 4s ease-in-out infinite; }
.help-demonstrating .help-phone-right { animation-delay: -2s; }
@keyframes help-phone-arrow { 0%, 40%, 100% { opacity: .2; } 12%, 28% { opacity: 1; } }

.card p {
  margin: 14px 0 18px;
  font-weight: 750;
  line-height: 1.45;
  text-wrap: pretty;
}

.overlay[data-kind="help"] #overlayCopy {
  max-width: 30ch;
  margin: 16px auto 24px;
  color: #183547;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
}

.play-button {
  width: 100%;
  padding: 13px 20px 14px;
  border-width: 4px;
  border-radius: 22px;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, .34),
    inset 0 -4px 0 rgba(151, 22, 79, .25),
    0 6px 0 #8f1e50,
    0 10px 18px rgba(82, 44, 34, .2);
  font-size: 1.18rem;
  letter-spacing: .04em;
}
.play-button:hover {
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, .36),
    inset 0 -4px 0 rgba(151, 22, 79, .25),
    0 8px 0 #8f1e50,
    0 13px 20px rgba(82, 44, 34, .22);
}
.play-button:active {
  transform: translateY(4px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .25),
    inset 0 -2px 0 rgba(151, 22, 79, .18),
    0 2px 0 #8f1e50,
    0 6px 12px rgba(82, 44, 34, .18);
}
.play-button:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 4px;
}

.home-link {
  display: block;
  margin: 17px auto 0;
  padding: 3px 9px;
  border: 0;
  color: var(--pink-dark);
  background: transparent;
  font: inherit;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: .035em;
  cursor: pointer;
  opacity: .88;
  transition: color 120ms ease, opacity 120ms ease;
}
.home-link:hover { color: #9e2458; opacity: 1; }
.home-link:focus-visible { outline: 3px solid rgba(223, 63, 123, .42); outline-offset: 3px; border-radius: 5px; }
.home-link.hidden { display: none; }

@media (min-width: 781px) {
  .start-logo-art {
    top: 22%;
    width: min(58vw, 760px);
    max-height: 38vh;
  }
}

@media (max-width: 780px) {
  .hud {
    width: min(168px, calc(100% - 118px));
    border-color: rgba(255,255,255,.34);
    border-radius: 13px;
    background: rgba(15, 55, 76, .34);
    box-shadow: 0 5px 16px rgba(8, 48, 68, .11);
    backdrop-filter: blur(9px) saturate(1.05);
  }
  .score-card, .best-card { padding: 2px 8px; }
  .best-card { border-left-color: rgba(255,255,255,.2); }
  .score-card small, .best-card small {
    font-size: .5rem;
    letter-spacing: .085em;
  }
  .score-card strong, .best-card strong {
    margin-top: 1px;
    font-size: clamp(.875rem, 4vw, 1rem);
  }
  .screen-actions {
    gap: 5px;
  }
}

@media (orientation: portrait) {
  .start-screen {
    --intro-video-top: clamp(42px, 6svh, 64px);
    --intro-video-bottom: clamp(64px, 8svh, 92px);
    background: linear-gradient(
      180deg,
      #86d4ef 0%,
      #78cfea 16%,
      #71cbe8 50%,
      #efd293 78%,
      #dfb56d 100%
    );
  }
  .start-background-poster,
  .start-background-video {
    inset: calc(var(--intro-video-top) - max((100% - var(--intro-video-top) - var(--intro-video-bottom)) * var(--intro-sky-height) / var(--intro-scene-height), 100vw * var(--intro-sky-height) / 1920)) 0 auto;
    width: 100%;
    height: calc((100% - var(--intro-video-top) - var(--intro-video-bottom)) * var(--intro-media-height) / var(--intro-scene-height));
    object-position: center top;
    transform: none;
    -webkit-mask-image: none;
    mask-image: none;
  }
  .start-screen::before {
    background: linear-gradient(
      180deg,
      rgba(134, 212, 239, 1) 0%,
      rgba(134, 212, 239, .74) 6%,
      transparent 14%,
      transparent 82%,
      rgba(239, 210, 147, .42) 91%,
      rgba(223, 181, 109, 1) 100%
    );
  }
  .start-scene {
    padding:
      max(14px, env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      max(18px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
  }
  .start-logo-art {
    top: 18%;
    width: min(82vw, 500px);
    max-height: 29vh;
  }
  .start-button-art {
    --button-border-width: 3px;
    --button-radius: 20px;
  }
}

/* Shared portrait colours and crop; geometry varies by available space. */
@media (max-width: 1100px) and (orientation: portrait) {
  .start-screen {
    background: linear-gradient(
      180deg,
      #61afea 0%,
      #61afea 32%,
      #69b8e8 57%,
      #efd293 78%,
      #dfb56d 100%
    );
  }
  .start-screen::before {
    background: linear-gradient(
      180deg,
      rgba(97, 175, 234, 1) 0%,
      rgba(97, 175, 234, .72) 18%,
      transparent 31%,
      transparent 100%
    );
  }
  .start-background-poster,
  .start-background-video { object-position: 51.5% top; }
}

@media (min-width: 600px) and (max-width: 1100px) and (orientation: portrait) {
  .start-screen {
    --intro-video-top: clamp(250px, 32svh, 430px);
    --intro-video-bottom: clamp(160px, 18svh, 210px);
  }
  .start-logo-art {
    left: 50%;
    top: 18%;
    width: min(58vw, 480px);
    max-height: 25vh;
  }
}

@media (max-width: 599px) and (orientation: portrait) {
  .start-screen {
    --home-content-offset: clamp(20px, 3svh, 28px);
    --intro-video-top: calc(clamp(192px, 30svh, 255px) + var(--home-content-offset));
    --intro-video-bottom: calc(clamp(112px, 18svh, 152px) - var(--home-content-offset));
  }
  .start-logo-art {
    left: 50%;
    /* The logo is centred here; allow half its maximum height below the island. */
    top: max(calc(14.8% + var(--home-content-offset) + 20px), calc(env(safe-area-inset-top, 0px) + 32px + 11.5vh));
    width: min(68vw, 330px);
    max-height: 23vh;
  }
  .start-button-art {
    position: relative;
    z-index: 1;
    --button-min-width: min(160px, 44vw);
    --button-padding-block: 9px;
    --button-padding-inline: 16px;
    --button-font-size: clamp(1.32rem, 5.8vw, 1.58rem);
  }
  .start-button-rays {
    z-index: 0;
    scale: .48;
  }
  .start-button-rays-left { right: calc(100% - 10px); }
  .start-button-rays-right { left: calc(100% - 10px); }
}

/* Landscape videos fill the viewport without the portrait framing gradients. */
@media (orientation: landscape) {
  .start-screen { background: #61afea; }
}

@media (min-width: 1101px), (min-width: 600px) and (min-height: 600px) and (orientation: landscape) {
  .start-screen {
    --wide-logo-centre-y: max(clamp(225px, calc(20vh + 50px), 265px), calc(env(safe-area-inset-top, 0px) + 180px));
    background: #61afea;
  }
  .start-logo-art {
    left: max(80px, calc(env(safe-area-inset-left, 0px) + 80px));
    top: var(--wide-logo-centre-y);
    width: clamp(420px, 33.7vw, 580px);
    height: auto;
    max-width: none;
    max-height: 42vh;
    translate: 0 -50%;
  }
  .start-stage {
    top: auto;
    right: max(80px, calc(env(safe-area-inset-right, 0px) + 80px));
    left: auto;
    max-width: none;
    translate: 0 0;
  }
  .start-button-art {
    --button-border-width: 4px;
    --button-radius: 22px;
    --button-font-size: clamp(1.35rem, 2vw, 1.85rem);
  }
  .start-button-rays {
    scale: .62;
  }
}

@media (min-width: 600px) and (max-width: 1100px) and (min-height: 600px) and (orientation: landscape) {
  .start-logo-art {
    left: max(24px, calc(env(safe-area-inset-left, 0px) + 24px));
    top: calc(var(--wide-logo-centre-y) - 50px);
    width: clamp(340px, 35vw, 380px);
  }
}

@media (max-height: 620px) and (min-aspect-ratio: 5 / 6) {
  .start-scene {
    padding-block: 12px;
  }
  .start-logo-art {
    width: min(62vw, 520px);
    max-height: 25vh;
  }
  .start-button-art {
    --button-min-width: 160px;
    --button-padding-block: 9px;
    --button-padding-inline: 24px;
    --button-font-size: 1.45rem;
  }
}

@media (orientation: landscape) and (max-height: 599px) {
  .start-logo-art {
    left: max(18px, env(safe-area-inset-left));
    top: max(58px, calc(env(safe-area-inset-top) + 44px));
    width: min(32vw, 300px);
    max-height: 46svh;
    translate: 0 0;
  }
  .start-scene .start-button-art {
    --button-min-width: 132px;
    --button-min-height: 44px;
    --button-padding-block: 8px;
    --button-padding-inline: 18px;
    --button-border-width: 3px;
    --button-radius: 18px;
    --button-font-size: 1.2rem;
  }
  .start-scene .start-button-rays { scale: .6; }
  .start-stage {
    left: auto;
    right: max(72px, env(safe-area-inset-right));
    translate: 0 0;
  }
}

/* Portrait reserves clear space for the logo and Start before playback. */
@media (min-width: 1101px), (orientation: landscape) {
  .start-screen::before,
  .start-screen::after {
    background: none;
    opacity: 0;
  }
  .start-screen .start-background-poster,
  .start-screen .start-background-video {
    inset: calc(-1 * max(100% * var(--intro-sky-height) / var(--intro-scene-height), 100vw * var(--intro-sky-height) / 1920)) 0 auto;
    height: calc(100% * var(--intro-media-height) / var(--intro-scene-height));
    object-position: center top;
    transform: translateY(min(0px, calc((100svh - 100vw * .5625) / 2)));
    -webkit-mask-image: none;
    mask-image: none;
  }
  .start-screen.video-playing .start-scene {
    opacity: 1;
    visibility: visible;
    pointer-events: none;
  }
  .start-screen.video-playing .start-scene .start-stage {
    opacity: 0;
    visibility: hidden;
  }
}
/* The matching still and video expand together as the framing fades away. */
.start-screen.video-playing::before,
.start-screen.video-playing::after {
  opacity: 0;
}
/* Sky and beach extensions are baked into the media; zoom one picture. */
.intro-media { position: absolute; inset: 0; }
@media (max-width: 1100px) and (orientation: portrait) {
  .intro-media {
    transform: translateY(0px) scale(1);
    transform-origin: 50% var(--intro-video-top);
    transition: transform 1000ms cubic-bezier(.4, 0, .2, 1);
  }
  .start-screen::before { background: none; }
  .start-screen::after { background: none; }
  .start-screen.video-playing .intro-media {
    transform: translateY(calc(-1 * var(--intro-video-top))) scale(var(--intro-camera-scale, 1));
  }
  .start-screen.video-playing .start-background-poster,
  .start-screen.video-playing .start-background-video {
    object-position: 51.5% top;
  }
}

@media (max-height: 650px) {
  .play-button { padding-block: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .help-phone-cue { animation: none !important; opacity: 1; }
}

/* Result cards share the same expressive typography and overlapping portrait. */
.overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) .kicker {
  color: #ef3f83;
  font-size: clamp(1.5rem, 6.8vw, 2rem);
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.1;
  margin: 2px 0 12px;
}
.overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) h2 {
  color: #12394f;
  font-size: clamp(3.1rem, 14vw, 4.6rem);
  letter-spacing: -.045em;
  line-height: 1;
}
.overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) #overlayCopy {
  max-width: 23ch;
  margin: 14px auto 22px;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.35;
  color: #183547;
}
.overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) .play-button {
  min-height: 58px;
  font-size: 1.4rem;
  border-radius: 24px;
}
.overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) .home-link {
  font-size: 1.05rem;
  color: #cf326c;
}
@media (max-height: 650px) {
  .overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) { padding-top: 68px; }
  .overlay[data-kind="pause"] .paused-ruby,
.overlay[data-kind="record"] .record-trophy,
  .overlay[data-kind="result"] .retry-ruby { width: 180px; margin-top: -72px; }
  .overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) #overlayCopy { margin-block: 10px 16px; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) { padding: 26px; }
  .overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) .card {
    width: min(620px, 100%);
    display: grid;
    grid-template-columns: 175px 1fr;
    column-gap: 20px;
    align-items: center;
  }
  .overlay[data-kind="pause"] .paused-ruby,
.overlay[data-kind="record"] .record-trophy,
  .overlay[data-kind="result"] .retry-ruby {
    grid-column: 1;
    grid-row: 1 / 6;
    width: 175px;
    margin: 0;
  }
  .overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) .card > :not(.result-ruby):not(.asset-picture) { grid-column: 2; }
  .overlay:is([data-kind="record"], [data-kind="result"], [data-kind="pause"]) h2 { font-size: 3.4rem; }
}

/* A quiet companion to the result cards: one heading and no celebration. */
.overlay[data-kind="pause"] .kicker { display: none; }
.overlay[data-kind="pause"] h2 {
  color: #ef3f83;
  font-size: clamp(2.2rem, 10vw, 3rem);
  letter-spacing: .01em;
  text-transform: uppercase;
  margin-top: 4px;
}
.overlay[data-kind="pause"] .paused-ruby { margin-bottom: 0; }

/* Ruby overlaps the help card just like the result and pause portraits. */
.overlay[data-kind="help"] { padding-top: 90px; }
.overlay[data-kind="help"] .kicker { display: none; }
.overlay[data-kind="help"] .help-visuals { height: auto; margin: -94px auto 12px; }
.overlay[data-kind="help"] .play-button { min-height: 58px; font-size: 1.4rem; border-radius: 24px; }
@media (max-height: 650px) {
  .overlay[data-kind="help"] { padding: 72px 20px 20px; }
  .overlay[data-kind="help"] .card { padding: 18px 20px 22px; }
  .overlay[data-kind="help"] .help-visuals { margin: -76px auto 8px; }
  .help-phone-ruby { width: 210px; }
  .overlay[data-kind="help"] #overlayCopy { margin-block: 12px 18px; font-size: 1.02rem; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .overlay[data-kind="help"] { padding: 20px; }
  .overlay[data-kind="help"] .card { width: min(660px, 100%); display: grid; grid-template-columns: 170px 1fr; gap: 0 24px; align-items: center; }
  .overlay[data-kind="help"] .help-visuals { grid-column: 1; grid-row: 1 / 4; margin: 0; }
  .help-phone-ruby { width: 170px; }
  .overlay[data-kind="help"] h2, .overlay[data-kind="help"] #overlayCopy, .overlay[data-kind="help"] .play-button { grid-column: 2; }
}

#hapticsButton[hidden] { display: none; }
#hapticsButton[aria-pressed="true"] .icon-state-haptics-off,
#hapticsButton[aria-pressed="false"] .icon-state-haptics { display: none; }

/* The approved video fills the game viewport, with captions following media time. */
.ending-scene { position: absolute; inset: 0; z-index: 30; overflow: hidden; background: #263147; animation: ending-appear .65s ease both; }
.ending-scene[hidden] { display: none; }
.ending-scene video { position: absolute; left: calc(50% + var(--ending-video-shift, 0px)); top: 50%; transform: translate(-50%, -50%); max-width: none; object-fit: contain; }
.ending-scene #endingBackdrop { position: absolute; inset: 0; width: 100%; height: 100%; filter: blur(16px); transform: translateX(var(--ending-video-shift, 0px)) scale(var(--ending-backdrop-scale, 1.08)); }
@media (max-width: 600px) and (orientation: portrait) {
  .ending-scene { --ending-backdrop-scale: 1.1; }
  .ending-scene[data-scene="ledge"] { --ending-video-shift: 19px; --ending-backdrop-scale: 1.13; }
  .ending-scene[data-scene="beach"] { --ending-video-shift: -10px; }
}
.ending-scene[data-extended="true"] video { -webkit-mask-image: linear-gradient(to bottom, transparent, black 30px, black calc(100% - 30px), transparent); mask-image: linear-gradient(to bottom, transparent, black 30px, black calc(100% - 30px), transparent); }
.ending-scene #endingBackdrop[hidden] { display: none; }
.ending-scene p {
  position: absolute;
  z-index: 1;
  bottom: calc(max(28px, calc(env(safe-area-inset-bottom, 0px) + 18px)) + var(--bottom-safe-zone));
  margin: 0;
  font-size: clamp(14px, 2.5vh, 18px);
  line-height: 1.4;
  text-align: center;
  text-wrap: balance;
}
.ending-scene p[hidden] { display: none; }
.ending-scene #endingResume { position: absolute; z-index: 3; top: 50%; left: 50%; transform: translate(-50%, -50%); border: 0; border-radius: 20px; padding: 10px 16px; font: inherit; color: #542b4c; background: #fff0f6; cursor: pointer; }
@keyframes ending-appear { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ending-scene { animation: none; } }

/* The closing dedication appears over the held video, without a result card. */
.arcade.story-complete .hud, .arcade.story-complete .screen-actions { visibility: hidden; }
.ending-confetti { z-index: 3; }
.ending-dedication { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.ending-dedication[hidden] { display: none; }
.ending-message { position: absolute; top: max(10%, env(safe-area-inset-top)); left: 6%; right: 6%; text-align: center; animation: ending-dedication-appear .6s ease both; }
.ending-message img { display: block; width: min(76%, 304px); height: auto; margin: 0 auto -20px; }
/* Replay uses the same top-right placement and button treatment as intro Skip. */
.ending-controls { position: absolute; top: max(var(--control-top), env(safe-area-inset-top)); right: max(var(--control-side), env(safe-area-inset-right)); animation: ending-dedication-appear .6s .35s ease both; }
.ending-controls button { pointer-events: auto; }
@keyframes ending-dedication-appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (min-aspect-ratio: 5 / 6) {
  .ending-message { top: max(4%, env(safe-area-inset-top)); }
  .ending-message img { width: min(90%, 220px); margin-bottom: -12px; }
}
@media (min-width: 768px) and (min-height: 600px) {
  .ending-message { top: max(6%, env(safe-area-inset-top)); }
  .ending-message img { width: min(76%, 400px); margin-bottom: -24px; }
}
@media (orientation: landscape) and (max-height: 599px) {
  .ending-message img {
    width: min(60%, clamp(132px, 42svh, 180px));
    margin-bottom: -12px;
  }

}
@media (prefers-reduced-motion: reduce) { .ending-message, .ending-controls { animation: none; } }

/* Keep primary actions compact on tablet and desktop while retaining tap space. */
@media (min-width: 600px) and (min-height: 600px) {
  .start-button-art {
    --button-min-width: clamp(150px, 13vw, 180px);
    --button-min-height: 44px;
    --button-padding-block: 9px;
    --button-padding-inline: 20px;
    --button-border-width: 3px;
    --button-radius: 18px;
    --button-font-size: clamp(1.2rem, 1.6vw, 1.5rem);
  }
  .start-button-rays { scale: .56; }
}

/* Start uses responsive bottom spacing. */
.arcade { --primary-button-bottom: calc(var(--primary-button-spacing) + var(--bottom-safe-zone)); --primary-button-spacing: max(clamp(34px, 7vh, 76px), env(safe-area-inset-bottom)); }
.start-stage { bottom: var(--primary-button-bottom); }
@media (orientation: portrait) {
  .arcade { --primary-button-spacing: calc(env(safe-area-inset-bottom, 0px) + clamp(48px, 7vh, 76px)); }
}
@media (min-width: 600px) and (max-width: 1100px) and (orientation: portrait) {
  .arcade { --primary-button-spacing: calc(env(safe-area-inset-bottom, 0px) + clamp(72px, 8vh, 96px)); }
}
@media (max-width: 599px) and (orientation: portrait) {
  .arcade { --primary-button-spacing: calc(max(calc(env(safe-area-inset-bottom, 0px) + 16px), calc(env(safe-area-inset-bottom, 0px) + clamp(48px, 6.5svh, 68px) - clamp(20px, 3svh, 28px))) - 8px); }
}
@media (min-width: 1101px), (min-width: 600px) and (min-height: 600px) and (orientation: landscape) {
  .arcade { --primary-button-spacing: max(76px, calc(env(safe-area-inset-bottom, 0px) + 76px)); }
}
@media (orientation: landscape) and (max-height: 599px) {
  .arcade { --primary-button-spacing: calc(env(safe-area-inset-bottom, 0px) + clamp(58px, 15svh, 76px)); }
}
