:root {
  --bg-deep: #08141c;
  --bg-mid: #10241c;
  --ink: #e8fff0;
  --muted: #8ab89a;
  --panel: rgba(8, 22, 16, 0.88);
  --accent: #3dff8a;
  --font-display: "Press Start 2P", monospace;
  --font-body: "Space Grotesk", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse 70% 50% at 15% 20%, rgba(255, 92, 138, 0.22), transparent 55%),
    radial-gradient(ellipse 60% 45% at 85% 15%, rgba(69, 208, 255, 0.2), transparent 50%),
    radial-gradient(ellipse 55% 50% at 80% 85%, rgba(247, 37, 133, 0.16), transparent 55%),
    radial-gradient(ellipse 50% 40% at 20% 90%, rgba(255, 209, 102, 0.14), transparent 50%),
    radial-gradient(ellipse 40% 35% at 50% 50%, rgba(61, 255, 138, 0.08), transparent 60%),
    linear-gradient(165deg, #061018 0%, #0b1f18 42%, #101028 100%);
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem 2rem;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
}

.mobile-only {
  display: none !important;
}

/* ----- colorful snake backdrop ----- */
.bg {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  animation: glow-drift 14s ease-in-out infinite alternate;
}

.bg-glow-a {
  width: min(48vw, 420px);
  height: min(48vw, 420px);
  left: -8%;
  top: 10%;
  background: radial-gradient(circle, #ff7a59 0%, transparent 70%);
}

.bg-glow-b {
  width: min(55vw, 480px);
  height: min(55vw, 480px);
  right: -10%;
  top: -5%;
  background: radial-gradient(circle, #45d0ff 0%, transparent 70%);
  animation-duration: 18s;
  animation-delay: -4s;
}

.bg-glow-c {
  width: min(50vw, 440px);
  height: min(50vw, 440px);
  left: 30%;
  bottom: -15%;
  background: radial-gradient(circle, #c77dff 0%, transparent 70%);
  animation-duration: 16s;
  animation-delay: -8s;
}

.bg-noise {
  position: absolute;
  inset: 0;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.fireworks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.crawl-fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.deco-snake {
  position: absolute;
  overflow: visible;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.25));
  opacity: 0.78;
  will-change: transform;
}

.deco-snake .body-path {
  stroke-dasharray: 8 10;
  animation: dash-crawl 2.8s linear infinite;
}

.s1 {
  width: clamp(180px, 28vw, 340px);
  top: 6%;
  left: -4%;
  animation: slither-a 11s ease-in-out infinite;
}

.s2 {
  width: clamp(200px, 30vw, 380px);
  top: 12%;
  right: -6%;
  animation: slither-b 13s ease-in-out infinite;
}

.s3 {
  width: clamp(140px, 20vw, 260px);
  bottom: 8%;
  left: 2%;
  animation: slither-c 15s ease-in-out infinite;
}

.s4 {
  width: clamp(170px, 24vw, 300px);
  bottom: 14%;
  right: 1%;
  animation: slither-d 12s ease-in-out infinite;
}

.s5 {
  width: clamp(120px, 16vw, 210px);
  top: 42%;
  left: 4%;
  opacity: 0.55;
  animation: slither-e 17s ease-in-out infinite;
}

.s6 {
  width: clamp(160px, 22vw, 280px);
  top: 58%;
  right: 6%;
  opacity: 0.5;
  animation: slither-f 14s ease-in-out infinite;
}

.s7 {
  width: clamp(110px, 14vw, 180px);
  top: 28%;
  left: 42%;
  opacity: 0.35;
  animation: slither-g 19s ease-in-out infinite;
}

@keyframes glow-drift {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(30px, -24px) scale(1.08);
  }
}

@keyframes dash-crawl {
  to {
    stroke-dashoffset: -36;
  }
}

@keyframes slither-a {
  0%,
  100% {
    transform: translate(0, 0) rotate(-6deg);
  }
  50% {
    transform: translate(40px, 18px) rotate(4deg);
  }
}

@keyframes slither-b {
  0%,
  100% {
    transform: translate(0, 0) rotate(8deg) scaleX(-1);
  }
  50% {
    transform: translate(-36px, 22px) rotate(-2deg) scaleX(-1);
  }
}

@keyframes slither-c {
  0%,
  100% {
    transform: translate(0, 0) rotate(-10deg);
  }
  50% {
    transform: translate(28px, -30px) rotate(6deg);
  }
}

@keyframes slither-d {
  0%,
  100% {
    transform: translate(0, 0) rotate(4deg);
  }
  50% {
    transform: translate(-30px, -16px) rotate(-8deg);
  }
}

@keyframes slither-e {
  0%,
  100% {
    transform: translate(0, 0) rotate(12deg);
  }
  50% {
    transform: translate(22px, 28px) rotate(-4deg);
  }
}

@keyframes slither-f {
  0%,
  100% {
    transform: translate(0, 0) rotate(-3deg) scaleX(-1);
  }
  50% {
    transform: translate(-24px, -20px) rotate(7deg) scaleX(-1);
  }
}

@keyframes slither-g {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  50% {
    transform: translate(18px, -14px) rotate(18deg) scale(1.05);
  }
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, 0.06) 2px,
    rgba(0, 0, 0, 0.06) 4px
  );
  z-index: 1;
}

