/* Orbitwall – styles of the HTML pages (homepage, leaderboard, legal, 404, admin). */

/* Orbitron, unmodified upstream variable font (only WOFF2-compressed): the OFL reserves the
   name "Orbitron", so subsetted copies must not be used under it (license audit #157). */
@font-face {
  font-family: "Orbitron";
  src: url("../fonts/orbitron-variable.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #04060e;
  --bg-alt: #070b1a;
  --panel: #0c1226;
  --panel-border: #22305a;
  --text: #e6ecff;
  --muted: #a8b4d8;
  --accent: #5ee1ff;
  --accent-2: #b388ff;
  --warm: #ffb35e;
  --display: "Orbitron", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  line-height: 1.55;
}

a {
  color: var(--accent);
}

a:focus-visible,
.button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

h1,
h2,
h3 {
  line-height: 1.2;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Header and footer ---------------------------------------------------- */

.skip-link {
  position: absolute;
  left: 8px;
  top: -100px;
  z-index: 20;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--accent);
  color: #04121a;
  font-weight: 600;
}

.skip-link:focus {
  top: 8px;
}

.site-header {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  max-width: 1120px;
  margin: 0 auto;
  padding:
    max(12px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    12px
    max(16px, env(safe-area-inset-left));
}

.home-page .site-header {
  position: absolute;
  left: 0;
  right: 0;
}

.brand {
  margin-right: auto;
  color: var(--text);
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}

.site-nav a:hover {
  background: rgba(94, 225, 255, 0.1);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
}

/* Language: a compact switcher (globe + code) that opens a small list, works without JS */
.lang-menu {
  position: relative;
}

.lang-menu > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(13, 19, 38, 0.6);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  list-style: none;
  cursor: pointer;
}

.lang-menu > summary::-webkit-details-marker {
  display: none;
}

.lang-menu > summary:hover,
.lang-menu[open] > summary {
  border-color: var(--accent);
  color: var(--text);
}

.lang-menu > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lang-chevron {
  transition: transform 0.15s ease;
}

.lang-menu[open] .lang-chevron {
  transform: rotate(180deg);
}

.lang-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 10;
  display: grid;
  min-width: 170px;
  padding: 6px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: #0d1326;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.lang-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.lang-list a:hover {
  background: rgba(94, 225, 255, 0.1);
}

.lang-list a[aria-current="true"] {
  color: var(--accent);
  font-weight: 700;
}

.lang-list a[aria-current="true"]::after {
  content: "✓";
  margin-left: auto;
}

.lang-list-code {
  min-width: 2.2em;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  max-width: 1120px;
  margin: 0 auto;
  padding:
    20px
    max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--panel-border);
  color: var(--muted);
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  column-gap: 16px;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: #121b3a;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.button:hover {
  background: #18244d;
}

