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

/* Letterbox bars for cinematic moments (boss arrival, game over): above the 3D scene, below
   the HUD (z-index -1 inside the .game stacking context), never in the way of taps */
.game::before,
.game::after {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  z-index: -1;
  height: 8vh;
  height: 8dvh;
  background: #000;
  pointer-events: none;
  transform: scaleY(0);
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.game::before {
  top: 0;
  transform-origin: top;
}

.game::after {
  bottom: 0;
  transform-origin: bottom;
}

.game.cinematic::before,
.game.cinematic::after {
  transform: scaleY(1);
}

/* Before the script measures the exact layout, CSS approximates it (no layout shift):
   square on the shorter side, minus padding (16px), HUD (266px portrait, 320px
   landscape, see layout.js) and gap (12px). */
.game:not([data-orientation]) .stage {
  width: min(calc(100vw - 16px), calc(100dvh - 294px));
  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 - 348px));
  }

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

/* 3D scene (WebGL) behind the whole page: the cinematic camera places the playfield in the
   stage square, around it space goes on (behind the HUD too). Taps go to the 2D canvas. */
.scene-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.scene-canvas[hidden] {
  display: none;
}

.stage #game-canvas {
  position: relative;
}

.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-arc {
  border-left-color: #8fb4ff;
}

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

.lock-short {
  display: none;
}

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

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

.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 {
  min-width: 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.03em;
  /* Long names shrink and wrap instead of being cut off (#145) */
  overflow-wrap: anywhere;
}

.player-card-name.name-long {
  font-size: 1.15rem;
}

.player-card-name.name-xlong {
  font-size: 0.95rem;
  letter-spacing: 0;
}

.hud-name.name-long {
  font-size: 0.85rem;
  letter-spacing: 0;
}

.hud-name.name-xlong {
  font-size: 0.72rem;
  letter-spacing: 0;
}

.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,
.player-card .card-perks {
  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;
}

.gameover-name-slot:empty {
  display: none;
}

.gameover-name-slot {
  margin: 0 0 16px;
  text-align: left;
}

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

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

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

/* Swatch and name on top, price or state below: the two-column grid is narrow on phones */
.cosmetic {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-content: start;
  align-items: center;
  gap: 4px 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  text-align: left;
}

.cosmetic .cosmetic-state,
.cosmetic .price {
  grid-column: 1 / -1;
  justify-self: start;
}

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

.cosmetic .price {
  max-width: 100%;
  gap: 2px;
  padding: 2px 6px 2px 4px;
  font-size: 0.75rem;
}

.cosmetic .price .icon {
  width: 12px;
  height: 12px;
}

