:root {
  --shell-side-pad: 28px;
  --shell-top-pad: 28px;
  --shell-bottom-pad: 28px;
  --cabinet-gap: 8px;
  --sidebar-width: 280px;
  --bg: #a6a6a6;
  --panel: #d8d8d8;
  --panel-alt: #efefef;
  --panel-dark: #404040;
  --screen: #cfcfcf;
  --ink: #0e0e0e;
  --white: #fafafa;
  --pattern-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' shape-rendering='crispEdges'%3E%3Crect width='12' height='12' fill='%23a6a6a6'/%3E%3Crect width='3' height='3' fill='%23858585'/%3E%3Crect x='6' width='3' height='3' fill='%23858585'/%3E%3Crect x='3' y='3' width='3' height='3' fill='%23858585'/%3E%3Crect x='9' y='3' width='3' height='3' fill='%23858585'/%3E%3Crect y='6' width='3' height='3' fill='%23858585'/%3E%3Crect x='6' y='6' width='3' height='3' fill='%23858585'/%3E%3Crect x='3' y='9' width='3' height='3' fill='%23858585'/%3E%3Crect x='9' y='9' width='3' height='3' fill='%23858585'/%3E%3C/svg%3E");
  --pattern-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' shape-rendering='crispEdges'%3E%3Crect width='12' height='12' fill='%23d8d8d8'/%3E%3Crect width='3' height='3' fill='%23c4c4c4'/%3E%3Crect x='6' width='3' height='3' fill='%23c4c4c4'/%3E%3Crect x='3' y='3' width='3' height='3' fill='%23c4c4c4'/%3E%3Crect x='9' y='3' width='3' height='3' fill='%23c4c4c4'/%3E%3Crect y='6' width='3' height='3' fill='%23c4c4c4'/%3E%3Crect x='6' y='6' width='3' height='3' fill='%23c4c4c4'/%3E%3Crect x='3' y='9' width='3' height='3' fill='%23c4c4c4'/%3E%3Crect x='9' y='9' width='3' height='3' fill='%23c4c4c4'/%3E%3C/svg%3E");
  --cursor-default: url("hand-cursor.png") 7 2, pointer;
  --cursor-pointer: url("hand-cursor.png") 7 2, pointer;
  font-family: "VT323", monospace;
}

* {
  box-sizing: border-box;
  cursor: var(--cursor-default);
  -webkit-tap-highlight-color: transparent;
}

