:root {
  --bg: #05060f;
  --ink: #e8f4ff;
  --dim: #6f7fa8;
  --cyan: #3df2ff;
  --pink: #ff3d9a;
  --gold: #ffd23d;
  --font: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: var(--font); overflow: hidden; overscroll-behavior: none;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
body {
  background:
    radial-gradient(ellipse at 50% 0%, #131a3d 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, #2a0f33 0%, transparent 55%),
    var(--bg);
}
#app {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.hud {
  display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center;
  width: var(--stage-w, 100%); height: 50px; flex: none;
}
.hud-cell.left { text-align: left; }
.hud-cell.center { text-align: center; }
.hud-cell.right { text-align: right; }
.label { font-size: 10px; letter-spacing: 2px; color: var(--dim); }
.value { font-size: 24px; font-weight: 700; letter-spacing: 1px; text-shadow: 0 0 12px rgba(61, 242, 255, .7); font-variant-numeric: tabular-nums; }
.value.small { font-size: 13px; text-shadow: 0 0 10px rgba(255, 61, 154, .7); white-space: nowrap; }
.combo { font-size: 20px; font-weight: 800; color: var(--dim); transition: color .15s, transform .15s; }
.combo.hot { color: var(--gold); text-shadow: 0 0 14px rgba(255, 210, 61, .9); transform: scale(1.15); }
.combo.max { color: var(--pink); text-shadow: 0 0 16px rgba(255, 61, 154, 1); animation: pulse .4s infinite alternate; }
@keyframes pulse { to { transform: scale(1.3); } }
.bar { width: 70%; max-width: 150px; height: 5px; margin: 4px auto 0; background: #151a33; border-radius: 3px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--pink)); border-radius: 3px; }
.bar.dash > div { background: linear-gradient(90deg, #2a7dff, var(--cyan)); width: 100%; }
.bar.dash.ready { box-shadow: 0 0 10px rgba(61, 242, 255, .8); }
#lives { display: flex; gap: 6px; }
#lives i {
  width: 16px; height: 16px; border-radius: 50%; background: #0b1020;
  border: 2px solid var(--cyan); box-shadow: 0 0 8px var(--cyan); display: block;
}
.icon {
  font: inherit; font-weight: 700; color: var(--ink); background: #10152c; border: 1px solid #2a3360;
  width: 44px; height: 44px; border-radius: 10px; cursor: pointer; margin-left: 6px;
}
.icon:hover { border-color: var(--cyan); }
.icon.off { color: #4a5270; text-decoration: line-through; }

#stage {
  position: relative; flex: none; border-radius: 12px; overflow: hidden;
  box-shadow: 0 0 0 1px #1c2450, 0 0 40px rgba(61, 120, 255, .25), inset 0 0 60px rgba(0, 0, 0, .6);
  background: #03040b;
}
#cv { display: block; }
.fx-scan {
  position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .13) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .55) 100%);
}

.overlay {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 16px; text-align: center;
  background: rgba(4, 5, 14, .78); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.overlay.show { display: flex; animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }
.logo { font-size: clamp(40px, 13vmin, 76px); font-weight: 900; line-height: .9; letter-spacing: 4px; display: flex; flex-direction: column; }
.logo span:first-child { color: #fff; text-shadow: 0 0 8px #fff, 0 0 28px var(--cyan), 0 0 60px var(--cyan); }
.logo .rush {
  background: linear-gradient(90deg, var(--gold), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 16px rgba(255, 61, 154, .7)); font-style: italic; transform: skewX(-6deg);
  animation: rush 2.4s ease-in-out infinite;
}
@keyframes rush { 50% { transform: skewX(-6deg) translateX(8px); } }
.tag { color: var(--dim); letter-spacing: 3px; font-size: 12px; margin-bottom: 10px; }
h2 { margin: 0 0 6px; font-size: 28px; letter-spacing: 5px; text-shadow: 0 0 18px var(--cyan); }
.btn {
  font: inherit; font-weight: 700; letter-spacing: 3px; font-size: 14px; color: var(--ink);
  min-width: 220px; min-height: 46px; padding: 10px 18px; border-radius: 10px; cursor: pointer;
  background: rgba(20, 26, 56, .85); border: 1px solid #2f3a75; transition: transform .08s, box-shadow .15s, border-color .15s;
}
.btn small { color: var(--dim); letter-spacing: 1px; font-weight: 400; }
.btn:hover, .btn:focus-visible { border-color: var(--cyan); box-shadow: 0 0 18px rgba(61, 242, 255, .45); outline: none; }
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(90deg, #1ec8ff, #3d6bff); border-color: #8fe9ff; color: #02101c; box-shadow: 0 0 22px rgba(61, 200, 255, .55); }
.btn.gold { background: linear-gradient(90deg, var(--gold), #ff9a3d); border-color: #fff0b0; color: #1c1002; box-shadow: 0 0 22px rgba(255, 210, 61, .55); }
.row { display: flex; gap: 8px; }
.row .btn { min-width: 120px; }
.best { margin-top: 8px; color: var(--dim); font-size: 12px; letter-spacing: 3px; }
.best b { color: var(--gold); }
.help { text-align: left; max-width: 420px; padding: 0 0 0 18px; margin: 0 0 8px; font-size: 13px; line-height: 1.55; color: #c5d2f5; }
.help b { color: var(--cyan); }
.final { font-size: 46px; font-weight: 900; color: var(--gold); text-shadow: 0 0 22px rgba(255, 210, 61, .8); font-variant-numeric: tabular-nums; }
.stats { color: var(--dim); font-size: 12px; letter-spacing: 2px; }
.rank { color: var(--pink); font-weight: 700; letter-spacing: 2px; min-height: 18px; }
#dash-btn {
  display: none; position: absolute; right: 10px; bottom: 10px; width: 68px; height: 68px; border-radius: 50%;
  font: inherit; font-size: 11px; font-weight: 800; letter-spacing: 1px; color: var(--cyan);
  background: rgba(10, 20, 50, .55); border: 2px solid var(--cyan); opacity: .75;
}
#dash-btn.cool { opacity: .25; }
body.touch.playing #dash-btn { display: block; }

/* Phones held sideways: HUD strips move beside the maze so it can use the full height. */
@media (orientation: landscape) and (max-height: 560px) {
  #app { flex-direction: row; gap: 10px; }
  .hud { display: flex; flex-direction: column; justify-content: space-between; width: 112px; height: var(--stage-h, 100%); }
  .hud .hud-cell { text-align: center; }
  .value { font-size: 19px; }
  .value.small { font-size: 11px; white-space: normal; }
  #lives { justify-content: center; flex-wrap: wrap; }
  .icon { margin: 0 2px; }
  .overlay { gap: 6px; padding: 8px; overflow-y: auto; justify-content: safe center; }
  .logo { font-size: 34px; flex-direction: row; gap: 10px; }
  .tag, .best { display: none; }
  h2 { font-size: 20px; margin: 0; }
  .btn { min-height: 44px; padding: 6px 14px; font-size: 12px; min-width: 200px; }
  .final { font-size: 30px; line-height: 1; }
  .help { font-size: 11px; line-height: 1.35; }
}
@media (max-width: 420px) {
  .help { font-size: 12px; line-height: 1.45; }
  .row .btn { min-width: 0; padding-inline: 12px; letter-spacing: 2px; font-size: 12px; }
}
