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

:root {
  color-scheme: dark;
  --display: "Orbitron", system-ui, sans-serif;
  --bg: #05070f;
  --panel: #0d1326;
  --panel-border: #22305a;
  --text: #e6ecff;
  --muted: #a3b0d6;
  --accent: #5ee1ff;
  --gap: 12px;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Game page: no scrolling, pull-to-refresh, text selection or callouts. */
.game-page {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.space-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.game {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  padding:
    max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
}

.game[data-orientation="landscape"] {
  flex-direction: row;
}

/* Before the script measures the exact layout, CSS approximates it (no layout shift):
   square on the shorter side, minus padding (16px), HUD (140px) and gap (12px). */
.game:not([data-orientation]) .stage {
  width: min(calc(100vw - 16px), calc(100dvh - 168px));
  aspect-ratio: 1;
}

@media (orientation: landscape) {
  .game:not([data-orientation]) {
    flex-direction: row;
  }

  .game:not([data-orientation]) .stage {
    width: min(calc(100dvh - 16px), calc(100vw - 168px));
  }

  .game:not([data-orientation]) .hud {
    max-width: 360px;
  }
}

.stage {
  position: relative;
  flex: none;
  touch-action: none;
}

/* Tutorial hint at the top of the HUD, so it never covers build slots */
.tutorial {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: rgba(7, 12, 28, 0.9);
}

.tutorial p {
  flex: 1 1 200px;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.btn-small {
  min-height: 44px;
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.stage canvas:focus {
  outline: none;
}

.stage canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hud {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 12px;
  background: rgba(13, 19, 38, 0.86);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  overflow: auto;
}

/* Wide screens: a second panel left of the playfield (player, stats, controls) */
.game[data-orientation="landscape"] .hud-left {
  order: -1;
  max-width: 340px;
}

.hud-left .hud-stats {
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.hud-left .hud-stats dd {
  font-size: 1.75rem;
}

.hud-left .hud-player {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto 8px 1.25em;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}

.hud-left .hud-record {
  justify-self: start;
}

.hud-left .emblem {
  width: 52px;
  height: 52px;
  font-size: 1.5rem;
}

.hud-left .hud-name {
  font-size: 1.25rem;
}

.hud-left .keys-hint {
  margin-top: auto;
}

.game[data-orientation="landscape"] .hud {
  max-width: 360px;
}

.hud-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0;
}

.hud-stats dt {
  font-size: 0.75rem;
  color: var(--muted);
}

.hud-stats dd {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hud-title {
  margin: 0 0 4px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hint,
.slot-info,
.keys-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.slot-info {
  color: var(--text);
  font-weight: 600;
}

.status {
  min-height: 1.25em;
  margin: 0;
  font-size: 0.875rem;
  color: #ffd27a;
}

.build-menu {
  display: grid;
  align-items: stretch;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.build-menu .hud-title {
  grid-column: 1 / -1;
}

.tower-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  text-align: left;
  border-left-width: 4px;
}

.tower-laser {
  border-left-color: #5ee1ff;
}

.tower-rocket {
  border-left-color: #ffb35e;
}

.tower-frost {
  border-left-color: #bdf0ff;
}

.tower-railgun {
  border-left-color: #d6b3ff;
}

.tower-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tower-menu .slot-info {
  flex-basis: 100%;
}

.btn-danger {
  border-color: #6b2a3a;
  background: #2a1220;
}

.btn-danger:hover {
  background: #3a1a2c;
}

.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.tower-desc {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--muted);
}

.tower-stats {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.tower-menu .tower-stats,
.upgrade-preview {
  flex-basis: 100%;
  margin: 0;
}

.tower-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Price row at the bottom of every tile (tiles of a row share their height) */
.tower-cost {
  display: flex;
  margin-top: auto;
  padding-top: 4px;
}

/* Stats: icon chips, values in plain text colour */
.tower-stats,
.upgrade-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(163, 176, 214, 0.1);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.icon {
  flex: none;
  width: 14px;
  height: 14px;
}

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

.stat-damage .icon,
.stat-dps .icon { color: #ff9a7a; }
.stat-slow .icon { color: #bdf0ff; }
.stat-range .icon { color: #5ee1ff; }
.stat-rate .icon { color: #ffe17a; }
.stat-splash .icon { color: #ffb35e; }

.stat-arrow {
  color: var(--muted);
  font-weight: 400;
}

.stat-delta {
  margin-left: 2px;
  color: #7dff9a;
  font-weight: 700;
}

/* Prices: a tag with a currency icon, clearly different from stats */
.price {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 3px;
  padding: 3px 8px 3px 6px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.price .icon {
  width: 15px;
  height: 15px;
}

.price-energy {
  color: #ffe17a;
  background: rgba(255, 225, 122, 0.12);
}

.price-stardust {
  color: #d6b3ff;
  background: rgba(214, 179, 255, 0.12);
}

.price-locked {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.price.is-short {
  color: #ff8a8a;
  background: rgba(255, 138, 138, 0.1);
}

.price.is-short .price-amount {
  text-decoration: line-through;
}

.price-missing {
  margin-left: 2px;
  font-size: 0.75rem;
}

/* Action buttons with a price: label left, tag right */
#upgrade-button,
#sell-button,
.btn-buy {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

kbd {
  padding: 0 5px;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  font: inherit;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Keyboard hints are noise on touch-only devices */
@media (pointer: coarse) {
  kbd,
  .keys-hint {
    display: none;
  }
}

.hud-player {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 8px 1.25em;
  align-items: center;
  gap: 4px 10px;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.hud-player-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 44px;
  padding: 0 8px 0 0;
  border: none;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.hud-player-button:hover .hud-name {
  color: var(--accent);
}

.hud-player-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.hud-name {
  overflow: hidden;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Guests are invited to pick a name */
.hud-player-button.is-guest .hud-name::after {
  content: " · " attr(data-hint);
  color: var(--accent);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
}

.hud-level {
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 700;
}

.hud-player progress {
  grid-column: 1 / -1;
  width: 100%;
  height: 8px;
  accent-color: var(--accent);
}

/* Player emblem: first letter on a coloured badge (variant derived from the name) */
.emblem {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid var(--emblem, #a3b0d6);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--emblem, #a3b0d6) 45%, #0d1326), #0d1326 75%);
  box-shadow: 0 0 12px color-mix(in srgb, var(--emblem, #a3b0d6) 45%, transparent);
  color: #fff;
  font-family: var(--display);
  font-size: 1.125rem;
  font-weight: 700;
}

.emblem-large {
  width: 64px;
  height: 64px;
  font-size: 1.75rem;
}

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

.hud-record {
  justify-self: end;
  color: var(--muted);
}

.hud-record.is-new {
  color: #ffe17a;
  font-weight: 700;
}

.hud-run-xp {
  grid-column: 1 / -1;
  color: #7dff9a;
  font-size: 0.8125rem;
}

@media (prefers-reduced-motion: no-preference) {
  .hud-record.is-new {
    animation: record-pulse 1.2s ease-out 2;
  }

  .run-progress.is-level-up {
    animation: record-pulse 1.2s ease-out 2;
  }
}

@keyframes record-pulse {
  0% { transform: scale(1); text-shadow: none; }
  30% { transform: scale(1.12); text-shadow: 0 0 12px #ffe17a; }
  100% { transform: scale(1); text-shadow: none; }
}

.wave-status {
  /* Reserved line: filled by the script without moving anything below */
  min-height: 1.5em;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.wave-status.boss {
  color: #ff8fa6;
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.hud-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  min-width: 44px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: #16203f;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:hover {
  background: #1d2a52;
}

.btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #04121a;
}

.btn-primary:hover {
  background: #8beaff;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 12, 0.72);
}

.overlay-panel {
  max-width: min(90%, 360px);
  padding: 24px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel);
  text-align: center;
}

.result {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 0 0 12px;
  text-align: left;
}

/* Wave and score large (3 columns each), kills, bosses and time small below */
.result > div {
  grid-column: span 2;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(5, 7, 15, 0.45);
}

.result > .result-main {
  grid-column: span 3;
}

.result dt {
  font-size: 0.8rem;
  color: var(--muted);
}

.result dd {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.result .result-main dd {
  font-size: 2rem;
}

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

.summary-record.is-new {
  color: #ffe17a;
  font-weight: 700;
}

.overlay-panel {
  max-height: calc(100% - 16px);
  overflow-y: auto;
}

/* Pause and game over: one column on phones, two columns on wide screens */
.overlay-wide {
  width: min(92vw, 940px);
  max-width: none;
}

@media (min-width: 760px) {
  .overlay-wide {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(320px, 1.4fr);
    gap: 28px;
    align-items: start;
    text-align: left;
  }

  .overlay-wide .overlay-main {
    position: sticky;
    top: 0;
  }

  .overlay-wide .result {
    justify-content: flex-start;
  }

  .overlay-wide .profile {
    margin-top: 0;
    padding-top: 0;
    padding-left: 28px;
    border-top: none;
    border-left: 1px solid var(--panel-border);
  }
}

/* Empty status lines take no space (they are live regions and fill when needed) */
.overlay .field-message:empty {
  min-height: 0;
  margin: 0;
}

.profile-group {
  margin: 8px 0;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
}

.profile-group > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 600;
  list-style-position: inside;
}

.profile-group > summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.profile-group > :not(summary) {
  margin-left: 12px;
  margin-right: 12px;
}

.profile-group[open] > :last-child {
  margin-bottom: 10px;
}

.profile-group .upgrade-list li {
  padding: 6px 10px;
}

.run-placement {
  margin: 0 0 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.run-progress {
  margin: 0 0 12px;
  color: #7dff9a;
  font-weight: 600;
}

.level-info {
  margin: 8px 0;
}

.level-line {
  margin: 0 0 4px;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.level-info progress {
  width: 100%;
  height: 8px;
  accent-color: var(--accent);
}

.upgrades h4 {
  margin: 12px 0 4px;
  font-size: 0.9375rem;
}

.stardust-line {
  margin: 0 0 8px;
  color: #d6b3ff;
  font-weight: 600;
}

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

.upgrade-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
}

.upgrade-list .upgrade-name {
  font-weight: 600;
}

.upgrade-list .upgrade-meta {
  grid-column: 1;
  font-size: 0.8125rem;
  color: var(--muted);
}

.upgrade-list .btn {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-size: 0.875rem;
}

.device h4 {
  margin: 16px 0 4px;
  font-size: 0.9375rem;
}

.recovery-result {
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
}

.recovery-code {
  margin: 0 0 8px;
  font-size: 1.125rem;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
  -webkit-user-select: all;
  user-select: all;
}

.danger-zone .btn {
  margin-bottom: 12px;
}

.profile {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--panel-border);
  text-align: left;
}

.profile h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.profile-status,
.field-hint,
.field-message {
  margin: 4px 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.field-message {
  min-height: 1.25em;
  color: #ffd27a;
}

.nickname-form label {
  display: block;
  margin: 8px 0 4px;
  font-size: 0.875rem;
}

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

/* 16px keeps iOS from zooming into the field on focus */
.nickname-row input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: #070b18;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  -webkit-user-select: text;
  user-select: text;
}

.nickname-row input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

.overlay-panel h2 {
  margin-top: 0;
}

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

/* Player card at the top of the profile (pause and game over) */
.player-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 14px;
  align-items: center;
  margin: 0 0 12px;
  padding: 14px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(94, 225, 255, 0.12), rgba(214, 179, 255, 0.06) 60%, transparent);
}

.player-card-head {
  min-width: 0;
}

.player-card-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.player-card-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.player-card-name {
  overflow: hidden;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.btn-icon {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.player-card-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
}

.player-card-stats div {
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(5, 7, 15, 0.5);
}

.player-card-stats dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.player-card-stats dd {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.player-card .level-info {
  grid-column: 1 / -1;
  margin: 0;
}

.gameover-greeting {
  margin: -4px 0 16px;
  font-family: var(--display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.card-slot .player-card {
  margin: 20px 0 0;
}

.gameover-join {
  margin: -8px 0 16px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.price.price-refund {
  color: #7dff9a;
  background: rgba(125, 255, 154, 0.1);
}

/* Not affordable: the button stays readable, the red price tag explains why */
.btn[aria-disabled="true"]:has(.price.is-short) {
  opacity: 0.85;
}

/* Language choice in the pause menu (the game page has no site header) */
.pause-lang {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.875rem;
}

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

.pause-lang a:hover {
  color: var(--text);
  background: rgba(94, 225, 255, 0.1);
}

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

/* Tower menu: one labelled row per stat (current → next level) */
.stat-list {
  flex-basis: 100%;
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stat-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(163, 176, 214, 0.08);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.stat-row .icon {
  width: 16px;
  height: 16px;
}

.stat-row-label {
  color: var(--muted);
}

.stat-row-values {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 700;
  white-space: nowrap;
}

.stat-row.stat-change {
  background: rgba(125, 255, 154, 0.08);
}

.stat-row .stat-to {
  color: #fff;
}

.upgrade-preview-title {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* --- 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 dialog in the game (native <dialog>, top layer above the pause menu) */
.help-dialog {
  width: min(880px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  -webkit-user-select: text;
  user-select: text;
}

.help-dialog::backdrop {
  background: rgba(3, 4, 11, 0.75);
}

.help-dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel);
}

.help-dialog-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
}

.help-dialog-body {
  padding: 0 16px 24px;
  font-size: 0.95rem;
}

.help-dialog .help-section h3 {
  font-size: 1.05rem;
}

/* Music and effects volume in the pause menu */
.settings-group {
  margin-top: 12px;
}

.settings-body {
  padding-bottom: 8px;
}

.audio-row select {
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #0b1122;
  color: var(--text);
  font: inherit;
}

.audio-row {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 0.9rem;
}

.audio-row input {
  width: 100%;
  accent-color: var(--accent);
}

.audio-row .toggle {
  justify-self: start;
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

/* Game over on wide screens: secondary actions side by side, compact player card
   (record and experience are already part of the summary) */
@media (min-width: 760px) {
  #gameover-overlay .overlay-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  #gameover-overlay .overlay-actions .btn-primary {
    grid-column: 1 / -1;
  }

  #gameover-overlay .player-card-stats {
    display: none;
  }
}

/* Achievements in the profile and after a run */
.achievement-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.achievement {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  opacity: 0.6;
}

.achievement.is-unlocked {
  border-color: rgba(255, 225, 122, 0.5);
  background: rgba(255, 225, 122, 0.06);
  opacity: 1;
}

.achievement-badge {
  color: var(--muted);
  font-size: 1.1rem;
  text-align: center;
}

.achievement.is-unlocked .achievement-badge {
  color: #ffe17a;
}

.achievement-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 0.85rem;
}

.achievement-text span {
  color: var(--muted);
  font-size: 0.8rem;
}

.run-achievements {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  color: #ffe17a;
  font-weight: 700;
}

.offline-hint {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid #ffb35e;
  border-radius: 10px;
  color: #ffd27a;
  font-size: 0.875rem;
}

/* 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);
}

/* Cosmetics shop in the profile */
.cosmetic-slot-title {
  margin: 4px 0 6px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cosmetic-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.cosmetic {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  text-align: left;
}

.cosmetic .cosmetic-state {
  margin-left: auto;
  color: #7dff9a;
  font-size: 0.75rem;
}

.cosmetic .price {
  margin-left: auto;
}

.cosmetic.is-active {
  border-color: #7dff9a;
}

.cosmetic-swatch {
  flex: none;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: conic-gradient(#5ee1ff, #ffb35e, #bdf0ff, #d6b3ff, #5ee1ff);
}

.cosmetic-theme_gold .cosmetic-swatch { background: conic-gradient(#ffd76a, #ffb347, #fff0b0, #f2c96b, #ffd76a); }
.cosmetic-theme_neon .cosmetic-swatch { background: conic-gradient(#ff4fd8, #5dff9e, #54f0ff, #ff5d7a, #ff4fd8); }
.cosmetic-theme_emerald .cosmetic-swatch { background: conic-gradient(#5dffa8, #b4ff5d, #9effe6, #3ff0b8, #5dffa8); }
.cosmetic-emblemFrame-default .cosmetic-swatch { background: #0d1326; border-color: #a3b0d6; }
.cosmetic-frame_silver .cosmetic-swatch { background: #0d1326; border-color: #e3e9f5; box-shadow: 0 0 6px #e3e9f5; }
.cosmetic-frame_gold .cosmetic-swatch { background: #0d1326; border-color: #ffd76a; box-shadow: 0 0 6px #ffd76a; }
.cosmetic-frame_nebula .cosmetic-swatch { background: #0d1326; border-color: #ff7ae0; box-shadow: 0 0 8px #7a5cff; }

.daily-banner {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid #ffd27a;
  border-radius: 10px;
  background: rgba(255, 210, 122, 0.1);
  color: #ffe9b0;
  font-size: 0.875rem;
  font-weight: 700;
}
