:root {
  --cyan: #33fff2;
  --magenta: #ff33d9;
  --yellow: #ffd633;
  --bg: #05030a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #eaf6ff;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  letter-spacing: 0.04em;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* CRT vignette + scanlines */
.post {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    radial-gradient(120% 120% at 50% 50%, transparent 55%, rgba(0,0,0,0.55) 100%),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.0) 0px, rgba(0,0,0,0.0) 2px, rgba(0,0,0,0.10) 3px);
  mix-blend-mode: multiply;
}

.flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  background: radial-gradient(120% 120% at 50% 50%, rgba(255,255,255,0.0) 40%, rgba(255,60,90,0.5) 100%);
  transition: opacity 0.05s linear;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}
.label {
  font-size: 11px;
  letter-spacing: 0.32em;
  color: #7fb6cc;
  text-transform: uppercase;
}
.hud-top-left { position: absolute; top: 22px; left: 26px; }
.hud-top-right { position: absolute; top: 22px; right: 26px; text-align: right; }

.score {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 46px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 18px rgba(80,220,255,0.8), 0 0 40px rgba(80,220,255,0.4);
}
.level {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 38px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 16px rgba(60,255,240,0.7);
}
.sub { font-size: 13px; color: #9fd; margin-top: 4px; opacity: 0.85; }
.mult { color: var(--yellow); font-weight: 700; text-shadow: 0 0 12px rgba(255,214,51,0.7); }
.mult.pop { animation: multpop 0.32s ease-out; }
@keyframes multpop {
  0% { transform: scale(1); }
  35% { transform: scale(1.5); color: #fff; }
  100% { transform: scale(1); }
}

.fire {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #ffb347;
  text-shadow: 0 0 14px rgba(255,140,40,0.9), 0 0 30px rgba(255,80,0,0.6);
  animation: firepulse 0.7s ease-in-out infinite;
}
@keyframes firepulse {
  0%,100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

/* floating score popups */
.popups {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
}
.popup {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, 0);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-shadow: 0 0 16px currentColor;
  animation: popfloat 0.95s ease-out forwards;
}
@keyframes popfloat {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.1); }
  35% { transform: translate(-50%, -6px) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -64px) scale(0.95); }
}

.zone-label {
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 0.28em;
  color: #bfe9ff;
  text-transform: uppercase;
  opacity: 0.8;
  text-shadow: 0 0 10px rgba(120,200,255,0.5);
}

.zone-banner {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 6;
  pointer-events: none;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: clamp(30px, 6vw, 64px);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fff;
  text-shadow: 0 0 26px var(--cyan), 0 0 60px rgba(60,255,240,0.5);
  opacity: 0;
}
.zone-banner.show {
  animation: zoneIn 1.9s ease-out forwards;
}
.zone-banner .warp-sub {
  display: block;
  font-size: clamp(11px, 1.6vw, 16px);
  letter-spacing: 0.4em;
  color: #9fe8ff;
  margin-bottom: 8px;
  -webkit-text-fill-color: #9fe8ff;
}
.zone-banner .warp-name { display: block; }
@keyframes zoneIn {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.8); letter-spacing: 0.5em; }
  18%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); letter-spacing: 0.14em; }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.05); }
}

.hud-bottom {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(520px, 80vw);
}
.shield { width: 100%; text-align: center; }
.bar {
  margin-top: 6px;
  width: 100%;
  height: 12px;
  border: 1px solid rgba(120,220,255,0.35);
  border-radius: 8px;
  background: rgba(10,20,40,0.5);
  overflow: hidden;
  box-shadow: 0 0 18px rgba(40,120,200,0.25) inset;
}
.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, #00e6ff, #36ff8a);
  box-shadow: 0 0 14px rgba(60,255,180,0.7);
  transition: width 0.12s linear, background 0.2s;
}

