:root {
  --bg: #050814;
  --bg-2: #0a0e1a;
  --card: #161925;
  --text: #e8eef8;
  --muted: #8b95a8;
  --cyan: #22d3ee;
  --teal: #2dd4bf;
  --rose: #fb7185;
  --amber: #fbbf24;
  --line: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font-d: "Orbitron", sans-serif;
  --font-b: "Sora", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-b);
  font-size: 15px;
  line-height: 1.55;
  user-select: none;
  touch-action: none;
}

img { -webkit-user-drag: none; }

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

#vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 38%, transparent 42%, rgba(5, 8, 20, 0.58) 100%),
    linear-gradient(180deg, rgba(5, 8, 20, 0.22) 0%, transparent 20%, transparent 70%, rgba(5, 8, 20, 0.42) 100%);
}

#fx-layer {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
}

.hidden { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  pointer-events: auto;
}

#screen-title {
  justify-content: flex-start;
  padding-top: 36px;
  padding-bottom: 28px;
  background: linear-gradient(180deg, rgba(5, 8, 20, 0.22) 0%, rgba(5, 8, 20, 0.06) 38%, rgba(5, 8, 20, 0.5) 100%);
}

#screen-loading,
#screen-error,
#screen-howto,
#screen-hangar,
#screen-ai-brief,
#screen-shop,
#screen-pause,
#screen-stage,
#screen-win,
#screen-gameover {
  background: rgba(6, 8, 18, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.kicker {
  margin: 0 0 8px;
  font-family: var(--font-d);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--teal);
}

.kicker.danger { color: var(--rose); }
.kicker.success { color: var(--teal); }

.display-md {
  margin: 0 0 12px;
  font-family: var(--font-d);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}

.body-copy {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.muted { color: var(--muted); }

.load-mark {
  position: relative;
  width: 88px;
  height: 88px;
  margin-bottom: 24px;
}

.load-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(34, 211, 238, 0.18);
  border-top-color: var(--cyan);
  animation: spin 0.9s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.load-core {
  position: absolute;
  inset: 26px;
  border-radius: 50%;
  background: radial-gradient(circle, #e8fbff 0%, var(--cyan) 42%, #0891b2 100%);
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.7);
  animation: pulse 1.4s var(--ease-out) infinite;
}

.load-title {
  margin: 8px 0 20px;
  font-family: var(--font-d);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--text);
}

.load-bar {
  width: min(280px, 72vw);
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 12px;
}

#load-fill {
  display: block;
  height: 100%;
  width: 8%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--cyan), var(--teal));
  transition: width 0.35s var(--ease-out);
}

.title-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  border-radius: 99px;
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.3);
  color: #67e8f9;
  font-family: var(--font-d);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  margin-bottom: 12px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22d3ee;
  box-shadow: 0 0 8px #22d3ee;
  animation: pulse-quick 1s infinite alternate;
}

@keyframes pulse-quick {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(1.3); opacity: 1; }
}

.wordmark {
  margin: 0 0 10px;
  text-align: center;
}

.wm-line {
  display: block;
  font-family: var(--font-d);
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 0.94;
  font-size: clamp(40px, 12vw, 64px);
  color: var(--text);
}

#wm-neon {
  letter-spacing: 10px;
  color: var(--text);
  text-shadow: 0 0 8px rgba(34, 211, 238, 0.75), 0 0 20px rgba(0, 240, 255, 0.45), 0 0 42px rgba(0, 240, 255, 0.28);
  filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.4));
}

.wm-line.accent {
  background: linear-gradient(90deg, var(--cyan), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(34, 211, 238, 0.35));
}

