/* SUPERNOVA — Sovereign dark UI (SPEC §6). No external fonts or assets. */

:root {
  --bg: #020203;
  --ink: #eaf6ff;
  --muted: #7f93ad;
  --cyan: #22d3ee;
  --cyan-soft: #7cf9ff;
  --violet: #a855f7;
  --amber: #fde68a;
  --danger: #ff3b5c;

  --glass: rgba(9, 13, 24, 0.6);
  --glass-strong: rgba(7, 10, 19, 0.82);
  --stroke: rgba(124, 249, 255, 0.16);
  --stroke-soft: rgba(124, 249, 255, 0.08);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

body {
  position: fixed;
  inset: 0;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

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

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

#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  padding: calc(var(--safe-top) + 10px) calc(var(--safe-right) + 14px)
    calc(var(--safe-bottom) + 14px) calc(var(--safe-left) + 14px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.hud-stats {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  min-width: 0;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  text-shadow: 0 0 18px rgba(34, 211, 238, 0.35);
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.stat-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: clamp(26px, 8.5vw, 42px);
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}

.stat-best .stat-value {
  font-size: clamp(14px, 4.4vw, 20px);
  color: var(--cyan-soft);
  font-weight: 700;
}

.hud-controls {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.icon-btn {
  pointer-events: auto;
  width: 46px;
  height: 46px;
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(30, 44, 72, 0.72), rgba(9, 13, 24, 0.72));
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition: transform 0.09s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  -webkit-appearance: none;
  appearance: none;
}

.icon-btn:active {
  transform: scale(0.93);
  border-color: rgba(124, 249, 255, 0.5);
  box-shadow: 0 0 22px rgba(34, 211, 238, 0.4);
}

.icon-pause {
  width: 14px;
  height: 16px;
  border-left: 4px solid currentColor;
  border-right: 4px solid currentColor;
}

.icon-speaker {
  position: relative;
  width: 10px;
  height: 12px;
  background: currentColor;
  clip-path: polygon(0 35%, 45% 35%, 100% 0, 100% 100%, 45% 65%, 0 65%);
}

.icon-speaker::after {
  content: "";
  position: absolute;
  left: 11px;
  top: -3px;
  width: 9px;
  height: 18px;
  border: 2px solid currentColor;
  border-left: 0;
  border-radius: 0 12px 12px 0;
  opacity: 0.85;
}

#btn-mute.is-muted {
  color: var(--muted);
}

#btn-mute.is-muted .icon-speaker::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 8px;
  width: 22px;
  height: 2px;
  background: var(--danger);
  transform: rotate(-45deg);
  box-shadow: 0 0 8px var(--danger);
}

#btn-mute.is-muted .icon-speaker::after {
  opacity: 0;
}

.hud-sub {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.next-orb {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke-soft);
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--cyan-soft);
  max-width: 100%;
  transition: color 0.2s ease;
}

.next-label {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.next-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cyan-soft);
  box-shadow: 0 0 12px currentColor;
  flex: 0 0 auto;
}

.next-name {
  color: var(--ink);
}