.swatches { display: flex; gap: 14px; pointer-events: auto; }
.swatch {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  cursor: pointer;
  opacity: 0.5;
  transition: transform 0.1s, opacity 0.15s, box-shadow 0.15s;
}
.swatch[data-color="0"] { background: var(--cyan); }
.swatch[data-color="1"] { background: var(--magenta); }
.swatch[data-color="2"] { background: var(--yellow); }
.swatch.active { opacity: 1; transform: scale(1.18); }
.swatch[data-color="0"].active { box-shadow: 0 0 24px var(--cyan); }
.swatch[data-color="1"].active { box-shadow: 0 0 24px var(--magenta); }
.swatch[data-color="2"].active { box-shadow: 0 0 24px var(--yellow); }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(80% 80% at 50% 40%, rgba(10,4,24,0.4), rgba(3,2,8,0.85));
  backdrop-filter: blur(3px);
}
.panel {
  text-align: center;
  padding: 40px 48px;
  border-radius: 18px;
  background: rgba(10,8,24,0.55);
  border: 1px solid rgba(120,200,255,0.18);
  box-shadow: 0 0 60px rgba(40,120,255,0.18), 0 0 1px rgba(255,255,255,0.4) inset;
  max-width: min(92vw, 620px);
  max-height: 92vh;
  overflow-y: auto;
}
.logo {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 64px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 0.95;
  color: #fff;
  text-shadow: 0 0 24px var(--cyan), 0 0 60px rgba(60,255,240,0.5);
}
.logo span {
  display: block;
  color: var(--magenta);
  text-shadow: 0 0 24px var(--magenta), 0 0 60px rgba(255,60,220,0.5);
}
.logo.small { font-size: 40px; }
.tag {
  margin-top: 14px;
  font-size: 15px;
  color: #bfe9ff;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.how {
  list-style: none;
  margin: 24px auto 6px;
  font-size: 14px;
  line-height: 2.0;
  color: #cfe9f5;
  max-width: 460px;
}
.how b { color: var(--yellow); }
.cta {
  margin-top: 26px;
  padding: 14px 26px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 16px;
  letter-spacing: 0.18em;
  color: #02121a;
  background: linear-gradient(90deg, var(--cyan), #7affd6);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 0 28px rgba(60,255,240,0.5);
  animation: pulse 1.6s ease-in-out infinite;
}
.cta:hover { filter: brightness(1.1); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 18px rgba(60,255,240,0.4);} 50% { box-shadow: 0 0 40px rgba(60,255,240,0.85);} }

