:root {
  color-scheme: dark;
  --ink: #f7f2da;
  --muted: #bdc6c8;
  --gold: #e6b93f;
  --gold-light: #ffe48a;
  --panel: rgba(5, 15, 23, .96);
}

* { box-sizing: border-box; }
html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(0, 0, 0, .72), rgba(0, 0, 0, .4)),
    repeating-linear-gradient(90deg, #101010 0 74px, #171717 75px 77px, #090909 78px 150px);
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background: radial-gradient(ellipse at 50% 16%, rgba(255, 207, 80, .14), transparent 36%), linear-gradient(180deg, transparent 70%, rgba(0, 0, 0, .74));
  pointer-events: none;
}

button, input { font: inherit; }
h1, h2, p { margin: 0; }

.arcade-room {
  min-height: 100vh;
  padding: 28px 14px 56px;
  display: grid;
  justify-items: center;
  align-items: start;
  perspective: 1600px;
}

.arcade-machine {
  position: relative;
  width: min(1240px, calc(100vw - 28px));
  isolation: isolate;
  filter: drop-shadow(0 34px 30px rgba(0, 0, 0, .65));
}

.arcade-machine::before,
.arcade-machine::after {
  position: absolute;
  top: 34px;
  bottom: 200px;
  z-index: -1;
  width: 66px;
  content: "";
  background: linear-gradient(90deg, #02080d, #0b2943 48%, #02080d);
  border: 3px solid #03070b;
}

.arcade-machine::before { left: -28px; transform: skewY(3deg); }
.arcade-machine::after { right: -28px; transform: skewY(-3deg); }

.machine-marquee {
  position: relative;
  z-index: 4;
  min-height: 166px;
  padding: 26px 110px 22px;
  text-align: center;
  text-transform: uppercase;
  background:
    radial-gradient(circle at 7px 7px, #fff3af 0 2px, #ad7615 3px 5px, transparent 6px) 0 0 / 28px 28px,
    linear-gradient(180deg, #173b5e 0, #07192c 47%, #030b13 100%);
  border: 10px solid #050a0e;
  border-bottom-color: #d29c27;
  border-radius: 32px 32px 10px 10px;
  box-shadow: inset 0 0 0 4px #896016, inset 0 0 45px rgba(255, 214, 93, .15), 0 12px 0 #02070b;
  clip-path: polygon(3% 0, 97% 0, 100% 88%, 96% 100%, 4% 100%, 0 88%);
}

.machine-marquee::after {
  position: absolute;
  inset: 17px 42px;
  z-index: -1;
  content: "";
  border: 2px solid rgba(255, 228, 138, .42);
  border-radius: 14px;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, .6), 0 0 24px rgba(255, 202, 65, .12);
}

.marquee-kicker, .marquee-subtitle, .eyebrow, .hud-label, .overlay-kicker {
  font-family: "Courier New", monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.marquee-kicker { color: #efc95d; font-size: .7rem; font-weight: 800; }
.machine-marquee h1 {
  margin: 5px 0 1px;
  color: #fff6c9;
  font: 1000 clamp(2.5rem, 6vw, 5rem)/.9 Impact, "Arial Black", sans-serif;
  letter-spacing: .04em;
  text-shadow: 0 3px 0 #9c1b2c, 0 6px 0 #50101c, 0 0 24px rgba(255, 225, 125, .45);
}
.marquee-subtitle { color: #d8eaff; font-size: .68rem; }

.machine-screen-section {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  gap: 18px;
  padding: 40px 42px 48px;
  background: linear-gradient(90deg, rgba(255,255,255,.045), transparent 12% 88%, rgba(255,255,255,.035)), linear-gradient(180deg, #0c2b48, #061625 72%, #030c14);
  border-inline: 10px solid #03090e;
  border-top: 10px solid #03090e;
  border-radius: 28px 28px 0 0;
  box-shadow: inset 0 0 0 3px #17436b, inset 0 -30px 45px rgba(0,0,0,.55);
}

.speaker-column {
  margin: 34px 0;
  border: 3px solid #020609;
  border-radius: 14px;
  background: radial-gradient(circle, #050708 0 3px, #32414a 3.5px 4.5px, transparent 5px) 0 0 / 15px 15px, #0a1116;
  box-shadow: inset 0 0 18px #000, 0 0 0 2px #31516a;
  opacity: .78;
}

.game-card {
  position: relative;
  min-width: 0;
  padding: 23px 25px 28px;
  overflow: hidden;
  background: linear-gradient(145deg, #11181c, #020405 54%, #0d1519);
  border: 9px solid #010304;
  border-radius: 36px / 24px;
  box-shadow: 0 0 0 4px #2a353b, inset 0 0 30px #000, 0 14px 28px rgba(0,0,0,.65);
}

.screen-glass {
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  background: linear-gradient(117deg, rgba(255,255,255,.11), transparent 19%, transparent 74%, rgba(255,255,255,.035));
  box-shadow: inset 0 0 32px rgba(126, 211, 255, .1);
  pointer-events: none;
}

.title-row, .hud {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.screen-title { margin-top: 2px; color: #fff5c2; font-size: 1.35rem; }
.eyebrow, .overlay-kicker { color: var(--gold-light); font-size: .64rem; }
.game-description, .overlay-copy { color: var(--muted); line-height: 1.45; }
.game-description { margin-top: 4px; font-size: .82rem; }

.ghost-button {
  padding: 12px 19px;
  border: 2px solid #7d5811;
  border-radius: 7px;
  color: #11120e;
  background: linear-gradient(180deg, #ffe784, #d8a627);
  box-shadow: inset 0 2px rgba(255,255,255,.5), 0 4px 0 #76500c, 0 8px 13px rgba(0,0,0,.35);
  font-family: "Courier New", monospace;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}
.ghost-button:hover, .ghost-button:focus-visible { transform: translateY(-2px); filter: brightness(1.08); }
.ghost-button:active { transform: translateY(2px); box-shadow: inset 0 2px rgba(255,255,255,.4), 0 1px 0 #76500c; }
.ghost-button.secondary { color: #d9e8ef; background: linear-gradient(#21343e, #111d23); border-color: #3e5965; box-shadow: inset 0 1px rgba(255,255,255,.16), 0 3px 0 #050a0d; }

.hud { margin: 14px 0; }
.hud-pill { min-width: 105px; padding: 8px 13px; color: #f7e9a9; background: #071019; border: 1px solid #273841; border-radius: 6px; box-shadow: inset 0 0 10px #000; }
.hud-label { display: block; margin-bottom: 2px; color: #82969e; font-size: .54rem; }
.controls-pill { flex: 1; font-size: .77rem; }

.canvas-wrap { position: relative; z-index: 2; overflow: hidden; border: 4px solid #151d21; border-radius: 18px / 13px; background: #020507; box-shadow: 0 0 0 2px #000, inset 0 0 22px #000; }
.canvas-wrap::after { position: absolute; inset: 0; z-index: 4; content: ""; background: repeating-linear-gradient(180deg, rgba(255,255,255,.018) 0 1px, transparent 1px 4px); border-radius: inherit; pointer-events: none; }
canvas { display: block; width: 100%; height: auto; cursor: crosshair; }

.overlay { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 22px; overflow-y: auto; text-align: center; background: linear-gradient(180deg, rgba(2,8,13,.48), rgba(2,8,13,.9)); transition: opacity 180ms ease, visibility 180ms ease; }
.overlay.hidden { visibility: hidden; opacity: 0; pointer-events: none; }
.overlay-panel { width: min(100%, 660px); max-height: 100%; padding: 24px; overflow-y: auto; background: var(--panel); border: 2px solid #9b721e; border-radius: 10px; box-shadow: 0 0 0 4px #172934, 0 22px 50px rgba(0,0,0,.6), inset 0 0 28px rgba(21,55,75,.3); }
.overlay-panel h2 { max-width: 24ch; margin: 7px auto 9px; font-size: clamp(1.35rem, 3vw, 2rem); }
.overlay-kicker { margin-bottom: 7px; }
.overlay-copy { font-size: .92rem; }

.kit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.kit-card { display: grid; justify-items: center; gap: 6px; min-height: 176px; padding: 14px 10px; color: var(--ink); background: linear-gradient(#14242d, #091219); border: 1px solid #3a4d56; border-radius: 8px; cursor: pointer; transition: transform 140ms ease, border-color 140ms ease; }
.kit-card:hover, .kit-card:focus-visible { transform: translateY(-3px); border-color: var(--gold); }
.kit-card small { color: var(--muted); font-size: .77rem; }
.kit-card strong { font-size: 1.03rem; }

.jersey-preview { position: relative; display: block; width: 100px; height: 92px; filter: drop-shadow(0 9px 8px rgba(0,0,0,.32)); }
.jersey-body { position: absolute; top: 12px; left: 24px; z-index: 2; width: 52px; height: 72px; border-radius: 9px 9px 7px 7px; background: var(--jersey); box-shadow: inset 0 -8px 14px rgba(0,0,0,.1); }
.jersey-sleeve { position: absolute; top: 17px; width: 34px; height: 35px; border-bottom: 6px solid var(--jersey-trim); background: var(--jersey); }
.jersey-sleeve-left { left: 7px; transform: rotate(17deg) skewY(-12deg); border-radius: 9px 0 5px 8px; }
.jersey-sleeve-right { right: 7px; transform: rotate(-17deg) skewY(12deg); border-radius: 0 9px 8px 5px; }
.jersey-collar { position: absolute; top: -1px; left: 15px; width: 22px; height: 14px; border: 5px solid var(--jersey-trim); border-top: 0; border-radius: 0 0 14px 14px; background: var(--panel); }
.jersey-number { position: absolute; inset: 24px 0 auto; color: var(--jersey-number); font: 900 1.55rem/1 "Courier New", monospace; text-align: center; }
.selected-kit-preview { display: grid; place-items: center; margin: 17px auto 8px; }
.selected-kit-preview .jersey-preview { transform: scale(1.12); }
.number-label { display: block; margin: 15px 0 7px; color: var(--muted); font-size: .83rem; font-weight: 700; }
.number-input { width: min(100%, 180px); padding: 10px 14px; border: 2px solid #485d67; border-radius: 7px; outline: 0; color: var(--ink); background: #08131a; font: 900 1.7rem/1 "Courier New", monospace; text-align: center; }
.number-input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(230,185,63,.14); }
.number-hint { margin-top: 7px; color: var(--muted); font-size: .75rem; }
.overlay-actions { display: flex; justify-content: center; gap: 13px; margin-top: 18px; }

.control-deck {
  position: relative;
  z-index: 5;
  min-height: 145px;
  display: grid;
  grid-template-columns: 180px 1fr 220px;
  align-items: center;
  padding: 16px 80px 22px;
  background: linear-gradient(105deg, transparent 48%, rgba(255,255,255,.07) 49%, transparent 50%), linear-gradient(180deg, #194a71 0, #0a2944 45%, #041522 100%);
  border: 9px solid #03080c;
  border-top-color: #d39c24;
  box-shadow: inset 0 3px 0 #315f81, 0 13px 0 #020609, 0 24px 24px rgba(0,0,0,.55);
  clip-path: polygon(4% 0, 96% 0, 100% 82%, 96% 100%, 4% 100%, 0 82%);
  transform-origin: top;
  transform: perspective(650px) rotateX(10deg);
}

.joystick-unit { position: relative; width: 125px; height: 102px; }
.joystick-base { position: absolute; left: 13px; bottom: 1px; width: 100px; height: 31px; border: 5px solid #020405; border-radius: 50%; background: radial-gradient(ellipse, #58636b, #10171b 66%); box-shadow: 0 7px 9px rgba(0,0,0,.6); }
.joystick-stick { position: absolute; left: 58px; bottom: 20px; z-index: 2; width: 14px; height: 62px; border: 3px solid #080a0c; border-radius: 7px; background: linear-gradient(90deg, #5f6c73, #e2e5df 45%, #343c40); transform: rotate(9deg); transform-origin: bottom; }
.joystick-ball { position: absolute; left: 43px; top: 4px; z-index: 3; width: 48px; height: 48px; border: 4px solid #4e0710; border-radius: 50%; background: radial-gradient(circle at 33% 27%, #ff6670, #c01d2b 42%, #620914 80%); box-shadow: inset -6px -8px 10px rgba(0,0,0,.28), 0 7px 10px rgba(0,0,0,.5); }
.control-instructions { justify-self: center; padding: 10px 30px; color: #f7d970; background: #03090d; border: 2px solid #8a6417; border-radius: 5px; box-shadow: inset 0 0 12px #000; font-family: "Courier New", monospace; text-align: center; text-transform: uppercase; }
.control-instructions strong { display: block; font-size: 1rem; }
.control-instructions span { display: block; margin-top: 4px; color: #a9bac1; font-size: .62rem; }
.arcade-buttons { display: flex; align-items: center; justify-content: center; gap: 17px; transform: rotate(-6deg); }
.arcade-button { width: 49px; height: 49px; border: 5px solid #030506; border-radius: 50%; box-shadow: inset 0 5px rgba(255,255,255,.28), inset 0 -7px rgba(0,0,0,.24), 0 7px 8px rgba(0,0,0,.65); }
.arcade-button-yellow { background: #eac02e; }
.arcade-button-blue { background: #2377c6; }
.arcade-button-red { background: #bd2031; }

.lower-cabinet { position: relative; z-index: 1; min-height: 230px; display: grid; grid-template-columns: 1fr 130px 1fr; place-items: center; gap: 55px; padding: 44px 150px 32px; background: linear-gradient(90deg, #02070b, #0c2b47 18%, #081d30 50%, #0c2b47 82%, #02070b); border: 10px solid #020609; border-top: 0; box-shadow: inset 0 0 0 3px #173d5c; clip-path: polygon(5% 0, 95% 0, 92% 100%, 8% 100%); }
.cabinet-vent { width: 100%; max-width: 260px; height: 82px; border: 4px solid #020507; border-radius: 7px; background: repeating-linear-gradient(180deg, #020405 0 5px, #21323a 6px 8px, #05090b 9px 13px); box-shadow: inset 0 0 14px #000; }
.coin-door { width: 112px; height: 144px; display: grid; place-items: center; padding: 15px; color: #e3a930; background: linear-gradient(135deg, #20292d, #06090b 62%); border: 5px solid #010202; border-radius: 7px; box-shadow: 0 0 0 2px #3c474b, inset 0 0 14px #000; font: 900 .72rem "Courier New", monospace; }
.coin-slot { width: 32px; height: 49px; border: 3px solid #050708; border-radius: 4px; background: linear-gradient(90deg, #8c151f, #e64450 45%, #620b13); box-shadow: 0 0 8px rgba(255,45,62,.55); }
.coin-slot::after { display: block; width: 5px; height: 23px; margin: 10px auto; content: ""; background: #110205; border-radius: 3px; }
.coin-return { width: 47px; height: 19px; border: 2px solid #303a3f; background: #020405; box-shadow: inset 0 0 5px #000; }

.orientation-lock {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: max(28px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  color: #fff4bd;
  background: radial-gradient(circle at 50% 40%, #153d5c, #030a10 72%);
  text-align: center;
}

.orientation-lock strong { font-size: clamp(1.55rem, 8vw, 2.3rem); }
.orientation-lock p { max-width: 28ch; color: #c4d3da; line-height: 1.45; }

.phone-rotate-icon {
  position: relative;
  width: 48px;
  height: 82px;
  margin-bottom: 15px;
  border: 4px solid #f2c850;
  border-radius: 9px;
  box-shadow: 0 0 22px rgba(242, 200, 80, .24);
  animation: rotate-phone 1.8s ease-in-out infinite;
}

.phone-rotate-icon::before {
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 6px;
  height: 6px;
  content: "";
  border-radius: 50%;
  background: #f2c850;
  transform: translateX(-50%);
}

@keyframes rotate-phone {
  0%, 24% { transform: rotate(0); }
  68%, 100% { transform: rotate(90deg); }
}

@media (max-width: 900px) {
  .arcade-room { padding-inline: 8px; }
  .arcade-machine { width: calc(100vw - 16px); }
  .machine-screen-section { grid-template-columns: 26px minmax(0,1fr) 26px; gap: 9px; padding: 32px 18px 38px; }
  .game-card { padding: 18px; border-width: 7px; }
  .control-deck { grid-template-columns: 130px 1fr 155px; padding-inline: 48px; }
  .lower-cabinet { padding-inline: 90px; }
}

@media (max-width: 700px) {
  .arcade-room { padding-top: 8px; }
  .arcade-machine::before, .arcade-machine::after, .speaker-column { display: none; }
  .machine-screen-section { grid-template-columns: minmax(0,1fr); padding: 20px 9px 29px; border-inline-width: 6px; }
  .game-card { padding: 13px; border-radius: 22px / 16px; }
  .title-row { align-items: flex-start; }
  .screen-title, .game-description { display: none; }
  .hud { margin: 10px 0; }
  .controls-pill { display: none; }
  .canvas-wrap { border-width: 2px; border-radius: 10px; }
  .overlay { padding: 10px; }
  .overlay-panel { padding: 17px 13px; }
  .kit-grid { grid-template-columns: 1fr; }
  .kit-card { min-height: 150px; }
  .control-deck { min-height: 102px; grid-template-columns: 92px 1fr 112px; padding: 6px 22px 15px; }
  .joystick-unit { width: 85px; transform: scale(.72); transform-origin: left center; }
  .control-instructions { padding: 8px 10px; }
  .control-instructions span { display: none; }
  .arcade-buttons { gap: 6px; }
  .arcade-button { width: 31px; height: 31px; border-width: 3px; }
  .lower-cabinet { min-height: 150px; grid-template-columns: 1fr 84px 1fr; gap: 15px; padding: 24px 42px 20px; }
  .coin-door { width: 75px; height: 104px; padding: 8px; }
  .cabinet-vent { height: 55px; }
}

@media (max-width: 430px) {
  .game-card { padding: 8px; }
  .eyebrow { font-size: .56rem; }
  .ghost-button { padding: 9px 11px; font-size: .7rem; }
  .control-deck { grid-template-columns: 75px 1fr 76px; padding-inline: 13px; }
  .arcade-buttons .arcade-button:nth-child(2) { display: none; }
  .lower-cabinet { padding-inline: 30px; }
  .cabinet-vent { opacity: .6; }
}

@media (orientation: portrait) and (max-width: 950px) {
  html, body { height: 100%; overflow: hidden; }
  .orientation-lock { display: flex; }
  .arcade-room { visibility: hidden; }
}

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

  body::before,
  .arcade-machine::before,
  .arcade-machine::after,
  .speaker-column,
  .control-deck,
  .lower-cabinet { display: none; }

  .arcade-room,
  .arcade-machine,
  .machine-screen-section,
  .game-card,
  .canvas-wrap {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    filter: none;
    transform: none;
  }

  .arcade-room { display: block; }
  .machine-screen-section { display: block; background: #000; }
  .game-card { overflow: hidden; background: #000; }
  .screen-glass, .canvas-wrap::after { display: none; }

  .canvas-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
  }

  canvas {
    width: min(100vw, calc(100dvh * 1.7777778));
    height: auto;
    max-height: 100dvh;
    flex: 0 0 auto;
  }

  .overlay {
    padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .overlay-panel {
    width: min(660px, 92vw);
    padding: 14px 18px;
  }

  .kit-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
  .kit-card { min-height: 128px; padding: 7px; }
  .kit-card .jersey-preview { transform: scale(.72); margin-block: -10px; }
  .selected-kit-preview { margin: 6px auto 0; }
  .selected-kit-preview .jersey-preview { transform: scale(.78); margin-block: -8px; }
  .number-label { margin-top: 4px; }
  .number-input { padding-block: 7px; font-size: 1.35rem; }
  .overlay-actions { margin-top: 10px; }
}
