:root {
  --bg: #0d0b12;
  --panel: #17141f;
  --line: #2e2838;
  --ink: #f3ecdf;
  --muted: #b3a9b9;
  --amber: #ffb627;
  --pink: #ff3d81;
  --cyan: #29e0ff;
  --green: #6bff8f;
  --pixel: "Press Start 2P", "Courier New", monospace;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 50% -20%, rgba(255, 61, 129, .18), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 3px);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--amber); }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bar ---------- */
.bar { border-bottom: 1px solid var(--line); background: rgba(13, 11, 18, .9); }
.bar .wrap { display: flex; align-items: center; gap: 16px; min-height: 54px; flex-wrap: wrap; }
.bar .home { color: var(--muted); text-decoration: none; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; }
.bar .home:hover { color: var(--amber); }
.bar .sp { flex: 1; }
.bar .logo { font-family: var(--pixel); font-size: .7rem; color: var(--amber); text-decoration: none; letter-spacing: .04em; }

/* ---------- marquee with chase lights ---------- */
.marquee {
  position: relative;
  margin: 36px auto 18px;
  padding: 34px 26px;
  border-radius: 14px;
  background: linear-gradient(180deg, #2a0f24, #140a1c);
  border: 4px solid #3b2034;
  text-align: center;
  overflow: hidden;
}
.marquee h1 {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(1.25rem, 5vw, 2.6rem);
  line-height: 1.35;
  color: var(--amber);
  text-shadow: 0 0 6px #ff7a00, 0 0 22px rgba(255, 122, 0, .75), 3px 3px 0 #7a1238;
  animation: flicker 6s infinite;
}
.marquee p { margin: 14px auto 0; max-width: 60ch; color: var(--muted); }
.bulbs { position: absolute; display: flex; justify-content: space-between; pointer-events: none; }
.bulbs.top, .bulbs.bot { left: 10px; right: 10px; height: 10px; }
.bulbs.top { top: 8px; }
.bulbs.bot { bottom: 8px; }
.bulbs i {
  width: 9px; height: 9px; border-radius: 50%;
  background: #5a3b1a;
  animation: chase 1.2s steps(1) infinite;
}
.bulbs i:nth-child(3n+2) { animation-delay: .4s; }
.bulbs i:nth-child(3n+3) { animation-delay: .8s; }
.bulbs.bot i:nth-child(3n+1) { animation-delay: .8s; }
.bulbs.bot i:nth-child(3n+3) { animation-delay: 0s; }
@keyframes chase {
  0% { background: #fff4c2; box-shadow: 0 0 6px #ffd65a, 0 0 14px #ffb627; }
  33.3% { background: #5a3b1a; box-shadow: none; }
}
@keyframes flicker {
  0%, 92%, 100% { opacity: 1; }
  93% { opacity: .55; }
  94% { opacity: 1; }
  96% { opacity: .7; }
}

/* ---------- lobby grid ---------- */
.cabinets { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 18px; margin: 28px 0 40px; }
.cab {
  display: grid; grid-template-rows: auto 1fr; text-decoration: none; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.cab:hover, .cab:focus-visible { transform: translateY(-4px); border-color: var(--c, var(--amber)); box-shadow: 0 16px 40px -18px var(--c, var(--amber)); color: var(--ink); }
.cab .scr { aspect-ratio: 16 / 9; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--c) 30%, #0d0b12), #0d0b12 75%); border-bottom: 1px solid var(--line); }
.cab .scr svg { width: 46%; height: auto; filter: drop-shadow(0 0 10px var(--c)); }
.cab .info { padding: 16px 18px 18px; display: grid; gap: 8px; align-content: start; }
.cab h2 { margin: 0; font-family: var(--pixel); font-weight: 400; font-size: .95rem; line-height: 1.4; color: var(--c); }
.cab p { margin: 0; color: var(--muted); font-size: .92rem; }
.cab .tag { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cab .go { font-family: var(--pixel); font-size: .62rem; color: var(--ink); margin-top: 4px; }
.cab .best { color: var(--c); }
.note { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); padding: 22px 0 40px; }

/* ---------- game page ---------- */
.game-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 16px 0 10px; }
.game-head h1 { margin: 0; font-family: var(--pixel); font-weight: 400; font-size: clamp(.9rem, 3vw, 1.25rem); color: var(--c, var(--amber)); line-height: 1.4; }
.stats { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; flex-wrap: wrap; }
.stats b { color: var(--ink); font-family: var(--pixel); font-size: .75rem; font-weight: 400; }
.hud { min-height: 1.4em; font-size: .8rem; color: var(--muted); text-align: center; margin-bottom: 8px; }
.stage {
  position: relative; margin: 0 auto; width: 100%;
  border: 3px solid var(--c, var(--amber)); border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 0 4px #000, 0 0 40px -8px var(--c, var(--amber));
  background: #000;
}
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.overlay {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 12px;
  padding: 16px; text-align: center; background: rgba(8, 6, 12, .85); overflow-y: auto;
}
.overlay[hidden] { display: none; }
.overlay h2 { margin: 0; font-family: var(--pixel); font-weight: 400; font-size: clamp(.95rem, 4vw, 1.4rem); color: var(--c, var(--amber)); line-height: 1.4; }
.overlay p { margin: 0; max-width: 40ch; color: var(--ink); font-size: clamp(.78rem, 2.6vw, .92rem); }
.overlay .small { color: var(--muted); font-size: .78rem; }
.overlay .big { font-family: var(--pixel); font-size: clamp(1.2rem, 6vw, 2rem); color: var(--ink); }
.overlay .rec { color: var(--green); font-family: var(--pixel); font-size: .65rem; line-height: 1.6; }
.overlay .back { font-size: .82rem; }
.play {
  font-family: var(--pixel); font-size: .75rem; line-height: 1.4; cursor: pointer;
  padding: 14px 18px; border-radius: 6px; border: 0;
  background: var(--c, var(--amber)); color: #120c16;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .55);
}
.play:hover { filter: brightness(1.12); }
.play:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .55); }
.pad { display: flex; justify-content: center; gap: 10px; margin: 14px auto 6px; flex-wrap: wrap; }
.pad button {
  min-width: 64px; min-height: 56px; padding: 0 14px; border-radius: 12px; cursor: pointer;
  font-family: var(--pixel); font-size: .7rem; color: var(--ink);
  background: #241e2d; border: 2px solid var(--line); box-shadow: 0 4px 0 #000;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.pad button.on { background: var(--c, var(--amber)); color: #120c16; transform: translateY(2px); box-shadow: 0 2px 0 #000; }
@media (hover: hover) and (pointer: fine) { .pad.touch-only { display: none; } }
.tools { display: flex; justify-content: center; gap: 10px; margin: 6px 0 24px; flex-wrap: wrap; }
.tools button, .tools a {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 12px; cursor: pointer; text-decoration: none;
}
.tools button:hover, .tools a:hover { color: var(--ink); border-color: var(--muted); }
.howto { max-width: 70ch; margin: 0 auto 40px; color: var(--muted); font-size: .9rem; }
.howto h2 { font-family: var(--pixel); font-weight: 400; font-size: .75rem; color: var(--ink); margin: 0 0 10px; }
.howto p { margin: 0 0 10px; }

@media (prefers-reduced-motion: reduce) {
  .bulbs i, .marquee h1 { animation: none; }
  .bulbs i:nth-child(odd) { background: #fff4c2; box-shadow: 0 0 6px #ffd65a; }
  .cab, .cab:hover { transition: none; transform: none; }
}
