:root {
  --bg-void: #040711;
  --bg-deep: #091024;
  --bg-panel: rgba(8, 14, 32, 0.9);
  --bg-card: rgba(12, 20, 44, 0.95);
  --border-cyan: rgba(0, 245, 255, 0.28);
  --border-strong: rgba(0, 245, 255, 0.65);
  --border-pink: rgba(255, 46, 151, 0.45);
  --text-main: #f0f6ff;
  --text-muted: #8ea3c9;
  --cyan: #00f5ff;
  --pink: #ff2e97;
  --amber: #ffb800;
  --mint: #22ffaa;
  --danger: #ff3b6b;
  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, Menlo, monospace;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #0d193a 0%, #040711 75%);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  touch-action: manipulation;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

#app-shell {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ================= TOP TELEMETRY BAR ================= */
.top-bar {
  flex-shrink: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(6, 10, 24, 0.94);
  border-bottom: 1px solid var(--border-cyan);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.55);
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-icon {
  flex-shrink: 0;
  border-radius: 6px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.1;
  white-space: nowrap;
}

.title-accent {
  color: var(--pink);
}

.brand-tag {
  font-size: 0.65rem;
  color: var(--cyan);
  letter-spacing: 0.08em;
}

.hud-telemetry {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tele-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 9px;
  background: rgba(11, 18, 38, 0.9);
  border: 1px solid rgba(0, 245, 255, 0.22);
  border-radius: 7px;
  min-width: 64px;
}

.tele-score {
  min-width: 96px;
}

.tele-mult.is-overdrive {
  border-color: var(--pink);
  background: rgba(56, 12, 39, 0.78);
  box-shadow: 0 0 14px rgba(255, 46, 151, 0.35);
}

.tele-mult.is-overdrive .tele-v {
  color: var(--pink);
}

.tele-k {
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.tele-v {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.shield-pips {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.shield-pip {
  width: 11px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0, 245, 255, 0.4);
  background: rgba(255, 255, 255, 0.06);
}

.shield-pip.is-full {
  background: var(--mint);
  border-color: #a8ffe0;
  box-shadow: 0 0 8px rgba(34, 255, 170, 0.6);
}

.tele-parry {
  min-width: 82px;
}

.parry-meter {
  width: 100%;
  height: 8px;
  margin-top: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 46, 151, 0.3);
}

.parry-meter-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--pink), #ff8ad0);
  transition: width 0.08s linear;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hdr-btn,
.hdr-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--border-cyan);
  background: rgba(13, 22, 46, 0.9);
  color: var(--text-main);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.hdr-btn:hover,
.hdr-link:hover {
  border-color: var(--cyan);
  background: rgba(0, 245, 255, 0.12);
}

.hdr-btn.is-active {
  border-color: var(--mint);
  color: var(--mint);
  background: rgba(34, 255, 170, 0.12);
}

.hdr-link {
  color: var(--text-muted);
}

.hdr-link-accent {
  border-color: var(--border-pink);
  color: #ffc2e2;
  background: rgba(255, 46, 151, 0.12);
}

.hdr-link-accent:hover {
  border-color: var(--pink);
  color: #ffffff;
  background: rgba(255, 46, 151, 0.25);
}

/* ================= ARENA & CANVAS ================= */
#arena-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

#canvas-wrap {
  position: absolute;
  inset: 0;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.active-upgrades {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
}

.upg-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 5px;
  background: rgba(7, 13, 30, 0.86);
  border: 1px solid rgba(34, 255, 170, 0.45);
  color: var(--mint);
  backdrop-filter: blur(6px);
}

.boss-hud {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 28px));
  z-index: 9;
  pointer-events: none;
  background: rgba(12, 8, 24, 0.88);
  border: 1px solid var(--border-pink);
  border-radius: 8px;
  padding: 7px 11px;
  box-shadow: 0 8px 28px rgba(255, 46, 151, 0.22);
}

.boss-hud-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  margin-bottom: 5px;
}

.boss-tag {
  color: var(--pink);
  font-weight: 800;
}

.boss-name {
  font-weight: 700;
  color: var(--text-main);
}

.boss-phase {
  color: var(--amber);
  font-weight: 700;
}

.boss-bar-track {
  width: 100%;
  height: 9px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid rgba(255, 46, 151, 0.35);
}

.boss-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff2e97, #ff8533);
  transition: width 0.06s linear;
}

.sector-banner {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 22px;
  border-radius: 8px;
  background: rgba(6, 11, 26, 0.84);
  border: 1px solid var(--border-strong);
  box-shadow: 0 0 32px rgba(0, 245, 255, 0.25);
}

.banner-sub {
  font-size: 0.74rem;
  color: var(--pink);
  letter-spacing: 0.16em;
  font-weight: 700;
}

.banner-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

/* ================= OVERLAY SCREENS ================= */
.overlay-screen {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(3, 6, 16, 0.72);
  backdrop-filter: blur(6px);
  overflow-y: auto;
}

.overlay-card {
  width: min(680px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 24px 26px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.75), 0 0 40px rgba(0, 245, 255, 0.12);
}

.compact-card {
  width: min(420px, 100%);
  text-align: center;
}

.upgrade-card {
  width: min(820px, 100%);
}

.eyebrow-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.chip-cyan {
  color: var(--cyan);
  background: rgba(0, 245, 255, 0.12);
  border-color: rgba(0, 245, 255, 0.36);
}