html,
body,
.shell,
.cabinet,
.frame-shell,
.frame,
#game,
.overlay,
.overlay-card,
.hud,
.score-stack,
.score-block,
.promo-banner,
.attract-panel,
.leaderboard-panel,
.control-panel,
#submit-score-button,
.audio-toggle {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

input,
textarea,
select,
[contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background-color: var(--panel);
  background-image: var(--pattern-light);
  color: var(--ink);
  touch-action: manipulation;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  font-size: 24px;
  line-height: 1.1;
  background-attachment: scroll;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--shell-top-pad) var(--shell-side-pad) var(--shell-bottom-pad);
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.cabinet {
  display: grid;
  grid-template-columns: max-content var(--sidebar-width);
  gap: var(--cabinet-gap);
  width: fit-content;
  max-width: calc(100vw - (var(--shell-side-pad) * 2));
  align-items: start;
  justify-content: center;
  position: relative;
  z-index: 10;
}

.ambient-scene {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.ambient-waterline,
.ambient-seabed,
.ambient-reef,
.ambient-rock,
.ambient-bubble {
  position: absolute;
}

.ambient-waterline {
  top: 0;
  left: 0;
  right: 0;
  height: 124px;
  opacity: 0.62;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(245, 245, 245, 0.95) 0 22px,
      rgba(245, 245, 245, 0) 22px 30px,
      rgba(208, 208, 208, 0.78) 30px 52px,
      rgba(208, 208, 208, 0) 52px 60px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(106, 106, 106, 0.28) 0 18px,
      rgba(106, 106, 106, 0) 18px 26px
    );
  background-position: 0 0, 8px 22px;
  background-size: auto 24px, auto 18px;
  background-repeat: repeat-x;
}

.ambient-seabed {
  left: 0;
  right: 0;
  bottom: 0;
  height: 24vh;
  min-height: 170px;
  background:
    linear-gradient(to top, rgba(17, 17, 17, 0.18), rgba(17, 17, 17, 0) 86%),
    repeating-linear-gradient(
      90deg,
      rgba(245, 245, 245, 0.18) 0 10px,
      rgba(245, 245, 245, 0) 10px 20px,
      rgba(184, 184, 184, 0.16) 20px 30px,
      rgba(184, 184, 184, 0) 30px 40px
    ),
    linear-gradient(to bottom, rgba(226, 226, 226, 0), rgba(106, 106, 106, 0.26));
  clip-path: polygon(0 34%, 9% 28%, 17% 34%, 28% 24%, 40% 30%, 52% 18%, 64% 24%, 74% 14%, 86% 20%, 100% 10%, 100% 100%, 0 100%);
}

.ambient-reef {
  --reef-flip: 1;
  bottom: 0;
  width: 196px;
  height: 230px;
  opacity: 0.36;
  animation: reef-sway 8s steps(2, end) infinite alternate;
}

.ambient-reef::before,
.ambient-reef::after {
  content: "";
  position: absolute;
  inset: 0;
}

.ambient-reef::before {
  background:
    linear-gradient(var(--panel-dark), var(--panel-dark)) 0 100% / 24px 88px no-repeat,
    linear-gradient(var(--panel-dark), var(--panel-dark)) 26px 74% / 18px 128px no-repeat,
    linear-gradient(var(--panel-dark), var(--panel-dark)) 48px 100% / 26px 98px no-repeat,
    linear-gradient(var(--panel-dark), var(--panel-dark)) 78px 62% / 20px 152px no-repeat,
    linear-gradient(var(--panel-dark), var(--panel-dark)) 106px 100% / 28px 108px no-repeat,
    linear-gradient(var(--panel-dark), var(--panel-dark)) 138px 70% / 22px 134px no-repeat,
    linear-gradient(var(--panel-dark), var(--panel-dark)) 166px 100% / 16px 90px no-repeat;
}

.ambient-reef::after {
  opacity: 0.62;
  background:
    linear-gradient(var(--ink), var(--ink)) 6px calc(100% - 64px) / 10px 52px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 34px calc(100% - 104px) / 10px 84px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 58px calc(100% - 74px) / 10px 58px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 84px calc(100% - 128px) / 10px 104px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 114px calc(100% - 80px) / 10px 62px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 144px calc(100% - 118px) / 10px 92px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 170px calc(100% - 68px) / 8px 54px no-repeat;
}

.ambient-reef-left {
  left: 32px;
}

.ambient-reef-right {
  right: 42px;
  --reef-flip: -1;
  animation-delay: -2.5s;
}

.ambient-rock {
  bottom: 0;
  width: 220px;
  height: 132px;
  background: rgba(106, 106, 106, 0.5);
  border: 4px solid rgba(17, 17, 17, 0.28);
  clip-path: polygon(0 82%, 12% 54%, 34% 44%, 48% 22%, 72% 20%, 84% 38%, 100% 56%, 100% 100%, 0 100%);
}

.ambient-rock::after {
  content: "";
  position: absolute;
  inset: 12px 16px 12px 18px;
  background:
    linear-gradient(135deg, rgba(245, 245, 245, 0.16) 0 26%, transparent 26% 100%),
    linear-gradient(45deg, rgba(17, 17, 17, 0.12) 0 18%, transparent 18% 100%);
}

.ambient-rock-left {
  left: -18px;
}

.ambient-rock-right {
  right: -22px;
  transform: scaleX(-1);
}

.ambient-bubble {
  --bubble-drift: 8px;
  --bubble-rise: -180px;
  width: 42px;
  height: 42px;
  border: 4px solid #6a6a6a;
  background: transparent;
  opacity: 0;
  z-index: 2;
  will-change: transform, opacity;
}

.ambient-bubble::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  top: 7px;
  left: 7px;
  background: #e2e2e2;
}

