:root {
  --bg: #07010f;
  --magenta: #ff2bd6;
  --cyan: #22f0ff;
  --amber: #ffb020;
  --gold: #ffd36a;
  --panel: #12061c;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: Orbitron, "Share Tech Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: #f4e9ff;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

#rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #05010a;
  color: var(--cyan);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  letter-spacing: 0.18em;
  font-size: 0.85rem;
}

@media (orientation: landscape) and (max-height: 520px) {
  #rotate { display: flex; }
  #cabinet { display: none; }
}

#cabinet {
  width: 100%;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 43, 214, 0.16), transparent 55%),
    linear-gradient(180deg, #16051f 0%, #07010f 40%, #05010a 100%);
  box-shadow: 0 0 0 2px #2a1038, 0 0 40px rgba(255, 43, 214, 0.18);
  position: relative;
  padding: calc(8px + var(--safe-t)) 8px calc(8px + var(--safe-b));
}

@media (min-width: 720px) {
  body {
    background:
      radial-gradient(ellipse at 50% 20%, #2a0a3d 0%, #07010f 55%, #030008 100%);
  }
  #cabinet {
    margin: 0;
    border-radius: 0;
    outline: 0;
    box-shadow: none;
  }
  #cabinet::before,
  #cabinet::after { display: none; }
}

#board {
  position: relative;
  z-index: 12;
  margin: 0 4px 6px;
  padding: 6px 8px 7px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(10, 2, 18, 0.86), rgba(8, 1, 14, 0.72));
  border: 1px solid rgba(255, 176, 32, 0.28);
  box-shadow: 0 0 22px rgba(255, 43, 214, 0.12), inset 0 0 18px rgba(0, 0, 0, 0.35);
}

.board-top {
  display: grid;
  grid-template-columns: 1fr minmax(120px, 38%) 1fr;
  gap: 8px;
  align-items: stretch;
}

.stat .lbl {
  display: block;
  font-size: 8px;
  letter-spacing: 0.22em;
  color: rgba(255, 176, 32, 0.7);
}
.stat b {
  display: block;
  font-size: clamp(16px, 4.6vw, 28px);
  line-height: 1.05;
  color: #ffe7a8;
  text-shadow: 0 0 10px rgba(255, 176, 32, 0.55);
  font-variant-numeric: tabular-nums;
}
.stat.right { text-align: right; }
.stat.right b { color: #22f0ff; text-shadow: 0 0 10px rgba(34, 240, 255, 0.45); font-size: clamp(13px, 3.4vw, 20px); }

#dmd-wrap {
  height: clamp(40px, 7vw, 58px);
  padding: 3px;
  border-radius: 5px;
  background: #070400;
  box-shadow: inset 0 0 0 1px #3a2208, 0 0 12px rgba(255, 176, 32, 0.16);
}
#dmd { width: 100%; height: 100%; display: block; image-rendering: pixelated; }

.board-mid, .board-bot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 5px;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--gold);
}

.mode {
  color: var(--cyan);
  font-weight: 800;
}
.mode.hot { color: #ff4de4; text-shadow: 0 0 10px #ff2bd6; }

.pips { display: flex; gap: 4px; }
.pips i {
  width: 9px; height: 9px; border-radius: 50%;
  background: #2a1830;
  box-shadow: inset 0 0 0 1px #664;
}
.pips i.on { background: #ffd36a; box-shadow: 0 0 8px #ffb020; }
.pips.locks i.on { background: #ff2bd6; box-shadow: 0 0 8px #ff2bd6; }

.spell { color: rgba(255,255,255,0.28); }
.spell b { color: #22f0ff; text-shadow: 0 0 8px #22f0ff; }
.spell.grid b { color: #ffd36a; text-shadow: 0 0 8px #ffd36a; }

.chip {
  padding: 2px 6px;
  border: 1px solid #39ff9a;
  color: #39ff9a;
  border-radius: 999px;
}

#comboEl { color: #ff4de4; font-weight: 800; }

#pops { pointer-events: none; position: absolute; inset: 0; z-index: 16; overflow: hidden; }
.pop {
  position: absolute;
  left: 50%;
  bottom: 28%;
  transform: translateX(-50%);
  color: #ffe7a8;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px #ffb020;
  animation: popscore 0.7s ease-out forwards;
}
@keyframes popscore {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -36px) scale(1); }
}

#stage {
  position: relative;
  min-height: 0;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 2px rgba(34, 240, 255, 0.22), 0 0 24px rgba(255, 43, 214, 0.12);
  background: #080014;
  touch-action: none;
}

#playfield {
  display: block;
  width: 100%;
  height: 100%;
}

#vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 70px 10px rgba(0, 0, 0, 0.32);
}

