/* HYPERLANE. Its own dark world: fullscreen, touch-first. */

html,
body {
  margin: 0;
  height: 100%;
  background: #04010b;
}

[hidden] {
  display: none !important;
}

.root {
  --cyan: #00f0ff;
  --pink: #ff2bd6;
  --gold: #ffd400;
  --red: #ff3b1f;
  --ink: #f4f1ff;
  --ink-soft: #cfc8f0;
  --ground: #04010b;
  --panel: rgba(12, 4, 30, 0.78);
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;

  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--mono);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.canvas {
  position: absolute;
  inset: 0;
}

/* ── Touch lanes ─────────────────────────────────────────────── */

.touch {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  z-index: 1;
}

.pad {
  position: relative;
}

.pad::after {
  content: '';
  position: absolute;
  inset: auto 6% 0 6%;
  height: 26%;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(to top, currentColor, transparent);
  opacity: 0;
  transition: opacity 90ms ease-out;
}

.pad[data-lane='0'] {
  color: rgba(0, 240, 255, 0.35);
}

.pad[data-lane='1'] {
  color: rgba(255, 43, 214, 0.35);
}

.pad[data-on]::after {
  opacity: 1;
  transition: none;
}

/* ── HUD ─────────────────────────────────────────────────────── */

.hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.hudTop {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.track {
  flex: 1;
  min-width: 0;
}

.trackTitle {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 8px var(--cyan);
}

.progress {
  margin-top: 6px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.progressFill {
  height: 100%;
  width: 100%;
  transform-origin: left;
  background: linear-gradient(90deg, var(--cyan), var(--pink));
  box-shadow: 0 0 10px var(--pink);
  animation-name: progress;
  animation-timing-function: linear;
  animation-fill-mode: both;
}

@keyframes progress {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

.scoreBox {
  text-align: right;
}

.score {
  font-size: clamp(22px, 5vw, 38px);
  font-weight: 800;
  font-style: italic;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  text-shadow:
    0 0 12px var(--cyan),
    2px 0 0 rgba(255, 43, 214, 0.8);
}

.mult {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 8px;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  font-size: 15px;
  font-weight: 800;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan);
}

.mult[data-hot] {
  color: var(--gold);
  border-color: var(--gold);
  text-shadow: 0 0 10px var(--red);
}

.pauseButton {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(10, 4, 26, 0.6);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.combo {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: comboPop 160ms ease-out;
}

.comboNumber {
  font-size: clamp(56px, 15vw, 120px);
  font-weight: 900;
  font-style: italic;
  line-height: 0.9;
  background: linear-gradient(180deg, #fff 20%, var(--cyan) 60%, var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(0, 240, 255, 0.7));
}

.combo[data-hot] .comboNumber {
  background: linear-gradient(180deg, #fff 15%, var(--gold) 55%, var(--red));
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 18px rgba(255, 80, 20, 0.9));
}

.comboLabel {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.6em;
  margin-right: -0.6em;
  text-shadow: 0 0 8px var(--pink);
}

@keyframes comboPop {
  from {
    transform: translate(-50%, -50%) scale(1.22);
  }
  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

.judge {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: clamp(28px, 7vw, 52px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.08em;
  animation: judge 520ms cubic-bezier(0.2, 1.6, 0.4, 1) forwards;
}

.judge[data-judgement='perfect'] {
  color: #fff;
  text-shadow:
    -3px 0 0 var(--cyan),
    3px 0 0 var(--pink),
    0 0 24px var(--cyan);
}

.judge[data-judgement='great'] {
  color: #7dffb0;
  text-shadow: 0 0 16px #00ff88;
}

.judge[data-judgement='good'] {
  color: #ffe27a;
  text-shadow: 0 0 14px #ffaa00;
}

.judge[data-judgement='miss'] {
  color: #ff6b7d;
  text-shadow: 0 0 14px #ff0033;
  animation-name: judgeMiss;
}

.timing {
  font-size: 13px;
  font-style: normal;
  letter-spacing: 0.25em;
  color: var(--ink);
  text-shadow: none;
  margin-top: 4px;
}

@keyframes judge {
  0% {
    transform: translate(-50%, -50%) scale(1.8);
    opacity: 0;
  }
  18% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  75% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -62%) scale(0.96);
    opacity: 0;
  }
}

@keyframes judgeMiss {
  0% {
    transform: translate(-50%, -50%) rotate(-6deg);
    opacity: 1;
  }
  20% {
    transform: translate(-46%, -50%) rotate(4deg);
  }
  40% {
    transform: translate(-53%, -50%) rotate(-2deg);
  }
  100% {
    transform: translate(-50%, -30%);
    opacity: 0;
  }
}

.overdrive {
  position: absolute;
  left: 0;
  right: 0;
  top: 16%;
  text-align: center;
  font-size: clamp(36px, 11vw, 96px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow:
    -5px 0 0 var(--red),
    5px 0 0 var(--gold),
    0 0 40px var(--red);
  animation: overdrive 1400ms ease-out forwards;
}

@keyframes overdrive {
  0% {
    transform: scale(3) skewX(-20deg);
    opacity: 0;
    filter: blur(10px);
  }
  15% {
    transform: scale(1) skewX(-12deg);
    opacity: 1;
    filter: blur(0);
  }
  25%,
  35% {
    transform: scale(1.05) skewX(-12deg) translateX(-6px);
  }
  30% {
    transform: scale(1.05) skewX(-12deg) translateX(6px);
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: scale(1.4) skewX(-12deg);
    opacity: 0;
  }
}

.hype {
  position: absolute;
  left: 0;
  right: 0;
  top: 20%;
  text-align: center;
  font-size: clamp(30px, 9vw, 72px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow:
    -4px 0 0 var(--cyan),
    4px 0 0 var(--pink),
    0 0 28px var(--pink);
  animation: hype 1100ms cubic-bezier(0.2, 1.5, 0.4, 1) forwards;
}

@keyframes hype {
  0% {
    transform: rotate(var(--tilt)) scale(0.2);
    opacity: 0;
  }
  18% {
    transform: rotate(var(--tilt)) scale(1.1);
    opacity: 1;
  }
  30% {
    transform: rotate(var(--tilt)) scale(1);
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: rotate(var(--tilt)) scale(1.25) translateY(-20px);
    opacity: 0;
  }
}

.overdriveFrame {
  position: absolute;
  inset: 0;
  box-shadow:
    inset 0 0 60px rgba(255, 60, 20, 0.55),
    inset 0 0 6px rgba(255, 212, 0, 0.9);
  animation: frameIn 300ms ease-out;
}

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

.count {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  font-size: clamp(80px, 26vw, 200px);
  font-weight: 900;
  font-style: italic;
  color: #fff;
  text-shadow:
    -6px 0 0 var(--cyan),
    6px 0 0 var(--pink),
    0 0 50px var(--pink);
  animation: count 700ms ease-out forwards;
}

@keyframes count {
  from {
    transform: translate(-50%, -50%) scale(2.2);
    opacity: 0;
  }
  30% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(-50%, -50%) scale(0.85);
    opacity: 0;
  }
}

/* ── Panels: title, pause, results ───────────────────────────── */

.headphones {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  background: radial-gradient(ellipse at 50% 45%, rgba(4, 1, 11, 0.35), rgba(4, 1, 11, 0.92) 70%);
  animation: panelIn 380ms ease-out;
}

.headphonesIcon {
  width: clamp(96px, 28vw, 160px);
  color: var(--cyan);
  filter: drop-shadow(0 0 18px rgba(0, 240, 255, 0.7));
  animation: thump 0.65s ease-in-out infinite;
}

.headphonesTitle {
  font-size: clamp(30px, 9vw, 72px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow:
    -4px 0 0 var(--cyan),
    4px 0 0 var(--pink),
    0 0 30px var(--pink);
}

.headphonesHint {
  font-size: 15px;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
  text-transform: uppercase;
  animation: blink 1.2s steps(2) infinite;
}

@keyframes thump {
  50% {
    transform: scale(1.1);
  }
}

.panel {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow-y: auto;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: max(28px, env(safe-area-inset-top)) 16px
    max(28px, env(safe-area-inset-bottom));
  background: radial-gradient(
    ellipse at 50% 35%,
    rgba(4, 1, 11, 0.2),
    rgba(4, 1, 11, 0.85) 70%
  );
  animation: panelIn 380ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: scale(1.06);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

.back {
  align-self: flex-start;
  color: var(--ink-soft);
  font-size: 14px;
  text-decoration: none;
  padding: 8px 0;
}

.logo {
  position: relative;
  margin: 8px 0 0;
  font-size: clamp(44px, 13vw, 120px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.06em;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 20px rgba(0, 240, 255, 0.8),
    0 0 60px rgba(255, 43, 214, 0.6);
}

.logo::before,
.logo::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
}

.logo::before {
  color: var(--cyan);
  animation: glitchA 2.6s infinite steps(1);
}

.logo::after {
  color: var(--pink);
  animation: glitchB 2.6s infinite steps(1);
}

@keyframes glitchA {
  0%,
  86%,
  100% {
    transform: translate(-2px, 0);
    clip-path: inset(0 0 0 0);
  }
  88% {
    transform: translate(-8px, 2px);
    clip-path: inset(10% 0 55% 0);
  }
  92% {
    transform: translate(6px, -2px);
    clip-path: inset(60% 0 8% 0);
  }
}

@keyframes glitchB {
  0%,
  86%,
  100% {
    transform: translate(2px, 0);
    clip-path: inset(0 0 0 0);
  }
  89% {
    transform: translate(9px, -1px);
    clip-path: inset(40% 0 30% 0);
  }
  93% {
    transform: translate(-5px, 3px);
    clip-path: inset(5% 0 75% 0);
  }
}

.tagline {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.45em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.songCard {
  width: min(100%, 420px);
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid rgba(0, 240, 255, 0.45);
  box-shadow:
    0 0 24px rgba(0, 240, 255, 0.25),
    inset 0 0 18px rgba(255, 43, 214, 0.15);
  text-align: center;
}

.songTitle {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.songArtist {
  margin-top: 4px;
  font-size: 14px;
  color: var(--ink-soft);
}

.play {
  width: min(100%, 420px);
  padding: 18px 0;
  border: none;
  border-radius: 14px;
  background: linear-gradient(100deg, var(--cyan), var(--pink));
  color: #0a0216;
  font: inherit;
  font-size: 24px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.3em;
  cursor: pointer;
  box-shadow:
    0 0 30px rgba(255, 43, 214, 0.55),
    0 0 60px rgba(0, 240, 255, 0.3);
  animation: playPulse 1.3s ease-in-out infinite;
}

.play:active {
  transform: scale(0.97);
}

@keyframes playPulse {
  50% {
    box-shadow:
      0 0 44px rgba(255, 43, 214, 0.85),
      0 0 90px rgba(0, 240, 255, 0.45);
  }
}

.secondary {
  width: min(100%, 420px);
  padding: 14px 0;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(10, 4, 26, 0.7);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.25em;
  cursor: pointer;
}

.secondary:active {
  transform: scale(0.97);
}

.hint {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
}

.hint kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 5px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 4px;
  color: var(--ink);
  font: inherit;
}

.offset {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.offset button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(10, 4, 26, 0.7);
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}

.offset output {
  min-width: 72px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.offsetHint {
  margin: -8px 0 0;
  max-width: 420px;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
}

.error {
  margin: 0;
  max-width: 420px;
  color: #ff8a9a;
  font-size: 14px;
  text-align: center;
}

.loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: rgba(4, 1, 11, 0.55);
  animation: panelIn 300ms ease-out;
}

.spinner {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--cyan);
  border-right-color: var(--pink);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.5);
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loadingText {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.4em;
  text-shadow: 0 0 10px var(--cyan);
  animation: blink 0.9s steps(2) infinite;
}

@keyframes blink {
  50% {
    opacity: 0.55;
  }
}

.pausedTitle {
  margin: 22vh 0 12px;
  font-size: 48px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.2em;
  text-shadow: 0 0 20px var(--pink);
}

/* ── Results ─────────────────────────────────────────────────── */

.grade {
  margin-top: 4vh;
  font-size: clamp(110px, 32vw, 220px);
  font-weight: 900;
  font-style: italic;
  line-height: 0.95;
  color: #fff;
  animation: slam 700ms cubic-bezier(0.2, 1.4, 0.3, 1);
}

.grade[data-grade='SSS'],
.grade[data-grade='SS'],
.grade[data-grade='S'] {
  text-shadow:
    -6px 0 0 var(--gold),
    6px 0 0 var(--red),
    0 0 60px var(--gold);
}

.grade[data-grade='A'] {
  text-shadow:
    -5px 0 0 var(--cyan),
    5px 0 0 var(--pink),
    0 0 50px var(--cyan);
}

.grade[data-grade='B'],
.grade[data-grade='C'],
.grade[data-grade='D'] {
  text-shadow:
    -4px 0 0 #7d6bff,
    4px 0 0 var(--pink),
    0 0 40px #7d6bff;
}

@keyframes slam {
  0% {
    transform: scale(4) rotate(-12deg);
    opacity: 0;
    filter: blur(12px);
  }
  60% {
    transform: scale(0.92) rotate(0);
    opacity: 1;
    filter: none;
  }
  100% {
    transform: scale(1);
  }
}

.newBest {
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--red));
  color: #1a0500;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.2em;
  animation:
    panelIn 400ms 500ms both,
    playPulse 1.2s ease-in-out infinite;
}

.finalScore {
  font-size: clamp(36px, 10vw, 64px);
  font-weight: 900;
  font-style: italic;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px var(--cyan);
}

.statsGrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: min(100%, 420px);
}

.stat {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.statValue {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.statLabel {
  font-size: 13px;
  color: var(--ink-soft);
}

.stat[data-tone='perfect'] .statValue {
  color: var(--cyan);
}

.stat[data-tone='great'] .statValue {
  color: #7dffb0;
}

.stat[data-tone='good'] .statValue {
  color: #ffe27a;
}

.stat[data-tone='miss'] .statValue {
  color: #ff8a9a;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 420px);
}

/* ── Score board ─────────────────────────────────────────────── */

.board {
  width: min(100%, 420px);
  min-height: 120px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid rgba(255, 43, 214, 0.4);
  box-shadow: 0 0 24px rgba(255, 43, 214, 0.18);
}

.board[data-loading] {
  animation: blink 1.2s ease-in-out infinite;
}

.boardTitle {
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3em;
  color: var(--pink);
  text-shadow: 0 0 8px var(--pink);
}

.boardEmpty {
  font-size: 14px;
  color: var(--ink-soft);
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.row {
  display: grid;
  grid-template-columns: 40px 1fr 44px auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 14px;
  animation: panelIn 300ms ease-out both;
}

.row[data-mine] {
  background: rgba(0, 240, 255, 0.16);
  box-shadow: inset 0 0 0 1px var(--cyan);
}

.rank {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rowGrade {
  font-weight: 900;
  font-style: italic;
  color: var(--gold);
  text-align: center;
}

.rowScore {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

@media (prefers-reduced-motion: reduce) {
  .logo::before,
  .logo::after,
  .play,
  .newBest {
    animation: none;
  }
}
