:root {
  --bg0: #050009;
  --bg1: #12001e;
  --violet: #7d4dff;
  --violet2: #b263ff;
  --cyan: #48fff1;
  --red: #ff3159;
  --amber: #ffcf66;
  --glass: rgba(26, 7, 44, 0.88);
}
* { box-sizing: border-box; }
html, body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
  color: #efe9ff;
  background: #000;
  font-family: Consolas, "Courier New", monospace;
}
.page {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  display: block;
  padding: 0;
  margin: 0;
  overflow: hidden;
  background: #000;
}
.cabinet {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
  overflow: hidden;
}
.bezel-top {
  display: none !important;
}
.brand {
  font-weight: 900;
  color: var(--amber);
  text-shadow: 0 0 10px rgba(255,207,102,.45);
}
.brand::before { content: "SPI02"; }
.led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #36ff8f;
  box-shadow: 0 0 13px #36ff8f;
}
.status {
  margin-left: auto;
  color: #8fffea;
  font-size: 12px;
  opacity: .9;
}
.status::before { content: attr(data-status); }
.screen-wrap {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  aspect-ratio: auto;
  margin: 0;
  border-radius: 0;
  overflow: hidden;
  background: #000;
  border: 0;
  box-shadow: none;
}
canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  image-rendering: auto;
  background: #000;
  cursor: crosshair;
  outline: none;
  touch-action: none;
}
#helpOverlay[hidden], #helpOverlay.is-hidden { display: none !important; visibility: hidden !important; opacity: 0 !important; pointer-events: none !important; }
.help-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 4px;
  padding: 28px;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, .68);
  text-shadow: 0 0 10px rgba(92, 255, 230, .8);
  pointer-events: none;
}
.help-overlay h1 { margin: 0 0 8px; font-size: clamp(30px, 7vw, 76px); color: var(--amber); }
.help-overlay p { margin: 3px 0; font-size: clamp(12px, 1.9vw, 19px); }
.touch-panel {
  position: fixed;
  z-index: 6;
  left: max(10px, env(safe-area-inset-left, 0px));
  right: max(10px, env(safe-area-inset-right, 0px));
  bottom: max(10px, env(safe-area-inset-bottom, 0px));
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}
body.touch-ui .touch-panel { display: flex; }
@media (hover: none) and (pointer: coarse) {
  .touch-panel { display: flex; }
}
.tp-group {
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.tp-move { grid-template-columns: repeat(2, minmax(60px, 76px)); }
.tp-act {
  grid-template-columns: repeat(4, minmax(46px, 58px));
  grid-template-areas: "g s p w" "st n f f";
}
.tp-act [data-action="special"] { grid-area: w; }
.tp-act [data-action="cycle"] { grid-area: n; }
.touch-panel .tp-wpn { border-color: rgba(234, 74, 94, .55); }
.touch-panel:not([data-mode="play"]) .tp-wpn,
.touch-panel:not([data-mode="play"]) .tp-cycle { opacity: .45; }
.tp-act [data-action="guided"] { grid-area: g; }
.tp-act [data-action="smart"] { grid-area: s; }
.tp-act [data-action="pulse"] { grid-area: p; }
.tp-act [data-action="start"] { grid-area: st; }
.tp-act [data-action="fire"] { grid-area: f; }
.touch-panel button {
  position: relative;
  overflow: hidden;
  min-height: 44px;
  padding: 0 4px;
  border: 1px solid rgba(236, 196, 76, .38);
  border-radius: 14px;
  color: #f6f4e6;
  background: linear-gradient(180deg, rgba(44, 38, 92, .62), rgba(10, 8, 26, .78));
  font: 800 13px Consolas, "Courier New", monospace;
  letter-spacing: .06em;
  box-shadow: inset 0 0 10px rgba(255,255,255,.05), 0 0 10px rgba(0, 0, 0, .35);
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.touch-panel button::before { content: attr(data-label); }
.tp-move button { min-height: 72px; font-size: 24px; }
.touch-panel .tp-fire {
  min-height: 62px;
  font-size: 18px;
  border-color: rgba(234, 74, 94, .7);
  background: linear-gradient(180deg, rgba(150, 40, 60, .72), rgba(40, 8, 18, .84));
}
.touch-panel .tp-start { font-size: 12px; }
.touch-panel .tp-small { min-height: 40px; font-size: 11px; }
.touch-panel .tp-small::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 4px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, #ecc44c calc(var(--ready, 1) * 100%), rgba(255, 255, 255, .14) 0);
}
.touch-panel:not([data-mode="play"]) .tp-small::after { display: none; }
.touch-panel .tp-cycle::after { display: none; }
.touch-panel button.is-down,
.touch-panel button:active { transform: translateY(1px); color: #ecc44c; border-color: rgba(236, 196, 76, .85); }
@media (max-height: 520px) {
  .tp-move button { min-height: 58px; }
  .touch-panel .tp-fire { min-height: 50px; }
  .touch-panel .tp-small { min-height: 34px; }
  .tp-group { gap: 6px; }
  .tp-move { grid-template-columns: repeat(2, 60px); }
  .tp-act { grid-template-columns: repeat(4, 42px); }
  .touch-panel .tp-small { font-size: 9px; letter-spacing: 0; }
  .touch-panel .tp-fire { font-size: 15px; }
}
@media (max-width: 600px) {
  .status { display: none; }
  .tp-move { grid-template-columns: repeat(2, minmax(56px, 68px)); }
  .tp-act { grid-template-columns: repeat(4, minmax(40px, 50px)); }
  .tp-group { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .touch-panel button:active, .touch-panel button.is-down { transform: none; }
}