* {
  box-sizing: border-box;
}

:root {
  /*
    DO NOT TOUCH — your working desktop coordinates
  */
  --computer-x: 50.4%;
  --computer-y: 48.6%;
  --computer-w: clamp(200px, 160vw, 200px);

  --mpc-x: 76.8%;
  --mpc-y: 54.9%;
  --mpc-w: clamp(95px, 8vw, 130px);

  --player-w: clamp(210px, 20vw, 330px);
  --player-bottom: 6%;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: #02020a;
  color: #fff;
  overflow-x: hidden;
  font-family: 'Inter', system-ui, sans-serif;
}

body {
  touch-action: manipulation;
}

button {
  font-family: inherit;
}

.game-shell {
  width: 100%;
  min-height: 100vh;
  background: #02020a;
}

.is-hidden {
  display: none !important;
}

/* PRELOADER */

.preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 212, 41, 0.16), transparent 28%),
    radial-gradient(circle at 50% 52%, rgba(139, 53, 255, 0.28), transparent 42%),
    #02020a;
  display: grid;
  place-items: center;
}

.loader-card,
.level-loader-card {
  width: min(90vw, 560px);
  padding: 34px 26px;
  border: 3px solid #7c3cff;
  background: rgba(4, 8, 25, 0.94);
  box-shadow:
    0 0 30px rgba(124, 60, 255, 0.65),
    inset 0 0 22px rgba(0, 229, 255, 0.18);
  text-align: center;
}

.loader-title {
  font-family: 'Press Start 2P', monospace;
  color: #ffd429;
  font-size: clamp(20px, 5vw, 38px);
  text-shadow:
    4px 4px 0 #3b136f,
    0 0 22px rgba(255, 212, 41, 0.5);
  margin-bottom: 18px;
}

.loader-subtitle {
  font-family: 'Press Start 2P', monospace;
  color: #21eaff;
  font-size: 12px;
  margin-bottom: 24px;
}

.loader-bar {
  width: 100%;
  height: 18px;
  border: 2px solid #21eaff;
  padding: 3px;
  background: #030617;
}

.loader-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #21eaff, #9b4dff, #ffd429);
  animation: loadBar 1.15s ease forwards;
}

@keyframes loadBar {
  to {
    width: 100%;
  }
}

/* START SCREEN */

.start-screen {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 212, 41, 0.14), transparent 24%),
    radial-gradient(circle at 50% 52%, rgba(139, 53, 255, 0.28), transparent 42%),
    radial-gradient(circle at 72% 72%, rgba(33, 234, 255, 0.12), transparent 30%),
    linear-gradient(180deg, #070013, #02020a 72%);
}

.start-grid {
  position: absolute;
  inset: -80px;
  background:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  transform: perspective(650px) rotateX(58deg);
  transform-origin: bottom;
  opacity: 0.55;
}

.start-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 40%, rgba(0,0,0,0.64) 100%),
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 18%, rgba(0,0,0,0.48));
}

.arcade-title-card {
  position: relative;
  z-index: 5;
  width: min(92vw, 820px);
  padding: clamp(32px, 6vw, 68px);
  text-align: center;
  border: 4px solid #8b35ff;
  background:
    linear-gradient(180deg, rgba(8, 14, 42, 0.94), rgba(2, 3, 14, 0.97));
  box-shadow:
    0 0 70px rgba(139, 53, 255, 0.58),
    0 0 28px rgba(33, 234, 255, 0.24),
    inset 0 0 38px rgba(33, 234, 255, 0.12);
}

.arcade-title-card::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(33, 234, 255, 0.28);
  pointer-events: none;
}

.arcade-crown {
  font-family: 'Press Start 2P', monospace;
  color: #ffd429;
  font-size: clamp(22px, 4vw, 38px);
  margin-bottom: 8px;
  text-shadow:
    3px 3px 0 #4b168f,
    0 0 18px rgba(255, 212, 41, 0.7);
}

.rah-logo {
  margin: 0;
  font-family: 'Press Start 2P', monospace;
  color: #ff593f;
  font-size: clamp(44px, 10vw, 96px);
  line-height: 1.05;
  letter-spacing: 2px;
  text-align: center;
  text-shadow:
    5px 5px 0 #240011,
    0 0 8px rgba(255, 91, 63, 0.95),
    0 0 22px rgba(255, 91, 63, 0.75),
    0 0 42px rgba(255, 91, 63, 0.45);
}

.insert-coin {
  margin-top: 26px;
  font-family: 'Press Start 2P', monospace;
  color: #ffd429;
  font-size: clamp(15px, 3vw, 26px);
  line-height: 1.4;
  text-shadow:
    3px 3px 0 #4b168f,
    0 0 18px rgba(255, 212, 41, 0.5);
  animation: blinkCoin 1s steps(2, start) infinite;
}

@keyframes blinkCoin {
  0%, 100% {
    opacity: 1;
  }

  50% {
    opacity: 0.36;
  }
}

.start-copy {
  margin: 24px auto 28px;
  font-family: 'Press Start 2P', monospace;
  color: #21eaff;
  font-size: clamp(9px, 1.8vw, 13px);
  line-height: 2;
}

.start-button {
  border: 0;
  cursor: pointer;
  padding: 18px 28px;
  min-width: 230px;
  background: linear-gradient(180deg, #ffd429, #ff8a00);
  color: #1a0b00;
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  box-shadow:
    0 8px 0 #7b3300,
    0 0 28px rgba(255, 212, 41, 0.54);
}

.start-button:hover {
  filter: brightness(1.12);
}

.start-button:active {
  transform: translateY(7px);
  box-shadow:
    0 1px 0 #7b3300,
    0 0 20px rgba(255, 212, 41, 0.45);
}

.start-footer {
  margin-top: 24px;
  font-family: 'Press Start 2P', monospace;
  color: rgba(255,255,255,0.56);
  font-size: 8px;
  line-height: 1.7;
}

/* LEVEL LOADER */

.level-loader {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(139, 53, 255, 0.25), transparent 42%),
    #02020a;
}

.level-loader-kicker {
  font-family: 'Press Start 2P', monospace;
  color: #21eaff;
  font-size: 11px;
  margin-bottom: 16px;
}

.level-loader-card h2 {
  margin: 0 0 16px;
  font-family: 'Press Start 2P', monospace;
  color: #ffd429;
  font-size: clamp(24px, 6vw, 52px);
  text-shadow:
    4px 4px 0 #4b168f,
    0 0 22px rgba(255, 212, 41, 0.5);
}

.level-loader-card p {
  margin: 0 0 24px;
  font-family: 'Press Start 2P', monospace;
  color: #fff;
  font-size: 10px;
}

/* LEVEL */

.level {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 720px;
  overflow: hidden;
  background: #02020a;
  touch-action: none;
}

.level-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  image-rendering: auto;
  z-index: 1;
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 42%, rgba(0,0,0,0.42) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.15), transparent 24%, rgba(0,0,0,0.42));
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  opacity: 0.12;
  background: repeating-linear-gradient(
    180deg,
    rgba(255,255,255,0.22) 0,
    rgba(255,255,255,0.22) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: overlay;
}

/* HUD */

.arcade-hud-css {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: min(94vw, 1160px);
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 12px;
  font-family: 'Press Start 2P', monospace;
  pointer-events: none;
}

.hud-panel {
  min-height: 78px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(8, 15, 46, 0.86), rgba(3, 7, 24, 0.86));
  border: 3px solid #8b35ff;
  box-shadow:
    0 0 18px rgba(139, 53, 255, 0.55),
    inset 0 0 18px rgba(0, 234, 255, 0.14);
}

.hud-left {
  justify-content: flex-start;
  gap: 18px;
}