.vignette {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 1;
  background: radial-gradient(ellipse 55% 60% at 50% 45%, transparent 35%, rgba(4, 10, 14, 0.55) 100%);
}

.stage {
  position: relative;
  z-index: 2;
  width: min(100%, 900px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: rise 0.7s ease-out both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hud {
  width: min(100%, 600px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  align-self: flex-start;
}

.floor {
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 1rem;
}

.play-zone {
  display: contents;
}

.touch-lr,
.touch-ud {
  display: none;
}

.arcade {
  position: relative;
  width: min(100%, 600px);
  flex: 1 1 600px;
  max-width: 600px;
}

.arcade-marquee,
.arcade-pillar {
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.45));
}

.stat {
  background: var(--panel);
  border: 1px solid #2a4d38;
  backdrop-filter: blur(8px);
  padding: 0.65rem 0.5rem;
  text-align: center;
}

.stat .label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.45rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.08em;
}

.stat span:last-child {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--ink);
}

/* ----- arcade cabinet ----- */
.arcade-marquee {
  position: relative;
  margin: 0 auto;
  width: 94%;
  padding: 0.9rem 1rem 0.85rem;
  text-align: center;
  border: 3px solid #d4af37;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background:
    linear-gradient(180deg, #2a1608 0%, #1a0e06 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 140, 0.35),
    inset 0 -8px 16px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.arcade-marquee-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 214, 70, 0.12) 40%,
    rgba(61, 255, 138, 0.14) 60%,
    transparent 100%
  );
  animation: marquee-sweep 4.5s ease-in-out infinite;
}

@keyframes marquee-sweep {
  0%,
  100% {
    transform: translateX(-30%);
    opacity: 0.5;
  }
  50% {
    transform: translateX(30%);
    opacity: 1;
  }
}

.arcade-marquee h1 {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(0.72rem, 3.2vw, 1.05rem);
  letter-spacing: 0.08em;
  color: #ffe66d;
  text-shadow:
    0 0 12px rgba(255, 214, 70, 0.55),
    0 0 28px rgba(255, 92, 138, 0.35),
    0 2px 0 #5a3208;
}

.arcade-marquee p {
  position: relative;
  margin: 0.45rem 0 0;
  color: #c9a87a;
  font-size: 0.78rem;
}