.ambient-bubble-one {
  left: 10%;
  bottom: 8%;
  --bubble-drift: 8px;
  --bubble-rise: -182px;
  animation: bubble-float 18s linear infinite;
}

.ambient-bubble-two {
  left: 22%;
  bottom: 22%;
  width: 34px;
  height: 34px;
  --bubble-drift: -10px;
  --bubble-rise: -168px;
  animation: bubble-float 21s linear infinite;
  animation-delay: -7s;
}

.ambient-bubble-three {
  right: 11%;
  bottom: 10%;
  width: 48px;
  height: 48px;
  --bubble-drift: 12px;
  --bubble-rise: -156px;
  animation: bubble-float 19s linear infinite;
  animation-delay: -11s;
}

.ambient-bubble-four {
  right: 19%;
  bottom: 26%;
  --bubble-drift: -8px;
  --bubble-rise: -176px;
  animation: bubble-float 25s linear infinite;
  animation-delay: -14s;
}

.ambient-bubble-five {
  left: 14%;
  bottom: 42%;
  width: 30px;
  height: 30px;
  --bubble-drift: 10px;
  --bubble-rise: -148px;
  animation: bubble-float 22s linear infinite;
  animation-delay: -5s;
}

.ambient-bubble-six {
  right: 8%;
  bottom: 46%;
  width: 36px;
  height: 36px;
  --bubble-drift: 6px;
  --bubble-rise: -164px;
  animation: bubble-float 24s linear infinite;
  animation-delay: -16s;
}

.promo-banner {
  position: relative;
  z-index: 12;
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--ink);
  border: 4px solid var(--ink);
  background: var(--panel-alt);
  background-color: var(--panel-alt);
  background-image: none !important;
  background-attachment: scroll;
  box-shadow: 8px 8px 0 rgba(106, 106, 106, 0.75);
}

.promo-banner:hover {
  background: var(--white);
}

.promo-kicker,
.promo-url {
  display: block;
  font-family: "Press Start 2P", monospace;
  font-size: 0.5rem;
  line-height: 1.6;
  text-transform: uppercase;
}

.promo-banner strong {
  display: block;
  font-family: "Press Start 2P", monospace;
  font-size: 0.78rem;
  line-height: 1.6;
}

.frame-shell,
.attract-panel,
.leaderboard-panel,
.control-panel {
  position: relative;
  z-index: 11;
  border: 4px solid var(--ink);
  background-color: var(--panel);
  background-image: var(--pattern-light);
  box-shadow: 8px 8px 0 var(--panel-dark);
}

.frame-shell {
  display: grid;
  padding: 14px;
  width: min(
    100%,
    calc(100vw - (var(--shell-side-pad) * 2) - var(--sidebar-width) - var(--cabinet-gap)),
    calc(100vh - var(--shell-top-pad) - var(--shell-bottom-pad) - 120px)
  );
  max-width: 760px;
}

.title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 4px solid var(--ink);
  background: var(--panel-alt);
}

.title-bar h1 {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0;
}

.title-tag {
  display: inline-block;
  padding: 5px 8px;
  border: 3px solid var(--ink);
  background: var(--white);
  font-family: "Press Start 2P", monospace;
  text-transform: uppercase;
  font-size: 0.52rem;
  line-height: 1.4;
}

.frame {
  position: relative;
  z-index: 11;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 4px solid var(--ink);
  background: var(--screen);
  overflow: hidden;
}

.attract-panel,
.leaderboard-panel,
.control-panel {
  padding: 14px;
}

.attract-screen {
  height: 124px;
  overflow: hidden;
  border: 3px solid var(--ink);
  background: var(--white);
  position: relative;
}

.attract-screen::before,
.attract-screen::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 10px;
  z-index: 1;
}

.attract-screen::before {
  top: 0;
  background: linear-gradient(to bottom, var(--white), transparent);
}

