:root {
  --bg-0: #04060f;
  --bg-1: #081226;
  --bg-2: #0b1c3a;
  --cyan: #29e6ff;
  --cyan-soft: #6df4ff;
  --blue: #2f7bff;
  --ink: #cdeaff;
  --ink-dim: #6f93bd;
  --glow: 0 0 8px var(--cyan), 0 0 18px rgba(41, 230, 255, 0.6);
  --panel-bg: linear-gradient(160deg, rgba(10, 26, 56, 0.92), rgba(6, 14, 32, 0.92));
  --panel-border: rgba(54, 150, 255, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--ink);
  font-family: "Rajdhani", system-ui, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

.scene {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(28, 78, 160, 0.45), transparent 60%),
    radial-gradient(100% 60% at 50% 110%, rgba(18, 58, 130, 0.4), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.frame {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1.2vh, 10px);
  padding: clamp(6px, 1.6vh, 14px);
}

/* ===== Top HUD ===== */
.hud-top {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(4px, 1.4vw, 10px);
}
.stat {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: clamp(4px, 1vh, 9px) 6px;
  text-align: center;
  box-shadow: inset 0 0 12px rgba(20, 90, 200, 0.25);
}
.stat-label {
  display: block;
  font-size: clamp(8px, 2.6vw, 11px);
  letter-spacing: 0.14em;
  color: var(--ink-dim);
  font-weight: 600;
}
.stat-value {
  display: block;
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: clamp(13px, 4.4vw, 20px);
  color: #fff;
  text-shadow: var(--glow);
  line-height: 1.1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.stat-value small { font-size: 0.6em; color: var(--cyan-soft); }

/* ===== Play area ===== */
.play {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: clamp(4px, 1.4vw, 9px);
  align-items: stretch;
  justify-content: center;
}
.rail {
  width: clamp(58px, 17vw, 86px);
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.4vh, 12px);
}
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: inset 0 0 14px rgba(20, 90, 200, 0.22);
}
.panel-title {
  font-size: clamp(8px, 2.4vw, 11px);
  letter-spacing: 0.18em;
  color: var(--cyan);
  text-align: center;
  margin-bottom: 4px;
  text-shadow: 0 0 6px rgba(41, 230, 255, 0.6);
}
.mini-canvas {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: auto;
}
.panel.mini .mini-canvas { aspect-ratio: 1 / 1; }
.rail-right .panel.mini .mini-canvas { aspect-ratio: 1 / 3.1; }

/* HOLD panel is tappable on touch devices */
.rail-left .panel.mini {
  cursor: pointer;
  touch-action: none;
  transition: box-shadow 0.1s, border-color 0.1s;
}
.rail-left .panel.mini:active {
  border-color: var(--cyan);
  box-shadow: inset 0 0 16px rgba(41, 230, 255, 0.35), 0 0 14px rgba(41, 230, 255, 0.5);
}

/* Board */
.board-wrap {
  position: relative;
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
#board {
  height: 100%;
  max-height: 100%;
  border-radius: 14px;
  border: 2px solid rgba(64, 170, 255, 0.85);
  box-shadow:
    0 0 0 2px rgba(8, 20, 44, 0.9),
    0 0 22px rgba(41, 160, 255, 0.55),
    inset 0 0 30px rgba(10, 40, 90, 0.6);
  background:
    linear-gradient(180deg, rgba(8, 18, 40, 0.96), rgba(4, 10, 26, 0.98));
  touch-action: none;
}

/* Gauges */
.gauge { display: flex; flex-direction: column; gap: 3px; }
.gauge-head {
  display: flex;
  justify-content: space-between;
  font-size: clamp(8px, 2.2vw, 10px);
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  font-weight: 600;
}
.gauge-head span:last-child { color: var(--cyan-soft); }
.gauge-track {
  height: 8px;
  border-radius: 6px;
  background: rgba(10, 28, 60, 0.8);
  border: 1px solid rgba(54, 150, 255, 0.4);
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  width: 76%;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  box-shadow: 0 0 10px var(--cyan);
  border-radius: 6px;
  transition: width 0.4s ease;
}
.gauge-fill.zone {
  width: 0%;
  background: linear-gradient(90deg, #7a3cff, #d23bff, #ff3bb0);
  box-shadow: 0 0 10px #c93bff;
}
.zone-gauge { margin-top: 2px; }

/* Combo box */
.combo-box {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 6px 4px;
  text-align: center;
  box-shadow: inset 0 0 14px rgba(20, 90, 200, 0.22);
}
.combo-label {
  font-size: clamp(8px, 2.4vw, 11px);
  letter-spacing: 0.16em;
  color: var(--cyan);
  text-shadow: 0 0 6px rgba(41, 230, 255, 0.6);
}
.combo-value {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: clamp(18px, 6vw, 28px);
  color: #fff;
  text-shadow: var(--glow);
  line-height: 1.1;
}
.combo-b2b {
  font-size: clamp(7px, 2vw, 9px);
  letter-spacing: 0.1em;
  color: #ff7be0;
  min-height: 1em;
  text-shadow: 0 0 6px rgba(255, 90, 200, 0.7);
}

/* ===== Overlay ===== */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 20, 0.82);
  backdrop-filter: blur(3px);
  border-radius: 14px;
  z-index: 5;
  transition: opacity 0.25s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay-card { text-align: center; padding: 16px; }
.title-neon {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: clamp(28px, 11vw, 46px);
  line-height: 1;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 0 10px var(--cyan), 0 0 26px var(--cyan), 0 0 50px rgba(41, 160, 255, 0.8);
  animation: flicker 3.5s infinite;
}
.overlay-sub { margin: 12px 0 18px; color: var(--ink-dim); font-size: 14px; }
.overlay-hint { margin-top: 16px; color: var(--ink-dim); font-size: 11px; letter-spacing: 0.05em; }
.btn-start {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.18em;
  color: var(--bg-0);
  background: linear-gradient(90deg, var(--cyan), var(--cyan-soft));
  border: none;
  border-radius: 30px;
  padding: 12px 38px;
  cursor: pointer;
  box-shadow: 0 0 18px var(--cyan), 0 0 36px rgba(41, 230, 255, 0.6);
  animation: pulse 1.8s infinite;
}
.btn-start:active { transform: scale(0.96); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 18px var(--cyan), 0 0 36px rgba(41, 230, 255, 0.6); }
  50% { box-shadow: 0 0 26px var(--cyan), 0 0 60px rgba(41, 230, 255, 0.9); }
}
@keyframes flicker {
  0%, 100%, 45%, 55% { opacity: 1; }
  48% { opacity: 0.75; }
  50% { opacity: 0.95; }
}

/* Pause button */
.pause-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 8px);
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--cyan-soft);
  background: rgba(10, 26, 56, 0.85);
  border: 1px solid rgba(64, 160, 255, 0.55);
  cursor: pointer;
  z-index: 6;
  display: none;
}
.pause-btn.show { display: block; }

/* Short-screen tweaks */
@media (max-height: 640px) {
  .overlay-hint { display: none; }
}
