:root {
  --ink: #07040d;
  --panel: #120b1d;
  --hot: #ff2f87;
  --cyan: #5cf7e8;
  --acid: #c8ff4d;
  --gold: #ffd45e;
  --violet: #7d4dff;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: #030207;
}

body {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-family: "Courier New", Courier, monospace;
  color: #fff;
  background:
    radial-gradient(circle at 50% 42%, rgba(84, 23, 111, .30), transparent 43%),
    radial-gradient(circle at 14% 92%, rgba(255, 47, 135, .12), transparent 28%),
    radial-gradient(circle at 88% 10%, rgba(92, 247, 232, .09), transparent 26%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.012) 0 1px, transparent 1px 5px),
    #030207;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,47,135,.045), transparent 18%, transparent 82%, rgba(92,247,232,.045)),
    radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,.75) 100%);
}

.cabinet {
  position: relative;
  width: min(96vw, calc((100vh - 96px) * 16 / 9));
  width: min(96vw, calc((100svh - 96px) * 16 / 9));
  max-width: 1440px;
  filter: drop-shadow(0 28px 55px rgba(0, 0, 0, .8));
}

.marquee {
  height: clamp(28px, 4.4vw, 54px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 clamp(10px, 1.7vw, 24px);
  border: 2px solid #3d1b52;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,.10), transparent 42%),
    repeating-linear-gradient(90deg, #160b22 0 5px, #1b0d2a 5px 10px);
  box-shadow: inset 0 0 22px rgba(255, 47, 135, .16), 0 -2px 18px rgba(125, 77, 255, .18);
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
}

.marquee-brand {
  color: var(--cyan);
  font-size: clamp(8px, 1.05vw, 14px);
  text-shadow: 0 0 8px rgba(92, 247, 232, .65);
}

.marquee-title {
  color: #fff4cf;
  font-size: clamp(11px, 1.55vw, 22px);
  text-shadow: 2px 2px 0 #9e195e, 0 0 15px rgba(255, 47, 135, .55);
  letter-spacing: .08em;
}

.marquee-free {
  color: var(--acid);
  font-size: clamp(8px, 1.05vw, 14px);
  text-shadow: 0 0 8px rgba(200, 255, 77, .55);
}

.screen-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 3px solid #3d1b52;
  border-top-width: 4px;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  background: #05030a;
  box-shadow:
    0 0 0 2px #09050f,
    0 0 34px rgba(125, 77, 255, .24),
    inset 0 0 35px rgba(0,0,0,.9);
  isolation: isolate;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #05030a;
  touch-action: none;
}

.crt, .glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.crt {
  opacity: .34;
  background:
    repeating-linear-gradient(180deg, rgba(0,0,0,.23) 0 1px, transparent 1px 3px),
    linear-gradient(90deg, rgba(255,0,70,.028), rgba(0,255,220,.02) 50%, rgba(255,0,70,.028));
  mix-blend-mode: multiply;
  animation: crtFlicker 7s steps(1) infinite;
}

.glass {
  background:
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0,0,0,.36) 100%),
    linear-gradient(115deg, rgba(255,255,255,.07), transparent 18%, transparent 75%, rgba(255,255,255,.025));
  box-shadow: inset 0 0 45px rgba(0,0,0,.62);
}

@keyframes crtFlicker {
  0%, 92%, 100% { opacity: .34; }
  93% { opacity: .27; }
  94% { opacity: .39; }
  95% { opacity: .30; }
}

.control-strip {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px 16px;
  padding: 7px 10px 0;
  font-size: clamp(7px, .85vw, 11px);
  letter-spacing: .06em;
  color: #8e7ba8;
  text-transform: uppercase;
}

.control-strip b { color: var(--gold); font-weight: 900; }
.control-strip span { white-space: nowrap; }

.mute-btn {
  appearance: none;
  border: 1px solid #4d2b68;
  border-radius: 3px;
  color: var(--cyan);
  background: #120b1d;
  font: inherit;
  font-size: inherit;
  letter-spacing: .08em;
  padding: 3px 7px;
  cursor: pointer;
}

.mute-btn:hover, .mute-btn:focus-visible { border-color: var(--cyan); outline: none; }

.touch-ui {
  position: relative;
  width: 100%;
  height: 116px;
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), transparent 45%),
    repeating-linear-gradient(90deg, #120b1d 0 5px, #160d23 5px 10px);
  border-top: 2px solid #3d1b52;
  box-shadow: inset 0 8px 18px rgba(0,0,0,.45);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.dpad {
  position: relative;
  width: 108px;
  height: 108px;
  flex: 0 0 auto;
  pointer-events: none;
}

.tbtn {
  position: absolute;
  width: 36px;
  height: 36px;
  border: 2px solid rgba(92, 247, 232, .55);
  border-radius: 8px;
  background: rgba(7, 4, 13, .72);
  color: rgba(255,255,255,.86);
  font: 900 13px/1 "Courier New", monospace;
  box-shadow: inset 0 0 12px rgba(92,247,232,.08), 0 3px 0 rgba(0,0,0,.42);
  pointer-events: auto;
  touch-action: none;
  backdrop-filter: blur(2px);
}

.tbtn:active, .tbtn.held {
  background: rgba(92, 247, 232, .22);
  border-color: var(--cyan);
  transform: translateY(2px);
  box-shadow: inset 0 0 16px rgba(92,247,232,.22);
}

.dpad .up { left: 36px; top: 0; }
.dpad .down { left: 36px; bottom: 0; }
.dpad .left { left: 0; top: 36px; }
.dpad .right { right: 0; top: 36px; }
.dpad-hub {
  position: absolute;
  left: 44px;
  top: 44px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(92,247,232,.13);
  border: 1px solid rgba(92,247,232,.30);
}

.action-pad {
  position: relative;
  width: 124px;
  height: 96px;
  flex: 0 0 auto;
  pointer-events: none;
}

.action-pad .tbtn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border-color: rgba(255, 47, 135, .65);
  color: #ffd9e9;
  font-size: 16px;
}

.action-pad .attack { right: 0; bottom: 0; background: rgba(255,47,135,.18); }
.action-pad .jump { right: 50px; bottom: 24px; border-color: rgba(255,212,94,.65); color: #fff1bd; }
.action-pad .special { right: 6px; bottom: 56px; border-color: rgba(200,255,77,.65); color: #edffc0; width: 38px; height: 38px; font-size: 13px; }

@media (pointer: coarse), (max-width: 700px) {
  .cabinet { width: min(96vw, calc((100vh - 190px) * 16 / 9)); width: min(96vw, calc((100svh - 190px) * 16 / 9)); }
  .touch-ui { display: flex; }
  body:not([data-state="playing"]) .touch-ui { visibility: hidden; }
  .control-strip span { display: none; }
  .control-strip { justify-content: flex-end; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .marquee { display: none; }
  .cabinet { width: min(100vw, calc((100vh - 122px) * 16 / 9)); width: min(100vw, calc((100svh - 122px) * 16 / 9)); }
  .control-strip { position: fixed; bottom: 0; right: 0; z-index: 20; background: rgba(3,2,7,.6); }
}

@media (prefers-reduced-motion: reduce) {
  .crt { animation: none; }
}