.attract-screen::after {
  bottom: 0;
  background: linear-gradient(to top, var(--white), transparent);
}

.marquee-track {
  display: grid;
  gap: 14px;
  padding: 14px 12px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.62rem;
  line-height: 1.6;
  animation: marquee-scroll 12s linear infinite;
}

.marquee-track span {
  display: block;
}

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 3;
  pointer-events: none;
}

.score-stack {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.score-block {
  min-width: 92px;
  padding: 8px 10px;
  border: 3px solid var(--ink);
  background: var(--panel-alt);
}

.label,
.eyebrow,
.controls {
  display: block;
  font-family: "Press Start 2P", monospace;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.5rem;
  line-height: 1.5;
}

.score-block strong {
  display: block;
  margin-top: 4px;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  line-height: 1.15;
}

.sidebar {
  position: relative;
  z-index: 11;
  display: grid;
  gap: 18px;
  width: var(--sidebar-width);
  margin-right: 10px;
}

.sidebar .attract-panel,
.sidebar .leaderboard-panel,
.sidebar .control-panel {
  background-image: none;
}

.leaderboard-header,
.panel-row {
  display: grid;
  gap: 6px;
}

.leaderboard-header {
  margin-bottom: 10px;
}

.leaderboard-header strong {
  font-family: "Press Start 2P", monospace;
  font-size: 1.15rem;
  line-height: 1.35;
}

.leaderboard-list {
  margin: 0;
  padding-left: 22px;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 2px solid rgba(17, 17, 17, 0.35);
  font-size: 1.2rem;
}

.leaderboard-list li:last-child {
  border-bottom: 0;
}

.leaderboard-list .empty {
  display: block;
  color: var(--panel-dark);
}

.leaderboard-more-link {
  display: inline-block;
  margin-top: 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.52rem;
  line-height: 1.5;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: underline;
}

.entry-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.entry-crown {
  display: inline;
  margin-left: 2px;
  font-size: 0.95em;
  line-height: 1;
  pointer-events: none;
}

.entry-rank {
  min-width: 2.3ch;
  font-weight: 700;
}

.entry-score {
  font-weight: 700;
}

.leaderboard-list li.recent-entry {
  margin: 2px 0;
  padding: 6px 8px;
  background: var(--panel-dark);
  color: var(--white);
  border: 2px solid var(--ink);
}

.leaderboard-list li.recent-entry .entry-rank,
.leaderboard-list li.recent-entry .entry-name,
.leaderboard-list li.recent-entry .entry-score {
  color: var(--white);
}

.leaderboard-list li.top-entry .entry-name {
  font-size: 1.12em;
  font-weight: 700;
}

.panel-copy {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.15;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: manipulation;
}

.overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: transparent;
  z-index: 1200;
  isolation: isolate;
}

.overlay::before {
  content: "";
  position: fixed;
  inset: 0;
  width: 100dvw;
  height: 100dvh;
  min-height: 100svh;
  background: rgba(106, 106, 106, 0.7);
  z-index: -1;
  pointer-events: none;
}

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

.overlay-card {
  width: min(360px, 100%);
  padding: 20px 18px;
  text-align: center;
  border: 4px solid var(--ink);
  background-color: var(--panel-alt);
  background-image: var(--pattern-light);
  box-shadow: 8px 8px 0 var(--panel-dark);
}

.overlay-card h2 {
  margin: 8px 0 12px;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(2rem, 4vw, 3rem) !important;
  line-height: 1.05;
  text-transform: uppercase;
}

.overlay-card p {
  margin: 0;
}

#overlay-copy {
  max-width: 28ch;
  margin: 0 auto 16px;
  line-height: 1.15;
}

.leaderboard-form {
  margin: 0 auto 14px;
  max-width: 320px;
}

.leaderboard-form.hidden {
  display: none;
}

.overlay-leaderboard {
  display: none;
  width: min(320px, 100%);
  margin: 0 auto 14px;
  padding: 10px;
  border: 3px solid var(--ink);
  background: var(--panel-alt);
}

