:root {
  color-scheme: dark;
  --ink: #06111d;
  --paper: #f2e4c8;
  --paper-ink: #24180f;
  --cyan: #15ddf0;
  --blue: #39aefb;
  --amber: #ffb42a;
  --red: #f45a3c;
  --line: rgba(255, 255, 255, 0.16);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 50% 0%, #17334a 0, transparent 44rem),
    #050a11;
}

body {
  min-height: 100svh;
  color: white;
  overscroll-behavior: none;
}

button {
  font: inherit;
}

.game-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
}

.game-card {
  width: min(100%, 1280px);
  border: 3px solid #02060a;
  border-radius: 18px;
  overflow: hidden;
  background: #0b1520;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.55),
    0 0 0 2px rgba(255, 180, 42, 0.34);
}

.hud {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 0.8rem;
  background:
    linear-gradient(180deg, rgba(20, 34, 47, 0.98), rgba(6, 15, 24, 0.98)),
    #08111b;
  border-bottom: 2px solid rgba(255, 180, 42, 0.45);
}

.brand-block {
  display: grid;
  line-height: 1;
  min-width: 112px;
}

.brand-block strong {
  color: var(--cyan);
  font-size: 1.42rem;
  letter-spacing: 0.06em;
  transform: rotate(-1deg);
  text-shadow: 2px 2px 0 #000;
}

.brand-block span,
.hud-label {
  margin-top: 0.28rem;
  color: #c9d6df;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meter-block {
  display: grid;
  min-width: 150px;
  flex: 1;
  max-width: 310px;
}

.groove-meter {
  height: 14px;
  overflow: hidden;
  border: 2px solid #02070b;
  border-radius: 99px;
  background: #1b2430;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
}

.groove-meter span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--amber), var(--red));
  transition: width 180ms ease;
}

.notes-block {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 72px;
}

.bonus-stats {
  display: grid;
  gap: 0.12rem;
  min-width: 92px;
  color: #f7d775;
  font-size: 0.78rem;
  line-height: 1.1;
}

.bonus-stats span:nth-child(2) {
  color: #79ebf5;
}

.bonus-stats span:last-child {
  color: #ffd86a;
}

.timer-block {
  display: grid;
  place-items: center;
  min-width: 62px;
  padding: 0.25rem 0.5rem;
  border: 2px solid rgba(21, 221, 240, 0.45);
  border-radius: 10px;
  color: var(--cyan);
  background: rgba(2, 10, 16, 0.62);
  line-height: 1;
}

