:root {
  --bg: #04010c;
  --cyan: #3df3ff;
  --magenta: #ff2fd0;
  --violet: #8b5cff;
  --lime: #c8ff4d;
  --ink: #eaf6ff;
  --dim: rgba(178, 216, 255, 0.55);
  --display: "Orbitron", "Trebuchet MS", system-ui, sans-serif;
  --body: "Space Grotesk", system-ui, -apple-system, sans-serif;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.vignette {
  background: radial-gradient(
    circle at 50% 48%,
    transparent 34%,
    rgba(2, 0, 8, 0.5) 76%,
    rgba(2, 0, 8, 0.92) 100%
  );
}

.scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(120, 220, 255, 0.035) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: screen;
  opacity: 0.5;
}

#hit-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, transparent 28%, rgba(255, 40, 110, 0.6) 100%);
}

/* ---------------- HUD ---------------- */

#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  padding: 22px 26px calc(22px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

#hud.hidden {
  opacity: 0;
}

.hud-label {
  font-family: var(--display);
  font-size: 0.6rem;
  letter-spacing: 0.32em;
  color: var(--dim);
}

.hud-score {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2rem, 4.4vw, 3.1rem);
  line-height: 1;
  letter-spacing: 0.08em;
  color: #dffbff;
  text-shadow: 0 0 18px rgba(61, 243, 255, 0.7), 0 0 42px rgba(61, 243, 255, 0.3);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.hud-best {
  font-family: var(--display);
  font-size: 0.62rem;
  letter-spacing: 0.26em;
  color: var(--dim);
  margin-top: 8px;
}

.hud-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-num {
  font-family: var(--display);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--dim);
}

.hud-num b {
  color: #eaffff;
  font-size: 0.95rem;
  text-shadow: 0 0 12px rgba(61, 243, 255, 0.6);
  font-variant-numeric: tabular-nums;
}

.pips {
  display: flex;
  gap: 5px;
}