.combo-badge {
  position: absolute;
  top: calc(var(--safe-top) + 96px);
  left: 50%;
  transform: translateX(-50%) scale(0.6);
  padding: 4px 16px;
  border-radius: 999px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.9), rgba(168, 85, 247, 0.9));
  box-shadow: 0 0 28px rgba(34, 211, 238, 0.6), 0 0 60px rgba(168, 85, 247, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.combo-badge.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.combo-badge.pop {
  animation: combo-pop 0.36s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes combo-pop {
  0% {
    transform: translateX(-50%) scale(0.55);
    filter: brightness(1.6);
  }
  60% {
    transform: translateX(-50%) scale(1.18);
  }
  100% {
    transform: translateX(-50%) scale(1);
  }
}

/* ------------------------------------------------------------ overlays ---- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + 16px)
    calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 16px);
  background: radial-gradient(
    120% 90% at 50% 20%,
    rgba(12, 20, 40, 0.55),
    rgba(2, 2, 3, 0.86)
  );
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.26s ease, visibility 0.26s ease;
  overflow: hidden;
}

.overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.panel {
  width: min(92vw, 380px);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 26px 22px;
  border-radius: 26px;
  border: 1px solid var(--stroke);
  background: linear-gradient(
    180deg,
    rgba(18, 28, 50, 0.72),
    rgba(6, 9, 17, 0.9)
  );
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 0 70px rgba(34, 211, 238, 0.08);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  text-align: center;
  animation: panel-in 0.34s cubic-bezier(0.2, 1.2, 0.35, 1);
}

@keyframes panel-in {
  from {
    transform: translateY(10px) scale(0.97);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.logo {
  font-size: clamp(30px, 11vw, 46px);
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 1;
  white-space: nowrap;
}

.logo-super {
  color: var(--ink);
  text-shadow: 0 0 26px rgba(34, 211, 238, 0.55);
}

.logo-nova {
  color: var(--cyan-soft);
  text-shadow: 0 0 30px rgba(34, 211, 238, 0.9), 0 0 70px rgba(168, 85, 247, 0.5);
}

.tagline {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.panel-title {
  margin: 0 0 2px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(34, 211, 238, 0.4);
}

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------- buttons --- */

.btn {
  pointer-events: auto;
  width: 100%;
  min-height: 52px;
  padding: 14px 22px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #04121a;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: transform 0.09s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

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

.btn-primary {
  background: linear-gradient(135deg, #7cf9ff 0%, #22d3ee 45%, #a855f7 100%);
  box-shadow: 0 10px 30px rgba(34, 211, 238, 0.35),
    0 0 40px rgba(168, 85, 247, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.btn-primary:active {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(34, 211, 238, 0.5), 0 0 60px rgba(34, 211, 238, 0.4);
}

.btn-ghost {
  background: rgba(124, 249, 255, 0.06);
  border-color: var(--stroke);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.btn-ghost:active {
  border-color: rgba(124, 249, 255, 0.5);
  box-shadow: 0 0 22px rgba(34, 211, 238, 0.28);
}

/* ---------------------------------------------------------- game over ---- */

.final-row {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--stroke-soft);
}

.final-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.final-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: 30px;
  font-weight: 900;
  color: var(--ink);
}

.final-row-best .final-value {
  color: var(--cyan-soft);
}

.record {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--amber);
  text-shadow: 0 0 20px rgba(253, 230, 138, 0.7);
  animation: record-glow 1.2s ease-in-out infinite alternate;
}

@keyframes record-glow {
  from {
    opacity: 0.7;
  }
  to {
    opacity: 1;
  }
}

/* -------------------------------------------------- supernova banner ----- */

.supernova-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: radial-gradient(
    60% 40% at 50% 50%,
    rgba(255, 255, 255, 0.14),
    rgba(2, 2, 3, 0) 70%
  );
  pointer-events: none;
}

.supernova-banner.is-visible {
  pointer-events: none;
}

.sn-text {
  font-size: clamp(34px, 13vw, 68px);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 0 30px #fff, 0 0 70px var(--cyan), 0 0 130px var(--violet);
}

.sn-sub {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.42em;
  color: var(--amber);
  text-shadow: 0 0 20px rgba(253, 230, 138, 0.8);
}

.supernova-banner.is-visible .sn-text {
  animation: sn-text 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

.supernova-banner.is-visible .sn-sub {
  animation: sn-sub 0.9s 0.08s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes sn-text {
  0% {
    transform: scale(0.5);
    opacity: 0;
    filter: blur(8px);
  }
  45% {
    transform: scale(1.08);
    opacity: 1;
    filter: blur(0);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes sn-sub {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* ------------------------------------------------------- rotate hint ----- */

.rotate-hint {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(2, 2, 3, 0.94);
  color: var(--ink);
  text-align: center;
  padding: 24px;
}

.rotate-hint[hidden] {
  display: none;
}

.rotate-hint p {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.rotate-icon {
  width: 46px;
  height: 72px;
  border: 3px solid var(--cyan);
  border-radius: 10px;
  box-shadow: 0 0 30px rgba(34, 211, 238, 0.5);
  animation: rotate-nudge 1.8s ease-in-out infinite;
}

@keyframes rotate-nudge {
  0%,
  60%,
  100% {
    transform: rotate(0deg);
  }
  80% {
    transform: rotate(-90deg);
  }
}

/* ----------------------------------------------------------- a11y -------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-height: 560px) {
  .panel {
    gap: 10px;
    padding: 18px 18px;
  }
  .tagline,
  .hint {
    display: none;
  }
}