#zones {
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: flex;
}

#zone-l, #zone-r { flex: 1; transition: box-shadow 0.08s; }
#zone-l.hot { box-shadow: inset 40px 0 50px -30px rgba(34, 240, 255, 0.35); }
#zone-r.hot { box-shadow: inset -40px 0 50px -30px rgba(255, 43, 214, 0.35); }

#plunger-meter {
  position: absolute;
  right: 6px;
  bottom: 10%;
  width: 10px;
  height: 28%;
  border-radius: 8px;
  background: #14081c;
  box-shadow: inset 0 0 0 1px #22f0ff;
  overflow: hidden;
}
#plunger-meter::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--c, 0) * 100%);
  background: linear-gradient(#ff2bd6, #22f0ff);
}

#dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 2px;
}

.hint {
  font-size: 9px;
  letter-spacing: 0.16em;
  color: rgba(34, 240, 255, 0.55);
}

.ghost {
  appearance: none;
  border: 1px solid rgba(34, 240, 255, 0.35);
  background: rgba(18, 6, 28, 0.7);
  color: var(--cyan);
  font: inherit;
  font-size: 9px;
  letter-spacing: 0.16em;
  padding: 7px 10px;
  border-radius: 999px;
}

.ghost:active { background: rgba(34, 240, 255, 0.16); }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px 16px calc(22px + 48px);
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(7, 1, 15, 0.05) 0%, rgba(7, 1, 15, 0.2) 42%, rgba(7, 1, 15, 0.88) 78%);
}

.overlay .btn,
.overlay .panel,
.overlay .brand,
.overlay .hiscores {
  pointer-events: auto;
}

.overlay.over {
  background:
    linear-gradient(180deg, rgba(7, 1, 15, 0.55), rgba(7, 1, 15, 0.94)),
    var(--art) center / cover no-repeat;
}

.brand {
  font-size: clamp(28px, 9vw, 46px);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow:
    0 0 8px var(--magenta),
    0 0 24px var(--cyan),
    0 4px 0 #3a0148;
}

.tag {
  margin: 8px 0 16px;
  color: var(--cyan);
  letter-spacing: 0.28em;
  font-size: 10px;
}

.btn {
  appearance: none;
  width: 100%;
  border: 0;
  margin: 6px 0;
  padding: 14px 16px;
  border-radius: 10px;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.2em;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(180deg, #ff4de4, #c400a2);
  color: #fff;
  box-shadow: 0 0 22px rgba(255, 43, 214, 0.45);
}

.btn.ghost {
  width: 100%;
  border-radius: 10px;
  padding: 12px;
}

.hiscores {
  list-style: none;
  margin: 8px 0 14px;
  padding: 0;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--gold);
}
.hiscores li {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 211, 106, 0.12);
}

.panel {
  background: rgba(8, 1, 16, 0.88);
  border: 1px solid rgba(34, 240, 255, 0.25);
  border-radius: 14px;
  padding: 16px;
  margin-top: auto;
}

.panel h2 {
  margin: 0 0 10px;
  letter-spacing: 0.2em;
  font-size: 14px;
  color: var(--cyan);
}

.help p { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.04em; line-height: 1.45; color: #d9c8ea; }

.hs-row { display: flex; justify-content: center; gap: 10px; margin: 12px 0; }
.hs-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hs-letter {
  width: 48px; height: 56px;
  display: grid; place-items: center;
  font-size: 28px; font-weight: 900;
  border: 1px solid rgba(255, 176, 32, 0.35);
  color: var(--amber);
}
.hs-letter.on { box-shadow: 0 0 16px rgba(255, 176, 32, 0.45); border-color: var(--amber); }

#final-score {
  font-size: 28px;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin: 4px 0 10px;
}

#boom-flash {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 14;
  opacity: 0;
  mix-blend-mode: screen;
}
#boom-flash.on { animation: flashout 0.3s ease-out; }
@keyframes flashout {
  0% { opacity: 0.8; }
  100% { opacity: 0; }
}
#callout {
  pointer-events: none;
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  z-index: 18;
  font-size: clamp(26px, 8vw, 58px);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 0 10px #ff2bd6, 0 0 28px #22f0ff, 0 4px 0 #3a0148;
  opacity: 0;
  white-space: nowrap;
}
#callout.on { animation: popcall 0.95s ease-out; }
@keyframes popcall {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.45); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -78%) scale(1.28); }
}

#webgl-note {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 40%;
  text-align: center;
  color: var(--cyan);
  letter-spacing: 0.12em;
  font-size: 12px;
  z-index: 5;
}

[hidden] { display: none !important; }
