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

@font-face {
  font-family: "Orbitron";
  src: url("../fonts/orbitron-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Orbitron";
  src: url("../fonts/orbitron-900.woff2") format("woff2");
  font-weight: 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;
  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%;
}

.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); }
.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-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;
  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;
}

.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.4;
  overflow: hidden;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.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;
}

@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);
}