.overlay-leaderboard.hidden {
  display: none !important;
}

.overlay-leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.overlay-leaderboard-header strong {
  font-family: "Press Start 2P", monospace;
  font-size: 0.8rem;
  line-height: 1.2;
}

.leaderboard-form-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

#player-name {
  min-width: 0;
  flex: 1;
  border: 3px solid var(--ink);
  padding: 11px 10px;
  font: inherit;
  color: var(--ink);
  background: var(--white);
}

#submit-score-button,
#skip-score-button,
.audio-toggle {
  appearance: none;
  border: 3px solid var(--ink);
  padding: 10px 12px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.7rem;
  line-height: 1.45;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--white);
  background: var(--ink);
  cursor: var(--cursor-pointer);
  touch-action: manipulation;
}

#submit-score-button,
#skip-score-button {
  min-width: 92px;
}

.audio-toggle {
  width: 100%;
}

.audio-toggle[data-muted="true"] {
  background: var(--panel-dark);
}

.mobile-audio-toggle {
  display: none;
  position: fixed;
  top: calc(var(--shell-top-pad) + env(safe-area-inset-top));
  right: var(--shell-side-pad);
  width: 42px;
  height: 42px;
  border: 3px solid var(--ink);
  background: var(--panel-alt);
  color: var(--ink);
  box-shadow: 4px 4px 0 rgba(106, 106, 106, 0.75);
  z-index: 90000;
  display: grid;
  place-items: center;
  padding: 0;
}

.mobile-audio-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.mobile-audio-icon .icon-speaker {
  fill: currentColor;
  stroke: none;
}

.mobile-audio-icon .icon-wave {
  display: block;
}

.mobile-audio-icon .icon-mute {
  display: none;
}

.mobile-audio-toggle[data-muted="true"] .icon-wave {
  display: none;
}

.mobile-audio-toggle[data-muted="true"] .icon-mute {
  display: block;
}

#submit-score-button:hover,
#skip-score-button:hover,
.audio-toggle:hover {
  background: var(--white);
  color: var(--ink);
}

.form-status {
  min-height: 1.25em;
  margin-top: 10px;
  color: var(--panel-dark);
  font-size: 1rem;
}

.form-status.error {
  color: #3f3f3f;
}

.form-status.success {
  color: #222222;
}

@keyframes marquee-scroll {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-50%);
  }
}

@keyframes bubble-float {
  0% {
    transform: translateY(28px) translateX(0) scale(0.92);
    opacity: 0;
  }
  12% {
    opacity: 0.28;
  }
  82% {
    opacity: 0.28;
  }
  100% {
    transform: translateY(var(--bubble-rise)) translateX(var(--bubble-drift)) scale(1.05);
    opacity: 0;
  }
}

@keyframes reef-sway {
  0% {
    transform: translateX(0) scaleX(var(--reef-flip));
  }
  100% {
    transform: translateX(6px) scaleX(var(--reef-flip));
  }
}

.controls {
  margin-top: 14px;
}

@media (min-width: 921px) {
  :root {
    --pattern-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' shape-rendering='crispEdges'%3E%3Crect width='12' height='12' fill='%23a6a6a6'/%3E%3Crect width='3' height='3' fill='%238f8f8f'/%3E%3Crect x='6' width='3' height='3' fill='%238f8f8f'/%3E%3Crect x='3' y='3' width='3' height='3' fill='%238f8f8f'/%3E%3Crect x='9' y='3' width='3' height='3' fill='%238f8f8f'/%3E%3Crect y='6' width='3' height='3' fill='%238f8f8f'/%3E%3Crect x='6' y='6' width='3' height='3' fill='%238f8f8f'/%3E%3Crect x='3' y='9' width='3' height='3' fill='%238f8f8f'/%3E%3Crect x='9' y='9' width='3' height='3' fill='%238f8f8f'/%3E%3C/svg%3E");
    --pattern-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' shape-rendering='crispEdges'%3E%3Crect width='12' height='12' fill='%23d8d8d8'/%3E%3Crect width='3' height='3' fill='%23cbcbcb'/%3E%3Crect x='6' width='3' height='3' fill='%23cbcbcb'/%3E%3Crect x='3' y='3' width='3' height='3' fill='%23cbcbcb'/%3E%3Crect x='9' y='3' width='3' height='3' fill='%23cbcbcb'/%3E%3Crect y='6' width='3' height='3' fill='%23cbcbcb'/%3E%3Crect x='6' y='6' width='3' height='3' fill='%23cbcbcb'/%3E%3Crect x='3' y='9' width='3' height='3' fill='%23cbcbcb'/%3E%3Crect x='9' y='9' width='3' height='3' fill='%23cbcbcb'/%3E%3C/svg%3E");
  }
}