.wm-line span {
  display: inline-block;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

.title-top {
  text-align: center;
  margin-bottom: 16px;
}

.title-stats {
  display: flex;
  gap: 8px;
  width: min(420px, 100%);
  margin-top: auto;
  margin-bottom: 20px;
}

.stat-chip {
  flex: 1;
  min-width: 0;
  padding: 10px 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid #4df0ff44;
  color: var(--text);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.stat-label {
  display: block;
  font-family: var(--font-d);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-family: var(--font-d);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.title-row {
  display: flex;
  gap: 8px;
}

.title-row .btn { flex: 1; }

.panel {
  width: min(400px, 100%);
  padding: 24px;
  border-radius: 16px;
  background: rgba(16, 18, 28, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.panel-lg { width: min(440px, 100%); }

.sheet { max-height: min(86vh, 720px); overflow: auto; }

.stack { display: flex; flex-direction: column; gap: 8px; }

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-d);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: var(--radius);
  min-height: 48px;
  padding: 12px 16px;
  color: var(--text);
  background: #1c2030;
  transition: transform 0.12s ease-out, filter 0.2s var(--ease-out), background 0.2s;
}

.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn-primary {
  background: linear-gradient(90deg, #2dd4bf, #22d3ee 55%, #67e8f9);
  color: #042028;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0, 240, 255, 0.38), 0 0 18px rgba(34, 211, 238, 0.35);
  font-weight: 800;
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-primary:active {
  background: linear-gradient(90deg, #0f766e, #0e7490);
  color: #d7fdff;
  box-shadow: 0 2px 10px rgba(0, 180, 200, 0.2);
  filter: brightness(0.85);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(77, 240, 255, 0.25);
  color: var(--text);
  border-radius: 14px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(77, 240, 255, 0.5);
}

.btn-icon {
  flex-shrink: 0;
}

.btn-ai-glow {
  border-color: rgba(34, 211, 238, 0.45);
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.12), rgba(167, 139, 250, 0.12));
}

.glow-pulse {
  animation: btn-glow 2s infinite alternate;
}

@keyframes btn-glow {
  0% { box-shadow: 0 8px 24px rgba(0, 240, 255, 0.25); }
  100% { box-shadow: 0 8px 32px rgba(0, 240, 255, 0.6), 0 0 20px rgba(45, 212, 191, 0.4); }
}

.section-title {
  font-family: var(--font-d);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #67e8f9;
  margin: 12px 0 6px;
}

.btn-xl { min-height: 56px; font-size: 14px; }

.manual {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.manual li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.manual-ico {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.18);
}

.manual strong {
  display: block;
  font-family: var(--font-d);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--text);
}

.manual p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.trail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 12px;
}

.trail-card {
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #121522;
  color: var(--text);
  min-height: 76px;
  font-family: var(--font-b);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.trail-card:hover {
  background: #191e30;
  border-color: rgba(34, 211, 238, 0.35);
}

.trail-card .swatch {
  width: 100%;
  height: 8px;
  border-radius: 99px;
  margin-bottom: 10px;
}

.trail-card strong {
  display: block;
  font-family: var(--font-d);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.trail-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.trail-card.on {
  border-color: #22d3ee;
  background: rgba(34, 211, 238, 0.12);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.25);
}

.trail-card.locked {
  opacity: 0.45;
  filter: grayscale(0.4);
}

/* AI co-pilot UI styles */
.ai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.ai-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.3);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.ai-pulse {
  position: absolute;
  inset: -3px;
  border-radius: 14px;
  border: 1px solid #22d3ee;
  animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
  opacity: 0.6;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(1.2); opacity: 0; }
}

.ai-card {
  padding: 14px;
  border-radius: 14px;
  background: rgba(10, 15, 28, 0.85);
  border: 1px solid rgba(34, 211, 238, 0.2);
  min-height: 110px;
}

.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #67e8f9;
  font-size: 13px;
}

.load-ring-sm {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(34, 211, 238, 0.2);
  border-top-color: #22d3ee;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.ai-text {
  font-size: 13px;
  line-height: 1.6;
  color: #cbd5e1;
}

/* Shop & Coin styles */
.shop-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.3);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.coin-balance-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.coin-num {
  color: #fbbf24;
  font-family: var(--font-d);
  font-size: 15px;
}

.shop-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}

.shop-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.shop-info strong {
  display: block;
  font-family: var(--font-d);
  font-size: 12px;
  color: var(--text);
}

.shop-info small {
  color: var(--muted);
  font-size: 11px;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 11px;
}

/* HUD enhancements */
.hud-progress-bar {
  position: absolute;
  top: 68px;
  left: 16px;
  right: 16px;
  pointer-events: none;
}

.track-line {
  position: relative;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  overflow: visible;
}

.track-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22d3ee, #fb7185);
  border-radius: 99px;
}

.track-dot {
  position: absolute;
  top: -4px;
  left: 0%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px #22d3ee;
  transform: translateX(-50%);
}

.track-end {
  position: absolute;
  right: 0;
  top: -8px;
  font-size: 10px;
  color: #67e8f9;
}