.hud-player {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-center {
  flex-direction: column;
  gap: 8px;
}

.hud-center strong {
  color: #22eaff;
  font-size: clamp(20px, 4vw, 42px);
  text-shadow: 0 0 12px rgba(34, 234, 255, 0.8);
}

.hud-right {
  flex-direction: column;
  gap: 10px;
}

.hud-small {
  color: #22eaff;
  font-size: clamp(9px, 1.4vw, 14px);
}

.hud-name {
  color: #ffd429;
  font-size: clamp(10px, 1.5vw, 16px);
}

.hearts {
  color: #ff304f;
  font-size: clamp(16px, 2vw, 24px);
  text-shadow: 0 0 10px rgba(255, 48, 79, 0.8);
}

.coins {
  color: #fff;
  font-size: clamp(10px, 1.6vw, 16px);
}

.coins::first-letter {
  color: #ffd429;
}

/* MISSION BOX */

.mission-box-css {
  position: absolute;
  top: 122px;
  left: 26px;
  z-index: 42;
  width: min(30vw, 360px);
  padding: 22px;
  font-family: 'Press Start 2P', monospace;
  background:
    linear-gradient(180deg, rgba(8, 15, 46, 0.86), rgba(3, 7, 24, 0.86));
  border: 3px solid #8b35ff;
  box-shadow:
    0 0 22px rgba(139, 53, 255, 0.55),
    inset 0 0 18px rgba(0, 234, 255, 0.12);
  transition: max-height 0.25s ease, padding 0.25s ease, width 0.25s ease;
}

.mission-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 28px;
  border: 2px solid #22eaff;
  background: rgba(0,0,0,0.35);
  color: #22eaff;
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  cursor: pointer;
  z-index: 5;
}

.mission-box-css h3 {
  margin: 0 42px 16px 0;
  color: #ffd429;
  font-size: clamp(18px, 2vw, 28px);
  text-shadow: 3px 3px 0 #4b168f;
}

.mission-level {
  color: #22eaff;
  font-size: 10px;
  line-height: 1.6;
  margin: 0 0 18px;
}

.mission-list {
  margin-top: 16px;
}

.mission-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #fff;
  font-size: 10px;
  line-height: 1.6;
  margin: 15px 0;
}

.mission-item .box {
  width: 14px;
  height: 14px;
  border: 2px solid #22eaff;
  flex: 0 0 auto;
  margin-top: 1px;
  box-shadow: 0 0 10px rgba(34, 234, 255, 0.45);
}

.mission-item.done .box {
  background: #ffd429;
  border-color: #ffd429;
  box-shadow: 0 0 14px rgba(255, 212, 41, 0.75);
}

.mission-item.done span:last-child {
  color: #ffd429;
}

.mission-reward {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid rgba(34, 234, 255, 0.45);
  color: #ffd429;
  font-size: 9px;
  line-height: 1.6;
}

.mission-box-css.is-collapsed {
  width: 210px;
  max-height: 58px;
  overflow: hidden;
  padding: 12px 52px 12px 14px;
}

.mission-box-css.is-collapsed h3 {
  margin: 0;
  font-size: 15px;
}

.mission-box-css.is-collapsed .mission-level,
.mission-box-css.is-collapsed .mission-list,
.mission-box-css.is-collapsed .mission-reward {
  display: none;
}

/* PROPS */

.prop {
  position: absolute;
  z-index: 18;
  image-rendering: auto;
  filter: drop-shadow(0 10px 16px rgba(0,0,0,0.38));
  transition: transform 0.2s ease, filter 0.2s ease;
}

.interactable {
  cursor: pointer;
}

.interactable:hover {
  filter:
    drop-shadow(0 10px 16px rgba(0,0,0,0.38))
    drop-shadow(0 0 16px rgba(33, 234, 255, 0.65));
}

/* COMPUTER + MPC POSITIONING — DO NOT TOUCH */

.computer-sprite {
  width: var(--computer-w);
  left: var(--computer-x);
  top: var(--computer-y);
  transform: translate(-50%, -50%);
  z-index: 20;
}

.computer-sprite:hover {
  transform: translate(-50%, -50%) scale(1.04);
}

.mpc-sprite {
  width: var(--mpc-w);
  left: var(--mpc-x);
  top: var(--mpc-y);
  transform: translate(-50%, -50%) rotate(-4deg);
  z-index: 21;
}

.mpc-sprite:hover {
  transform: translate(-50%, -50%) rotate(-4deg) scale(1.04);
}

/* PLAYER */

.player-sprite {
  position: absolute;
  z-index: 30;
  width: var(--player-w);
  left: 38%;
  bottom: var(--player-bottom);
  transform: translateX(-50%) scaleX(1);
  transform-origin: bottom center;
  image-rendering: auto;
  filter:
    drop-shadow(0 20px 20px rgba(0,0,0,0.55))
    drop-shadow(0 0 16px rgba(255, 212, 41, 0.45));
  transition: left 0.12s linear, bottom 0.12s linear;
}

.player-sprite.near-object {
  filter:
    drop-shadow(0 20px 20px rgba(0,0,0,0.55))
    drop-shadow(0 0 26px rgba(255, 212, 41, 0.95));
}

/* DIALOGUE BOX */

.dialogue-box-css {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 45;
  width: min(92vw, 980px);
  min-height: 132px;
  padding: 24px 34px;
  font-family: 'Press Start 2P', monospace;
  background:
    linear-gradient(180deg, rgba(8, 15, 46, 0.9), rgba(3, 7, 24, 0.9));
  border: 3px solid #8b35ff;
  box-shadow:
    0 0 24px rgba(139, 53, 255, 0.65),
    inset 0 0 20px rgba(0, 234, 255, 0.12);
}

.dialogue-speaker {
  color: #ffd429;
  font-size: 12px;
  margin-bottom: 12px;
}

.dialogue-box-css p {
  margin: 0;
  max-width: 82%;
  color: #fff;
  font-size: clamp(10px, 1.6vw, 15px);
  line-height: 1.8;
  text-shadow: 2px 2px 0 #000;
}

.next-label {
  position: absolute;
  right: 24px;
  bottom: 18px;
  border: 0;
  background: transparent;
  color: #22eaff;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  cursor: pointer;
  animation: blinkNext 0.9s infinite;
}