.timer-block > span {
  color: #c9d6df;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.timer-block > strong {
  margin-top: 0.14rem;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.timer-block small {
  margin-left: 0.08rem;
  font-size: 0.7rem;
}

.timer-block.is-urgent {
  border-color: var(--red);
  color: #ff7960;
  animation: timer-pulse 700ms ease-in-out infinite alternate;
}

@keyframes timer-pulse {
  to {
    background: rgba(137, 31, 18, 0.46);
    box-shadow: 0 0 18px rgba(244, 90, 60, 0.48);
  }
}

.blue-note {
  color: var(--cyan);
  font-size: 1.85rem;
  line-height: 1;
  text-shadow: 0 0 12px rgba(21, 221, 240, 0.8);
}

.crew-block {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
}

.crew-block span {
  padding: 0.42rem 0.48rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101d29;
  color: #aeb9c2;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.crew-block span.is-rescued {
  border-color: rgba(21, 221, 240, 0.72);
  color: #8ff7ff;
  background: rgba(8, 92, 104, 0.42);
}

.utility-buttons {
  display: flex;
  gap: 0.35rem;
}

.utility-buttons button,
.game-help button {
  min-width: 42px;
  min-height: 42px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  color: white;
  background: #142433;
  cursor: pointer;
}

.utility-buttons button:hover,
.utility-buttons button:focus-visible,
.game-help button:hover,
.game-help button:focus-visible {
  outline: none;
  border-color: var(--cyan);
  background: #1b3548;
}

.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #09111a;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

.story-crawl {
  position: absolute;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  color: #ffd86a;
  background:
    radial-gradient(circle at 18% 22%, rgba(255,255,255,.75) 0 1px, transparent 1.7px),
    radial-gradient(circle at 74% 38%, rgba(255,255,255,.62) 0 1px, transparent 1.6px),
    radial-gradient(circle at 43% 76%, rgba(77,215,238,.6) 0 1px, transparent 1.8px),
    radial-gradient(circle at 86% 82%, rgba(255,216,106,.55) 0 1px, transparent 1.7px),
    #02050b;
  background-size: 137px 119px, 193px 173px, 227px 211px, 281px 263px, auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
}

.story-crawl.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.story-crawl[hidden] {
  display: none;
}

.crawl-perspective {
  position: absolute;
  inset: 0;
  overflow: hidden;
  perspective: 520px;
  perspective-origin: 50% 27%;
  transform-style: preserve-3d;
}

.crawl-plane {
  position: absolute;
  inset: 7% 7% -48%;
  transform: rotateX(25deg);
  transform-origin: 50% 100%;
  transform-style: preserve-3d;
}

.crawl-content {
  position: absolute;
  top: 100%;
  left: 50%;
  width: min(84%, 850px);
  margin: 0;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(1.2rem, 3.1vw, 2.35rem);
  font-weight: 800;
  line-height: 1.45;
  letter-spacing: 0.025em;
  text-align: justify;
  text-shadow: 0 2px 8px rgba(0,0,0,.9);
  transform-origin: center top;
  will-change: top, transform;
  animation: bluesion-crawl 62s linear forwards;
}

.crawl-content h1,
.crawl-content h2,
.crawl-kicker {
  text-align: center;
}

.crawl-content h1 {
  margin: 0 0 0.35em;
  color: #57d9ef;
  font-size: clamp(3.5rem, 10vw, 8rem);
  line-height: 0.9;
  letter-spacing: 0.04em;
  -webkit-text-stroke: 2px #0a2536;
  text-shadow: 4px 5px 0 #101820, 0 0 24px rgba(87,217,239,.35);
}

.crawl-content h2 {
  margin: 0 0 1.3em;
  font-size: 1.15em;
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.crawl-content p {
  margin: 0 0 1.2em;
}

.crawl-kicker {
  margin-bottom: 0.45em !important;
  color: #f6f0da;
  font-family: system-ui, sans-serif;
  font-size: 0.55em;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.crawl-fade {
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  height: 35%;
  background:
    radial-gradient(ellipse at 50% 67%, rgba(87,217,239,.16), transparent 48%),
    linear-gradient(to bottom, #02050b 0%, rgba(2,5,11,.98) 34%, rgba(2,5,11,.72) 62%, transparent 100%);
  pointer-events: none;
}

.crawl-fade::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 18%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(87,217,239,.38), transparent);
  box-shadow: 0 0 18px rgba(87,217,239,.28);
}

.skip-crawl-button,
.intro-music-button {
  position: absolute;
  z-index: 3;
  top: max(0.65rem, env(safe-area-inset-top));
  min-height: 44px;
  padding: 0.55rem 0.85rem;
  border: 2px solid rgba(255,216,106,.8);
  border-radius: 999px;
  color: #fff4cf;
  background: rgba(2,5,11,.78);
  font: inherit;
  font-size: clamp(0.8rem, 2vw, 0.95rem);
  font-weight: 850;
  cursor: pointer;
  backdrop-filter: blur(5px);
}

.skip-crawl-button {
  right: max(0.65rem, env(safe-area-inset-right));
}

.intro-music-button {
  left: max(0.65rem, env(safe-area-inset-left));
}

.intro-music-button.is-playing {
  border-color: #57d9ef;
  color: #07111d;
  background: #57d9ef;
}

.skip-crawl-button:focus-visible,
.intro-music-button:focus-visible {
  outline: 4px solid #57d9ef;
  outline-offset: 3px;
}

@keyframes bluesion-crawl {
  0% {
    top: 100%;
    transform: translate3d(-50%, 0, 0);
  }
  100% {
    top: 0;
    transform: translate3d(-50%, -100%, 0);
  }
}

.screen-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 3rem);
  background: linear-gradient(90deg, rgba(3, 8, 13, 0.9), rgba(3, 8, 13, 0.3));
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  overflow-y: auto;
  touch-action: pan-y;
}

.screen-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.screen-overlay[hidden] {
  display: none;
}

#complete {
  place-items: start center;
}

#complete .complete-panel {
  margin-block: clamp(0.35rem, 3vh, 1.5rem);
}