.button-primary {
  border-color: transparent;
  background: linear-gradient(135deg, #5ee1ff, #7f9bff);
  color: #04121a;
  box-shadow: 0 0 24px rgba(94, 225, 255, 0.45), 0 6px 18px rgba(0, 0, 0, 0.4);
}

.button-primary:hover {
  background: linear-gradient(135deg, #8beaff, #9fb3ff);
  box-shadow: 0 0 36px rgba(94, 225, 255, 0.7), 0 8px 22px rgba(0, 0, 0, 0.45);
}

.button-ghost {
  border-color: rgba(94, 225, 255, 0.5);
  background: rgba(10, 16, 36, 0.6);
}

.button-large {
  min-height: 56px;
  padding: 14px 30px;
  font-size: 1.1rem;
}

@media (prefers-reduced-motion: no-preference) {
  .button:hover {
    transform: translateY(-2px);
  }
}

/* --- Homepage: hero --------------------------------------------------------- */

.hero {
  position: relative;
  display: flex;
  align-items: center;
  min-height: min(100svh, 860px);
  overflow: hidden;
  background:
    radial-gradient(ellipse at 70% 50%, rgba(42, 111, 209, 0.25), transparent 60%),
    radial-gradient(ellipse at 15% 20%, rgba(120, 60, 180, 0.25), transparent 55%),
    radial-gradient(ellipse at 85% 90%, rgba(30, 140, 170, 0.2), transparent 50%),
    var(--bg);
}

.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Live 3D scene of the game behind the hero (#243); the 2D layer fades out once it shows */
.hero-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.hero-live .hero-scene {
  opacity: 1;
}

.hero-canvas {
  transition: opacity 1.2s ease;
}

.hero-live .hero-canvas {
  opacity: 0;
}

/* Keep the text readable over the live scene: a dark veil on the text side */
.hero-live::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(5, 8, 20, 0.82) 0%, rgba(5, 8, 20, 0.55) 38%, transparent 62%);
}

@media (max-width: 899px) {
  .hero-live::before {
    background: linear-gradient(180deg, rgba(5, 8, 20, 0.1) 0%, rgba(5, 8, 20, 0.2) 22%, rgba(5, 8, 20, 0.75) 42%, rgba(5, 8, 20, 0.92) 100%);
  }
}

.hero::after {
  /* Fade into the page below */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 120px;
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 120px max(20px, env(safe-area-inset-right)) 80px max(20px, env(safe-area-inset-left));
}

.hero-content > * {
  max-width: 560px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: var(--display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.display {
  margin: 0;
  /* Gradient text is clipped to the element box, so it must never be narrower than the word */
  max-width: none !important;
  white-space: nowrap;
  font-family: var(--display);
  font-size: clamp(2.4rem, 11.5vw, 5.6rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff 20%, #9fe9ff 60%, #5e8cff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 24px rgba(94, 225, 255, 0.45));
}

.tagline {
  margin: 12px 0;
  font-size: clamp(1.2rem, 3.4vw, 1.6rem);
  font-weight: 700;
}

.hero-text {
  color: var(--muted);
  font-size: 1.05rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0 16px;
}

.hero-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-note strong {
  color: var(--warm);
}

@media (max-width: 760px) {
  /* Compact header: brand and language on one line, navigation below */
  .site-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 8px;
  }

  .site-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-left: -12px;
  }

  .lang-menu {
    grid-column: 2;
    grid-row: 1;
  }

  .hero {
    align-items: flex-end;
  }

  .hero-content {
    padding-top: 34vh;
    padding-bottom: 48px;
    text-align: center;
  }

  .kicker {
    letter-spacing: 0.16em;
  }

  .hero-text {
    font-size: 0.98rem;
  }

  .hero-content > * {
    margin-left: auto;
    margin-right: auto;
  }

  .cta-row {
    justify-content: center;
  }

  .hero-canvas {
    top: 90px;
    height: 34vh;
  }
}

/* --- Homepage: sections ----------------------------------------------------- */

.section {
  padding: 72px max(20px, env(safe-area-inset-right)) 72px max(20px, env(safe-area-inset-left));
}

.section-alt {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(94, 225, 255, 0.07), transparent 60%),
    var(--bg-alt);
  border-top: 1px solid rgba(94, 225, 255, 0.08);
  border-bottom: 1px solid rgba(94, 225, 255, 0.08);
}

.section-inner {
  max-width: 1120px;
  margin: 0 auto;
}

.display-sub {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: clamp(1.5rem, 4.5vw, 2.4rem);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.section-intro {
  max-width: 640px;
  margin: 0 0 32px;
  color: var(--muted);
  font-size: 1.05rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.feature-card {
  position: relative;
  padding: 24px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(25, 36, 76, 0.85), rgba(10, 15, 33, 0.95));
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.feature-card::before {
  /* Colored glow behind the illustration */
  content: "";
  position: absolute;
  top: -40px;
  left: -40px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--card-glow, rgba(94, 225, 255, 0.3)), transparent 70%);
  pointer-events: none;
}

.feature-card:hover {
  border-color: var(--card-color, var(--accent));
  box-shadow: 0 0 30px var(--card-glow, rgba(94, 225, 255, 0.3));
}

@media (prefers-reduced-motion: no-preference) {
  .feature-card:hover {
    transform: translateY(-4px);
  }
}

.feature-art {
  position: relative;
  display: block;
  margin-bottom: 8px;
  overflow: visible;
}

.feature-card h3 {
  position: relative;
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
}

.feature-card p {
  position: relative;
  margin: 0;
  color: var(--muted);
}

.feature-laser { --card-color: #5ee1ff; --card-glow: rgba(94, 225, 255, 0.35); }
.feature-rocket { --card-color: #ffb35e; --card-glow: rgba(255, 179, 94, 0.35); }
.feature-frost { --card-color: #bdf0ff; --card-glow: rgba(189, 240, 255, 0.3); }
.feature-railgun { --card-color: #d6b3ff; --card-glow: rgba(214, 179, 255, 0.35); }
.feature-arc { --card-color: #8fb4ff; --card-glow: rgba(143, 180, 255, 0.35); }
.enemy-asteroid { --card-color: #d9b28a; --card-glow: rgba(217, 178, 138, 0.25); }
.enemy-alien { --card-color: #c9a6ff; --card-glow: rgba(255, 120, 220, 0.3); }
.enemy-splitter { --card-color: #ff9650; --card-glow: rgba(255, 150, 80, 0.3); }
.enemy-swarm { --card-color: #7dff9a; --card-glow: rgba(125, 255, 154, 0.3); }
.enemy-armored { --card-color: #ffd27a; --card-glow: rgba(255, 210, 122, 0.3); }
.enemy-phantom { --card-color: #7ef3ff; --card-glow: rgba(126, 243, 255, 0.3); }
.enemy-carrier { --card-color: #ffb070; --card-glow: rgba(255, 176, 112, 0.3); }
.enemy-boss { --card-color: #ff6b8a; --card-glow: rgba(255, 107, 138, 0.4); }

.feature-grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.step {
  padding: 24px;
  border-left: 3px solid var(--accent);
  border-radius: 0 16px 16px 0;
  background: rgba(12, 18, 38, 0.8);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5ee1ff, #7f9bff);
  color: #04121a;
  font-family: var(--display);
  font-weight: 900;
  box-shadow: 0 0 20px rgba(94, 225, 255, 0.5);
}

.step h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  letter-spacing: 0.04em;
}

.step p {
  margin: 0;
  color: var(--muted);
}

.final-cta {
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(94, 225, 255, 0.2), transparent 60%),
    var(--bg);
}

.final-cta p {
  color: var(--muted);
}

/* --- Leaderboard (homepage preview and full page) -------------------------- */

.board-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.board-card {
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: rgba(12, 18, 38, 0.85);
}

.board-card h3 {
  margin: 0 0 12px;
  font-family: var(--display);
  letter-spacing: 0.04em;
}

.podium {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.podium li {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.podium-rank {
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-family: var(--display);
  font-weight: 900;
  color: #04121a;
}

.podium-1 .podium-rank { background: linear-gradient(135deg, #fff1a8, #e5b33a); box-shadow: 0 0 18px rgba(255, 215, 100, 0.6); }
.podium-2 .podium-rank { background: linear-gradient(135deg, #f2f5ff, #9aa7c4); }
.podium-3 .podium-rank { background: linear-gradient(135deg, #ffd2a8, #b8733d); }

.podium-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.podium-score {
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.board {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
}

.board caption {
  padding: 0 0 8px;
  text-align: left;
  color: var(--muted);
}

.board th,
.board td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
  text-align: left;
}

.board thead th {
  font-size: 0.875rem;
  color: var(--muted);
}

.board tbody th {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.board tbody tr:nth-child(-n + 3) td:first-child {
  color: #ffe17a;
  font-weight: 700;
}

.board .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.board-compact th,
.board-compact td {
  padding: 7px 10px;
}

.board-compact tbody tr:nth-child(-n + 3) td:first-child {
  color: inherit;
  font-weight: 400;
}

/* --- Inner pages ---------------------------------------------------------- */

.page {
  max-width: 820px;
  margin: 0 auto;
  padding:
    max(24px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(48px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.page h1 {
  margin: 8px 0 20px;
  font-family: var(--display);
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #ffffff 30%, #9fe9ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: #121b3a;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.tab[aria-current="page"] {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 16px rgba(94, 225, 255, 0.3);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
}

.own-rank,
.notice {
  padding: 12px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--panel);
}

.note {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Imprint and privacy policy: long running text */
.legal {
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.legal h2 {
  margin: 32px 0 8px;
  font-size: 1.25rem;
}

.legal h3 {
  margin: 20px 0 6px;
  font-size: 1.05rem;
}

.legal p,
.legal ul {
  margin: 0 0 12px;
}

.legal ul {
  padding-left: 1.25em;
}

.legal li + li {
  margin-top: 4px;
}

.legal a {
  color: var(--accent);
}

.legal code {
  font-size: 0.85em;
}

.language-chooser {
  text-align: center;
}

.language-chooser h1 {
  font-size: clamp(2.6rem, 10vw, 4.5rem);
}

.language-chooser p {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 24px 0;
}

.language-chooser .button {
  min-width: 220px;
}

/* --- Scroll reveal (only with JS and without reduced motion; see site.js) --- */

@media (prefers-reduced-motion: no-preference) {
  .js-reveal .reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.7s ease, transform 0.7s ease;
  }

  .js-reveal .reveal.is-visible {
    opacity: 1;
    transform: none;
  }
}

/* --- Admin ------------------------------------------------------------------ */

.admin {
  max-width: 1100px;
}

.admin section {
  margin: 24px 0;
}

.admin-form {
  display: grid;
  gap: 8px;
  max-width: 360px;
}

.admin-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  max-width: none;
  margin: 12px 0;
}

.admin input {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: #070b18;
  color: var(--text);
  font: inherit;
}

.admin .board form {
  margin: 0;
}

.admin-logout {
  margin-top: 32px;
}

/* --- Returning players (html.has-account is set before the first paint) --- */

.emblem {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid var(--emblem, #a8b4d8);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--emblem, #a8b4d8) 45%, #0c1226), #0c1226 75%);
  box-shadow: 0 0 12px color-mix(in srgb, var(--emblem, #a8b4d8) 45%, transparent);
  color: #fff;
  font-family: var(--display);
  font-size: 0.9rem;
  font-weight: 700;
}

.emblem-large {
  width: 60px;
  height: 60px;
  font-size: 1.6rem;
}

.emblem-v1 { --emblem: #5ee1ff; }
.emblem-v2 { --emblem: #ffb35e; }
.emblem-v3 { --emblem: #d6b3ff; }
.emblem-v4 { --emblem: #7dff9a; }
.emblem-v5 { --emblem: #ff7aa8; }

.header-player,
.home-player,
.cta-back {
  display: none;
}

.has-account .cta-new {
  display: none;
}

.has-account .cta-back {
  display: inline;
}

/* Header chip: fixed width, so filling in the name does not move the navigation */
.has-account .header-player {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 168px;
  min-height: 44px;
  padding: 0 12px 0 6px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(12, 18, 38, 0.6);
  color: var(--text);
  text-decoration: none;
}

.header-player:hover {
  border-color: var(--accent);
}

.header-player-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.header-player-name {
  min-height: 1.15em;
  overflow: hidden;
  font-family: var(--display);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.header-player-level {
  min-height: 1.15em;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Until the profile has loaded, the reserved space stays calm (no flashing placeholders) */
.header-player:not(.is-loaded) > *,
.home-player:not(.is-loaded) > * {
  visibility: hidden;
}

/* Homepage card: reserved height, filled by player-card.js */
.has-account .home-player {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 460px;
  margin: 24px 0 0;
  padding: 14px 18px;
  border: 1px solid rgba(94, 225, 255, 0.35);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(94, 225, 255, 0.14), rgba(179, 136, 255, 0.08) 60%, rgba(12, 18, 38, 0.6));
  box-shadow: 0 0 32px rgba(94, 225, 255, 0.12);
  text-align: left;
}

.home-player-main {
  flex: 1;
  min-width: 0;
}

.home-player-hello {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.3;
}

.home-player-name {
  min-height: 1.4em;
  margin: 0 0 6px;
  line-height: 1.25;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  /* Long names shrink and wrap instead of being cut off (#145) */
  overflow-wrap: anywhere;
}

.home-player-name.name-long,
.home-player-name.name-xlong {
  font-size: 1rem;
}

.home-player-level {
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-badge {
  flex: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 5.5em;
  height: 1.8em;
  padding: 2px 10px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.home-player-level progress {
  flex: 1;
  height: 8px;
  accent-color: var(--accent);
}

.home-player-stats {
  min-height: 1.4em;
  margin: 6px 0 0;
  line-height: 1.4;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Hints for the next run (#166): small chips under the level bar. flex-start: Safari would
   otherwise stretch a single row of chips to the reserved height (#181); one row is
   reserved on the homepage so the card does not grow after loading */
.card-perks {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  gap: 4px 6px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.perk {
  padding: 2px 8px;
  border: 1px solid rgba(255, 225, 122, 0.5);
  border-radius: 999px;
  background: rgba(255, 225, 122, 0.1);
  color: #ffe17a;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.5;
}

.home-player .card-perks {
  min-height: 1.5rem;
}

/* Phones: up to two rows of hints (streak, bonus, next goal) without the card growing */
@media (max-width: 520px) {
  .home-player .card-perks {
    min-height: 3.25rem;
  }
}

@media (max-width: 760px) {
  .has-account .site-header {
    grid-template-columns: 1fr auto auto;
  }

  .has-account .header-player {
    grid-column: 2;
    grid-row: 1;
    width: 96px;
    padding-right: 10px;
  }

  .has-account .lang-menu {
    grid-column: 3;
  }

  /* Phones: emblem and level only */
  .header-player-name {
    display: none;
  }

  .has-account .home-player {
    margin: 20px auto 0;
  }
}

/* --- Help content (shared by the help page and the game dialog) --- */

.help-toc {
  margin: 16px 0 8px;
  padding: 12px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(12, 18, 38, 0.6);
}

.help-toc-title {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.help-toc ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.help-toc a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  background: rgba(94, 225, 255, 0.08);
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
}

.help-toc a:hover {
  background: rgba(94, 225, 255, 0.18);
}

.help-section {
  scroll-margin-top: 16px;
  margin: 28px 0 0;
}

.help-section h2,
.help-section h3 {
  margin: 0 0 8px;
}

.help-section p {
  margin: 0 0 10px;
  line-height: 1.6;
}

.help-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  margin: 8px 0 12px;
}

.help-item {
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(12, 18, 38, 0.5);
}

.help-item dt {
  font-weight: 700;
}

.help-item dd {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.help-tag {
  margin-left: 4px;
  padding: 1px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.help-symbols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 6px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.help-symbol {
  display: flex;
  align-items: center;
  gap: 10px;
}

.help-symbol .icon { flex: none; }
.help-symbol-damage .icon,
.help-symbol-dps .icon { color: #ff9a7a; }
.help-symbol-slow .icon { color: #bdf0ff; }
.help-symbol-range .icon { color: #5ee1ff; }
.help-symbol-rate .icon { color: #ffe17a; }
.help-symbol-splash .icon { color: #ffb35e; }
.help-symbol-energy .icon { color: #ffe17a; }
.help-symbol-stardust .icon { color: #d6b3ff; }
.help-symbol-lock .icon { color: var(--muted); }

.help-keys {
  display: grid;
  gap: 6px;
  margin: 0;
}

.help-keys div {
  display: grid;
  grid-template-columns: 7.5em 1fr;
  align-items: baseline;
  gap: 12px;
}

.help-keys dd {
  margin: 0;
  color: var(--muted);
}

.help-keys kbd {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--panel-border);
  border-bottom-width: 2px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
}

.help-faq {
  margin: 6px 0;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
}

.help-faq summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-weight: 600;
  cursor: pointer;
}

.help-faq p {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--muted);
}

.help-page {
  max-width: 920px;
}

/* Hero badges: "Browser game" stands out */
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(12, 18, 38, 0.7);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.badge-primary {
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(94, 225, 255, 0.25), rgba(179, 136, 255, 0.25));
  box-shadow: 0 0 18px rgba(94, 225, 255, 0.35);
  color: #fff;
  font-family: var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 760px) {
  .hero-badges {
    justify-content: center;
    gap: 6px;
  }

  .badge {
    padding: 4px 9px;
    font-size: 0.75rem;
  }

  .badge-primary {
    letter-spacing: 0.04em;
  }
}

/* --- Story: four chapters along a glowing line --- */
.story {
  position: relative;
}

.story-chapters {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
}

/* The connecting line behind the illustrations */
.story-chapters::before {
  content: "";
  position: absolute;
  top: 60px;
  left: 12%;
  right: 12%;
  height: 2px;
  background: linear-gradient(90deg, rgba(94, 225, 255, 0), rgba(94, 225, 255, 0.6), rgba(179, 136, 255, 0.6), rgba(255, 107, 138, 0));
}

.story-chapter {
  position: relative;
  text-align: center;
}

.story-art {
  position: relative;
  display: block;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #0c1430 60%, transparent 61%);
  filter: drop-shadow(0 0 14px rgba(94, 225, 255, 0.25));
}

.story-number {
  display: block;
  color: var(--accent);
  font-family: var(--display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.story-chapter h3 {
  margin: 4px 0 8px;
  font-family: var(--display);
  font-size: 1.05rem;
}

.story-chapter p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.story-cta {
  margin: 32px 0 0;
  text-align: center;
}

@media (max-width: 900px) {
  .story-chapters {
    grid-template-columns: 1fr;
    gap: 28px;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
  }

  /* Vertical line on narrow screens */
  .story-chapters::before {
    top: 0;
    bottom: 0;
    left: 59px;
    right: auto;
    width: 2px;
    height: auto;
    background: linear-gradient(180deg, rgba(94, 225, 255, 0.6), rgba(255, 107, 138, 0.3));
  }

  .story-chapter {
    display: grid;
    grid-template-columns: 120px 1fr;
    column-gap: 16px;
    text-align: left;
  }

  .story-art {
    grid-row: 1 / span 3;
    margin: 0;
  }
}

@media (max-width: 420px) {
  .story-chapter {
    grid-template-columns: 84px 1fr;
  }

  .story-art {
    width: 84px;
    height: 84px;
  }

  .story-chapters::before {
    left: 41px;
  }
}

/* --- Tower and enemy pages --- */
.detail-page {
  max-width: 980px;
}

.detail-card {
  margin: 24px 0 0;
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-left: 4px solid var(--card-color, var(--accent));
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(12, 18, 38, 0.9), rgba(12, 18, 38, 0.6));
  scroll-margin-top: 16px;
}

.detail-card h2 {
  margin: 0;
  font-family: var(--display);
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 0 12px;
}

.detail-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.detail-art {
  flex: none;
  filter: drop-shadow(0 0 14px var(--card-glow, rgba(94, 225, 255, 0.3)));
}

.detail-tag {
  display: inline-block;
  padding: 1px 10px;
  border: 1px solid var(--card-color, var(--accent));
  border-radius: 999px;
  color: var(--card-color, var(--accent)) !important;
  font-size: 0.8rem;
  font-weight: 700;
}

.table-scroll {
  overflow-x: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.stats-table th,
.stats-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
  text-align: left;
  white-space: nowrap;
}

.stats-table thead th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.stats-table .num {
  text-align: right;
}

.stats-table .icon {
  vertical-align: -3px;
  color: var(--card-color, var(--accent));
}

.detail-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.detail-facts,
.detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
  margin: 14px 0 0;
}

.detail-stats {
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
}

.detail-facts div,
.detail-stats div {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(5, 7, 15, 0.5);
}

.detail-facts dt,
.detail-stats dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.detail-facts dd,
.detail-stats dd {
  margin: 4px 0 0;
}

.detail-stats dd {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.detail-special {
  margin: 10px 0 0;
  color: var(--card-color, var(--accent));
  font-weight: 700;
}

.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 32px 0 0;
}

@media (max-width: 520px) {
  .detail-head {
    align-items: flex-start;
  }

  .detail-art {
    width: 64px;
    height: auto;
  }
}

/* Emblem frames (cosmetics) */
.emblem.frame_silver {
  border-color: #e3e9f5;
  box-shadow: 0 0 0 2px #8f9bb3, 0 0 14px rgba(227, 233, 245, 0.6);
}

.emblem.frame_gold {
  border-color: #ffd76a;
  box-shadow: 0 0 0 2px #b8862b, 0 0 18px rgba(255, 215, 106, 0.7);
}

.emblem.frame_nebula {
  border-color: #ff7ae0;
  box-shadow: 0 0 0 2px #7a5cff, 0 0 20px rgba(255, 122, 224, 0.6), 0 0 34px rgba(122, 92, 255, 0.5);
}

/* Level reward frames (#168) */
.emblem.frame_comet {
  border-color: #bdf3ff;
  box-shadow: 0 0 0 2px #3fa9d6, 0 0 16px rgba(189, 243, 255, 0.7);
}

.emblem.frame_aurora {
  border-color: #5dffa8;
  box-shadow: 0 0 0 2px #7a5cff, 0 0 18px rgba(93, 255, 168, 0.55), 0 0 30px rgba(122, 92, 255, 0.4);
}

.emblem.frame_supernova {
  border-color: #ffb02e;
  box-shadow: 0 0 0 2px #ff4d3a, 0 0 20px rgba(255, 176, 46, 0.7), 0 0 36px rgba(255, 77, 58, 0.45);
}

.emblem.frame_legend {
  border-color: #fff0b0;
  box-shadow: 0 0 0 2px #ffd76a, 0 0 0 5px #5ee1ff, 0 0 26px rgba(255, 215, 106, 0.75), 0 0 44px rgba(94, 225, 255, 0.45);
}

/* Planet tabs on the leaderboard (#57) */
.tabs-planets {
  margin-top: -8px;
}

.tab.tab-small {
  min-height: 44px;
  padding: 0 12px;
  font-size: 0.85rem;
}

/* Player level in leaderboards (#127) */
.level-pill {
  display: inline-block;
  min-width: 2em;
  padding: 1px 8px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

/* Admin statistics (#125) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 12px 0 20px;
}

.kpi {
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--panel);
}

.kpi p {
  margin: 0;
}

.kpi-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.kpi-row {
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
}

.range-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}

.range-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel);
  color: inherit;
  text-decoration: none;
}

.range-link[aria-current="page"] {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.admin-chart {
  display: block;
  width: 100%;
  height: auto;
  padding: 8px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--panel);
}

.chart-axis {
  stroke: var(--panel-border);
  stroke-width: 1;
}

.chart-views,
.chart-visitors {
  fill: none;
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.chart-views { stroke: #5ee1ff; }
.chart-visitors { stroke: #ffb35e; }

.chart-label {
  fill: var(--muted);
  font-size: 11px;
}

.chart-label-end {
  text-anchor: end;
}

.chart-label-mid {
  text-anchor: middle;
}

/* Hover values (#197): transparent columns over the chart, tooltip placed by admin/charts.js */
.chart-box {
  position: relative;
}

.chart-hit {
  fill: transparent;
  cursor: crosshair;
}

.chart-hit:hover,
.chart-hit.is-active {
  fill: rgba(163, 176, 214, 0.14);
}

.chart-tip {
  position: absolute;
  z-index: 2;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #0b1020;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.chart-bar-views { fill: #5ee1ff; }
.chart-bar-runs { fill: #b58bff; }

.chart-legend span::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 3px;
  margin: 0 6px 3px 12px;
  vertical-align: middle;
}

.legend-views::before { background: #5ee1ff; }
.legend-visitors::before { background: #ffb35e; }
.legend-runs::before { background: #b58bff; }

.admin-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.bar-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.bar-list li {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) 2fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.88rem;
}

.bar-list li > span:first-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(163, 176, 214, 0.15);
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}
.bar-0 { width: 0%; }
.bar-5 { width: 5%; }
.bar-10 { width: 10%; }
.bar-15 { width: 15%; }
.bar-20 { width: 20%; }
.bar-25 { width: 25%; }
.bar-30 { width: 30%; }
.bar-35 { width: 35%; }
.bar-40 { width: 40%; }
.bar-45 { width: 45%; }
.bar-50 { width: 50%; }
.bar-55 { width: 55%; }
.bar-60 { width: 60%; }
.bar-65 { width: 65%; }
.bar-70 { width: 70%; }
.bar-75 { width: 75%; }
.bar-80 { width: 80%; }
.bar-85 { width: 85%; }
.bar-90 { width: 90%; }
.bar-95 { width: 95%; }
.bar-100 { width: 100%; }

/* --- 3D portraits (#244) ---------------------------------------------------------
   A holder keeps its vector art until the portrait (rendered by showcase.js) is drawn. */
.model {
  position: relative;
  display: grid;
  place-items: center;
  width: fit-content;
}

.model > .model-canvas {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 165%;
  aspect-ratio: 1;
  height: auto;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.model.model-live > .model-canvas {
  opacity: 1;
}

.model.model-live > svg {
  opacity: 0;
}

.model > svg {
  transition: opacity 0.4s ease;
}

/* ==========================================================================
   M16 relaunch (#245): the website in the look of the game's HUD. Glass panels with
   corner brackets and glowing edges, Orbitron headings, live 3D portraits.
   ========================================================================== */

:root {
  --glass: rgba(10, 16, 36, 0.62);
  --edge: rgba(94, 225, 255, 0.22);
  --bracket: rgba(140, 235, 255, 0.8);
}

/* Glass with four corner brackets, drawn with background gradients (no extra markup) */
.unit-card,
.world-card,
.chapter-text,
.step,
.board-card,
.home-player,
.detail-card,
.help-toc,
.page > .board {
  --b: 12px;
  background:
    linear-gradient(var(--bracket), var(--bracket)) top left / var(--b) 2px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) top left / 2px var(--b) no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) top right / var(--b) 2px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) top right / 2px var(--b) no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) bottom left / var(--b) 2px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) bottom left / 2px var(--b) no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) bottom right / var(--b) 2px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) bottom right / 2px var(--b) no-repeat,
    linear-gradient(180deg, rgba(94, 225, 255, 0.06), transparent 120px),
    var(--glass);
  border: 1px solid var(--edge);
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(94, 225, 255, 0.05), 0 18px 50px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Section heads: kicker, big title, a glowing rule */
.section {
  padding-top: clamp(64px, 10vw, 120px);
  padding-bottom: clamp(64px, 10vw, 120px);
}

.section-head {
  margin-bottom: clamp(24px, 4vw, 48px);
}

.section-head .display-sub {
  font-size: clamp(1.7rem, 5.2vw, 3rem);
  background: linear-gradient(180deg, #ffffff 30%, #9fe9ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.section-head::after {
  content: "";
  display: block;
  width: 96px;
  height: 2px;
  margin-top: 14px;
  background: linear-gradient(90deg, var(--accent), transparent);
  box-shadow: 0 0 12px var(--accent);
}

/* --- Story: filmic chapters, picture and text alternating ---------------------- */
.chapters {
  display: grid;
  gap: clamp(28px, 6vw, 64px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.chapter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: center;
  gap: clamp(16px, 4vw, 48px);
}

.chapter:nth-child(even) .chapter-visual {
  order: 2;
}

.chapter-visual {
  display: grid;
  place-items: center;
  min-height: 220px;
  background: radial-gradient(circle, rgba(94, 225, 255, 0.12), transparent 65%);
}

.chapter-model {
  width: 180px;
  height: 180px;
}

.chapter-model > svg {
  width: 100%;
  height: 100%;
}

.chapter-model > .model-canvas {
  width: 190%;
}

.chapter-text {
  position: relative;
  padding: clamp(20px, 3vw, 32px);
}

.chapter-number {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-family: var(--display);
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1;
  opacity: 0.35;
}

.chapter-text h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  letter-spacing: 0.04em;
}

.chapter-text p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

@media (max-width: 720px) {
  .chapter {
    grid-template-columns: 1fr;
  }

  .chapter:nth-child(even) .chapter-visual {
    order: 0;
  }

  .chapter-visual {
    min-height: 160px;
  }

  .chapter-model {
    width: 140px;
    height: 140px;
  }
}

/* --- Arsenal and threats: unit cards with a 3D portrait ------------------------- */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
}

.unit-grid-small {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.unit-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0 18px 18px;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--card-color, var(--accent)) 30%, transparent);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.unit-card::before {
  /* Spotlight under the model */
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 220px;
  height: 180px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 60%, var(--card-glow, rgba(94, 225, 255, 0.3)), transparent 70%);
  opacity: 0.55;
  pointer-events: none;
}

.unit-card:hover {
  border-color: var(--card-color, var(--accent));
  box-shadow: 0 0 34px var(--card-glow, rgba(94, 225, 255, 0.3)), 0 18px 50px rgba(0, 0, 0, 0.4);
}

@media (prefers-reduced-motion: no-preference) {
  .unit-card:hover {
    transform: translateY(-4px);
  }
}

.unit-model {
  align-self: center;
  width: 150px;
  height: 150px;
  margin: 8px 0 4px;
}

.unit-grid-small .unit-model {
  width: 120px;
  height: 120px;
}

.unit-model > svg {
  width: 64%;
  height: 64%;
}

.unit-model > .model-canvas {
  width: 100%;
}

.unit-card h3 {
  position: relative;
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 1.05rem;
  overflow-wrap: anywhere;
  letter-spacing: 0.05em;
  color: var(--card-color, var(--text));
}

.unit-card p {
  position: relative;
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.unit-unlock {
  position: absolute !important;
  top: 12px;
  right: 12px;
  padding: 2px 8px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: rgba(5, 8, 20, 0.7);
  font-size: 0.72rem !important;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.unit-stats {
  position: relative;
  display: grid;
  gap: 4px;
  margin: auto 0 0;
  padding-top: 14px;
}

.unit-stats div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(94, 225, 255, 0.06);
  border: 1px solid rgba(94, 225, 255, 0.12);
}

.unit-stats dt {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.unit-stats dd {
  margin: 0;
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

/* --- Worlds: the four planets --------------------------------------------------- */
.world-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.world-card {
  position: relative;
  padding: 0 20px 22px;
  overflow: hidden;
}

.world-model {
  width: 190px;
  height: 190px;
  margin: 6px auto 4px;
}

.world-model > .model-canvas {
  width: 120%;
}

.world-fallback {
  display: block;
  width: 62%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--planet-light, #7fd6ff), var(--planet-dark, #0a2a5a) 70%);
  box-shadow: 0 0 30px var(--planet-glow, rgba(94, 200, 255, 0.4));
}

.model-live > .world-fallback {
  opacity: 0;
}

.world-terra { --planet-light: #7fd6ff; --planet-dark: #0a2a5a; --planet-glow: rgba(94, 200, 255, 0.4); }
.world-mars { --planet-light: #ffb08a; --planet-dark: #5a1e0e; --planet-glow: rgba(255, 140, 100, 0.4); }
.world-ice { --planet-light: #e6f7ff; --planet-dark: #2a4a6a; --planet-glow: rgba(170, 230, 255, 0.4); }
.world-gas { --planet-light: #ffe0a8; --planet-dark: #6a4020; --planet-glow: rgba(255, 210, 150, 0.4); }

.world-card h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.2rem;
  letter-spacing: 0.05em;
}

.world-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Story CTA and section links get some air */
.story-cta {
  margin-top: clamp(28px, 5vw, 56px);
  text-align: center;
}

/* Phones: the live scene gets the top of the screen, the text starts below it */
@media (max-width: 899px) {
  .hero-live .hero-content {
    padding-top: max(120px, 38vh);
  }
}

/* Phones: two unit cards per row keep the lists short */
@media (max-width: 600px) {
  .unit-grid,
  .unit-grid-small {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .unit-card {
    padding: 0 12px 14px;
  }

  .unit-model,
  .unit-grid-small .unit-model {
    width: 110px;
    height: 110px;
  }

  .unit-unlock {
    top: 8px;
    right: 8px;
  }

  .unit-stats dt {
    font-size: 0.62rem;
  }

  .world-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .world-card {
    padding: 0 12px 16px;
  }

  .world-model {
    width: 120px;
    height: 120px;
  }
}

/* --- Inner pages, header and footer (#246) --------------------------------------- */

/* A quiet starry backdrop like the game's sky */
body.site:not(.home-page) {
  background:
    radial-gradient(ellipse at 80% -10%, rgba(94, 140, 255, 0.16), transparent 55%),
    radial-gradient(ellipse at 0% 30%, rgba(140, 80, 200, 0.12), transparent 50%),
    radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 70% 60%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 40% 80%, rgba(255, 255, 255, 0.35), transparent),
    var(--bg);
  background-size: auto, auto, 240px 240px, 320px 320px, 280px 280px, auto;
}

/* Header: a glass bar across the page (the box shadow paints the full width without
   widening the layout) */
body.site:not(.home-page) .site-header {
  position: sticky;
  top: 0;
  background: rgba(6, 10, 24, 0.78);
  box-shadow: 0 0 0 100vmax rgba(6, 10, 24, 0.78), 0 1px 0 100vmax rgba(94, 225, 255, 0.12);
  clip-path: inset(0 -100vmax -1px);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.brand {
  text-shadow: 0 0 18px rgba(94, 225, 255, 0.45);
}

.site-nav a[aria-current="page"] {
  position: relative;
}

.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 6px;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

/* Footer: brand line and a glowing edge */
.site-footer {
  position: relative;
  align-items: center;
  border-top-color: rgba(94, 225, 255, 0.18);
}

.site-footer::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 160px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
  box-shadow: 0 0 10px var(--accent);
}

.footer-brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}

.footer-brand small {
  display: block;
  font-family: var(--body);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

/* Tower and enemy pages: glass cards, the portrait large beside the text */
.detail-card {
  border-left-width: 1px;
  border-radius: 6px;
  padding: 22px;
}

.detail-card::after {
  /* Colour of the unit as a glowing strip on the left */
  content: "";
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: -1px;
  width: 3px;
  background: var(--card-color, var(--accent));
  box-shadow: 0 0 14px var(--card-color, var(--accent));
}

.detail-card {
  position: relative;
}

.detail-art.model {
  width: 120px;
  height: 120px;
}

.detail-art.model > svg {
  width: 80%;
  height: 80%;
}

.detail-art.model > .model-canvas {
  width: 150%;
}

.detail-card h2 {
  letter-spacing: 0.05em;
  color: var(--card-color, var(--text));
}

@media (max-width: 560px) {
  .detail-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Help: the table of contents as a glass panel */
.help-toc {
  padding: 18px 20px;
}

/* Leaderboard and other tables */
.board {
  border-collapse: separate;
  border-spacing: 0;
}

.board thead th {
  font-family: var(--display);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.board tbody tr:hover {
  background: rgba(94, 225, 255, 0.05);
}

.page > .board {
  overflow: hidden;
}

.page > .board th,
.page > .board td {
  padding-left: 14px;
  padding-right: 14px;
}

/* Tabs like the HUD buttons */
.tab {
  border-radius: 6px;
  font-family: var(--display);
  letter-spacing: 0.04em;
}

.tab[aria-current="page"] {
  box-shadow: 0 0 16px rgba(94, 225, 255, 0.35);
}

/* Anchors land below the sticky header */
body.site:not(.home-page) [id] {
  scroll-margin-top: 84px;
}

/* --- Expedition (#257): text with feature points beside a decorative sector map ------ */
.expedition-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(24px, 5vw, 64px);
}

.expedition-points {
  display: grid;
  gap: 14px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
}

.expedition-point {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: start;
  gap: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.expedition-point strong {
  color: var(--text);
}

.expedition-point-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 225, 122, 0.4);
  border-radius: 12px;
  background: rgba(255, 225, 122, 0.08);
  color: #ffe17a;
}

.expedition-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
}

.expedition-visual {
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 28px);
  background: radial-gradient(circle at 50% 10%, rgba(255, 59, 59, 0.16), transparent 55%), radial-gradient(circle at 50% 95%, rgba(94, 225, 255, 0.14), transparent 60%);
}

.expedition-map {
  width: min(100%, 360px);
  height: auto;
  overflow: visible;
}

.expedition-map line {
  stroke: rgba(150, 170, 255, 0.35);
  stroke-width: 2;
  stroke-dasharray: 4 5;
}

.expedition-map line.is-taken {
  stroke: #ffe17a;
  stroke-width: 3;
  stroke-dasharray: none;
  filter: drop-shadow(0 0 4px rgba(255, 225, 122, 0.6));
}

.exp-node {
  --node: #ff8a5e;
}

.exp-node circle {
  fill: #0f1636;
  stroke: var(--node);
  stroke-width: 1.5;
}

.exp-node path {
  fill: none;
  stroke: var(--node);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.exp-node-elite {
  --node: #ff4f7a;
}

.exp-node-shop {
  --node: #ffe17a;
}

.exp-node-repair {
  --node: #7dff9a;
}

.exp-node-event {
  --node: #b388ff;
}

.exp-node-flagship {
  --node: #ff3b3b;
}

.exp-node-flagship circle {
  stroke-width: 2.5;
  filter: drop-shadow(0 0 8px rgba(255, 59, 59, 0.7));
}

.help-item dt .icon {
  vertical-align: -3px;
  color: var(--accent);
}

@media (max-width: 760px) {
  .expedition-layout {
    grid-template-columns: 1fr;
  }

  .expedition-visual {
    order: -1;
  }

  .expedition-map {
    width: min(78%, 300px);
  }
}

/* Arsenal cards: what the stats rows mean (#265) */
.unit-stats-head {
  margin: auto 0 0;
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-transform: uppercase;
}

.unit-stats-head + .unit-stats {
  margin-top: 0;
  padding-top: 6px;
}

/* "6 → 19" needs more room than one stat value: wrap below the label in narrow cards */
.unit-stats div {
  flex-wrap: wrap;
  row-gap: 0;
}

.unit-stats dd {
  margin-left: auto;
  font-size: 0.88rem;
}