@media (max-width: 920px) {
  :root {
    --sidebar-width: 100%;
    --cabinet-gap: 14px;
  }

  .cabinet {
    grid-template-columns: 1fr;
    width: min(760px, calc(100vw - (var(--shell-side-pad) * 2)));
  }

  .frame-shell {
    width: 100%;
    max-width: none;
  }

  .frame {
    width: 100%;
  }

  .sidebar {
    width: 100%;
    margin-right: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .promo-banner {
    grid-column: 1 / -1;
  }

  .leaderboard-panel {
    grid-column: 1 / -1;
  }

  .ambient-bubble-four,
  .ambient-bubble-six {
    display: none;
  }

}

@media (max-width: 620px) {
  :root {
    --shell-side-pad: 12px;
    --shell-top-pad: 12px;
    --shell-bottom-pad: 12px;
    --cabinet-gap: 10px;
  }

  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  body {
    font-size: 20px;
  }

  .shell {
    place-items: start center;
    min-height: 100dvh;
    height: 100dvh;
    padding-bottom: calc(var(--shell-bottom-pad) + env(safe-area-inset-bottom) + 82px);
  }

  .cabinet {
    width: min(100%, calc(100vw - (var(--shell-side-pad) * 2)));
    max-height: calc(100dvh - var(--shell-top-pad) - var(--shell-bottom-pad) - env(safe-area-inset-bottom) - 82px);
    align-content: start;
    gap: 12px;
    overflow: auto;
  }

  .frame-shell,
  .attract-panel,
  .leaderboard-panel,
  .control-panel,
  .overlay-card {
    box-shadow: 4px 4px 0 var(--panel-dark);
  }

  .title-bar {
    align-items: flex-start;
    flex-direction: column;
    padding: 8px 10px;
  }

  .leaderboard-form-row {
    flex-direction: column;
  }

  .title-bar h1 {
    font-size: clamp(1.4rem, 8vw, 2rem);
  }

  .frame-shell {
    gap: 10px;
  }

  .score-stack {
    gap: 6px;
  }

  .score-block {
    min-width: 58px;
    padding: 4px 6px;
    border-width: 2px;
  }

  .score-block strong {
    margin-top: 2px;
    font-size: clamp(0.95rem, 5vw, 1.35rem);
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 120px;
  }

  .attract-panel,
  .leaderboard-panel,
  .control-panel,
  .promo-banner {
    width: 100%;
  }

  .leaderboard-panel {
    display: none;
  }

  .control-panel {
    display: none;
  }

  .mobile-audio-toggle {
    display: block;
  }

  .frame {
    width: min(100%, calc(100dvh - 250px));
    margin-inline: auto;
    touch-action: none;
  }

  #game {
    touch-action: none;
  }

  .hud {
    top: 6px;
    left: 6px;
    right: 6px;
  }

  .promo-banner,
  .leaderboard-panel {
    grid-column: 1 / -1;
  }

  .attract-panel {
    display: none;
  }

  .promo-banner {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    width: min(calc(100vw - (var(--shell-side-pad) * 2)), 460px);
    right: auto;
    bottom: calc(env(safe-area-inset-bottom) + 6px);
    z-index: 50000;
    margin-top: 0;
    padding: 8px 10px;
    gap: 4px;
    border-width: 3px;
    background: var(--panel-alt) !important;
    background-color: var(--panel-alt) !important;
    background-image: none !important;
    box-shadow: 4px 4px 0 rgba(106, 106, 106, 0.75);
  }

  .promo-banner strong {
    font-size: 0.56rem;
    line-height: 1.35;
  }

  .promo-kicker,
  .promo-url {
    font-size: 0.42rem;
    line-height: 1.35;
  }

  .attract-screen {
    height: 96px;
  }

  .marquee-track {
    gap: 10px;
    padding: 10px;
    font-size: 0.52rem;
  }

  .panel-copy,
  .leaderboard-list li {
    font-size: 1rem;
  }

  .overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    padding:
      calc(env(safe-area-inset-top) + 10px)
      8px
      calc(env(safe-area-inset-bottom) + 14px);
    z-index: 99999;
    overflow-y: auto;
    place-items: start center;
    align-content: start;
  }

  .overlay-card {
    width: min(320px, 100%);
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 28px);
    overflow: auto;
    margin: 0 auto 8px;
    padding: 12px 10px;
    gap: 8px;
  }

  .overlay-card h2 {
    margin: 4px 0 6px;
    font-size: clamp(1.15rem, 8.5vw, 1.85rem) !important;
  }

  #overlay-copy {
    max-width: 20ch;
    margin-bottom: 8px;
    font-size: 0.95rem;
    line-height: 1.05;
  }

  .leaderboard-form {
    margin: 0 auto 8px;
  }

  .overlay-leaderboard {
    display: block;
    margin: 0 auto 10px;
  }

  .overlay-leaderboard .leaderboard-list {
    margin: 0;
    padding-left: 18px;
  }

  .overlay-leaderboard .leaderboard-list li {
    padding: 4px 0;
    font-size: 0.95rem;
  }

  #submit-score-button,
  #skip-score-button,
  .audio-toggle {
    font-size: 0.58rem;
    padding: 8px 9px;
  }

  #submit-score-button,
  #skip-score-button {
    width: 100%;
    min-width: 0;
  }

  .ambient-reef {
    width: 140px;
    height: 180px;
    opacity: 0.24;
  }

  .ambient-rock {
    width: 150px;
    height: 92px;
  }

  .ambient-bubble-three,
  .ambient-bubble-five {
    display: none;
  }
}