.paper-panel {
  width: min(92%, 570px);
  padding: clamp(1.2rem, 4vw, 2.4rem);
  border: 4px solid #1b120c;
  border-radius: 8px 18px 10px 20px;
  color: var(--paper-ink);
  background:
    linear-gradient(rgba(255,255,255,.2), rgba(255,255,255,0)),
    var(--paper);
  box-shadow: 10px 12px 0 rgba(0,0,0,.46);
  transform: rotate(-0.7deg);
  text-align: center;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: #8c321f;
  font-size: clamp(0.82rem, 2vw, 1rem);
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.paper-panel h1,
.paper-panel h2 {
  margin: 0;
  color: #0b7087;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(3rem, 9vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: 0.025em;
  text-shadow: 3px 3px 0 #23170f;
}

.paper-panel h2 {
  font-size: clamp(2rem, 6vw, 4.2rem);
}

.story-copy,
.complete-panel p {
  margin: 1rem auto;
  max-width: 47ch;
  font-size: clamp(1rem, 2.3vw, 1.2rem);
  line-height: 1.45;
}

.complete-panel .final-score {
  margin-top: -0.15rem;
  color: #78311f;
  font-weight: 900;
}

.time-score {
  margin-top: -0.7rem !important;
  color: #0b7087;
  font-weight: 900;
}

.dream-score {
  margin-top: -0.7rem !important;
  color: #7b3594;
  font-weight: 900;
}

.alex-next-chapter {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: end;
  width: min(100%, 545px);
  margin: 0.8rem auto 1rem;
}

.alex-announcer {
  position: relative;
  z-index: 2;
  display: block;
  width: 112px;
  max-width: none;
  margin: 0 -20px -4px 0;
  filter: drop-shadow(4px 5px 0 rgba(33, 20, 13, 0.34));
  transform: rotate(-2deg);
}

.next-chapter-preview {
  position: relative;
  z-index: 1;
  width: 100%;
  margin: 0;
  padding: 0.85rem 1rem 0.9rem 1.25rem;
  border: 3px solid #21140d;
  border-radius: 7px 14px 8px 12px;
  color: #f8efd8;
  background:
    radial-gradient(circle at 92% 12%, rgba(255, 180, 42, 0.3), transparent 28%),
    linear-gradient(135deg, #132c36, #311d43 72%);
  box-shadow: 5px 6px 0 rgba(33, 20, 13, 0.28);
  transform: rotate(0.45deg);
  text-align: left;
}

.next-chapter-preview::before {
  position: absolute;
  left: -25px;
  bottom: 30px;
  width: 38px;
  height: 32px;
  border-bottom: 4px solid #21140d;
  background: #172b39;
  content: "";
  clip-path: polygon(100% 0, 100% 100%, 0 72%);
  transform: rotate(-7deg);
}

.complete-panel .next-chapter-kicker {
  margin: 0 0 0.2rem;
  color: #ffcf63;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.next-chapter-preview h3 {
  margin: 0;
  color: #74f1d3;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  line-height: 1.05;
  letter-spacing: 0.025em;
}

.complete-panel .next-chapter-preview #nextChapterCopy {
  margin: 0.45rem 0 0;
  max-width: none;
  font-size: clamp(0.9rem, 2vw, 1rem);
  line-height: 1.35;
}

.next-chapter-preview.is-future {
  background:
    radial-gradient(circle at 92% 12%, rgba(197, 156, 255, 0.35), transparent 28%),
    linear-gradient(135deg, #172923, #39254d 72%);
}

.next-chapter-preview.is-future::before {
  background: #24302f;
}

@media (max-width: 520px) {
  .alex-next-chapter {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .alex-announcer {
    width: 84px;
    margin-right: -18px;
  }

  .next-chapter-preview {
    padding: 0.72rem 0.75rem 0.78rem 1rem;
  }

  .next-chapter-preview h3 {
    font-size: clamp(1.08rem, 5.5vw, 1.42rem);
  }

  .complete-panel .next-chapter-preview #nextChapterCopy {
    font-size: 0.86rem;
  }
}

.highscore-form {
  display: grid;
  gap: 0.42rem;
  margin: 0.9rem auto;
  font-size: 0.9rem;
  font-weight: 900;
}

.finale-encore {
  width: min(100%, 545px);
  margin: 1rem auto 1.1rem;
  padding: 1rem;
  border: 3px solid #21140d;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: 5px 6px 0 rgba(33, 20, 13, 0.2);
}

.demo-teaser {
  width: min(100%, 545px);
  margin: 1rem auto 1.1rem;
  padding: 1rem;
  border: 3px solid #21140d;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 207, 99, 0.5), rgba(116, 241, 211, 0.42));
  box-shadow: 5px 6px 0 rgba(33, 20, 13, 0.2);
}

.demo-teaser h3 {
  margin: 0.2rem 0 0.45rem;
  color: #0b7087;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  line-height: 1.05;
}

.complete-panel .demo-teaser p:last-child {
  margin: 0.45rem auto 0;
  font-size: clamp(0.9rem, 2vw, 1rem);
}

.complete-panel .encore-kicker {
  margin: 0;
  color: #8c321f;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.finale-encore > h3 {
  margin: 0.15rem 0 0.35rem;
  color: #0b7087;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(1.45rem, 4vw, 2rem);
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.highscore-form > label {
  color: #21140d;
  font-size: 0.9rem;
}

.highscore-form > div {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.highscore-form input {
  width: min(52%, 230px);
  min-height: 50px;
  padding: 0.65rem 0.75rem;
  border: 3px solid #21140d;
  border-radius: 10px;
  color: #19110b;
  background: #fffaf0;
  font: inherit;
  font-size: 1rem;
}

.highscore-form input:focus-visible {
  outline: 4px solid var(--cyan);
  outline-offset: 2px;
}

.highscore-form .primary-button {
  padding-inline: 0.85rem;
}

.highscore-saved {
  margin: 0.7rem 0 !important;
  color: #0b7087;
  font-weight: 900;
}

.leaderboard {
  width: min(100%, 420px);
  margin: 0.75rem auto;
  padding: 0.55rem 0.7rem;
  border: 2px solid rgba(36, 24, 15, 0.4);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.28);
  text-align: left;
}

.leaderboard h3 {
  margin: 0 0 0.32rem;
  color: #8c321f;
  font-size: 0.88rem;
  letter-spacing: 0.09em;
  text-align: center;
  text-transform: uppercase;
}

.leaderboard ol {
  margin: 0;
  padding: 0;
  counter-reset: groove-rank;
  list-style: none;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 1.35rem 1fr auto;
  gap: 0.25rem;
  padding: 0.18rem 0;
  border-top: 1px dashed rgba(36, 24, 15, 0.22);
  font-size: 0.82rem;
  counter-increment: groove-rank;
}

.leaderboard li::before {
  content: counter(groove-rank) ".";
  color: #8c321f;
  font-weight: 900;
}

.leaderboard li:first-child {
  border-top: 0;
}

.leaderboard .empty-score {
  display: block;
  text-align: center;
}

.leaderboard .empty-score::before {
  content: "";
}

.berlin-waltz-button {
  min-height: 46px;
  margin-top: 0.55rem;
  padding: 0.65rem 1rem;
  border: 3px solid #21140d;
  border-radius: 999px;
  color: #fff8df;
  background: #0b7087;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 900;
  cursor: pointer;
}

.berlin-waltz-button.is-playing {
  color: #21140d;
  background: var(--cyan);
}

.leaderboard--intro {
  margin: 0.7rem auto 0;
  padding: 0.42rem 0.65rem;
  background: rgba(255, 255, 255, 0.4);
}

.leaderboard--intro li:nth-child(n + 4) {
  display: none;
}

.leaderboard--intro li {
  padding-block: 0.12rem;
}

.primary-button {
  min-height: 50px;
  padding: 0.8rem 1.4rem;
  border: 3px solid #21140d;
  border-radius: 10px;
  background: var(--amber);
  color: #1b110b;
  font-weight: 900;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 4px 5px 0 #21140d;
}

.primary-button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 3px 0 #21140d;
}

.primary-button:focus-visible {
  outline: 4px solid var(--cyan);
  outline-offset: 3px;
}

.start-button {
  margin-top: 0.8rem;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
}

.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0 auto 0.55rem;
  padding: 0.22rem;
  border: 2px solid rgba(8, 25, 36, 0.5);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
}

.language-switch button {
  min-height: 36px;
  padding: 0.35rem 0.7rem;
  border: 0;
  border-radius: 999px;
  color: #102432;
  background: transparent;
  font: 800 0.82rem/1 system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

.language-switch button.is-active {
  color: #fff;
  background: #0b7285;
  box-shadow: 0 2px 0 #064956;
}

.language-switch button:focus-visible {
  outline: 3px solid #ffcf63;
  outline-offset: 2px;
}

.language-gate {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  color: #fff4cf;
  text-align: center;
  background:
    radial-gradient(circle at 22% 25%, rgba(255,255,255,.72) 0 1px, transparent 1.7px),
    radial-gradient(circle at 78% 68%, rgba(87,217,239,.62) 0 1px, transparent 1.7px),
    radial-gradient(circle at 54% 42%, rgba(255,216,106,.56) 0 1px, transparent 1.6px),
    #02050b;
  background-size: 137px 119px, 193px 173px, 227px 211px, auto;
}

.language-gate[hidden] {
  display: none;
}

.language-gate:not([hidden]) + .story-crawl .crawl-content {
  animation-play-state: paused;
}

.language-gate-card {
  width: min(92%, 620px);
  padding: clamp(1.2rem, 4vw, 2.4rem);
  border: 3px solid rgba(255, 216, 106, 0.9);
  border-radius: 1.2rem;
  background: rgba(7, 17, 29, 0.92);
  box-shadow: 0 0 42px rgba(87, 217, 239, 0.18), 8px 10px 0 rgba(0, 0, 0, 0.45);
}

.language-gate-card h1 {
  margin: 0.2rem 0 1.2rem;
  color: #ffd86a;
  font: 900 clamp(1.5rem, 5vw, 2.6rem)/1.05 Impact, "Arial Black", sans-serif;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.language-gate-card p {
  margin: 0.8rem 0 0;
  font-size: clamp(0.78rem, 2vw, 1rem);
}

.language-switch--gate {
  display: flex;
  width: fit-content;
  margin: 0 auto;
  border-color: rgba(255, 216, 106, 0.8);
  background: rgba(2, 5, 11, 0.78);
}

.language-switch--gate button {
  min-height: 48px;
  padding-inline: clamp(0.75rem, 3vw, 1.2rem);
  color: #fff4cf;
  font-size: clamp(0.8rem, 2.4vw, 1rem);
}

.language-switch--gate button.is-active {
  color: #06111a;
  background: #ffd86a;
  box-shadow: none;
}

.start-actions [hidden],
.save-summary[hidden] {
  display: none;
}

.save-summary {
  margin: 0.75rem 0 0;
  color: #5b3517;
  font-weight: 900;
}

.app-offer {
  display: grid;
  gap: 0.25rem;
  width: min(100%, 470px);
  margin: 0.85rem auto 0;
  padding: 0.72rem 0.9rem;
  border: 3px solid #21140d;
  border-radius: 10px;
  color: #21140d;
  background: linear-gradient(135deg, rgba(255, 207, 99, 0.72), rgba(116, 241, 211, 0.58));
  box-shadow: 4px 5px 0 rgba(33, 20, 13, 0.28);
  transform: rotate(0.35deg);
}

.app-offer strong {
  color: #8c321f;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  text-transform: uppercase;
}

.app-offer span {
  color: #0b7087;
  font-size: clamp(1.15rem, 3vw, 1.45rem);
  font-weight: 900;
}

.app-offer em {
  font-size: 0.88rem;
  font-style: normal;
  font-weight: 800;
  line-height: 1.35;
}

.start-actions:has(#continueButton:not([hidden])) #startButton {
  background: #efe1c3;
  box-shadow: 3px 4px 0 #21140d;
}

.key-hint {
  margin: 1.2rem 0 0;
  font-size: 0.86rem;
  font-weight: 700;
}

.tutorial-overlay {
  z-index: 40;
  background: rgba(3, 8, 13, 0.92);
}

.tutorial-panel {
  width: min(94%, 760px);
  max-height: calc(100% - 1rem);
  overflow-y: auto;
}

.tutorial-panel h2 {
  margin: 0.2rem 0 1rem;
}

.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  text-align: left;
}

.tutorial-grid article {
  display: grid;
  gap: 0.22rem;
  padding: 0.7rem;
  border: 2px solid #4a2d18;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.28);
}

.tutorial-grid strong {
  color: #8b1738;
}

.tutorial-grid span,
.tutorial-tip {
  font-size: 0.9rem;
  line-height: 1.3;
}

.tutorial-tip {
  margin: 0.85rem 0;
  color: #5b3517;
}

.audio-credit {
  margin: 0.45rem 0 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
}

.audio-credit a {
  color: #5b3517;
}

@media (max-width: 520px) and (orientation: portrait) {
  .tutorial-grid {
    grid-template-columns: 1fr;
  }

  .message-bubble {
    top: 0.38rem;
    width: calc(100% - 1rem);
    max-width: none;
    max-height: 2.85rem;
    padding: 0.34rem 0.5rem;
    border-width: 1px;
    border-radius: 8px;
    box-shadow: 2px 3px 0 rgba(0,0,0,.42);
    font-size: 0.72rem;
    line-height: 1.15;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    pointer-events: none;
  }
}

.message-bubble {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 1rem;
  width: max-content;
  max-width: min(82%, 620px);
  padding: 0.65rem 0.9rem;
  border: 2px solid #101318;
  border-radius: 12px 12px 12px 3px;
  color: #15110c;
  background: var(--paper);
  box-shadow: 5px 6px 0 rgba(0,0,0,.42);
  font-weight: 800;
  transform: translate(-50%, -130%);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}

.message-bubble.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.touch-controls {
  position: absolute;
  z-index: 7;
  inset: auto 0 0;
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 0.7rem max(0.7rem, env(safe-area-inset-right)) max(0.7rem, env(safe-area-inset-bottom)) max(0.7rem, env(safe-area-inset-left));
  pointer-events: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.touch-controls,
.touch-controls *,
.touch-controls button::before,
.touch-controls button::after {
  -webkit-tap-highlight-color: transparent !important;
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-user-drag: none !important;
}

.direction-pad,
.action-pad {
  display: flex;
  gap: 0.55rem;
}

.touch-controls button {
  width: clamp(56px, 9vw, 76px);
  height: clamp(56px, 9vw, 76px);
  border: 3px solid rgba(255,255,255,.72);
  border-radius: 50%;
  color: white;
  background: rgba(5, 16, 26, 0.68);
  box-shadow: 0 4px 0 rgba(0,0,0,.48);
  backdrop-filter: blur(5px);
  font-weight: 900;
  pointer-events: auto;
  touch-action: none;
  -webkit-appearance: none;
  appearance: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  caret-color: transparent;
  outline: none;
}

.touch-controls button:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 3px;
}

.touch-controls button::selection {
  color: inherit;
  background: transparent;
}

.touch-controls button::-moz-selection {
  color: inherit;
  background: transparent;
}

.touch-controls button[hidden] {
  display: none;
}

.touch-controls button.is-pressed,
.touch-controls button:active {
  transform: translateY(3px) scale(0.97);
  color: #22140b;
  border-color: var(--paper);
  background: rgba(255, 180, 42, 0.9);
  box-shadow: 0 1px 0 rgba(0,0,0,.48);
}

.touch-controls .bark-button {
  width: clamp(66px, 10vw, 84px);
  border-color: var(--amber);
  color: #22140b;
  background: rgba(255, 180, 42, 0.87);
  font-size: clamp(0.72rem, 2vw, 0.95rem);
}

.touch-controls .bark-button:disabled {
  color: rgba(255, 255, 255, 0.7);
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(45, 47, 62, 0.72);
  box-shadow: 0 2px 0 rgba(0,0,0,.4);
  cursor: not-allowed;
  opacity: 0.72;
}

.touch-controls .jump-button {
  width: clamp(88px, 15vw, 112px);
  height: clamp(88px, 15vw, 112px);
  border-width: 4px;
  border-color: #74f1d3;
  color: #07111d;
  background: rgba(116, 241, 211, 0.92);
  box-shadow: 0 6px 0 rgba(0,0,0,.52), 0 0 24px rgba(116, 241, 211, .28);
  font-size: clamp(1.8rem, 5vw, 2.65rem);
}

.game-help {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 0;
  padding: 0.65rem 1rem;
  color: #c9d3db;
  background: #08111a;
  font-size: 0.9rem;
  text-align: center;
}

.game-help button {
  min-height: 36px;
  padding: 0.3rem 0.7rem;
  white-space: nowrap;
}

.rotate-hint {
  display: none;
  margin: 0;
  padding: 0.45rem;
  color: #f5c96a;
  background: #111b24;
  text-align: center;
}

@media (hover: hover) and (pointer: fine) {
  .touch-controls {
    opacity: 0.28;
  }

  .touch-controls:hover,
  .touch-controls:focus-within {
    opacity: 1;
  }
}

@media (max-width: 1120px) {
  .hud {
    flex-wrap: wrap;
  }

  .crew-block {
    order: 10;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    flex-basis: 100%;
    gap: 0.2rem;
    margin-left: 0;
  }

  .crew-block span {
    min-width: 0;
    text-align: center;
  }
}

@media (max-width: 900px) {
  .game-shell {
    padding: 0;
  }

  .game-card {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .crew-block {
    order: 10;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    flex-basis: 100%;
    gap: 0.2rem;
    margin-left: 0;
  }

  .crew-block span {
    width: auto;
    padding: 0.32rem 0.34rem;
    overflow: visible;
    font-size: 0.58rem;
    text-align: center;
  }

  .brand-block span,
  .hud-label {
    display: none;
  }

  .bonus-stats {
    min-width: 62px;
    font-size: 0.68rem;
  }

  .hud {
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 54px;
    padding: 0.35rem 0.5rem;
  }

  .brand-block {
    min-width: 92px;
  }

  .brand-block strong {
    font-size: 1.13rem;
  }

  .meter-block {
    min-width: 80px;
  }

  .utility-buttons button {
    min-width: 36px;
    min-height: 36px;
    padding: 0;
  }

  .game-help {
    display: none;
  }
}

@media (orientation: portrait) and (max-width: 700px) {
  .hud {
    display: grid;
    grid-template-columns: auto auto auto 1fr;
    gap: 0.28rem 0.38rem;
  }

  .brand-block {
    grid-column: 1;
    grid-row: 1;
  }

  .meter-block {
    display: none;
  }

  .notes-block {
    grid-column: 2;
    grid-row: 1;
    min-width: 52px;
  }

  .timer-block {
    grid-column: 3;
    grid-row: 1;
    min-width: 52px;
    padding-inline: 0.3rem;
  }

  .utility-buttons {
    grid-column: 4;
    grid-row: 1;
    justify-self: end;
  }

  .bonus-stats {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    align-items: center;
    gap: 0.45rem;
  }

  .crew-block {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
    justify-content: stretch;
    margin-left: 0;
  }

  .crawl-perspective {
    inset: 0;
    perspective: 460px;
    perspective-origin: 50% 25%;
  }

  .crawl-plane {
    inset: 6% 1% -52%;
    transform: rotateX(23deg);
  }

  .crawl-content {
    width: 94%;
    font-size: clamp(1rem, 5vw, 1.45rem);
  }

  .crawl-content h1 {
    font-size: clamp(3rem, 18vw, 5rem);
  }

  .screen-overlay {
    place-items: start center;
    padding: 0.35rem;
  }

  .intro-panel {
    width: 100%;
    margin: 0 auto;
    padding: 0.55rem 0.8rem;
  }

  .intro-panel .eyebrow {
    display: none;
  }

  .intro-panel h1 {
    font-size: clamp(2rem, 12vw, 3rem);
  }

  .intro-panel .start-button {
    min-height: 44px;
    margin-top: 0.45rem;
    padding: 0.5rem 1.2rem;
  }

  .start-actions {
    gap: 0.4rem;
  }

  .save-summary {
    margin-top: 0.45rem;
    font-size: 0.82rem;
  }

  .intro-panel .story-copy,
  .intro-panel .key-hint {
    display: none;
  }

  .leaderboard--intro {
    width: min(100%, 360px);
    margin-top: 0.4rem;
    padding: 0.3rem 0.55rem;
  }

  .leaderboard--intro h3 {
    margin-bottom: 0.16rem;
    font-size: 0.76rem;
  }

  .leaderboard--intro li {
    padding-block: 0.08rem;
    font-size: 0.75rem;
  }

  .rotate-hint {
    display: block;
  }
}

@media (max-height: 560px) {
  .crawl-perspective {
    inset: 0;
    perspective: 500px;
    perspective-origin: 50% 24%;
  }

  .crawl-plane {
    inset: -2% 9% -62%;
    transform: rotateX(24deg);
  }

  .crawl-content {
    width: min(76%, 760px);
    font-size: clamp(1rem, 2.7vw, 1.55rem);
  }

  .crawl-content h1 {
    font-size: clamp(3rem, 9vw, 5rem);
  }

  .game-shell {
    padding: 0;
  }

  .game-card {
    width: min(100%, calc((100svh - 48px) * 1.7778));
  }

  .hud {
    min-height: 48px;
  }

  .screen-overlay {
    place-items: start center;
    padding: 0.35rem;
  }

  .paper-panel {
    margin: 0 auto;
    padding: 0.85rem 1.1rem;
  }

  .intro-panel .eyebrow {
    display: none;
  }

  .intro-panel h1 {
    font-size: clamp(2.2rem, 9vw, 3.6rem);
  }

  .intro-panel .start-button {
    min-height: 44px;
    margin-top: 0.45rem;
    padding-block: 0.5rem;
  }

  .save-summary {
    margin-top: 0.35rem;
    font-size: 0.78rem;
  }

  .intro-panel .story-copy {
    display: none;
  }

  .leaderboard--intro {
    width: min(76%, 390px);
    margin-top: 0.35rem;
    padding: 0.22rem 0.5rem;
  }

  .leaderboard--intro h3 {
    margin-bottom: 0.12rem;
    font-size: 0.72rem;
  }

  .leaderboard--intro li {
    padding-block: 0.05rem;
    font-size: 0.72rem;
  }

  .key-hint {
    display: none;
  }

  .game-help,
  .rotate-hint {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  .game-shell {
    width: 100%;
    height: 100svh;
    min-height: 0;
    padding: 0;
  }

  .game-card {
    position: relative;
    display: block;
    width: min(100vw, calc(100svh * 1.7778));
    height: min(100svh, calc(100vw * 0.5625));
    border: 0;
    border-radius: 0;
  }

  .hud {
    position: absolute;
    z-index: 9;
    inset: 0 0 auto;
    display: grid;
    grid-template-columns: auto minmax(58px, 1fr) auto auto auto;
    grid-template-rows: 25px 16px;
    align-items: center;
    column-gap: 0.28rem;
    row-gap: 0.08rem;
    min-height: 0;
    padding: max(0.12rem, env(safe-area-inset-top)) max(0.34rem, env(safe-area-inset-right)) 0.12rem max(0.34rem, env(safe-area-inset-left));
    background: linear-gradient(180deg, rgba(5, 14, 24, 0.94), rgba(5, 14, 24, 0.73));
  }

  .message-bubble {
    z-index: 12;
    top: calc(max(0.12rem, env(safe-area-inset-top)) + 44px);
    max-width: min(76%, 620px);
    max-height: 2.7rem;
    padding: 0.32rem 0.58rem;
    font-size: clamp(0.68rem, 2.4svh, 0.88rem);
    line-height: 1.14;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    pointer-events: none;
  }

  .brand-block {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .brand-block strong {
    font-size: clamp(0.72rem, 2.3svh, 0.95rem);
  }

  .brand-block span,
  .hud-label {
    display: none;
  }

  .meter-block {
    grid-column: 2;
    grid-row: 1;
    min-width: 58px;
    max-width: 150px;
  }

  .groove-meter {
    height: 8px;
    border-width: 1px;
  }

  .notes-block {
    grid-column: 3;
    grid-row: 1;
    min-width: 43px;
    gap: 0.12rem;
    font-size: 0.68rem;
  }

  .blue-note {
    font-size: 1.12rem;
  }

  .bonus-stats {
    grid-column: 4;
    grid-row: 1;
    display: flex;
    min-width: 0;
    gap: 0.3rem;
    font-size: clamp(0.52rem, 1.7svh, 0.66rem);
    white-space: nowrap;
  }

  .timer-block {
    grid-column: 5;
    grid-row: 1;
    min-width: 42px;
    padding: 0.1rem 0.22rem;
    border-width: 1px;
    border-radius: 6px;
  }

  .timer-block > span {
    display: none;
  }

  .timer-block > strong {
    margin: 0;
    font-size: 0.82rem;
  }

  .timer-block small {
    font-size: 0.52rem;
  }

  .crew-block {
    grid-column: 1 / -1;
    grid-row: 2;
    order: initial;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    margin: 0;
    gap: 0.14rem;
  }

  .crew-block span {
    min-width: 0;
    padding: 0.08rem 0.18rem;
    border-radius: 4px;
    overflow: visible;
    font-size: clamp(0.46rem, 1.55svh, 0.6rem);
    line-height: 1.1;
    text-align: center;
  }

  .utility-buttons {
    position: fixed;
    z-index: 30;
    top: 46%;
    right: max(0.26rem, env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    transform: translateY(-50%);
  }

  .utility-buttons button {
    min-width: 28px;
    width: 28px;
    min-height: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    border-color: rgba(255, 255, 255, 0.34);
    background: rgba(5, 12, 20, 0.72);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.34);
    font-size: 0.72rem;
    line-height: 1;
  }

  .stage-wrap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }

  .touch-controls {
    inset: auto 0 0;
    opacity: 1;
    padding: 0.45rem max(0.6rem, env(safe-area-inset-right)) max(0.55rem, env(safe-area-inset-bottom)) max(0.6rem, env(safe-area-inset-left));
  }

  .touch-controls button {
    width: clamp(54px, 16svh, 68px);
    height: clamp(54px, 16svh, 68px);
  }

  .touch-controls .bark-button {
    width: clamp(62px, 18svh, 76px);
  }

  .touch-controls .jump-button {
    width: clamp(82px, 24svh, 104px);
    height: clamp(82px, 24svh, 104px);
  }

  .tutorial-overlay {
    place-items: start center;
    padding: 0.35rem;
  }

  .tutorial-panel {
    width: min(92%, 820px);
    padding: 0.65rem 0.9rem;
  }

  .tutorial-panel .eyebrow,
  .tutorial-tip,
  .audio-credit {
    display: none;
  }

  .tutorial-panel h2 {
    margin: 0 0 0.45rem;
    font-size: 1.15rem;
  }

  .tutorial-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .tutorial-grid article {
    padding: 0.38rem 0.5rem;
  }

  .tutorial-grid span {
    font-size: 0.7rem;
  }

  .tutorial-panel .primary-button {
    min-height: 36px;
    margin-top: 0.45rem;
    padding: 0.35rem 0.8rem;
    font-size: 0.82rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .crawl-perspective {
    inset: 12% 6% 5%;
    overflow-y: auto;
    perspective: none;
  }

  .crawl-plane {
    position: static;
    transform: none;
  }

  .crawl-content {
    position: static;
    width: min(92%, 720px);
    margin: 0 auto;
    animation: none;
    transform: none;
  }
}

.game-card:fullscreen {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  background: #02060a;
}

.game-card:fullscreen .stage-wrap {
  flex: 1;
  width: min(100%, calc((100vh - 50px) * 1.7778));
  margin: auto;
}

.game-card:fullscreen .game-help,
.game-card:fullscreen .rotate-hint {
  display: none;
}

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

@media (orientation: landscape) and (max-height: 560px) {
  .game-card:fullscreen {
    position: relative;
    display: block;
  }

  .game-card:fullscreen .stage-wrap {
    position: absolute;
    inset: 0;
    width: min(100vw, calc(100vh * 1.7778));
    height: min(100vh, calc(100vw * 0.5625));
    margin: auto;
  }
}