.arcade-pillar {
  position: relative;
  width: 100%;
  padding: 0.55rem 0.7rem 0.75rem;
  border: 3px solid #d4af37;
  border-radius: 0 0 14px 14px;
  background:
    linear-gradient(90deg, #1a120c 0%, #2c2118 12%, #3a2c20 50%, #2c2118 88%, #1a120c 100%);
  box-shadow:
    inset 0 0 0 2px #5a4632,
    inset 8px 0 18px rgba(0, 0, 0, 0.35),
    inset -8px 0 18px rgba(0, 0, 0, 0.35);
}

.cabinet-coin-intake {
  position: absolute;
  right: -2px;
  top: 18%;
  width: 12px;
  height: 38px;
  border-radius: 2px 5px 5px 2px;
  background: linear-gradient(90deg, #111 0%, #333 45%, #0a0a0a 100%);
  border: 1px solid #8a7350;
  box-shadow:
    inset 2px 0 4px rgba(0, 0, 0, 0.8),
    0 0 0 1px #5a4632;
  z-index: 4;
}

.flying-coin {
  position: absolute;
  right: -48px;
  top: calc(18% + 5px);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  z-index: 6;
  background:
    radial-gradient(circle at 32% 28%, #fff6c2 0%, #ffe66d 28%, #d4af37 62%, #8a6a00 100%);
  border: 2px solid #c9a227;
  box-shadow:
    inset 0 0 0 3px rgba(255, 230, 109, 0.35),
    inset -2px -2px 4px rgba(90, 50, 0, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.45);
}

.flying-coin::after {
  content: "¢";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.55rem;
  color: #7a5a10;
  text-shadow: 0 1px 0 rgba(255, 246, 194, 0.5);
}

.flying-coin.inserting {
  animation: coin-insert 0.75s cubic-bezier(0.4, 0.05, 0.3, 1) forwards;
}

@keyframes coin-insert {
  0% {
    opacity: 0;
    transform: translateX(36px) rotate(-20deg) scale(0.85);
  }
  18% {
    opacity: 1;
    transform: translateX(18px) rotate(8deg) scale(1);
  }
  72% {
    opacity: 1;
    transform: translateX(-8px) rotate(280deg) scale(1);
  }
  88% {
    opacity: 1;
    transform: translateX(-18px) rotate(340deg) scale(0.82);
  }
  100% {
    opacity: 0;
    transform: translateX(-28px) rotate(380deg) scale(0.45);
  }
}

.arcade-bezel {
  padding: 0.7rem;
  border: 2px solid #8a7350;
  border-radius: 6px;
  background:
    radial-gradient(ellipse at center, #1a1a1a 0%, #0a0a0a 70%),
    #0a0a0a;
  box-shadow:
    inset 0 0 0 4px #222,
    inset 0 0 0 7px #4a4035,
    inset 0 10px 24px rgba(0, 0, 0, 0.65);
}

.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid #1c3324;
  box-shadow:
    inset 0 0 28px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(61, 255, 138, 0.12);
  background: #07140c;
  border-radius: 2px;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.arcade-shelf {
  margin-top: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem 0.7rem;
  border: 2px solid #8a7350;
  border-radius: 4px 4px 8px 8px;
  background:
    linear-gradient(180deg, #4a3828 0%, #2a1e14 55%, #1a120c 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 220, 160, 0.18),
    inset 0 -6px 12px rgba(0, 0, 0, 0.4);
  transform: perspective(400px) rotateX(8deg);
  transform-origin: top center;
}

.arcade-stick {
  position: relative;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.stick-base {
  position: absolute;
  bottom: 4px;
  width: 34px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #666 0%, #222 70%);
  box-shadow: 0 2px 0 #111;
}

.stick-shaft {
  position: absolute;
  bottom: 12px;
  width: 7px;
  height: 22px;
  border-radius: 3px;
  background: linear-gradient(90deg, #888, #ddd, #666);
}

.stick-ball {
  position: absolute;
  bottom: 28px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff7a7a, #c62828 60%, #7a1010);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

.insert-coin {
  position: relative;
  flex: 1;
  max-width: 180px;
  margin: 0 auto;
  font-family: var(--font-display);
  font-size: clamp(0.42rem, 1.8vw, 0.52rem);
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-transform: uppercase;
  color: #ffe66d;
  padding: 0.7rem 0.55rem;
  border: 2px solid #c9a227;
  border-radius: 4px;
  cursor: pointer;
  background:
    linear-gradient(180deg, #3a3a3a 0%, #1a1a1a 45%, #0d0d0d 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 140, 0.35),
    inset 0 -3px 6px rgba(0, 0, 0, 0.5),
    0 3px 0 #111;
  text-shadow: 0 0 8px rgba(255, 214, 70, 0.45);
  transition: transform 0.1s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.insert-coin-lamp {
  display: block;
  width: 8px;
  height: 8px;
  margin: 0 auto 0.35rem;
  border-radius: 50%;
  background: #5a4a20;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.insert-coin.waiting .insert-coin-lamp {
  background: #ffe66d;
  box-shadow:
    0 0 8px rgba(255, 230, 109, 0.9),
    0 0 16px rgba(255, 180, 40, 0.55);
  animation: coin-blink 1s steps(1) infinite;
}

.insert-coin.waiting {
  animation: coin-pulse 1.4s ease-in-out infinite;
}

@keyframes coin-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0.25;
  }
}

@keyframes coin-pulse {
  0%,
  100% {
    box-shadow:
      inset 0 1px 0 rgba(255, 230, 140, 0.35),
      inset 0 -3px 6px rgba(0, 0, 0, 0.5),
      0 3px 0 #111,
      0 0 0 0 rgba(255, 230, 109, 0);
  }
  50% {
    box-shadow:
      inset 0 1px 0 rgba(255, 230, 140, 0.45),
      inset 0 -3px 6px rgba(0, 0, 0, 0.5),
      0 3px 0 #111,
      0 0 12px 2px rgba(255, 214, 70, 0.35);
  }
}

.insert-coin:hover,
.insert-coin:focus-visible {
  color: #fff6c2;
  outline: none;
}

.insert-coin:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.65),
    0 1px 0 #111;
}

.arcade-buttons {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-shrink: 0;
}

.cab-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.35),
    0 3px 0 rgba(0, 0, 0, 0.45);
}

.cab-btn.red {
  background: radial-gradient(circle at 35% 30%, #ff8a8a, #e53935 65%, #8b0000);
}

.cab-btn.yellow {
  background: radial-gradient(circle at 35% 30%, #fff59d, #fbc02d 65%, #8a6a00);
}

.cab-btn.blue {
  background: radial-gradient(circle at 35% 30%, #90caf9, #1e88e5 65%, #0d47a1);
}

.arcade-base {
  margin: 0.55rem auto 0;
  width: 88%;
  height: 34px;
  border: 2px solid #8a7350;
  border-top: none;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(180deg, #2a1e14, #120e0a);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.4);
}

.coin-slot {
  width: 42px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(180deg, #111, #333 40%, #111);
  box-shadow: inset 0 0 0 1px #555;
  flex-shrink: 0;
}

.mute-label {
  font-family: var(--font-display);
  font-size: 0.38rem;
  letter-spacing: 0.06em;
  color: #8a7350;
  text-transform: uppercase;
}

.mute-btn {
  border: none;
  padding: 0;
  cursor: pointer;
  position: relative;
}

.mute-btn::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  box-shadow: 0 0 0 0 transparent;
  transition: box-shadow 0.15s ease;
}

.mute-btn:focus-visible {
  outline: none;
}

.mute-btn:focus-visible::after {
  box-shadow: 0 0 0 2px #ffe66d;
}

.mute-btn[aria-pressed="true"] {
  filter: grayscale(0.7) brightness(0.65);
}

.mute-btn[aria-pressed="true"]::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 120%;
  height: 2px;
  background: #1a0820;
  transform: translate(-50%, -50%) rotate(-35deg);
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(255, 230, 109, 0.35);
  z-index: 1;
}

/* ----- controls side panel (matches game screen) ----- */
.controls-cabinet {
  width: min(100%, 220px);
  flex: 0 0 220px;
  align-self: center;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.45));
}

.controls-marquee {
  width: 94%;
  margin: 0 auto;
  padding: 0.7rem 0.5rem;
  text-align: center;
  border: 3px solid #d4af37;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, #2a1608 0%, #1a0e06 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 140, 0.35),
    inset 0 -8px 16px rgba(0, 0, 0, 0.35);
}

.controls-marquee h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  color: #ffe66d;
  text-shadow:
    0 0 10px rgba(255, 214, 70, 0.45),
    0 2px 0 #5a3208;
}

.controls-pillar {
  padding: 0.5rem 0.55rem 0.6rem;
  border: 3px solid #d4af37;
  border-radius: 0 0 14px 14px;
  background:
    linear-gradient(90deg, #1a120c 0%, #2c2118 12%, #3a2c20 50%, #2c2118 88%, #1a120c 100%);
  box-shadow:
    inset 0 0 0 2px #5a4632,
    inset 8px 0 18px rgba(0, 0, 0, 0.35),
    inset -8px 0 18px rgba(0, 0, 0, 0.35);
}

.controls-bezel {
  padding: 0.55rem;
  border: 2px solid #8a7350;
  border-radius: 6px;
  background:
    radial-gradient(ellipse at center, #1a1a1a 0%, #0a0a0a 70%),
    #0a0a0a;
  box-shadow:
    inset 0 0 0 4px #222,
    inset 0 0 0 7px #4a4035,
    inset 0 10px 24px rgba(0, 0, 0, 0.65);
}

.controls-screen {
  background: #07140c;
  border: 2px solid #1c3324;
  box-shadow:
    inset 0 0 28px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(61, 255, 138, 0.12);
  border-radius: 2px;
  padding: 0.75rem 0.65rem 0.85rem;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.controls-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.controls-list li {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 0.35rem;
  align-items: baseline;
  border-bottom: 1px solid #143221;
  padding-bottom: 0.45rem;
}

.controls-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.controls-list .key {
  font-family: var(--font-display);
  font-size: 0.42rem;
  line-height: 1.45;
  color: #3dff8a;
  letter-spacing: 0.04em;
}

.controls-list .action {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: #e8fff0;
  text-align: right;
}

.controls-tip {
  margin: auto 0 0;
  padding-top: 0.5rem;
  border-top: 1px solid #1a3d28;
  font-family: var(--font-body);
  font-size: 0.72rem;
  line-height: 1.35;
  color: #7eae90;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.5rem;
  background: rgba(5, 16, 10, 0.82);
  text-align: center;
  padding: 1rem;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

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

#overlay-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 3.5vw, 1.05rem);
  color: var(--accent);
  line-height: 1.5;
}

#overlay-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.touch-lr button,
.touch-ud button {
  width: 72px;
  height: 64px;
  border: 1px solid #2f5a40;
  background: var(--panel);
  color: var(--accent);
  font-size: 1.35rem;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 12px;
  box-shadow: 0 4px 0 #1a3324;
}

.touch-lr button:active,
.touch-ud button:active {
  background: #1c3d28;
  transform: translateY(2px);
  box-shadow: 0 2px 0 #1a3324;
}

@media (max-width: 820px) {
  .floor {
    flex-direction: column;
    align-items: center;
  }

  .hud {
    width: 100%;
    align-self: center;
  }

  .arcade {
    width: 100%;
    max-width: 600px;
  }

  .controls-cabinet {
    width: min(100%, 600px);
    flex-basis: auto;
  }

  .controls-screen {
    min-height: 0;
  }

  .controls-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem 1rem;
  }

  .controls-list li:last-child {
    border-bottom: 1px solid #143221;
    padding-bottom: 0.45rem;
  }
}

/* Phone portrait: controls under cabinet — L/R left, U/D right */
@media (max-width: 640px) and (orientation: portrait) {
  body {
    padding: 0.65rem max(0.65rem, env(safe-area-inset-right, 0px))
      calc(0.85rem + env(safe-area-inset-bottom, 0px))
      max(0.65rem, env(safe-area-inset-left, 0px));
    place-items: start center;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
  }

  .stage {
    width: 100%;
    gap: 0.65rem;
  }

  .play-zone {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "arcade arcade"
      "lr ud";
    align-items: start;
    column-gap: 0.65rem;
    row-gap: 0.7rem;
    width: 100%;
  }

  .play-zone .arcade {
    grid-area: arcade;
    width: 100%;
    max-width: none;
  }

  .touch-lr,
  .touch-ud {
    display: flex;
    position: static;
    gap: 0.45rem;
    padding: 0.35rem;
    background: rgba(8, 22, 16, 0.78);
    border: 1px solid #2f5a40;
    backdrop-filter: blur(8px);
    border-radius: 14px;
    width: fit-content;
  }

  .touch-lr {
    grid-area: lr;
    justify-self: start;
    flex-direction: row;
  }

  .touch-ud {
    grid-area: ud;
    justify-self: end;
    flex-direction: column;
  }

  .hud {
    gap: 0.35rem;
  }

  .stat {
    padding: 0.45rem 0.3rem;
  }

  .stat .label {
    font-size: 0.38rem;
    margin-bottom: 0.28rem;
  }

  .stat span:last-child {
    font-size: 0.72rem;
  }

  .arcade-marquee {
    padding: 0.65rem 0.55rem 0.55rem;
  }

  .arcade-marquee h1 {
    font-size: clamp(0.58rem, 3.8vw, 0.85rem);
    letter-spacing: 0.06em;
  }

  .arcade-marquee p {
    font-size: 0.7rem;
    margin-top: 0.35rem;
  }

  .arcade-pillar {
    padding: 0.4rem 0.45rem 0.55rem;
  }

  .arcade-bezel {
    padding: 0.45rem;
  }

  .arcade-shelf {
    margin-top: 0.45rem;
    padding: 0.65rem 0.55rem 0.55rem;
    gap: 0.45rem;
  }

  .arcade-stick {
    width: 40px;
    height: 40px;
    transform: scale(0.85);
    transform-origin: center;
  }

  .insert-coin {
    max-width: none;
    font-size: 0.4rem;
    padding: 0.7rem 0.4rem;
  }

  .arcade-base {
    height: 30px;
    width: 92%;
  }

  .mute-label {
    font-size: 0.34rem;
  }

  .cabinet-coin-intake {
    top: 14%;
    height: 28px;
    width: 9px;
  }

  .flying-coin {
    top: calc(14% + 2px);
    width: 22px;
    height: 22px;
    right: -36px;
  }

  .controls-cabinet {
    display: none;
  }

  .desktop-only {
    display: none !important;
  }

  .board-wrap,
  #board {
    touch-action: none;
  }

  .s5,
  .s6,
  .s7 {
    display: none;
  }

  .deco-snake {
    opacity: 0.4;
  }

  .s1,
  .s2 {
    width: clamp(120px, 42vw, 200px);
  }

  .s3,
  .s4 {
    width: clamp(100px, 34vw, 160px);
    opacity: 0.35;
  }
}

/* Landscape phone + tablet (incl. large iPads): board center, L/R left, U/D right */
@media (max-width: 1400px) and (orientation: landscape),
  (hover: none) and (pointer: coarse) and (orientation: landscape) {
  body {
    padding: 0.4rem max(0.4rem, env(safe-area-inset-right, 0px)) 0.4rem max(0.4rem, env(safe-area-inset-left, 0px));
    place-items: center;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
    min-height: 100dvh;
  }

  .stage {
    width: 100%;
    max-width: none;
    gap: 0.4rem;
  }

  .hud {
    width: min(100%, 520px);
    align-self: center;
    gap: 0.35rem;
  }

  .stat {
    padding: 0.35rem 0.25rem;
  }

  .stat .label {
    font-size: 0.34rem;
  }

  .stat span:last-child {
    font-size: 0.65rem;
  }

  .floor {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 100%;
  }

  .play-zone {
    display: grid;
    grid-template-columns: auto minmax(0, 56vh) auto;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: auto;
    max-width: 100%;
  }

  .arcade {
    width: auto;
    max-width: 56vh;
    flex: none;
  }

  .arcade-marquee {
    padding: 0.4rem 0.4rem 0.35rem;
  }

  .arcade-marquee h1 {
    font-size: clamp(0.5rem, 1.6vh, 0.75rem);
  }

  .arcade-marquee p {
    display: none;
  }

  .arcade-pillar {
    padding: 0.3rem 0.35rem 0.4rem;
  }

  .arcade-bezel {
    padding: 0.3rem;
  }

  .arcade-shelf {
    margin-top: 0.3rem;
    padding: 0.4rem 0.45rem;
  }

  .arcade-stick {
    display: none;
  }

  .insert-coin {
    font-size: 0.36rem;
    padding: 0.55rem 0.4rem;
  }

  .arcade-base {
    height: 22px;
    margin-top: 0.3rem;
  }

  .mute-label {
    font-size: 0.3rem;
  }

  .touch-lr,
  .touch-ud {
    display: flex;
    gap: 0.5rem;
    padding: 0.35rem;
    background: rgba(8, 22, 16, 0.78);
    border: 1px solid #2f5a40;
    border-radius: 14px;
    backdrop-filter: blur(8px);
  }

  .touch-lr {
    flex-direction: row;
  }

  .touch-ud {
    flex-direction: column;
  }

  .touch-lr button,
  .touch-ud button {
    width: clamp(56px, 9vw, 76px);
    height: clamp(52px, 12vh, 72px);
  }

  .controls-cabinet {
    display: none;
  }

  .desktop-only {
    display: none !important;
  }

  .board-wrap,
  #board {
    touch-action: none;
  }

  .s5,
  .s6,
  .s7,
  .s3,
  .s4 {
    display: none;
  }

  .deco-snake {
    opacity: 0.3;
  }
}

/* Tablet portrait (incl. large iPads): controls under cabinet — L/R left, U/D right */
@media (min-width: 641px) and (max-width: 1400px) and (orientation: portrait),
  (hover: none) and (pointer: coarse) and (orientation: portrait) and (min-width: 641px) {
  body {
    padding: 0.75rem max(0.75rem, env(safe-area-inset-right, 0px))
      calc(0.9rem + env(safe-area-inset-bottom, 0px))
      max(0.75rem, env(safe-area-inset-left, 0px));
    -webkit-tap-highlight-color: transparent;
  }

  .play-zone {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "arcade arcade"
      "lr ud";
    align-items: start;
    column-gap: 0.85rem;
    row-gap: 0.85rem;
    width: min(100%, 820px);
  }

  .play-zone .arcade {
    grid-area: arcade;
    max-width: none;
    width: 100%;
  }

  .touch-lr,
  .touch-ud {
    display: flex;
    position: static;
    gap: 0.55rem;
    padding: 0.45rem;
    background: rgba(8, 22, 16, 0.78);
    border: 1px solid #2f5a40;
    backdrop-filter: blur(8px);
    border-radius: 16px;
    width: fit-content;
  }

  .touch-lr {
    grid-area: lr;
    justify-self: start;
    flex-direction: row;
  }

  .touch-ud {
    grid-area: ud;
    justify-self: end;
    flex-direction: column;
  }

  .touch-lr button,
  .touch-ud button {
    width: 84px;
    height: 72px;
    font-size: 1.5rem;
  }

  .controls-cabinet {
    display: none;
  }

  .board-wrap,
  #board {
    touch-action: none;
  }
}

/* Very large tablets: bigger thumbs */
@media (min-width: 900px) and (max-width: 1400px) and (orientation: portrait),
  (min-width: 900px) and (hover: none) and (pointer: coarse) and (orientation: portrait) {
  .touch-lr button,
  .touch-ud button {
    width: 96px;
    height: 84px;
    font-size: 1.65rem;
  }
}

@media (max-width: 400px) and (orientation: portrait) {
  .arcade-stick {
    display: none;
  }

  .arcade-buttons .cab-btn.red,
  .arcade-buttons .cab-btn.yellow {
    display: none;
  }

  .insert-coin {
    flex: 1;
  }

  .touch-lr button,
  .touch-ud button {
    width: 64px;
    height: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .deco-snake,
  .bg-glow,
  .arcade-marquee-glow,
  .insert-coin.waiting,
  .insert-coin.waiting .insert-coin-lamp,
  .flying-coin.inserting,
  .deco-snake .body-path {
    animation: none !important;
  }
}