@keyframes blinkNext {
  0%, 100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

/* PROMPT */

.interaction-prompt {
  position: absolute;
  left: 50%;
  top: 34%;
  z-index: 70;
  transform: translateX(-50%) translateY(-10px);
  opacity: 0;
  padding: 10px 12px;
  border: 2px solid #21eaff;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  pointer-events: none;
  box-shadow: 0 0 18px rgba(33, 234, 255, 0.42);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.interaction-prompt.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* VICTORY */

.victory-overlay {
  position: absolute;
  inset: 0;
  z-index: 120;
  background:
    radial-gradient(circle at center, rgba(255, 212, 41, 0.22), transparent 34%),
    rgba(0, 0, 0, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.victory-overlay.show {
  display: flex;
}

.victory-card {
  width: min(92vw, 680px);
  padding: 34px;
  text-align: center;
  border: 4px solid #ffd429;
  background: rgba(3, 7, 25, 0.95);
  box-shadow:
    0 0 38px rgba(255, 212, 41, 0.48),
    inset 0 0 24px rgba(124, 60, 255, 0.2);
}

.victory-card h2 {
  font-family: 'Press Start 2P', monospace;
  color: #ffd429;
  font-size: clamp(22px, 6vw, 48px);
  margin: 10px 0 18px;
  text-shadow: 4px 4px 0 #5b1d99;
}

.victory-card p {
  line-height: 1.7;
  color: rgba(255,255,255,0.9);
  margin-bottom: 24px;
}

.tiny-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  color: #21eaff;
  margin: 0 0 18px;
}

.arcade-btn {
  border: 0;
  cursor: pointer;
  padding: 18px 26px;
  background: linear-gradient(180deg, #ffd429, #ff8a00);
  color: #1a0b00;
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  box-shadow:
    0 8px 0 #7b3300,
    0 0 24px rgba(255, 212, 41, 0.45);
}

.arcade-btn.small {
  font-size: 11px;
  padding: 14px 18px;
}

/* CONTROLS */

.mobile-controls {
  position: absolute;
  left: 50%;
  bottom: 176px;
  z-index: 90;
  transform: translateX(-50%);
  display: none;
  gap: 8px;
  pointer-events: auto;
}

.mobile-controls button {
  border: 2px solid #21eaff;
  color: #fff;
  background: rgba(3, 7, 25, 0.72);
  box-shadow: 0 0 12px rgba(33, 234, 255, 0.25);
  padding: 10px 12px;
  min-width: 48px;
  min-height: 40px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  border-radius: 8px;
  touch-action: none;
}

#actionBtn {
  min-width: 76px;
  color: #ffd429;
  border-color: #ffd429;
}

.keyboard-help {
  position: absolute;
  left: 24px;
  bottom: 20px;
  z-index: 55;
  color: rgba(255,255,255,0.58);
  font-size: 12px;
  background: rgba(0,0,0,0.42);
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.12);
}

/* TABLET */

@media (max-width: 980px) {
  :root {
    --player-w: 260px;
    --player-bottom: 5%;
  }

  .level {
    height: 100svh;
    min-height: 760px;
  }

  .arcade-hud-css {
    top: 10px;
    width: 94vw;
    grid-template-columns: 1fr 0.75fr 0.85fr;
    gap: 6px;
  }

  .hud-panel {
    min-height: 46px;
    padding: 7px 9px;
    border-width: 2px;
  }

  .hud-center {
    display: flex;
    gap: 4px;
  }

  .hud-center .hud-small {
    font-size: 7px;
  }

  .hud-center strong {
    font-size: 16px;
    line-height: 1;
  }

  .mission-box-css {
    top: 68px;
    left: 12px;
    width: 260px;
    padding: 14px;
  }

  .mission-box-css h3 {
    font-size: 18px;
  }

  .mission-level,
  .mission-item {
    font-size: 8px;
  }

  .dialogue-box-css {
    bottom: 64px;
    width: 88vw;
    min-height: 92px;
    padding: 14px 18px;
  }

  .dialogue-speaker {
    font-size: 9px;
    margin-bottom: 8px;
  }

  .dialogue-box-css p {
    max-width: 88%;
    font-size: 9px;
    line-height: 1.55;
  }

  .next-label {
    right: 14px;
    bottom: 10px;
    font-size: 8px;
  }

  .mobile-controls {
    display: flex;
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .keyboard-help {
    display: none;
  }
}

/* MOBILE */

@media (max-width: 700px) {
  :root {
    --player-w: 250px;
    --player-bottom: 7%;
  }

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

  .level {
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
  }

  .level-bg {
    position: absolute;
    inset: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100svh;
    object-fit: cover;
    object-position: center center;
    transform: none;
  }

  .arcade-hud-css {
    top: max(6px, env(safe-area-inset-top));
    width: 96vw;
    grid-template-columns: 1fr 0.72fr 0.72fr;
    gap: 4px;
  }

  .hud-panel {
    min-height: 32px;
    padding: 5px 6px;
    border-width: 1px;
    background:
      linear-gradient(180deg, rgba(8, 15, 46, 0.58), rgba(3, 7, 24, 0.58));
    box-shadow:
      0 0 10px rgba(139, 53, 255, 0.36),
      inset 0 0 10px rgba(0, 234, 255, 0.08);
  }

  .hud-left {
    gap: 6px;
    overflow: hidden;
  }

  .hud-left > .hud-small {
    display: none;
  }

  .hud-player {
    gap: 4px;
    min-width: 0;
  }

  .hud-right {
    gap: 3px;
  }

  .hud-small {
    font-size: 6px;
    line-height: 1;
  }

  .hud-name {
    font-size: 7px;
    line-height: 1;
    white-space: nowrap;
  }

  .hearts {
    font-size: 9px;
    line-height: 1;
  }

  .hud-center {
    display: flex;
    gap: 3px;
    min-width: 0;
  }

  .hud-center .hud-small {
    font-size: 5.5px;
    line-height: 1;
  }

  .hud-center strong {
    font-size: 10px;
    line-height: 1;
    letter-spacing: -1px;
    white-space: nowrap;
  }

  .coins {
    font-size: 7px;
    line-height: 1;
    white-space: nowrap;
  }

  .mission-box-css {
    top: 44px;
    left: 8px;
    width: 215px;
    max-height: 240px;
    padding: 12px;
    border-width: 2px;
    background:
      linear-gradient(180deg, rgba(8, 15, 46, 0.62), rgba(3, 7, 24, 0.62));
  }

  .mission-box-css h3 {
    font-size: 14px;
    margin-bottom: 10px;
  }

  .mission-level {
    font-size: 7px;
    margin-bottom: 8px;
  }

  .mission-list {
    margin-top: 8px;
  }

  .mission-item {
    font-size: 7px;
    margin: 8px 0;
    gap: 7px;
  }

  .mission-item .box {
    width: 10px;
    height: 10px;
    border-width: 1px;
  }

  .mission-reward {
    font-size: 6px;
    margin-top: 10px;
    padding-top: 8px;
  }

  .mission-toggle {
    top: 7px;
    right: 7px;
    width: 26px;
    height: 24px;
    font-size: 10px;
    border-width: 1px;
  }

  .mission-box-css.is-collapsed {
    width: 138px;
    max-height: 38px;
    padding: 9px 38px 9px 10px;
  }

  .mission-box-css.is-collapsed h3 {
    font-size: 10px;
  }

  .dialogue-box-css {
    bottom: max(58px, calc(env(safe-area-inset-bottom) + 54px));
    width: 92vw;
    min-height: 72px;
    padding: 10px 12px;
    border-width: 2px;
    background:
      linear-gradient(180deg, rgba(8, 15, 46, 0.66), rgba(3, 7, 24, 0.66));
  }

  .dialogue-speaker {
    font-size: 8px;
    margin-bottom: 6px;
  }

  .dialogue-box-css p {
    max-width: 100%;
    font-size: 7px;
    line-height: 1.55;
    padding-right: 44px;
  }

  .next-label {
    right: 10px;
    bottom: 9px;
    font-size: 7px;
  }

  .interaction-prompt {
    top: 38%;
    font-size: 7px;
    padding: 8px 9px;
  }

  .mobile-controls {
    display: flex;
    bottom: max(8px, env(safe-area-inset-bottom));
    gap: 6px;
  }

  .mobile-controls button {
    min-width: 42px;
    min-height: 34px;
    padding: 8px 9px;
    font-size: 7px;
    border-width: 1px;
    background: rgba(3, 7, 25, 0.66);
  }

  #actionBtn {
    min-width: 64px;
  }

  .arcade-title-card {
    width: 90vw;
    max-width: 380px;
    padding: 34px 18px;
    overflow: hidden;
  }

  .arcade-title-card::before {
    inset: 8px;
  }

  .arcade-crown {
    font-size: 22px;
    margin-bottom: 10px;
  }

  .rah-logo {
    font-size: clamp(34px, 10.7vw, 48px);
    line-height: 1.18;
    letter-spacing: 0;
    text-align: center;
    width: 100%;
    text-shadow:
      3px 3px 0 #240011,
      0 0 8px rgba(255, 91, 63, 0.95),
      0 0 18px rgba(255, 91, 63, 0.68),
      0 0 28px rgba(255, 91, 63, 0.42);
  }

  .insert-coin {
    margin-top: 22px;
    font-size: clamp(13px, 3.6vw, 18px);
  }

  .start-copy {
    font-size: 7.5px;
    line-height: 1.9;
  }

  .start-button {
    min-width: 190px;
    padding: 15px 18px;
    font-size: 10px;
  }

  .start-footer {
    font-size: 6px;
    line-height: 1.7;
    padding: 0 8px;
  }
}

/* SMALL MOBILE */

@media (max-width: 480px) {
  :root {
    --player-w: 235px;
    --player-bottom: 7%;
  }

  .arcade-hud-css {
    grid-template-columns: 1fr 0.68fr 0.68fr;
  }

  .hud-panel {
    min-height: 30px;
    padding: 4px 5px;
  }

  .hud-center strong {
    font-size: 9px;
    letter-spacing: -1px;
  }

  .hud-center .hud-small {
    display: none;
  }

  .coins {
    font-size: 6.5px;
  }

  .dialogue-box-css {
    bottom: max(54px, calc(env(safe-area-inset-bottom) + 50px));
  }

  .dialogue-box-css p {
    font-size: 6.5px;
  }

  .arcade-title-card {
    width: 90vw;
    max-width: 350px;
    padding: 32px 15px;
  }

  .rah-logo {
    font-size: clamp(30px, 10vw, 42px);
    line-height: 1.2;
    letter-spacing: 0;
  }

  .insert-coin {
    font-size: 13px;
  }
}
/* iPHONE SAFARI FULL-BLEED LEVEL BACKGROUND FIX */
@media (max-width: 700px) {
  html,
  body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #02020a;
  }

  .game-shell,
  .level {
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #02020a;
  }

  .level-one {
    position: relative;
    isolation: isolate;
    background-image: url("../images/level1_background.png");
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
  }

  /*
    Hide the img version on mobile because Safari sometimes
    treats 100vw/100svh weird with image elements.
    The background-image above becomes the real wallpaper.
  */
  .level-one .level-bg {
    display: none;
  }

  /*
    Overscan layer: this pushes the wallpaper beyond the visible screen
    so no black/empty edge appears on iPhone Safari.
  */
  .level-one::before {
    content: "";
    position: absolute;
    z-index: 1;
    top: -3vh;
    left: -6vw;
    width: 112vw;
    height: 106vh;
    height: 106dvh;
    background-image: url("../images/level1_background.png");
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    pointer-events: none;
  }

  .vignette,
  .scanlines,
  .arcade-hud-css,
  .mission-box-css,
  .prop,
  .player-sprite,
  .dialogue-box-css,
  .interaction-prompt,
  .mobile-controls,
  .keyboard-help,
  .victory-overlay {
    position: absolute;
  }

  .vignette {
    z-index: 4;
  }

  .scanlines {
    z-index: 80;
  }

  .arcade-hud-css {
    z-index: 50;
  }

  .mission-box-css {
    z-index: 42;
  }

  .prop {
    z-index: 18;
  }

  .computer-sprite {
    z-index: 20;
  }

  .mpc-sprite {
    z-index: 21;
  }

  .player-sprite {
    z-index: 30;
  }

  .dialogue-box-css {
    z-index: 45;
  }

  .interaction-prompt {
    z-index: 70;
  }

  .mobile-controls {
    z-index: 90;
  }

  .victory-overlay {
    z-index: 120;
  }
}

/* =========================================================
   MUSIC MINI PLAYER V2 + MOBILE MISSION TOGGLE FIX
   Added after original CSS so it safely overrides only what is needed.
   ========================================================= */

/* Fix the mission +/- button clipping on mobile and desktop */
.mission-toggle {
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1;
  overflow: visible;
  box-sizing: border-box;
}

/* Premium arcade music widget */
.music-player-css {
  position: absolute;
  top: max(112px, calc(env(safe-area-inset-top) + 94px));
  right: 24px;
  z-index: 76;
  width: min(340px, 37vw);
  min-width: 260px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  font-family: 'Press Start 2P', monospace;
  color: #fff;
  border: 3px solid #ffd429;
  background:
    linear-gradient(180deg, rgba(7, 13, 42, 0.9), rgba(2, 4, 18, 0.9));
  box-shadow:
    0 0 22px rgba(255, 212, 41, 0.34),
    0 0 18px rgba(33, 234, 255, 0.18),
    inset 0 0 18px rgba(139, 53, 255, 0.22);
  pointer-events: auto;
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.music-player-css::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(33, 234, 255, 0.24);
  pointer-events: none;
}

.music-player-css::after {
  content: "";
  position: absolute;
  top: -3px;
  left: 14px;
  width: 44px;
  height: 3px;
  background: #21eaff;
  box-shadow:
    52px 0 0 rgba(255, 212, 41, 0.95),
    104px 0 0 rgba(255, 89, 63, 0.85);
  pointer-events: none;
}

.music-toggle-css {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 2px solid #21eaff;
  background:
    radial-gradient(circle at 50% 45%, rgba(33, 234, 255, 0.22), transparent 55%),
    linear-gradient(180deg, rgba(12, 24, 62, 0.92), rgba(3, 7, 24, 0.92));
  box-shadow:
    0 0 14px rgba(33, 234, 255, 0.35),
    inset 0 0 12px rgba(255, 212, 41, 0.12);
  cursor: pointer;
  touch-action: manipulation;
}

.music-toggle-css:active {
  transform: translateY(2px);
}

.music-toggle-icon {
  position: relative;
  width: 18px;
  height: 18px;
  display: block;
}

.music-toggle-icon::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 2px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 12px solid #ffd429;
  filter: drop-shadow(0 0 7px rgba(255, 212, 41, 0.75));
}