.result { display: flex; gap: 60px; justify-content: center; margin-top: 24px; }
.big {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 44px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 18px rgba(80,220,255,0.7);
}
.result2 { margin-top: 18px; font-size: 14px; color: #bfe9ff; display: flex; gap: 28px; justify-content: center; }
.result2 b { color: var(--yellow); }
.newbest {
  margin-top: 16px;
  color: var(--yellow);
  font-weight: 800;
  letter-spacing: 0.2em;
  text-shadow: 0 0 20px rgba(255,214,51,0.8);
  animation: pulse 1s ease-in-out infinite;
}
.backend {
  margin-top: 18px;
  font-size: 11px;
  letter-spacing: 0.24em;
  color: #5a7f93;
  text-transform: uppercase;
}

.title-row {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.title-row .cta2 { margin-top: 0; }

/* game-over leaderboard + initials + daily */
.daily-result {
  margin-top: 14px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--yellow);
  text-shadow: 0 0 16px rgba(255,214,51,0.7);
}
.hsentry {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: #cfe9f5;
}
.hsentry input {
  width: 96px;
  padding: 8px 10px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
  color: #fff;
  background: rgba(10,20,40,0.6);
  border: 1px solid rgba(120,200,255,0.4);
  border-radius: 8px;
  outline: none;
}
.hsentry .cta2 { margin-top: 0; }
.miniboard {
  margin: 18px auto 6px;
  max-width: 420px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px;
}
.miniboard .row {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  color: #bfe9ff;
  border-bottom: 1px solid rgba(120,200,255,0.08);
}
.miniboard .row.me { color: var(--yellow); text-shadow: 0 0 12px rgba(255,214,51,0.6); }
.miniboard .row .rk { color: #5a7f93; width: 28px; }
.miniboard .row .nm { flex: 1; text-align: left; padding-left: 10px; letter-spacing: 0.1em; }
.miniboard .row .sc { font-weight: 700; }
.miniboard .empty { color: #5a7f93; text-align: center; padding: 12px; }

.rank-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 18px 0;
}
.rank-tabs button {
  padding: 7px 14px;
  font-size: 13px;
  color: #9fd1e6;
  background: rgba(20,40,70,0.4);
  border: 1px solid rgba(120,200,255,0.18);
  border-radius: 7px;
  cursor: pointer;
}
.rank-tabs button.active {
  color: #02121a;
  background: linear-gradient(90deg, var(--cyan), #7affd6);
  border-color: transparent;
}
.ranklist {
  min-height: 220px;
  max-width: 460px;
  margin: 0 auto 10px;
}

/* missions + unlocks */
.missions {
  margin: 16px auto 4px;
  max-width: 440px;
  text-align: left;
}
.missions .mtitle {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: #7fb6cc;
  text-transform: uppercase;
  margin-bottom: 6px;
  text-align: center;
}
.missions .mrow {
  font-size: 13px;
  color: #cfe9f5;
  padding: 3px 8px;
  letter-spacing: 0.04em;
}
.missions .mrow.done {
  color: #36ff8a;
  text-shadow: 0 0 12px rgba(54,255,138,0.6);
  font-weight: 700;
}
.unlockbox {
  margin: 12px auto;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--yellow);
  text-shadow: 0 0 18px rgba(255,214,51,0.8);
  animation: firepulse 0.8s ease-in-out infinite;
}
.seg button.locked {
  opacity: 0.45;
  cursor: not-allowed;
}
.seg button.locked:hover {
  color: #9fd1e6;
  border-color: rgba(120,200,255,0.18);
}

/* ============================ Title screen ============================ */
.overlay.title-screen {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  padding: 26px clamp(20px, 4vw, 56px) 24px;
  backdrop-filter: none;
  /* dim top (behind logo) + bottom (behind buttons) + edge vignette, leave the
     middle clear so the live attract-mode tunnel shows through */
  background:
    radial-gradient(125% 80% at 50% 16%, rgba(4,3,12,0.82), rgba(4,3,12,0) 48%),
    linear-gradient(180deg, rgba(3,2,8,0.45) 0%, rgba(3,2,8,0) 26%, rgba(3,2,8,0) 52%, rgba(3,2,8,0.9) 100%),
    radial-gradient(150% 130% at 50% 50%, transparent 52%, rgba(2,1,6,0.72) 100%);
}

.title-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.title-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px 0;
}

.badge {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #bfe9ff;
  padding: 9px 15px;
  border: 1px solid rgba(120,200,255,0.22);
  border-radius: 11px;
  background: rgba(8,14,30,0.55);
  box-shadow: 0 0 24px rgba(40,120,255,0.12);
  white-space: nowrap;
}
.badge b { color: #fff; font-weight: 800; }
.badge.ghost { color: var(--yellow); border-color: rgba(255,214,51,0.28); }
.badge.ghost b { color: var(--yellow); }

.supertitle {
  font-size: clamp(10px, 1.4vw, 14px);
  letter-spacing: 0.62em;
  padding-left: 0.62em;
  color: #84c4e6;
  text-transform: uppercase;
  margin-bottom: 18px;
  text-shadow: 0 0 18px rgba(80,180,255,0.45);
}
.hero .logo {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 800;
  font-size: clamp(58px, 12vw, 138px);
  line-height: 0.84;
  letter-spacing: 0.04em;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-shadow: none;
}
.hero .logo .c1 {
  color: #eafcff;
  text-shadow: 0 0 26px var(--cyan), 0 0 80px rgba(60,255,240,0.45);
}
.hero .logo .c2 {
  color: #ff5ad8;
  text-shadow: 0 0 26px var(--magenta), 0 0 80px rgba(255,60,220,0.45);
}
.logo-rule {
  width: min(420px, 60vw);
  height: 2px;
  margin: 18px 0 14px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--magenta), transparent);
  box-shadow: 0 0 18px rgba(120,200,255,0.6);
  opacity: 0.85;
}
.title-screen .tag {
  margin-top: 0;
  font-size: clamp(12px, 1.5vw, 15px);
  letter-spacing: 0.2em;
  color: #cfeaf6;
  text-transform: uppercase;
}

.cta.play {
  margin-top: 34px;
  padding: 18px 64px;
  font-size: 22px;
  letter-spacing: 0.24em;
  border-radius: 13px;
}
.press-hint {
  margin-top: 12px;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #8fb6cc;
  opacity: 0.85;
}
.press-hint b { color: var(--cyan); font-weight: 700; }

.title-screen .title-row { margin-top: 22px; }
.title-screen .hint {
  margin-top: 16px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--yellow);
  text-shadow: 0 0 14px rgba(255,214,51,0.5);
  min-height: 14px;
}