.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; }
.cosmetic-theme_ice .cosmetic-swatch { background: conic-gradient(#bdf3ff, #8fd8ff, #e8fbff, #a8c8ff, #bdf3ff); }
.cosmetic-theme_solar .cosmetic-swatch { background: conic-gradient(#ffb02e, #ff6a2e, #ffe066, #ff4d3a, #ffb02e); }
.cosmetic-theme_void .cosmetic-swatch { background: conic-gradient(#b98cff, #e06bff, #8f9bff, #ff7af0, #b98cff); }
.cosmetic-frame_comet .cosmetic-swatch { background: #0d1326; border-color: #bdf3ff; box-shadow: 0 0 6px #3fa9d6; }
.cosmetic-frame_aurora .cosmetic-swatch { background: #0d1326; border-color: #5dffa8; box-shadow: 0 0 8px #7a5cff; }
.cosmetic-frame_supernova .cosmetic-swatch { background: #0d1326; border-color: #ffb02e; box-shadow: 0 0 8px #ff4d3a; }
.cosmetic-frame_legend .cosmetic-swatch { background: #0d1326; border-color: #fff0b0; box-shadow: 0 0 0 2px #5ee1ff, 0 0 8px #ffd76a; }

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

/* Planet chooser (pause and game over, right column) */
.planet-chooser {
  margin: 0 0 10px;
}

.planet-chooser-title {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.planet-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

@media (max-width: 520px) {
  .planet-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

.planet-choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  gap: 4px 8px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

a.planet-choice:hover {
  border-color: var(--accent);
}

.planet-choice.is-current {
  border-color: var(--accent);
  background: rgba(94, 225, 255, 0.1);
}

.planet-choice.is-locked {
  opacity: 0.65;
}

.planet-choice .price {
  flex-basis: 100%;
  justify-content: center;
  font-size: 0.7rem;
}

.planet-dot {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7fd6ff, #1f5fb8 60%, #071640);
}

.planet-mars .planet-dot { background: radial-gradient(circle at 35% 30%, #f0a070, #a8522e 60%, #3a160c); }
.planet-ice .planet-dot { background: radial-gradient(circle at 35% 30%, #ffffff, #b8d4ec 60%, #4a6a8e); }
.planet-gas .planet-dot { background: repeating-linear-gradient(170deg, #e2c8a0 0 3px, #ba7c4e 3px 6px); }

@media (min-width: 760px) {
  /* Aligned with the profile column (same indent and divider) */
  .overlay-wide .planet-chooser {
    margin: 0;
    padding: 0 0 10px 28px;
    border-left: 1px solid var(--panel-border);
  }
}

/* Confirmation dialog (#124) */
.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
}

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

.confirm-dialog h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.confirm-dialog p {
  margin: 0 0 16px;
  color: var(--muted);
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ------------------------------------------------------------------------
   Compact HUD for phones (#129, #149): portrait phones and low landscape screens.
   Everything for a round fits without scrolling: the player row (name, level,
   record) is in the pause menu, status messages float over the playfield and
   the playfield leaves enough height for the tower menu (layout.js). Tablets in
   portrait and small landscape screens use it too: the HUD below or beside the
   square playfield is short or narrow there as well.
   ------------------------------------------------------------------------ */
@media (max-width: 600px), (max-height: 520px), (orientation: portrait), (orientation: landscape) and (max-width: 1100px) {
  .hud {
    gap: 6px;
    padding: 8px 10px;
  }

  .hud:not(.hud-left) .keys-hint {
    display: none;
  }

  .hud:not(.hud-left) .hud-player {
    display: none;
  }

  /* Tutorial hint and status messages float over the playfield (moved into .stage by
     main.js); taps go through to the build slots below. The tutorial sits at the bottom
     edge, away from the inner ring and the planet it points to (#269). */
  .stage > .tutorial {
    position: absolute;
    bottom: 6px;
    left: 6px;
    right: 6px;
    z-index: 2;
    flex-wrap: nowrap;
    padding: 4px 4px 4px 12px;
    background: rgba(7, 12, 28, 0.94);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
    pointer-events: none;
  }

  .stage > .tutorial p {
    flex: 1 1 auto;
    font-size: 0.8rem;
    line-height: 1.3;
  }

  .stage > .tutorial .btn {
    flex: none;
    max-width: 8em;
    padding: 4px 8px;
    font-size: 0.72rem;
    line-height: 1.15;
    white-space: normal;
    pointer-events: auto;
  }

  .stage > .status {
    position: absolute;
    top: 6px;
    left: 50%;
    z-index: 2;
    max-width: calc(100% - 12px);
    padding: 6px 14px;
    border: 1px solid rgba(255, 210, 122, 0.4);
    border-radius: 999px;
    background: rgba(7, 12, 28, 0.92);
    transform: translateX(-50%);
    pointer-events: none;
    text-align: center;
  }

  /* Messages stay at the top; the tutorial has the bottom edge */

  .stage > .status:empty {
    display: none;
  }

  /* An open build or tower menu needs the room more than the planet/daily banner */
  .hud:has(> .build-menu:not([hidden]), > .tower-menu:not([hidden])) > .daily-banner {
    display: none;
  }

  .hud-stats {
    gap: 4px;
  }

  .hud-stats dt {
    font-size: 0.65rem;
  }

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

  .hud-player {
    grid-template-rows: auto 6px auto;
    gap: 2px 8px;
    font-size: 0.75rem;
  }

  .hud-player .emblem {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }

  .hud-player-button {
    gap: 8px;
  }

  .hud-name {
    font-size: 0.9rem;
  }

  .hud-level,
  .hud-record {
    font-size: 0.72rem;
  }

  .hud-player progress {
    height: 6px;
  }

  .hud-run-xp {
    font-size: 0.7rem;
  }

  .hud-run-xp:empty {
    display: none;
  }

  .wave-status {
    margin: 0;
    font-size: 0.85rem;
  }

  .hud-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .hud-actions .btn {
    padding: 6px 8px;
    font-size: 0.85rem;
  }

  .hint,
  .status,
  .daily-banner {
    font-size: 0.78rem;
  }

  .status {
    min-height: 0;
  }

  .daily-banner {
    padding: 4px 10px;
    line-height: 1.3;
  }

  /* Build menu as a bar: all five towers side by side, name and price */
  .build-menu {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .build-menu .hud-title,
  .tower-desc,
  .build-menu .tower-stats {
    display: none;
  }

  .tower-btn {
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    border-left-width: 1px;
    border-top-width: 3px;
    text-align: center;
  }

  .tower-laser { border-top-color: #5ee1ff; }
  .tower-rocket { border-top-color: #ffb35e; }
  .tower-frost { border-top-color: #bdf0ff; }
  .tower-railgun { border-top-color: #d6b3ff; }
  .tower-arc { border-top-color: #8fb4ff; }

  .tower-name {
    font-size: 0.78rem;
  }

  .tower-cost {
    justify-content: center;
    padding-top: 2px;
  }

  .tower-cost .price {
    padding: 2px 6px 2px 4px;
    font-size: 0.75rem;
  }

  .tower-cost .price-missing,
  .tower-cost .lock-long {
    display: none;
  }

  .tower-cost .lock-short {
    display: inline;
  }

  /* Tower menu: tight stat rows, the three actions in one row */
  .tower-menu {
    gap: 4px;
  }

  .tower-menu .slot-info {
    font-size: 0.85rem;
  }

  /* "Stats · level 1 → 2" is implied by the arrows */
  .upgrade-preview-title {
    display: none;
  }

  /* Stats in two columns: icon, value → next value (the label stays for screen readers) */
  .stat-list {
    grid-template-columns: 1fr 1fr;
    gap: 3px;
  }

  .stat-row {
    grid-template-columns: 14px 1fr;
    gap: 6px;
    min-height: 26px;
    padding: 2px 8px;
    font-size: 0.8rem;
  }

  .stat-row .stat-row-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .stat-row-values {
    gap: 4px;
  }

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

  #target-button,
  #upgrade-button,
  #sell-button {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    padding: 6px;
    font-size: 0.75rem;
    white-space: normal;
  }

  #upgrade-button,
  #sell-button {
    flex-direction: column;
    gap: 2px;
  }

  #upgrade-button .price,
  #sell-button .price {
    font-size: 0.72rem;
  }
}

/* Pause menu tabs (#128): only on narrow screens, one pane at a time */
.pause-tabs {
  display: none;
}

@media (max-width: 759px) {
  .pause-tabs {
    position: sticky;
    top: -1px;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin: 0 0 12px;
    padding: 4px;
    border-radius: 12px;
    background: #0b1122;
  }

  .pause-tab {
    min-height: 44px;
    padding: 0 4px;
    border: none;
    border-radius: 9px;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
  }

  .pause-tab[aria-selected="true"] {
    background: var(--accent);
    color: #05070f;
  }

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

  #pause-overlay .overlay-panel[data-pane="game"] [data-pane-of]:not([data-pane-of="game"]),
  #pause-overlay .overlay-panel[data-pane="profile"] [data-pane-of]:not([data-pane-of="profile"]),
  #pause-overlay .overlay-panel[data-pane="progress"] [data-pane-of]:not([data-pane-of="progress"]),
  #pause-overlay .overlay-panel[data-pane="settings"] [data-pane-of]:not([data-pane-of="settings"]) {
    display: none;
  }

  /* The profile section's own heading and divider are not needed inside a tab */
  #pause-overlay .profile {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }

  /* Upgrades as a two-column grid: name, level, buy button below */
  #pause-overlay .stardust-line {
    display: none;
  }

  .upgrade-list {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .upgrade-list li {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 8px;
  }

  .upgrade-list .upgrade-name {
    font-size: 0.85rem;
    line-height: 1.2;
  }

  .upgrade-list .upgrade-meta {
    order: 1;
    font-size: 0.72rem;
  }

  .upgrade-list .btn {
    order: 2;
    grid-column: 1;
    grid-row: auto;
    justify-content: center;
    margin-top: 4px;
    padding: 6px;
    font-size: 0.78rem;
  }

  /* Achievements as a compact grid on phones */
  .achievement-list {
    grid-template-columns: 1fr 1fr;
  }

  .achievement {
    grid-template-columns: 18px 1fr;
    padding: 6px 8px;
  }

  .achievement .price {
    grid-column: 2;
    justify-self: start;
    font-size: 0.7rem;
  }

  .achievement-text span {
    font-size: 0.72rem;
  }
}

/* Level-up moment after a run (#168) */
.levelup {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 225, 122, 0.6);
  border-radius: 14px;
  background: radial-gradient(circle at 50% 0%, rgba(255, 225, 122, 0.22), rgba(13, 19, 38, 0.6) 70%);
  box-shadow: 0 0 28px rgba(255, 225, 122, 0.25);
  text-align: center;
}

.levelup-title {
  margin: 0 0 6px;
  color: #ffe17a;
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 0 18px rgba(255, 225, 122, 0.6);
}

.levelup-rewards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.levelup-rewards li {
  padding: 3px 10px;
  border: 1px solid rgba(214, 179, 255, 0.5);
  border-radius: 999px;
  background: rgba(214, 179, 255, 0.12);
  color: #e9dcff;
  font-size: 0.8rem;
  font-weight: 700;
}

@media (prefers-reduced-motion: no-preference) {
  .levelup.is-shown {
    animation: levelup-in 700ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
  }

  .levelup.is-shown .levelup-title {
    animation: levelup-glow 1.6s ease-in-out 700ms 2;
  }
}

@keyframes levelup-in {
  from {
    opacity: 0;
    transform: scale(0.7);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes levelup-glow {
  50% {
    text-shadow: 0 0 28px rgba(255, 225, 122, 1), 0 0 48px rgba(255, 179, 71, 0.6);
  }
}

/* Daily and weekly missions (#170) */
.mission-scope + .mission-scope {
  margin-top: 12px;
}

.mission-scope h4 {
  margin: 0 0 2px;
  font-size: 0.9375rem;
}

.mission-reward {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.75rem;
}

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

.mission {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 4px 8px;
  padding: 6px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  font-size: 0.85rem;
}

.mission-badge {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 900;
}

.mission.is-done {
  border-color: rgba(125, 255, 154, 0.5);
  color: var(--muted);
}

.mission.is-done .mission-badge {
  border-color: #7dff9a;
  background: rgba(125, 255, 154, 0.15);
  color: #7dff9a;
}

.mission-text {
  grid-column: 2 / -1;
}

.mission progress {
  grid-column: 2;
  width: 100%;
  height: 6px;
  accent-color: var(--accent);
}

.mission-count {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.run-missions li {
  color: #7dff9a;
}

/* Cards after a defeated boss (#171) */
.card-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 16px;
  border: 1px solid rgba(255, 225, 122, 0.6);
  border-radius: 18px;
  background: radial-gradient(circle at 50% 0%, rgba(255, 225, 122, 0.16), var(--panel) 60%);
  color: var(--text);
  box-shadow: 0 0 40px rgba(255, 225, 122, 0.2);
  text-align: center;
}

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

.card-dialog h2 {
  margin: 0;
  color: #ffe17a;
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 900;
}

.card-dialog > p {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 0.875rem;
}

.card-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 14px 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: linear-gradient(180deg, #1a2550, #10173a);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.game-card:hover,
.game-card:focus-visible {
  border-color: #ffe17a;
  box-shadow: 0 0 18px rgba(255, 225, 122, 0.35);
  outline: none;
}

.game-card-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 225, 122, 0.14);
  color: #ffe17a;
}

.game-card-icon .icon {
  width: 26px;
  height: 26px;
}

.game-card-name {
  font-size: 1rem;
}

.game-card-text {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.game-card-stack {
  color: #ffe17a;
  font-size: 0.75rem;
  font-weight: 700;
}

.game-card-key {
  position: absolute;
  top: 6px;
  right: 8px;
  color: var(--muted);
  font: 700 0.7rem/1 system-ui, sans-serif;
}

.active-cards {
  margin: 0 0 12px;
  color: #ffe17a;
  font-size: 0.875rem;
}

/* Phones in portrait: cards as rows (icon left), all three visible without scrolling */
@media (max-width: 600px) {
  .card-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .game-card {
    display: grid;
    grid-template-columns: 40px 1fr;
    grid-template-rows: auto auto;
    column-gap: 10px;
    row-gap: 2px;
    align-items: center;
    padding: 10px 28px 10px 10px;
    text-align: left;
  }

  .game-card-icon {
    grid-row: 1 / 3;
    width: 40px;
    height: 40px;
  }

  .game-card-name {
    font-size: 0.95rem;
  }

  .game-card-stack {
    position: absolute;
    right: 8px;
    bottom: 6px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .card-dialog[open] .game-card {
    animation: card-in 420ms cubic-bezier(0.2, 1.3, 0.4, 1) both;
  }

  .card-dialog[open] .game-card:nth-child(2) {
    animation-delay: 80ms;
  }

  .card-dialog[open] .game-card:nth-child(3) {
    animation-delay: 160ms;
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.92);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ==========================================================================
   Studio look (M14, #210): glass panels with corner brackets, glowing edges,
   display font for numbers and titles, animated dialogs. Only visual
   properties: sizes and spacing stay as above (compact HUD fits without scrolling).
   ========================================================================== */

:root {
  /* Lighter glass over the full-screen 3D scene (M15): space shows through the HUD */
  --glass: rgba(9, 14, 32, 0.52);
  --glass-strong: rgba(8, 12, 28, 0.9);
  --edge: rgba(94, 225, 255, 0.28);
  --edge-strong: rgba(94, 225, 255, 0.65);
  --bracket: rgba(140, 235, 255, 0.85);
  --glow: 0 0 0 1px rgba(94, 225, 255, 0.08), 0 10px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Corner brackets: four short L-shaped lines drawn with background gradients */
.hud,
.overlay-panel {
  --b: 14px;
  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.07), transparent 120px),
    var(--glass);
  border-color: var(--edge);
  box-shadow: var(--glow);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
}

/* Panels slide in once when the page opens */
@media (prefers-reduced-motion: no-preference) {
  .hud {
    animation: hud-enter 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
  }

  .hud-left {
    animation-name: hud-enter-left;
  }
}

@keyframes hud-enter {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
}

@keyframes hud-enter-left {
  from {
    opacity: 0;
    transform: translateX(-18px);
  }
}

.overlay-panel {
  background-color: var(--glass-strong);
}

.hud-stats dt,
.hud-title,
.result dt {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.6875rem;
  font-weight: 600;
}

.hud-stats dd,
.result dd {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 0 14px rgba(94, 225, 255, 0.35);
}

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

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

.overlay-panel h2,
#card-title {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff, #8fe9ff);
  /* Text keeps its colour where clipping is not supported */
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 10px rgba(94, 225, 255, 0.35));
}

.wave-status {
  font-family: var(--display);
  font-size: 0.875rem;
  letter-spacing: 0.04em;
}

.wave-status.boss {
  text-shadow: 0 0 12px rgba(255, 107, 138, 0.7);
}

/* Buttons: dark metal with a light top edge, glowing border on hover and focus */
.btn {
  background: linear-gradient(180deg, #1d2a55, #121b3c);
  border-color: rgba(120, 160, 255, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, transform 0.08s;
}

.btn:hover {
  background: linear-gradient(180deg, #24346a, #16214a);
  border-color: var(--edge-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 16px rgba(94, 225, 255, 0.25);
}

.btn:active {
  transform: scale(0.97);
}

.btn[aria-pressed="true"] {
  box-shadow: inset 0 0 12px rgba(94, 225, 255, 0.25), 0 0 12px rgba(94, 225, 255, 0.25);
}

.btn-primary {
  background: linear-gradient(180deg, #8beeff, #39c6f0);
  color: #03131c;
  box-shadow: 0 0 22px rgba(94, 225, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #b0f4ff, #5ed7ff);
}

.btn-danger {
  background: linear-gradient(180deg, #4a1426, #2c0b17);
}

/* Tower tiles: tinted from the left in the tower colour */
.tower-laser { --tower: #5ee1ff; }
.tower-rocket { --tower: #ffb35e; }
.tower-frost { --tower: #bdf0ff; }
.tower-railgun { --tower: #d6b3ff; }
.tower-arc { --tower: #8fb4ff; }

.tower-btn {
  background: linear-gradient(90deg, color-mix(in srgb, var(--tower, #5ee1ff) 20%, transparent), transparent 70%), linear-gradient(180deg, #1a2550, #10183a);
  border-left-color: var(--tower, #5ee1ff);
}

.tower-btn:hover {
  box-shadow: inset 4px 0 12px -4px var(--tower, #5ee1ff), 0 0 16px color-mix(in srgb, var(--tower, #5ee1ff) 35%, transparent);
}

.tower-name {
  font-family: var(--display);
  letter-spacing: 0.03em;
}

/* Dialogs: darkened, slightly blurred playfield; panels slide in */
.overlay {
  background: radial-gradient(ellipse at center, rgba(8, 14, 34, 0.55), rgba(2, 3, 9, 0.85));
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.game-card {
  background: linear-gradient(180deg, rgba(255, 225, 122, 0.06), transparent 50%), linear-gradient(180deg, #1c2856, #0f163a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.game-card-name {
  font-family: var(--display);
  letter-spacing: 0.03em;
}

.game-card-icon {
  box-shadow: 0 0 18px rgba(255, 225, 122, 0.3);
}

/* Native dialogs (help, cards, confirmation) in the same glass look */
.help-dialog,
.card-dialog,
.confirm-dialog {
  border-color: var(--edge);
  background: linear-gradient(180deg, rgba(94, 225, 255, 0.07), transparent 120px), var(--glass-strong);
  box-shadow: var(--glow), 0 0 60px rgba(94, 225, 255, 0.08);
}

.help-dialog::backdrop,
.card-dialog::backdrop,
.confirm-dialog::backdrop {
  background: radial-gradient(ellipse at center, rgba(8, 14, 34, 0.55), rgba(2, 3, 9, 0.85));
}

.card-dialog h2,
.confirm-dialog h2,
.help-dialog-head h2 {
  font-family: var(--display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

@media (prefers-reduced-motion: no-preference) {
  .overlay:not([hidden]) .overlay-panel,
  .confirm-dialog[open],
  .help-dialog[open] {
    animation: panel-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  }

  .game-card:hover {
    transform: translateY(-3px);
  }

  .wave-status.boss {
    animation: boss-glow 1.2s ease-in-out infinite alternate;
  }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes boss-glow {
  from { text-shadow: 0 0 6px rgba(255, 107, 138, 0.4); }
  to { text-shadow: 0 0 16px rgba(255, 107, 138, 0.95); }
}

.tutorial {
  border-color: var(--edge-strong);
  background: linear-gradient(180deg, rgba(94, 225, 255, 0.1), transparent), var(--glass-strong);
  box-shadow: 0 0 24px rgba(94, 225, 255, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Compact HUD: five tower tiles in one bar need the narrower system font for the names */
@media (max-width: 600px), (max-height: 520px), (orientation: portrait), (orientation: landscape) and (max-width: 1100px) {
  .tower-name {
    max-width: 100%;
    overflow: hidden;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Short landscape phones: the side HUD is narrow, the tiles even more so */
@media (orientation: landscape) and (max-height: 520px) {
  .tower-name {
    font-size: 0.64rem;
  }
}

/* Expedition (#255): start kit, rewards, sector map, trader, shipyard, events */
.daily-banner.is-elite {
  border-color: #ff6b8a;
  background: rgba(255, 79, 122, 0.12);
  color: #ffc2cf;
}

#gameover-overlay.is-victory h2 {
  color: #ffe17a;
  text-shadow: 0 0 18px rgba(255, 225, 122, 0.55);
}

.expedition-dialog {
  width: min(720px, calc(100vw - 24px));
  overflow: auto;
  overscroll-behavior: contain;
}

.expedition-dialog[data-kind="route"],
.expedition-dialog[data-kind="map"] {
  border-color: rgba(143, 211, 255, 0.6);
  background: radial-gradient(circle at 50% 100%, rgba(80, 160, 255, 0.18), var(--panel) 65%);
  box-shadow: 0 0 40px rgba(143, 211, 255, 0.2);
}

.expedition-dialog[data-kind="route"] h2,
.expedition-dialog[data-kind="map"] h2 {
  color: #8fd3ff;
}

.expedition-dialog[data-kind="event"] h2 {
  color: #c9a8ff;
}

.card-list-two {
  grid-template-columns: repeat(2, 1fr);
}

.expedition-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.expedition-card.is-blueprint .game-card-icon {
  background: rgba(143, 211, 255, 0.16);
  color: #8fd3ff;
}

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

.expedition-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.expedition-actions:empty {
  display: none;
}

.sector-map {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
}

.sector-map-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

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

.sector-map-lines line.is-taken {
  stroke: #ffe17a;
  stroke-width: 3;
  stroke-dasharray: none;
}

.sector-map-lines line.is-next {
  stroke: #8fd3ff;
  stroke-width: 2.5;
  animation: sector-dash 0.9s linear infinite;
}

@keyframes sector-dash {
  to {
    stroke-dashoffset: -18;
  }
}

.sector-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 8px;
}

.sector-node {
  --node: #ff8a5e;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 76px;
  min-height: 48px;
  padding: 5px 8px;
  border: 1px solid rgba(150, 170, 255, 0.25);
  border-radius: 12px;
  background: #0f1636;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.1;
  touch-action: manipulation;
}

.sector-node .icon {
  width: 20px;
  height: 20px;
  color: var(--node);
}

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

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

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

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

.node-flagship {
  --node: #ff3b3b;
  min-width: 120px;
  border-color: rgba(255, 59, 59, 0.5);
}

.sector-node:disabled {
  cursor: default;
}

.sector-node.is-visited {
  opacity: 0.6;
}

.sector-node.is-current {
  opacity: 1;
  border-color: #ffe17a;
  color: var(--text);
  box-shadow: 0 0 16px rgba(255, 225, 122, 0.45);
}

.sector-node.is-option {
  border-color: #8fd3ff;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 0 14px rgba(143, 211, 255, 0.45);
  animation: node-pulse 1.4s ease-in-out infinite;
}

.sector-node.is-option:hover,
.sector-node.is-option:focus-visible {
  outline: none;
  border-color: #ffffff;
  box-shadow: 0 0 22px rgba(143, 211, 255, 0.8);
}

@keyframes node-pulse {
  50% {
    box-shadow: 0 0 22px rgba(143, 211, 255, 0.75);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sector-node.is-option,
  .sector-map-lines line.is-next {
    animation: none;
  }
}

@media (max-width: 600px) {
  .card-list-two {
    grid-template-columns: 1fr;
  }

  /* Price or lock in its own column on the right, never over the text */
  .expedition-card {
    grid-template-columns: 40px 1fr auto;
    padding-right: 10px;
  }

  .expedition-card .game-card-stack {
    position: static;
    grid-column: 3;
    grid-row: 1 / 3;
  }

  .sector-map {
    gap: 9px;
  }

  .sector-node {
    min-width: 0;
    flex: 0 1 30%;
    font-size: 0.68rem;
  }

  .node-flagship {
    flex-basis: 50%;
  }
}

/* Short landscape screens: the map runs from left (start) to right (flagship) */
@media (orientation: landscape) and (max-height: 520px) {
  .expedition-dialog > p {
    margin-bottom: 6px;
  }

  .sector-map {
    flex-direction: row-reverse;
    gap: 8px;
  }

  .sector-row {
    flex: 1;
    flex-direction: column;
    gap: 6px;
  }

  .sector-node {
    min-width: 0;
    width: 100%;
    min-height: 44px;
    padding: 3px 4px;
  }

  /* Cards as compact rows (like on phones), three or two per line */
  .expedition-dialog .card-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .expedition-dialog .card-list:has(> :nth-child(4)),
  .expedition-dialog .card-list-two {
    grid-template-columns: repeat(2, 1fr);
  }

  .expedition-card {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 2px;
    align-items: center;
    padding: 8px 10px;
    text-align: left;
  }

  .expedition-card .game-card-icon {
    grid-row: 1 / 3;
    width: 36px;
    height: 36px;
  }

  .expedition-card .game-card-stack {
    position: static;
    grid-column: 3;
    grid-row: 1 / 3;
  }

  .expedition-card .game-card-key {
    display: none;
  }
}

/* Name and text of a compact expedition card always share the middle column */
.expedition-card {
  min-width: 0;
}

@media (max-width: 600px), (orientation: landscape) and (max-height: 520px) {
  .expedition-card .game-card-name,
  .expedition-card .game-card-text {
    grid-column: 2;
    min-width: 0;
    overflow-wrap: anywhere;
    hyphens: auto;
  }

  .expedition-card .game-card-name {
    font-size: 0.88rem;
  }
}