.music-toggle-css.is-playing {
  border-color: #ffd429;
  box-shadow:
    0 0 16px rgba(255, 212, 41, 0.42),
    inset 0 0 12px rgba(33, 234, 255, 0.12);
}

.music-toggle-css.is-playing .music-toggle-icon::before {
  left: 1px;
  top: 2px;
  width: 5px;
  height: 14px;
  border: 0;
  background: #ffd429;
  box-shadow:
    9px 0 0 #ffd429,
    0 0 8px rgba(255, 212, 41, 0.72),
    9px 0 8px rgba(255, 212, 41, 0.72);
}

.music-meta-css {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.music-topline-css {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.music-label-css {
  color: #21eaff;
  font-size: 7px;
  line-height: 1;
  white-space: nowrap;
}

.music-loop-css {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 6px;
  line-height: 1;
  white-space: nowrap;
}

.music-loop-css::before {
  content: "";
  width: 6px;
  height: 6px;
  background: #ffd429;
  box-shadow: 0 0 8px rgba(255, 212, 41, 0.8);
}

.music-title-css {
  color: #fff;
  font-size: 8px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 2px 2px 0 #000;
}

.music-player-css.is-playing .music-title-css {
  color: #ffd429;
}

.music-player-css.is-playing .music-loop-css::before {
  animation: musicPulse 0.8s steps(2, start) infinite;
}

@keyframes musicPulse {
  0%, 100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

.music-volume-wrap-css {
  display: grid;
  grid-template-columns: auto minmax(70px, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
}

.music-volume-label-css {
  color: #21eaff;
  font-size: 6px;
  line-height: 1;
  white-space: nowrap;
}

.music-volume-css {
  width: 100%;
  height: 16px;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

.music-volume-css:focus {
  outline: none;
}

.music-volume-css::-webkit-slider-runnable-track {
  height: 5px;
  border: 1px solid rgba(33, 234, 255, 0.75);
  background:
    linear-gradient(90deg, rgba(33, 234, 255, 0.95), rgba(255, 212, 41, 0.95));
  box-shadow: 0 0 8px rgba(33, 234, 255, 0.28);
}

.music-volume-css::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border: 2px solid #02020a;
  background: #ffd429;
  box-shadow: 0 0 10px rgba(255, 212, 41, 0.72);
  -webkit-appearance: none;
  appearance: none;
}

.music-volume-css::-moz-range-track {
  height: 5px;
  border: 1px solid rgba(33, 234, 255, 0.75);
  background:
    linear-gradient(90deg, rgba(33, 234, 255, 0.95), rgba(255, 212, 41, 0.95));
}

.music-volume-css::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 2px solid #02020a;
  border-radius: 0;
  background: #ffd429;
  box-shadow: 0 0 10px rgba(255, 212, 41, 0.72);
}

@media (max-width: 980px) {
  .music-player-css {
    top: max(58px, calc(env(safe-area-inset-top) + 50px));
    right: 12px;
    width: min(280px, 36vw);
    min-width: 230px;
    padding: 10px 12px;
    gap: 10px;
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .music-toggle-css {
    width: 38px;
    height: 38px;
  }

  .music-title-css {
    font-size: 7px;
  }
}

@media (max-width: 700px) {
  .mission-toggle {
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    font-size: 11px;
    line-height: 1;
  }

  .mission-box-css.is-collapsed {
    width: 146px;
    max-height: 46px;
    min-height: 46px;
    padding: 12px 46px 12px 10px;
  }

  .mission-box-css.is-collapsed h3 {
    font-size: 10px;
    line-height: 1;
  }

  .music-player-css {
    top: max(46px, calc(env(safe-area-inset-top) + 38px));
    right: 8px;
    width: min(176px, 46vw);
    min-width: 0;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 7px;
    padding: 8px;
    border-width: 2px;
    background:
      linear-gradient(180deg, rgba(7, 13, 42, 0.76), rgba(2, 4, 18, 0.76));
  }

  .music-player-css::before {
    inset: 4px;
  }

  .music-player-css::after {
    left: 10px;
    width: 28px;
    height: 2px;
    box-shadow:
      34px 0 0 rgba(255, 212, 41, 0.95),
      68px 0 0 rgba(255, 89, 63, 0.85);
  }

  .music-toggle-css {
    width: 32px;
    height: 32px;
    border-width: 1px;
  }

  .music-toggle-icon {
    width: 16px;
    height: 16px;
  }

  .music-toggle-icon::before {
    left: 4px;
    top: 2px;
    border-top-width: 6px;
    border-bottom-width: 6px;
    border-left-width: 10px;
  }

  .music-toggle-css.is-playing .music-toggle-icon::before {
    left: 1px;
    top: 2px;
    width: 4px;
    height: 12px;
    box-shadow:
      8px 0 0 #ffd429,
      0 0 8px rgba(255, 212, 41, 0.72),
      8px 0 8px rgba(255, 212, 41, 0.72);
  }

  .music-meta-css {
    gap: 4px;
  }

  .music-topline-css {
    gap: 5px;
  }

  .music-label-css {
    font-size: 5.5px;
  }

  .music-loop-css {
    font-size: 5px;
  }

  .music-loop-css::before {
    width: 5px;
    height: 5px;
  }

  .music-title-css {
    font-size: 6px;
    line-height: 1.25;
  }

  .music-volume-wrap-css {
    grid-template-columns: auto minmax(48px, 1fr);
    gap: 5px;
  }

  .music-volume-label-css {
    font-size: 5px;
  }

  .music-volume-css {
    height: 14px;
  }

  .music-volume-css::-webkit-slider-runnable-track {
    height: 4px;
  }

  .music-volume-css::-webkit-slider-thumb {
    width: 12px;
    height: 12px;
    margin-top: -5px;
  }
}

@media (max-width: 480px) {
  .mission-box-css.is-collapsed {
    width: 144px;
  }

  .music-player-css {
    width: min(164px, 45vw);
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 6px;
    padding: 7px;
  }

  .music-toggle-css {
    width: 30px;
    height: 30px;
  }

  .music-label-css {
    font-size: 5px;
  }

  .music-loop-css {
    display: none;
  }

  .music-title-css {
    font-size: 5.6px;
  }

  .music-volume-wrap-css {
    grid-template-columns: auto minmax(42px, 1fr);
  }
}

/* =========================================================
   FINAL POSITION + iPHONE PORTRAIT FULL-BLEED OVERRIDES
   This is intentionally appended at the bottom so it wins
   over the earlier audio-player/mobile rules.
   ========================================================= */

/* Keep the player clear of the SCORE / LEVEL 1 HUD on desktop. */
.music-player-css {
  top: max(154px, calc(env(safe-area-inset-top) + 138px)) !important;
  right: 22px !important;
  width: min(318px, 30vw) !important;
  min-width: 264px !important;
  z-index: 76;
}

/* Keep the mission +/- button fully visible. */
.mission-toggle {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  line-height: 1 !important;
  overflow: visible !important;
  box-sizing: border-box !important;
}

.mission-box-css.is-collapsed {
  overflow: visible !important;
}

@media (max-width: 1180px) and (min-width: 981px) {
  .music-player-css {
    top: max(158px, calc(env(safe-area-inset-top) + 142px)) !important;
    width: min(292px, 28vw) !important;
    min-width: 248px !important;
    right: 16px !important;
  }

  .music-label-css {
    font-size: 6px;
  }

  .music-title-css {
    font-size: 7px;
  }
}

@media (max-width: 980px) and (min-width: 701px) {
  .music-player-css {
    top: max(78px, calc(env(safe-area-inset-top) + 66px)) !important;
    right: 10px !important;
    width: min(244px, 32vw) !important;
    min-width: 218px !important;
    grid-template-columns: 36px minmax(0, 1fr) !important;
    gap: 8px !important;
    padding: 9px 10px !important;
  }

  .music-toggle-css {
    width: 36px !important;
    height: 36px !important;
  }

  .music-label-css {
    font-size: 5.5px !important;
  }

  .music-title-css {
    font-size: 6.4px !important;
  }

  .music-loop-css {
    font-size: 5px !important;
  }
}

/*
  iPhone / mobile game viewport:
  - regular Safari cannot let a website draw over Safari's actual URL/status bars;
    those are browser chrome.
  - this uses the largest viewport unit + an overscanned background so when Safari
    collapses its bars, or when launched from Home Screen/WebView, the art reaches
    the physical top and bottom edges.
*/
@media (max-width: 700px) {
  html,
  body {
    width: 100%;
    min-width: 100%;
    height: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #02020a;
    overscroll-behavior: none;
  }

  body.level-viewport-active {
    position: fixed;
    inset: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100lvh;
    min-height: 100lvh;
    overflow: hidden;
  }

  body.level-viewport-active .game-shell {
    position: fixed;
    inset: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100lvh;
    min-height: 100lvh;
    overflow: hidden;
    background: #02020a;
  }

  body.level-viewport-active .level {
    position: fixed;
    inset: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100lvh;
    min-height: 100lvh;
    max-height: none;
    overflow: hidden;
    background: #02020a;
    transform: translateZ(0);
  }

  body.level-viewport-active .level-one {
    isolation: isolate;
    background: #02020a;
  }

  body.level-viewport-active .level-one .level-bg {
    display: none !important;
  }

  body.level-viewport-active .level-one::before {
    content: "";
    position: absolute;
    z-index: 1;
    top: -12lvh;
    left: -12vw;
    width: 124vw;
    width: 124dvw;
    height: 124vh;
    height: 124lvh;
    background-image: url("../images/level1_background.png");
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    pointer-events: none;
    transform: translateZ(0);
  }

  body.level-viewport-active .vignette,
  body.level-viewport-active .scanlines {
    inset: -2px;
  }

  /* Move the music player away from the top HUD on phones. */
  .music-player-css {
    top: auto !important;
    right: 8px !important;
    bottom: max(168px, calc(env(safe-area-inset-bottom) + 154px)) !important;
    width: min(212px, 56vw) !important;
    min-width: 0 !important;
    grid-template-columns: 32px minmax(0, 1fr) !important;
    gap: 7px !important;
    padding: 8px !important;
    border-width: 2px !important;
    z-index: 78;
  }

  .music-toggle-css {
    width: 32px !important;
    height: 32px !important;
  }

  .music-label-css {
    font-size: 5.2px !important;
  }

  .music-title-css {
    font-size: 5.9px !important;
    line-height: 1.25 !important;
  }

  .music-loop-css {
    display: none !important;
  }

  .music-volume-wrap-css {
    grid-template-columns: auto minmax(54px, 1fr) !important;
    gap: 5px !important;
  }

  .music-volume-label-css {
    font-size: 5px !important;
  }

  .music-volume-css {
    height: 16px !important;
  }

  .mission-toggle {
    top: 6px !important;
    right: 6px !important;
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    min-height: 30px !important;
    font-size: 11px !important;
    border-width: 1px !important;
  }

  .mission-box-css.is-collapsed {
    width: 150px !important;
    max-height: none !important;
    min-height: 48px !important;
    padding: 13px 48px 13px 10px !important;
  }

  .mission-box-css.is-collapsed h3 {
    line-height: 1.15 !important;
  }
}

@media (max-width: 480px) {
  .music-player-css {
    right: 7px !important;
    bottom: max(160px, calc(env(safe-area-inset-bottom) + 148px)) !important;
    width: min(196px, 58vw) !important;
    grid-template-columns: 30px minmax(0, 1fr) !important;
    gap: 6px !important;
    padding: 7px !important;
  }

  .music-toggle-css {
    width: 30px !important;
    height: 30px !important;
  }

  .music-title-css {
    font-size: 5.5px !important;
  }

  .mission-box-css.is-collapsed {
    width: 150px !important;
    min-height: 48px !important;
  }
}

@media (display-mode: standalone) and (max-width: 700px) {
  body.level-viewport-active,
  body.level-viewport-active .game-shell,
  body.level-viewport-active .level {
    height: 100vh;
    min-height: 100vh;
  }

  body.level-viewport-active .level-one::before {
    top: -10vh;
    height: 120vh;
  }
}


/* =========================================================
   V3 MOBILE AUDIO + VOLUME + BACKGROUND FIX
   Appended last so it overrides previous mobile rules.
   ========================================================= */

/* Desktop: keep audio box below the HUD, not over LEVEL 1. */
.music-player-css {
  top: max(154px, calc(env(safe-area-inset-top) + 138px)) !important;
  right: 22px !important;
  bottom: auto !important;
  width: min(318px, 30vw) !important;
  min-width: 264px !important;
  z-index: 76 !important;
}

/* Give the volume slider a bigger real touch target, especially on iPhone. */
.music-volume-css {
  height: 22px !important;
  touch-action: pan-x !important;
}

.music-volume-css::-webkit-slider-runnable-track {
  height: 6px !important;
}

.music-volume-css::-webkit-slider-thumb {
  width: 18px !important;
  height: 18px !important;
  margin-top: -7px !important;
}

/* Mission toggle: stop the + / - box from clipping. */
.mission-toggle {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  line-height: 1 !important;
  overflow: visible !important;
  box-sizing: border-box !important;
}

.mission-box-css.is-collapsed {
  overflow: visible !important;
}

@media (max-width: 1180px) and (min-width: 981px) {
  .music-player-css {
    top: max(158px, calc(env(safe-area-inset-top) + 142px)) !important;
    right: 16px !important;
    width: min(292px, 28vw) !important;
    min-width: 248px !important;
  }
}

@media (max-width: 980px) and (min-width: 701px) {
  .music-player-css {
    top: max(78px, calc(env(safe-area-inset-top) + 66px)) !important;
    right: 10px !important;
    bottom: auto !important;
    width: min(244px, 32vw) !important;
    min-width: 218px !important;
    grid-template-columns: 36px minmax(0, 1fr) !important;
    gap: 8px !important;
    padding: 9px 10px !important;
  }
}

@media (max-width: 700px) {
  html {
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    background: #02020a !important;
    overflow: hidden !important;
    overscroll-behavior: none !important;
    -webkit-text-size-adjust: 100%;
  }

  body {
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #02020a !important;
    overscroll-behavior: none !important;
  }

  body.level-viewport-active {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
  }

  body.level-viewport-active .game-shell,
  body.level-viewport-active .level {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #02020a !important;
  }

  body.level-viewport-active .level-one {
    isolation: isolate !important;
    background-color: #02020a !important;
    background-image: url("../images/level1_background.png") !important;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
  }

  body.level-viewport-active .level-one .level-bg {
    display: none !important;
  }

  /*
    Overscan only the wallpaper, not the controls.
    This prevents black top/bottom edges while keeping ACTION/arrows visible.
  */
  body.level-viewport-active .level-one::before {
    content: "" !important;
    position: absolute !important;
    z-index: 1 !important;
    top: -10dvh !important;
    left: -16dvw !important;
    width: 132dvw !important;
    height: 120dvh !important;
    background-image: url("../images/level1_background.png") !important;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    pointer-events: none !important;
    transform: translateZ(0) !important;
  }

  body.level-viewport-active .vignette,
  body.level-viewport-active .scanlines {
    inset: -2px !important;
  }

  /* Mobile: keep music player at the TOP, tucked right, clear of mission box. */
  .music-player-css {
    top: max(50px, calc(env(safe-area-inset-top) + 42px)) !important;
    right: 7px !important;
    bottom: auto !important;
    width: min(204px, 54vw) !important;
    min-width: 0 !important;
    grid-template-columns: 32px minmax(0, 1fr) !important;
    gap: 7px !important;
    padding: 8px !important;
    border-width: 2px !important;
    z-index: 78 !important;
    background: linear-gradient(180deg, rgba(7, 13, 42, 0.82), rgba(2, 4, 18, 0.82)) !important;
  }

  .music-toggle-css {
    width: 32px !important;
    height: 32px !important;
  }

  .music-label-css {
    font-size: 5.3px !important;
  }

  .music-title-css {
    font-size: 5.9px !important;
    line-height: 1.25 !important;
  }

  .music-loop-css {
    display: none !important;
  }

  .music-volume-wrap-css {
    grid-template-columns: auto minmax(62px, 1fr) !important;
    gap: 5px !important;
  }

  .music-volume-label-css {
    font-size: 5px !important;
  }

  .music-volume-css {
    height: 24px !important;
    touch-action: pan-x !important;
  }

  .music-volume-css::-webkit-slider-runnable-track {
    height: 6px !important;
  }

  .music-volume-css::-webkit-slider-thumb {
    width: 18px !important;
    height: 18px !important;
    margin-top: -7px !important;
  }

  /* Keep arrows/ACTION visible inside Safari's usable viewport. */
  .mobile-controls {
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
    z-index: 90 !important;
  }

  .dialogue-box-css {
    bottom: max(58px, calc(env(safe-area-inset-bottom) + 54px)) !important;
  }

  .mission-toggle {
    top: 6px !important;
    right: 6px !important;
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    min-height: 30px !important;
    font-size: 11px !important;
    border-width: 1px !important;
  }

  .mission-box-css.is-collapsed {
    width: 150px !important;
    max-height: none !important;
    min-height: 48px !important;
    padding: 13px 48px 13px 10px !important;
  }
}

@media (max-width: 480px) {
  .music-player-css {
    top: max(50px, calc(env(safe-area-inset-top) + 42px)) !important;
    right: 6px !important;
    bottom: auto !important;
    width: min(190px, 52vw) !important;
    grid-template-columns: 30px minmax(0, 1fr) !important;
    gap: 6px !important;
    padding: 7px !important;
  }

  .music-toggle-css {
    width: 30px !important;
    height: 30px !important;
  }

  .music-title-css {
    font-size: 5.5px !important;
  }

  .music-volume-wrap-css {
    grid-template-columns: auto minmax(54px, 1fr) !important;
  }
}

@media (display-mode: standalone) and (max-width: 700px) {
  body.level-viewport-active,
  body.level-viewport-active .game-shell,
  body.level-viewport-active .level {
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
  }

  body.level-viewport-active .level-one::before {
    top: -10vh !important;
    height: 120vh !important;
  }
}


/* =========================================================
   LEVEL 2 — 2010 BLOCK TRADE MUSIC STUDIO SEQUENCE
   Added for images/level2_background.png, images/level2_keyboard.png,
   and images/level2_sitting.png.
   ========================================================= */

:root {
  --level2-keyboard-x: 38.8%;
  --level2-keyboard-y: 53.2%;
  --level2-keyboard-w: clamp(165px, 14.6vw, 265px);

  /* Keep walking + sitting sprite at the same displayed size so it does not jump. */
  --level2-character-w: clamp(230px, 22vw, 360px);
  --level2-player-w: var(--level2-character-w);
  --level2-player-bottom: 6%;

  --level2-sitting-x: 40.2%;
  --level2-sitting-bottom: 5.5%;
  --level2-sitting-w: var(--level2-character-w);
}

.victory-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.arcade-btn-secondary {
  background: linear-gradient(180deg, #22eaff, #3868ff);
  color: #02020a;
  box-shadow:
    0 8px 0 #122066,
    0 0 24px rgba(34, 234, 255, 0.32);
}

.level-two {
  isolation: isolate;
}

.level-two .level-bg {
  object-position: center center;
}

.level2-keyboard-sprite {
  width: var(--level2-keyboard-w);
  left: var(--level2-keyboard-x);
  top: var(--level2-keyboard-y);
  transform: translate(-50%, -50%);
  z-index: 40;
  pointer-events: auto;
  touch-action: manipulation;
}

.level2-keyboard-sprite:hover {
  transform: translate(-50%, -50%) scale(1.04);
}

.level2-player-sprite {
  width: var(--level2-player-w);
  left: 27%;
  bottom: var(--level2-player-bottom);
  z-index: 31;
}

.level2-player-sprite.is-sitting-level2 {
  width: var(--level2-sitting-w);
  left: var(--level2-sitting-x) !important;
  bottom: var(--level2-sitting-bottom) !important;
  z-index: 32;
  transform: translateX(-50%) scaleX(1) !important;
  filter:
    drop-shadow(0 22px 22px rgba(0,0,0,0.58))
    drop-shadow(0 0 18px rgba(33, 234, 255, 0.42));
}

.level-two .mission-reward {
  color: #22eaff;
}

.level-two .mission-item.done span:last-child {
  color: #22eaff;
}

.level-two .mission-item.done .box {
  background: #22eaff;
  border-color: #22eaff;
  box-shadow: 0 0 14px rgba(34, 234, 255, 0.75);
}

/* TABLET LEVEL 2 PLACEMENT */
@media (max-width: 980px) {
  :root {
    --level2-keyboard-x: 38%;
    --level2-keyboard-y: 54%;
    --level2-keyboard-w: clamp(158px, 24vw, 255px);

    --level2-character-w: 285px;
    --level2-player-w: var(--level2-character-w);
    --level2-player-bottom: 6%;

    --level2-sitting-x: 40%;
    --level2-sitting-bottom: 6%;
    --level2-sitting-w: var(--level2-character-w);
  }

  .level2-player-sprite {
    left: 25%;
  }
}

/* MOBILE LEVEL 2 FULL-BLEED + PROP PLACEMENT */
@media (max-width: 700px) {
  :root {
    --level2-keyboard-x: 39%;
    --level2-keyboard-y: 54%;
    --level2-keyboard-w: clamp(102px, 32vw, 165px);

    --level2-character-w: 246px;
    --level2-player-w: var(--level2-character-w);
    --level2-player-bottom: 8%;

    --level2-sitting-x: 41%;
    --level2-sitting-bottom: 7%;
    --level2-sitting-w: var(--level2-character-w);
  }

  .level-two {
    position: relative;
    isolation: isolate;
    background-image: url("../images/level2_background.png");
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
  }

  .level-two .level-bg {
    display: none;
  }

  .level-two::before {
    content: "";
    position: absolute;
    z-index: 1;
    top: -3vh;
    left: -6vw;
    width: 112vw;
    height: 106vh;
    height: 106dvh;
    background-image: url("../images/level2_background.png");
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    pointer-events: none;
  }

  .level-two .level2-keyboard-sprite {
    z-index: 40;
  }

  .level2-player-sprite {
    left: 23%;
  }
}

@media (max-width: 480px) {
  :root {
    --level2-keyboard-x: 40%;
    --level2-keyboard-y: 54%;
    --level2-keyboard-w: clamp(92px, 30vw, 142px);

    --level2-character-w: 232px;
    --level2-player-w: var(--level2-character-w);
    --level2-player-bottom: 8%;

    --level2-sitting-x: 42%;
    --level2-sitting-bottom: 7%;
    --level2-sitting-w: var(--level2-character-w);
  }
}

/* iPHONE SAFARI LEVEL 2 BACKGROUND OVERSCAN */
@media (max-width: 700px) {
  body.level-viewport-active .level-two::before {
    top: -10vh !important;
    height: 120vh !important;
  }
}


/* =========================================================
   START LEVEL 2 BUTTON CLICK FIX
   Keeps the completion overlay and buttons touchable above every game layer.
   ========================================================= */
.victory-overlay.show {
  pointer-events: auto;
}

.victory-card,
.victory-card * {
  pointer-events: auto;
}

.victory-buttons {
  position: relative;
  z-index: 5;
  pointer-events: auto;
}

#nextLevelBtn,
#replayBtn,
#closeLevel2OverlayBtn {
  position: relative;
  z-index: 6;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}


/* =========================================================
   GAMEPLAY FIX 4 — mobile victory buttons and Level 2 sizing
   ========================================================= */
@media (max-width: 700px) {
  .victory-buttons {
    flex-direction: column;
    gap: 18px;
    width: 100%;
  }

  .victory-buttons .arcade-btn {
    width: min(86vw, 270px);
    min-height: 48px;
    margin: 0;
  }
}

@media (max-width: 480px) {
  .victory-buttons {
    gap: 20px;
  }
}

/* =========================================================
   MOBILE PORTRAIT FIX 5 — bigger character + uncropped Level 2 studio
   This goes last so it wins over every older mobile/background rule.
   ========================================================= */

@media (max-width: 700px) {
  :root {
    /* Make the character larger on mobile while keeping walk/sitting equal. */
    --player-w: 280px;
    --level2-character-w: 286px;
    --level2-player-w: var(--level2-character-w);
    --level2-sitting-w: var(--level2-character-w);

    /* Keep the keyboard small enough to sit on the desk. */
    --level2-keyboard-w: clamp(88px, 26vw, 132px);
    --level2-keyboard-x: 40%;
    --level2-keyboard-y: 54%;

    --level2-player-bottom: 6%;
    --level2-sitting-x: 42%;
    --level2-sitting-bottom: 6%;
  }

  .player-sprite {
    width: var(--player-w);
  }

  .level2-player-sprite,
  .level2-player-sprite.is-sitting-level2 {
    width: var(--level2-character-w) !important;
  }

  /*
    Portrait phones were using cover/overscan, which cuts the studio off.
    Stretching the full background to the viewport keeps the whole room visible.
  */
  .level-two {
    background-image: url("../images/level2_background.png") !important;
    background-size: 100% 100% !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
  }

  .level-two .level-bg {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: fill !important;
    object-position: center center !important;
    z-index: 1 !important;
  }

  .level-two::before,
  body.level-viewport-active .level-two::before {
    display: none !important;
    content: none !important;
  }

  .level-two::after {
    display: none !important;
    content: none !important;
  }
}

@media (max-width: 480px) {
  :root {
    --player-w: 268px;
    --level2-character-w: 274px;
    --level2-player-w: var(--level2-character-w);
    --level2-sitting-w: var(--level2-character-w);

    --level2-keyboard-w: clamp(80px, 25vw, 122px);
    --level2-keyboard-x: 41%;
    --level2-keyboard-y: 54%;

    --level2-player-bottom: 6%;
    --level2-sitting-x: 43%;
    --level2-sitting-bottom: 6%;
  }
}

@media (max-width: 390px) {
  :root {
    --player-w: 258px;
    --level2-character-w: 264px;
    --level2-player-w: var(--level2-character-w);
    --level2-sitting-w: var(--level2-character-w);
  }
}

/* =========================================================
   MOBILE UNSQUISHED BACKGROUND FIX 6
   Fixes Level 2 portrait without stretching the studio image.
   - Removes the old 100% x 100% stretch that made the room look squished.
   - Shows the full Level 2 background with the correct aspect ratio.
   - Uses a soft cover layer behind it so the phone screen still feels full.
   This block goes last so it overrides portrait fix 5.
   ========================================================= */

@media (max-width: 700px) {
  .level-two {
    background-image: url("../images/level2_background.png") !important;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-color: #02020a !important;
  }

  /* Soft full-screen backing layer so portrait mode does not show ugly black gaps. */
  .level-two::before,
  body.level-viewport-active .level-two::before {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    z-index: 1 !important;
    inset: -6vh -10vw !important;
    width: auto !important;
    height: auto !important;
    background-image: url("../images/level2_background.png") !important;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    filter: blur(12px) brightness(0.62) saturate(1.08) !important;
    transform: scale(1.05) !important;
    pointer-events: none !important;
  }

  /* Real studio image layer: keeps the original aspect ratio, no squish. */
  .level-two .level-bg {
    display: block !important;
    position: absolute !important;
    z-index: 2 !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center center !important;
    transform: none !important;
    background: transparent !important;
  }

  /* Keep all gameplay layers above the background + blur backing. */
  .level-two .vignette { z-index: 4 !important; }
  .level-two .prop { z-index: 23 !important; }
  .level-two .level2-keyboard-sprite { z-index: 24 !important; }
  .level-two .player-sprite { z-index: 31 !important; }
  .level-two .arcade-hud-css { z-index: 50 !important; }
  .level-two .mission-box-css { z-index: 52 !important; }
  .level-two .dialogue-box-css { z-index: 56 !important; }
  .level-two .interaction-prompt { z-index: 70 !important; }
  .level-two .scanlines { z-index: 80 !important; }
  .level-two .mobile-controls { z-index: 90 !important; }
  .level-two .victory-overlay { z-index: 120 !important; }
}

@media (max-width: 480px) {
  .level-two .level-bg {
    object-fit: contain !important;
    object-position: center center !important;
  }
}


/* =========================================================
   LEVEL 2 MOBILE BACKGROUND REVERT 7 — no blur, no squish
   Makes Level 2 behave like Level 1 on mobile portrait:
   cover-cropped full-bleed background, no blurred contain layer.
   This must stay at the very bottom so it overrides old fixes.
   ========================================================= */
@media (max-width: 700px) {
  .level-two {
    position: relative !important;
    isolation: isolate !important;
    background-image: url("../images/level2_background.png") !important;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-color: #02020a !important;
  }

  /* Same approach as Level 1: hide the image tag on mobile Safari. */
  .level-two .level-bg {
    display: none !important;
  }

  /* Real mobile wallpaper layer — full bleed, cropped naturally, NO blur. */
  .level-two::before,
  body.level-viewport-active .level-two::before {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    z-index: 1 !important;
    top: -3vh !important;
    left: -6vw !important;
    width: 112vw !important;
    height: 106vh !important;
    height: 106dvh !important;
    background-image: url("../images/level2_background.png") !important;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    filter: none !important;
    transform: none !important;
    opacity: 1 !important;
    pointer-events: none !important;
  }

  /* When the game locks into mobile viewport mode, overscan like Level 1. */
  body.level-viewport-active .level-two::before {
    top: -10vh !important;
    left: -6vw !important;
    width: 112vw !important;
    height: 120vh !important;
    height: 120dvh !important;
  }

  .level-two::after {
    display: none !important;
    content: none !important;
  }

  .level-two .vignette { z-index: 4 !important; }
  .level-two .prop { z-index: 23 !important; }
  .level-two .level2-keyboard-sprite { z-index: 24 !important; }
  .level-two .player-sprite { z-index: 31 !important; }
  .level-two .arcade-hud-css { z-index: 50 !important; }
  .level-two .mission-box-css { z-index: 52 !important; }
  .level-two .dialogue-box-css { z-index: 56 !important; }
  .level-two .interaction-prompt { z-index: 70 !important; }
  .level-two .scanlines { z-index: 80 !important; }
  .level-two .mobile-controls { z-index: 90 !important; }
  .level-two .victory-overlay { z-index: 120 !important; }
}


/* LEVEL 2 KEYBOARD DIRECT CLICK FIX */
.level-two .level2-keyboard-sprite {
  z-index: 40 !important;
  pointer-events: auto !important;
  touch-action: manipulation;
  cursor: pointer;
}

.level-two .player-sprite {
  pointer-events: none;
}


/* =========================================================
   LEVEL 2 KEYBOARD SIZE + LAYER FIX 9
   - Makes the keyboard a little bigger.
   - Keeps the keyboard behind the walking/sitting character.
   - Keeps direct keyboard click/tap working because the player ignores pointer events.
   This must stay at the very bottom of style.css.
   ========================================================= */
:root {
  --level2-keyboard-w: clamp(205px, 17vw, 305px);
}

.level-two .level2-keyboard-sprite {
  width: var(--level2-keyboard-w) !important;
  z-index: 25 !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
  cursor: pointer !important;
}

.level-two .player-sprite,
.level-two .level2-player-sprite {
  z-index: 38 !important;
  pointer-events: none !important;
}

.level-two .level2-player-sprite.is-sitting-level2 {
  z-index: 39 !important;
  pointer-events: none !important;
}

@media (max-width: 980px) {
  :root {
    --level2-keyboard-w: clamp(180px, 27vw, 285px);
  }
}

@media (max-width: 700px) {
  :root {
    --level2-keyboard-w: clamp(116px, 35vw, 168px);
  }

  .level-two .level2-keyboard-sprite {
    z-index: 25 !important;
  }

  .level-two .player-sprite,
  .level-two .level2-player-sprite {
    z-index: 38 !important;
  }
}

@media (max-width: 480px) {
  :root {
    --level2-keyboard-w: clamp(106px, 34vw, 156px);
  }
}


/* =========================================================
   LEVEL 2 — ALVARO DIAZ NPC + SIGNING SEQUENCE
   ========================================================= */
:root {
  --diaz-w: clamp(210px, 18vw, 325px);
  --diaz-bottom: 6%;
}

.npc-sprite {
  position: absolute;
  z-index: 37;
  width: var(--diaz-w);
  left: -20%;
  bottom: var(--diaz-bottom);
  transform: translateX(-50%) scaleX(1);
  transform-origin: bottom center;
  image-rendering: auto;
  pointer-events: none;
  filter:
    drop-shadow(0 20px 20px rgba(0,0,0,0.55))
    drop-shadow(0 0 16px rgba(34, 234, 255, 0.45));
  transition: opacity 0.18s ease;
}

.diaz-sprite.is-hidden {
  display: none !important;
}

.level-two.is-story-locked .mobile-controls,
.level-two.is-story-locked .level2-keyboard-sprite {
  pointer-events: none !important;
}

.level-two.is-story-locked .level2-keyboard-sprite {
  filter: drop-shadow(0 10px 16px rgba(0,0,0,0.38));
}

.level2-choice-overlay {
  z-index: 135;
}

.level2-choice-card h2 {
  font-size: clamp(20px, 5vw, 44px);
}

.level2-choice-buttons {
  margin-top: 20px;
}

.arcade-btn-danger {
  background: linear-gradient(180deg, #ff304f, #8f0019);
  color: #fff;
  box-shadow:
    0 8px 0 #3d0009,
    0 0 24px rgba(255, 48, 79, 0.45);
}

.level2-fail-overlay .victory-card {
  border-color: #ff304f;
  box-shadow:
    0 0 38px rgba(255, 48, 79, 0.45),
    inset 0 0 24px rgba(124, 60, 255, 0.2);
}

.level2-fail-overlay h2 {
  color: #ff304f;
}

.level-three {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 212, 41, 0.16), transparent 24%),
    radial-gradient(circle at 50% 52%, rgba(139, 53, 255, 0.30), transparent 42%),
    radial-gradient(circle at 72% 72%, rgba(33, 234, 255, 0.14), transparent 30%),
    linear-gradient(180deg, #070013, #02020a 72%);
}

.level-three-card {
  position: relative;
  z-index: 8;
  width: min(92vw, 760px);
  padding: clamp(30px, 5vw, 56px);
  text-align: center;
  border: 4px solid #ffd429;
  background: rgba(3, 7, 25, 0.92);
  box-shadow:
    0 0 52px rgba(255, 212, 41, 0.32),
    0 0 36px rgba(139, 53, 255, 0.35),
    inset 0 0 28px rgba(33, 234, 255, 0.12);
}

.level-three-card h2 {
  margin: 12px 0 18px;
  font-family: 'Press Start 2P', monospace;
  color: #ffd429;
  font-size: clamp(24px, 6vw, 56px);
  line-height: 1.18;
  text-shadow: 4px 4px 0 #4b168f;
}

.level-three-card p {
  margin: 0;
  color: rgba(255,255,255,0.9);
  line-height: 1.8;
}

.level3-dialogue-box {
  bottom: 28px;
}

@media (max-width: 980px) {
  :root {
    --diaz-w: 282px;
    --diaz-bottom: 6%;
  }
}

@media (max-width: 700px) {
  :root {
    --diaz-w: 236px;
    --diaz-bottom: 8%;
  }

  .level-two .npc-sprite {
    z-index: 37 !important;
  }

  .level2-choice-card {
    padding: 24px 18px;
  }

  .level2-choice-buttons .arcade-btn.small {
    width: 100%;
    max-width: 250px;
  }

  .level-three-card {
    width: 90vw;
    padding: 28px 18px;
  }

  .level3-dialogue-box {
    bottom: max(58px, calc(env(safe-area-inset-bottom) + 54px));
  }
}

@media (max-width: 480px) {
  :root {
    --diaz-w: 224px;
  }
}