.shield-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shield-label {
  font-family: var(--font-d);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.status-flags {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.copilot-toast {
  margin-top: 6px;
  padding: 4px 12px;
  border-radius: 99px;
  background: rgba(10, 15, 28, 0.85);
  border: 1px solid rgba(34, 211, 238, 0.35);
  backdrop-filter: blur(12px);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: fadeIn 0.25s ease-out;
}

.ai-tag {
  font-family: var(--font-d);
  color: #22d3ee;
  font-weight: 700;
  font-size: 9px;
}

.ai-feedback-box {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.2);
  margin-bottom: 12px;
}

.ai-sm-badge {
  font-family: var(--font-d);
  font-size: 9px;
  font-weight: 700;
  color: #22d3ee;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

.text-cyan { color: #22d3ee; }
.text-amber { color: #fbbf24; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 18px;
}

.unlock-line {
  margin: 0 0 16px;
  color: var(--amber);
  font-size: 13px;
  font-weight: 600;
}

#hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

#hud .icon-btn,
#hud .ctrl-btn,
#hud .jump-btn { pointer-events: auto; }

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 12px 0;
  gap: 8px;
}

.hud-cluster {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  max-width: 38vw;
}

.hud-center {
  max-width: none;
  flex: 0 0 auto;
}

.hud-chip {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(12, 14, 24, 0.62);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  min-width: 0;
}

.hud-chip .stat-value { font-size: 15px; }
.hud-chip .stat-label { font-size: 9px; }

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(12, 14, 24, 0.62);
  backdrop-filter: blur(16px);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:active { transform: scale(0.96); }
.icon-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.timer-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  color: var(--text);
}

.timer-ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer-bg { fill: none; stroke: rgba(255, 255, 255, 0.08); stroke-width: 3; }
.timer-fg {
  fill: none;
  stroke: url(#none);
  stroke: var(--cyan);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 125.6;
  stroke-dashoffset: 0;
  transition: stroke 0.2s;
}

.timer-wrap.low .timer-fg { stroke: var(--rose); }

#hud-time {
  font-family: var(--font-d);
  font-size: 13px;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.hud-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  pointer-events: none;
}

.shields { display: flex; gap: 6px; }

.pip {
  width: 18px;
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.pip.on {
  background: linear-gradient(90deg, var(--cyan), var(--teal));
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.45);
}

.combo-flag,
.boost-flag {
  font-family: var(--font-d);
  font-size: 11px;
  letter-spacing: 0.14em;
  padding: 4px 10px;
  border-radius: 99px;
  color: #1a1203;
  background: var(--amber);
}

.boost-flag {
  color: #042024;
  background: var(--cyan);
}

.announce {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-d);
  font-weight: 800;
  font-size: clamp(42px, 14vw, 72px);
  letter-spacing: 0.08em;
  color: var(--text);
  text-shadow: 0 0 28px rgba(34, 211, 238, 0.45);
  pointer-events: none;
  white-space: nowrap;
}

.hud-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 16px;
  pointer-events: none;
}

.steer-cluster {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.ctrl-btn,
.jump-btn {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(12, 14, 24, 0.62);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: var(--font-d);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ctrl-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
}

.jump-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  pointer-events: auto;
  color: #042024;
  background: linear-gradient(180deg, #67e8f9, #2dd4bf);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 28px rgba(45, 212, 191, 0.28);
}

.ctrl-btn.is-down,
.jump-btn.is-down { transform: scale(0.94); filter: brightness(1.1); }

.ctrl-btn:focus-visible,
.jump-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.floater {
  position: absolute;
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 16px;
  color: var(--amber);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.floater.boost { color: var(--cyan); }
.floater.hurt { color: var(--rose); }

@media (max-width: 430px) {
  .hud-cluster.hud-left,
  .hud-cluster.hud-right { max-width: 36vw; }
  .hud-chip { padding: 6px 8px; }
  .hud-chip .stat-value { font-size: 13px; }
  .result-grid { grid-template-columns: 1fr; }
}

@media (min-width: 900px) {
  .display-md { font-size: 34px; }
  .wm-line { font-size: 72px; }
  .hud-bottom { padding: 0 48px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .load-ring, .load-core { animation: none; }
  .btn { transition: none; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.86); opacity: 0.75; }
}