.pips i {
  width: 20px;
  height: 9px;
  background: linear-gradient(90deg, var(--cyan), #1a7dff);
  box-shadow: 0 0 12px rgba(61, 243, 255, 0.8);
  clip-path: polygon(0 0, 100% 0, 82% 100%, 0 100%);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.pips i.off {
  background: rgba(255, 255, 255, 0.09);
  box-shadow: none;
}

.meter {
  width: 132px;
  height: 9px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  clip-path: polygon(0 0, 100% 0, 95% 100%, 0 100%);
}

.meter i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, #ff2fd0, #ffb03d);
  box-shadow: 0 0 16px rgba(255, 47, 208, 0.8);
  transition: transform 0.08s linear;
}

.combo {
  position: absolute;
  top: 40%;
  right: 30px;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.4rem, 2.6vw, 2.1rem);
  letter-spacing: 0.1em;
  color: var(--magenta);
  text-shadow: 0 0 20px rgba(255, 47, 208, 0.75);
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.combo.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ---------------- Buttons ---------------- */

.btn {
  position: relative;
  font-family: var(--display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: #041016;
  background: linear-gradient(100deg, #8dfdfc, var(--cyan) 45%, #b8a0ff);
  border: 0;
  padding: 17px 40px;
  cursor: pointer;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  box-shadow: 0 0 30px rgba(61, 243, 255, 0.55), 0 0 80px rgba(61, 243, 255, 0.2);
  transition: transform 0.14s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 40px rgba(61, 243, 255, 0.8), 0 0 110px rgba(255, 47, 208, 0.3);
  filter: saturate(1.15);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn:focus-visible {
  outline: 2px solid var(--magenta);
  outline-offset: 6px;
}

.ghost-btn {
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(61, 243, 255, 0.4);
  box-shadow: none;
  clip-path: none;
  padding: 15px 26px;
  font-size: 0.7rem;
}

.ghost-btn:hover {
  box-shadow: 0 0 24px rgba(61, 243, 255, 0.25);
  background: rgba(61, 243, 255, 0.07);
}

.ghost {
  position: fixed;
  z-index: 20;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-size: 0.55rem;
  letter-spacing: 0.24em;
  color: var(--dim);
  background: rgba(6, 4, 18, 0.5);
  border: 1px solid rgba(120, 200, 255, 0.18);
  padding: 8px 14px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.ghost:hover {
  color: var(--ink);
  border-color: rgba(61, 243, 255, 0.5);
}

.boost-btn {
  position: fixed;
  z-index: 20;
  right: 22px;
  bottom: calc(26px + env(safe-area-inset-bottom));
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: none;
  font-family: var(--display);
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  color: #fff;
  background: radial-gradient(circle at 40% 35%, rgba(255, 47, 208, 0.85), rgba(90, 20, 80, 0.6));
  border: 1px solid rgba(255, 130, 230, 0.6);
  box-shadow: 0 0 30px rgba(255, 47, 208, 0.5);
  touch-action: none;
}

.boost-btn:active {
  transform: scale(0.95);
}

.touch-only {
  display: none;
}

@media (pointer: coarse) {
  .boost-btn {
    display: block;
  }
  .touch-only {
    display: inline-flex;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 13%;
  z-index: 15;
  transform: translate(-50%, 12px);
  font-family: var(--display);
  font-size: 0.62rem;
  letter-spacing: 0.3em;
  color: var(--magenta);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  text-shadow: 0 0 18px rgba(255, 47, 208, 0.7);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------- Screens ---------------- */

.screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: radial-gradient(circle at 50% 50%, rgba(4, 1, 12, 0.35), rgba(4, 1, 12, 0.86));
  backdrop-filter: blur(2px);
}

.screen.active {
  display: flex;
  animation: fade 0.35s ease both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.wrap,
.panel {
  text-align: center;
  max-width: 780px;
}

.panel {
  border: 1px solid rgba(61, 243, 255, 0.22);
  background: linear-gradient(160deg, rgba(11, 8, 32, 0.86), rgba(4, 1, 12, 0.92));
  padding: clamp(28px, 5vw, 54px) clamp(24px, 6vw, 68px);
  box-shadow: 0 0 60px rgba(61, 243, 255, 0.08), inset 0 0 80px rgba(61, 243, 255, 0.04);
  clip-path: polygon(22px 0, 100% 0, 100% calc(100% - 22px), calc(100% - 22px) 100%, 0 100%, 0 22px);
}

.panel.small {
  max-width: 460px;
}

.eyebrow {
  font-family: var(--display);
  font-size: 0.6rem;
  letter-spacing: 0.42em;
  color: rgba(255, 47, 208, 0.85);
  margin-bottom: 18px;
}

.logo {
  position: relative;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.6rem, 10.5vw, 7rem);
  letter-spacing: 0.06em;
  line-height: 0.94;
  color: #f2ffff;
  text-shadow: 0 0 18px rgba(61, 243, 255, 0.9), 0 0 60px rgba(61, 243, 255, 0.45),
    0 0 120px rgba(139, 92, 255, 0.5);
}

.logo::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: transparent;
  -webkit-text-stroke: 1px rgba(255, 47, 208, 0.55);
  transform: translate(5px, 4px);
  filter: blur(0.2px);
  z-index: -1;
}

.tagline {
  margin-top: 18px;
  font-size: clamp(0.9rem, 1.8vw, 1.06rem);
  font-weight: 300;
  color: rgba(214, 236, 255, 0.78);
  letter-spacing: 0.02em;
}

.actions {
  margin-top: 32px;
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.controls {
  margin-top: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 26px;
  justify-content: center;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: rgba(178, 216, 255, 0.65);
}

kbd {
  display: inline-block;
  font-family: var(--display);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: #dffcff;
  border: 1px solid rgba(61, 243, 255, 0.35);
  border-bottom-width: 2px;
  padding: 3px 6px;
  margin: 0 2px;
  background: rgba(61, 243, 255, 0.06);
}

.best-line {
  margin-top: 26px;
  font-family: var(--display);
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  color: var(--dim);
}

.best-line b {
  color: var(--lime);
  text-shadow: 0 0 14px rgba(200, 255, 77, 0.5);
}

.panel-title {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(1.6rem, 4.6vw, 2.7rem);
  letter-spacing: 0.08em;
  color: #ffe9f9;
  text-shadow: 0 0 24px rgba(255, 47, 208, 0.7);
}

.stat-grid {
  margin-top: 32px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: rgba(61, 243, 255, 0.16);
  border: 1px solid rgba(61, 243, 255, 0.16);
}

.stat-grid div {
  background: rgba(4, 1, 12, 0.9);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-grid span {
  font-family: var(--display);
  font-size: 0.55rem;
  letter-spacing: 0.28em;
  color: var(--dim);
}

.stat-grid b {
  font-family: var(--display);
  font-size: clamp(1.3rem, 3.4vw, 1.8rem);
  letter-spacing: 0.06em;
  color: #eafcff;
  font-variant-numeric: tabular-nums;
}

.new-best {
  margin-top: 22px;
  font-family: var(--display);
  font-size: 0.62rem;
  letter-spacing: 0.34em;
  color: var(--lime);
  text-shadow: 0 0 18px rgba(200, 255, 77, 0.6);
  display: none;
}

.new-best.show {
  display: block;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.hint {
  margin-top: 20px;
  font-size: 0.72rem;
  color: rgba(178, 216, 255, 0.5);
  letter-spacing: 0.06em;
}

@media (max-width: 560px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  #hud {
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .meter {
    width: 88px;
  }
  .combo {
    top: 34%;
    right: 18px;
  }
  .controls {
    margin-top: 28px;
    gap: 10px 18px;
  }
  .ghost {
    top: auto;
    bottom: calc(30px + env(safe-area-inset-bottom));
    left: 16px;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen.active,
  .new-best.show {
    animation: none;
  }
}