@media (max-width: 420px) {
  .shell {
    padding-bottom: calc(var(--shell-bottom-pad) + env(safe-area-inset-bottom) + 72px);
  }

  .cabinet {
    max-height: calc(100dvh - var(--shell-top-pad) - var(--shell-bottom-pad) - env(safe-area-inset-bottom) - 72px);
    overflow: hidden;
  }

  .frame {
    width: min(100%, calc(100dvh - 260px));
  }

  .promo-banner {
    width: calc(100vw - (var(--shell-side-pad) * 2));
    padding: 7px 9px;
  }

  .title-tag,
  .label,
  .eyebrow,
  .controls,
  .promo-kicker,
  .promo-url {
    font-size: 0.44rem;
  }

  .frame-shell {
    padding: 8px;
  }

  .title-bar {
    margin-bottom: 8px;
    padding: 6px 8px;
  }

  .hud {
    top: 4px;
    left: 4px;
    right: 4px;
  }

  .score-stack {
    gap: 4px;
  }

  .score-block {
    min-width: 48px;
    padding: 3px 5px;
  }

  .score-block strong {
    font-size: clamp(0.82rem, 4.8vw, 1.05rem);
  }

  .overlay-card {
    width: 100%;
  }

  .overlay-card h2 {
    font-size: clamp(1rem, 8vw, 1.5rem) !important;
  }

  #overlay-copy {
    max-width: 35ch;
    font-size: 1.2rem;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  #player-name {
    padding: 9px 8px;
  }

  .ambient-reef,
  .ambient-rock,
  .ambient-bubble {
    display: none;
  }
}