.chip-pink {
  color: #ff7bc0;
  background: rgba(255, 46, 151, 0.14);
  border-color: rgba(255, 46, 151, 0.42);
}

.chip-mint {
  color: var(--mint);
  background: rgba(34, 255, 170, 0.12);
  border-color: rgba(34, 255, 170, 0.38);
}

.hero-title {
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 4vw, 2.45rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.05;
}

.hero-copy {
  margin: 0 0 18px;
  color: #c5d4f0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-heading {
  margin: 4px 0 6px;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.modal-sub {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.title-stats,
.debrief-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.debrief-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-pill,
.debrief-cell {
  background: rgba(7, 13, 30, 0.88);
  border: 1px solid rgba(0, 245, 255, 0.22);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-k {
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.stat-v {
  font-size: 0.95rem;
  font-weight: 800;
}

.accent-pink {
  color: #ff6cb8;
}

.accent-cyan {
  color: var(--cyan);
}

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

.mech-item {
  background: rgba(9, 16, 36, 0.85);
  border: 1px solid rgba(0, 245, 255, 0.24);
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mech-item.mech-pink {
  border-color: rgba(255, 46, 151, 0.45);
  background: rgba(42, 11, 32, 0.45);
}

.mech-key {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--cyan);
}

.mech-item.mech-pink .mech-key {
  color: #ff76bd;
}

.mech-desc {
  font-size: 0.78rem;
  color: #c8d7f2;
}

.title-cta-row,
.pause-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.btn-primary,
.btn-secondary {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #00e5ff, #0099ff);
  color: #031020;
  box-shadow: 0 0 22px rgba(0, 229, 255, 0.38);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 28px rgba(0, 245, 255, 0.55);
}

.btn-secondary {
  background: rgba(15, 26, 56, 0.95);
  border-color: var(--border-cyan);
  color: var(--text-main);
}

.btn-secondary:hover {
  border-color: var(--cyan);
  background: rgba(0, 245, 255, 0.12);
}

/* ================= ROGUE-LITE UPGRADE CARDS ================= */
.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.upg-choice-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 8px;
  padding: 14px;
  border-radius: 10px;
  background: rgba(8, 15, 34, 0.94);
  border: 1px solid var(--border-cyan);
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.upg-choice-card:hover,
.upg-choice-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--mint);
  box-shadow: 0 10px 26px rgba(34, 255, 170, 0.22);
  outline: none;
}

.upg-choice-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
}

.upg-choice-key {
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(0, 245, 255, 0.14);
  color: var(--cyan);
  font-weight: 800;
}

.upg-choice-lvl {
  color: var(--mint);
  font-weight: 700;
}

.upg-choice-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.upg-choice-desc {
  margin: 0;
  font-size: 0.82rem;
  color: #bed0ee;
  line-height: 1.42;
}

.debrief-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.rank-unlocked {
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid rgba(255, 184, 0, 0.45);
  background: rgba(255, 184, 0, 0.1);
  color: var(--amber);
}

/* ================= DESKTOP & MOBILE CONTROLS ================= */
.desktop-controls-bar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(6, 11, 26, 0.8);
  border: 1px solid rgba(0, 245, 255, 0.2);
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
}

.desktop-controls-bar kbd {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 245, 255, 0.14);
  border: 1px solid rgba(0, 245, 255, 0.35);
  color: var(--cyan);
  font-family: inherit;
  font-weight: 700;
}

.touch-dock {
  display: none;
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  z-index: 12;
  gap: 8px;
  align-items: stretch;
}

.touch-btn {
  border-radius: 10px;
  border: 1px solid var(--border-cyan);
  background: rgba(8, 15, 34, 0.88);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.82rem;
  padding: 12px 10px;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(6px);
}

.touch-btn:active {
  transform: scale(0.96);
}

.touch-move {
  flex: 1;
}

.touch-parry {
  flex: 1.25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-color: var(--pink);
  background: rgba(58, 12, 42, 0.88);
  box-shadow: 0 0 18px rgba(255, 46, 151, 0.28);
}

.touch-parry-main {
  font-size: 0.88rem;
  color: #ff8bc8;
}

.touch-parry-sub {
  font-size: 0.64rem;
  color: var(--text-muted);
}

.touch-fire {
  flex: 0.95;
  border-color: var(--mint);
  color: var(--mint);
  background: rgba(10, 34, 30, 0.86);
}

@media (max-width: 920px) {
  .top-bar {
    flex-wrap: wrap;
    padding: 6px 10px;
    gap: 6px;
  }

  .hud-telemetry {
    order: 3;
    width: 100%;
    justify-content: space-between;
    gap: 5px;
  }

  .tele-cell {
    flex: 1;
    min-width: 0;
    padding: 3px 6px;
  }

  .tele-v {
    font-size: 0.78rem;
  }

  .desktop-controls-bar {
    display: none;
  }

  .touch-dock {
    display: flex;
  }

  .title-stats,
  .mechanics-trio,
  .upgrade-grid,
  .debrief-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overlay-card {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .brand-title {
    font-size: 0.84rem;
  }

  .hdr-link {
    padding: 0 6px;
    font-size: 0.64rem;
    height: 26px;
  }

  .hdr-btn {
    padding: 0 6px;
    font-size: 0.64rem;
    height: 26px;
  }

  .title-stats,
  .mechanics-trio,
  .upgrade-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hdr-btn,
  .btn-primary,
  .upg-choice-card {
    transition: none;
  }
}