.missions.card {
  margin: 0;
  max-width: 320px;
  padding: 14px 18px;
  border: 1px solid rgba(120,200,255,0.16);
  border-radius: 12px;
  background: rgba(8,12,26,0.5);
}
.version {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #5a7f93;
  align-self: flex-end;
}

@media (max-width: 620px) {
  .title-bottom .missions.card { display: none; }
  .supertitle { letter-spacing: 0.4em; }
}

/* ============================ Touch controls ============================ */
.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  display: none;
}
body.is-touch.touch-play .touch-controls { display: block; }

.rotzone {
  position: fixed;
  bottom: 0;
  top: 28%;
  width: 42%;
  margin: 0;
  border: none;
  background: transparent;
  pointer-events: auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: calc(54px + env(safe-area-inset-bottom));
  color: rgba(150,210,255,0.22);
  font-size: 52px;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  transition: background 0.1s;
}
.rotzone.left { left: 0; border-top-right-radius: 40px; }
.rotzone.right { right: 0; border-top-left-radius: 40px; }
.rotzone.pressed {
  background: radial-gradient(80% 60% at 50% 100%, rgba(60,200,255,0.16), transparent 70%);
  color: rgba(120,240,255,0.6);
}

/* Bigger color buttons on touch devices */
@media (pointer: coarse) {
  .swatch { width: 58px; height: 58px; }
  .hud-bottom { gap: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); }
}

/* ============================ Responsive HUD ============================ */
@media (max-width: 640px) {
  .hud-top-left { top: calc(12px + env(safe-area-inset-top)); left: 16px; }
  .hud-top-right { top: calc(12px + env(safe-area-inset-top)); right: 16px; }
  .score { font-size: 32px; }
  .level { font-size: 26px; }
  .label { font-size: 9px; letter-spacing: 0.24em; }
  .sub { font-size: 11px; }
  .zone-label { font-size: 9px; letter-spacing: 0.18em; }
  .hud-bottom { width: min(440px, 92vw); }
  .gear { top: calc(12px + env(safe-area-inset-top)); }
  .fire { font-size: 11px; }
}
@media (max-height: 480px) {
  .rotzone { top: 18%; font-size: 40px; }
}

@media (max-width: 560px) {
  .logo { font-size: 46px; }
  .score { font-size: 36px; }
  .panel { padding: 28px 22px; }
}

/* ---------- Settings ---------- */
.cta2 {
  margin-top: 12px;
  padding: 11px 22px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: #bfe9ff;
  background: rgba(40,80,140,0.18);
  border: 1px solid rgba(120,200,255,0.3);
  border-radius: 9px;
  cursor: pointer;
  font-weight: 700;
}
.cta2:hover { background: rgba(60,120,200,0.3); color: #fff; }
.cta2.danger { color: #ff9bb0; border-color: rgba(255,80,120,0.4); }
.cta2.danger:hover { background: rgba(255,60,100,0.2); }

.gear {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: #bfe9ff;
  background: rgba(10,20,40,0.55);
  border: 1px solid rgba(120,200,255,0.3);
  cursor: pointer;
  pointer-events: auto;
}
.gear:hover { color: #fff; box-shadow: 0 0 18px rgba(60,200,255,0.5); }

.settings-panel { max-width: min(94vw, 560px); text-align: left; }
.settings-panel .logo { text-align: center; }
.settings-grid {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.srow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.srow > label {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #9fd1e6;
  min-width: 120px;
}
.slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, #00e6ff, #ff33d9);
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 12px rgba(60,255,240,0.9);
  cursor: pointer;
}
.slider::-moz-range-thumb {
  width: 18px; height: 18px; border: none; border-radius: 50%;
  background: #fff; box-shadow: 0 0 12px rgba(60,255,240,0.9); cursor: pointer;
}
.seg {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.seg button {
  padding: 7px 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #9fd1e6;
  background: rgba(20,40,70,0.4);
  border: 1px solid rgba(120,200,255,0.18);
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
}
.seg button:hover { color: #fff; border-color: rgba(120,200,255,0.4); }
.seg button.active {
  color: #02121a;
  background: linear-gradient(90deg, var(--cyan), #7affd6);
  border-color: transparent;
  box-shadow: 0 0 14px rgba(60,255,240,0.5);
}
.settings-actions {
  margin-top: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.settings-actions .cta { margin-top: 0; }
.settings-actions .cta2 { margin-top: 0; }
