html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #07060a;
  color-scheme: dark;
  overscroll-behavior: none;
}

#arcade {
  position: fixed;
  inset: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.cabinet-art {
  position: absolute;
  inset: 0;
  display: block;
}

.cabinet-screen {
  position: absolute;
  display: block;
  pointer-events: none;
  border-radius: 2.5% / 3.3%;
  background: #000;
}

/* --- exit chip, shown over a cabinet when there's a lobby to go back to --- */

.arcade-exit {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: calc(env(safe-area-inset-left, 0px) + 8px);
  z-index: 2;
  padding: 6px 9px;
  border-radius: 6px;
  background: rgba(10, 8, 14, 0.55);
  color: #ffd23f;
  font: 10px/1 'Press Start 2P', monospace;
  text-decoration: none;
  opacity: 0.85;
}

.arcade-exit:hover,
.arcade-exit:focus-visible {
  opacity: 1;
}

/* --- lobby: the arcade floor --- */

.lobby {
  --room: 100vh;
  --neon: #ffd23f;
  --neon-2: #ff4fa3;
  --ink: #e9e3f5;
  --muted: #a89fbe;
  /* How much floor shows in front of the wall, the sign's band on the wall, and the cabinets'
     height so they fill what's left. Cabinets stand a little in front of the wall line. */
  --floor: calc(var(--room) * 0.17);
  --sign: max(60px, calc(var(--room) * 0.12));
  --step-out: calc(var(--room) * 0.03);
  --cab-h: min(calc(var(--room) - var(--floor) - var(--sign) + var(--step-out)), 820px);
  position: fixed;
  inset: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: 'Press Start 2P', monospace;
  background: #0b0912;
}

@supports (height: 100dvh) {
  .lobby {
    --room: 100dvh;
  }
}

#arcade.lobby {
  touch-action: auto;
  user-select: auto;
  -webkit-user-select: auto;
}

.lobby-sign {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  height: var(--sign);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--sign) * 0.1);
  padding-top: env(safe-area-inset-top, 0px);
  box-sizing: border-box;
  text-align: center;
  pointer-events: none;
}

.lobby-sign h1 {
  margin: 0;
  font-size: clamp(16px, min(5.5vw, calc(var(--sign) * 0.32)), 40px);
  font-weight: 400;
  color: #fff3c4;
  text-shadow:
    0 0 2px #fff,
    0 0 8px var(--neon),
    0 0 18px var(--neon-2),
    0 0 36px rgba(255, 79, 163, 0.7);
  animation: neon-flicker 7s infinite;
}

.lobby-sign p {
  margin: 0;
  font-size: clamp(7px, calc(var(--sign) * 0.11), 11px);
  color: #9fe7ff;
  text-shadow: 0 0 6px rgba(80, 200, 255, 0.8);
}

@keyframes neon-flicker {
  0%, 91%, 93.5%, 96%, 100% { opacity: 1; }
  92%, 95% { opacity: 0.55; }
}

.floor-row {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0 0 calc(var(--floor) - var(--step-out));
  list-style: none;
  display: flex;
  align-items: flex-end;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  /* The room scrolls with the cabinets: lighting, carpet, baseboard, then the wall. */
  background:
    radial-gradient(ellipse 140% 55% at 50% 0%, rgba(255, 79, 163, 0.16), transparent 70%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 35%) left bottom / 100% var(--floor) no-repeat,
    url('../art/lobby/carpet.webp') left bottom / calc(var(--floor) * 2.4) var(--floor) repeat-x,
    linear-gradient(#2a1e3c, #120c1c) left calc(100% - var(--floor)) / 100% calc(var(--room) * 0.022) no-repeat,
    linear-gradient(to bottom, rgba(5, 3, 10, 0.65), rgba(5, 3, 10, 0.1) 40%, rgba(5, 3, 10, 0.45)),
    url('../art/lobby/wall.webp') left top / calc(var(--room) * 0.5) repeat,
    #1a1226;
  background-attachment: local;
}

@media (pointer: coarse) {
  .floor-row {
    scroll-snap-type: x mandatory;
  }
}

.floor-row::-webkit-scrollbar {
  display: none;
}

/* Room for the first and last cabinets to be scrolled to the middle. */
.floor-row::before,
.floor-row::after {
  content: '';
  flex: 0 0 max(16px, min(calc(50vw - var(--cab-h) * 0.27), calc(4vw + 24px)));
}

.floor-slot {
  position: relative;
  flex: none;
  margin: 0 calc(var(--cab-h) * 0.025);
  scroll-snap-align: center;
}

.floor-cabinet {
  position: relative;
  display: block;
  height: var(--cab-h);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

/* Contact shadow on the carpet. */
.floor-cabinet::before {
  content: '';
  position: absolute;
  left: -6%;
  right: -6%;
  bottom: -2.2%;
  height: 5%;
  background: radial-gradient(ellipse at 50% 40%, rgba(0, 0, 0, 0.85), transparent 70%);
}

.floor-art {
  position: relative;
  display: block;
  height: 100%;
  width: 100%;
  transition: filter 0.2s;
}

.floor-attract,
.floor-glass {
  position: absolute;
  left: var(--screen-x);
  top: var(--screen-y);
  width: var(--screen-w);
  height: var(--screen-h);
  border-radius: 3% / 4%;
  z-index: 1;
}

.floor-attract {
  object-fit: fill;
  background: #000;
  image-rendering: auto;
  filter: saturate(1.15) brightness(1.08);
}

/* Scanlines, curved-glass vignette and a little reflection, standing in for the CRT shader. */
.floor-glass {
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.1), transparent 30%),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.2) 0 1px, transparent 1px 3px);
  box-shadow:
    0 0 calc(var(--cab-h) * 0.03) rgba(140, 200, 255, 0.28),
    inset 0 0 calc(var(--cab-h) * 0.01) rgba(0, 0, 0, 0.8);
}

.floor-cabinet:hover .floor-art,
.floor-cabinet:focus-visible .floor-art {
  filter: brightness(1.12) drop-shadow(0 0 calc(var(--cab-h) * 0.012) rgba(255, 210, 63, 0.75));
}

.floor-plaque {
  position: absolute;
  top: calc(100% + var(--step-out) * 0.6);
  left: 50%;
  width: calc(var(--cab-h) * 0.5);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  pointer-events: none;
}

.floor-players {
  font-size: clamp(7px, calc(var(--floor) * 0.07), 10px);
  color: var(--neon-2);
  text-shadow: 0 0 6px rgba(255, 79, 163, 0.8), 0 1px 2px #000;
}

.floor-blurb {
  font: clamp(11px, calc(var(--floor) * 0.09), 14px) / 1.35 system-ui, sans-serif;
  color: var(--ink);
  text-shadow: 0 1px 3px #000, 0 0 8px #000;
}

@media (max-height: 520px) {
  .floor-blurb {
    display: none;
  }
}

.floor-nav {
  position: absolute;
  top: calc(var(--sign) + (var(--room) - var(--sign) - var(--floor)) / 2);
  z-index: 3;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  border: 2px solid rgba(255, 210, 63, 0.7);
  border-radius: 50%;
  background: rgba(12, 8, 20, 0.7);
  color: var(--neon);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(255, 210, 63, 0.35);
  transition: opacity 0.2s;
}

.floor-prev {
  left: max(10px, env(safe-area-inset-left, 0px));
}

.floor-next {
  right: max(10px, env(safe-area-inset-right, 0px));
}

.lobby.at-start .floor-prev,
.lobby.at-end .floor-next {
  opacity: 0;
  pointer-events: none;
}
