/* Title screen (js/title-menu.js): the main menu (hero ship, mode cards that launch, Armory and Leaderboard
   tiles) and its Armory / Leaderboard / Settings pages, over one moving backdrop. Layout notes:
   - the root's data-page picks the view on screen; hidden views take no space and no controller focus;
   - the backdrop is opaque, so the game world isn't drawn under the title (Game.loop);
   - no backdrop-filter, no animated box-shadow on big areas: hover and focus glows sit on small cards. */

/* Shared with the menu pages (css/menu-pages.css). */
:root {
  --tm-bg-1: #0c0020;
  --tm-bg-2: #1d0035;
  --tm-bg-3: #2a0038;
  --tm-bg-4: #3a0020;
  --tm-card: rgba(20, 4, 38, 0.82);
  --tm-line: rgba(238, 246, 255, 0.14);
  --tm-text: #eef6ff;
  --tm-dim: #a7b4cf;
  --tm-pink: #ff2a8a;
  --tm-chrome: linear-gradient(180deg, #f4fbff 0%, #6fd3ff 46%, #1a0533 50%, #ff3ea5 53%, #ffb36b 80%, #fff1c2 100%);
  --tm-display: Impact, Haettenschweiler, 'Arial Narrow Bold', 'Arial Black', sans-serif; /* the death screen's headline face */
  --tm-mono: Consolas, 'Courier New', monospace;
  --tm-pad-l: max(24px, env(safe-area-inset-left, 0px));
  --tm-pad-r: max(24px, env(safe-area-inset-right, 0px));
}

#title-modal.title-menu {
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  color: var(--tm-text);
  text-align: left;
  background: linear-gradient(180deg, var(--tm-bg-1) 0%, var(--tm-bg-2) 48%, var(--tm-bg-3) 72%, var(--tm-bg-4) 100%);
}
#title-modal.title-menu.hidden { display: none !important; }

/* Nebula: static gradients over the dusk wash, under the moving stars. */
#title-modal.title-menu::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 45% at 72% 30%, rgba(255, 42, 138, 0.18), transparent 70%),
    radial-gradient(36% 44% at 12% 18%, rgba(181, 101, 255, 0.20), transparent 70%),
    radial-gradient(34% 40% at 90% 80%, rgba(0, 243, 255, 0.08), transparent 72%),
    linear-gradient(180deg, transparent 55%, rgba(7, 2, 15, 0.72) 100%);
}
.tm-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }

.tm-ui {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top" "rail view";
  padding: max(6px, env(safe-area-inset-top, 0px)) var(--tm-pad-r) max(14px, env(safe-area-inset-bottom, 0px)) var(--tm-pad-l);
}
/* A menu over the title (Field Guide, patch notes, tutorial, save, starting-weapon pick) keeps the moving
   backdrop behind it but hides the title's own controls. */
body.menu-held #title-modal.title-menu { visibility: visible; }
body.menu-held #title-modal.title-menu .tm-ui { visibility: hidden; }
body.menu-held .modal-overlay:not(#title-modal) { background: radial-gradient(circle at center, rgba(12, 2, 28, 0.62), rgba(5, 1, 12, 0.86)); }

/* ---------- Top bar ---------- */
.tm-top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  position: relative;
  z-index: 3;
}
.tm-mark { width: 30px; height: 30px; flex: none; margin-right: 8px; filter: drop-shadow(0 0 6px rgba(0, 243, 255, 0.5)); }
.tm-spacer { flex: 1; }
#title-modal .version-tag {
  font-family: var(--tm-mono);
  font-size: 12px;
  color: var(--tm-dim);
  border: 1px solid var(--tm-line);
  border-radius: 999px;
  padding: 5px 11px;
  margin: 0 4px 0 0;
  letter-spacing: 1px;
}
.tm-nav, .tm-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 13px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--tm-text);
  font: 800 13px/1 'Segoe UI', system-ui, sans-serif;
  letter-spacing: 1.6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}
.tm-icon { padding: 0; width: 44px; }
.tm-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tm-icon .tm-wave { stroke: #00ff88; }
.tm-nav:hover, .tm-icon:hover, .tm-nav:focus-visible, .tm-icon:focus-visible,
.tm-nav.gp-focus, .tm-icon.gp-focus { border-color: rgba(0, 243, 255, 0.55); background: rgba(0, 243, 255, 0.08); outline: none; }
.tm-nav:active, .tm-icon:active { transform: scale(0.95); }
.tm-range { color: #00ff88; }

#title-modal .tm-nav .guide-btn-badge,
#title-modal .tm-nav .notes-badge {
  position: static;
  display: inline-block;
  margin: 0;
  padding: 3px 7px;
  border-radius: 999px;
  font: 800 10px/1 'Segoe UI', system-ui, sans-serif;
  letter-spacing: 0.5px;
  animation: none;
  transform: none;
}
#title-modal .tm-nav .notes-badge { background: #ff007f; color: #fff; }
#title-modal .tm-nav .notes-badge.hidden, #title-modal .tm-nav .guide-btn-badge:empty { display: none; }
#title-modal .tm-nav .guide-btn-badge { background: #00f3ff; color: #03121a; box-shadow: none; }
#title-modal #unlock-count-title { background: transparent; color: var(--tm-dim); padding: 0; font-size: 12px; font-family: var(--tm-mono); }
/* Touch screens only: full screen sits in the top bar (desktop has [V] and the Settings button). */
.tm-fs { display: none; }
body.touch-mode .tm-fs { display: inline-flex; }

.tm-vol-wrap { position: relative; }
.tm-vol-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(14, 4, 30, 0.97);
  border: 1px solid rgba(0, 243, 255, 0.3);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  z-index: 5;
}
#title-modal .tm-vol-pop .quick-vol { margin: 0; width: 100%; }

/* ---------- Views ---------- */
.tm-view { grid-area: view; display: none; min-height: 0; min-width: 0; }
#title-modal[data-page="home"] .tm-home,
#title-modal[data-page="armory"] [data-tm-view="armory"],
#title-modal[data-page="board"] [data-tm-view="board"],
#title-modal[data-page="settings"] [data-tm-view="settings"] { display: grid; }
#title-modal[data-page="home"] .tm-home { grid-column: 1 / -1; }
.tm-view.tm-enter { animation: tm-view-in 0.26s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
@keyframes tm-view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Main menu ---------- */
.tm-home {
  width: 100%;
  max-width: 1400px;
  justify-self: center;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(110px, 1fr) auto auto auto auto;
  grid-template-areas: "logo ship" "prompt prompt" "modes modes" "tiles tiles" "hint hint";
  column-gap: 28px;
  row-gap: 14px;
  padding: 0 clamp(0px, 4vw, 96px);
}
.tm-logo {
  grid-area: logo;
  align-self: center;
  margin: 0;
  min-width: 0;
  container-type: inline-size;
  line-height: 1;
}
/* The wordmark never clips: TitleMenu.fitWordmark measures it and sets --tm-logo-fit so it fills its cell
   in whatever face loaded (the italic overhang sits in the padding); before that, 15.5cqi leaves room for a
   wide fallback face. The viewport-height cap keeps it off the cards on short screens. */
.tm-chrome {
  display: inline-block;
  font-family: var(--tm-display);
  font-style: italic;
  font-weight: 900;
  text-transform: uppercase;
  background: var(--tm-chrome);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 10px rgba(255, 42, 138, 0.55)) drop-shadow(0 2px 0 rgba(26, 5, 51, 0.9));
  padding: 0.06em 0.18em 0.06em 0.04em;
  line-height: 1.05;
}
.tm-logo .tm-chrome { font-size: min(var(--tm-logo-fit, 15.5cqi), 19vh, 168px); letter-spacing: 0.02em; white-space: nowrap; }
.tm-ship { grid-area: ship; position: relative; min-height: 0; min-width: 0; }
/* LAUNCH: a short crouch, then the ship zooms off along its heading (up, leaning left: LAUNCH_HEADING in
   js/ship-preview.js) while its thruster burns. Transform only, so it costs the compositor nothing. */
.tm-ship.tm-ship-launch { animation: tm-ship-launch var(--tm-ign-ms, 1520ms) linear forwards; }
/* Crouch, a slow lift-off, then the burn throws it off the screen. */
@keyframes tm-ship-launch {
  0% { transform: none; animation-timing-function: cubic-bezier(0.3, 0, 0.6, 1); }
  14% { transform: translate(0.5vh, 2.5vh) scale(0.97); animation-timing-function: cubic-bezier(0.4, 0, 0.7, 0.6); }
  55% { transform: translate(-2.5vh, -11vh) scale(1.04); animation-timing-function: cubic-bezier(0.55, 0, 0.9, 0.4); }
  100% { transform: translate(-26vh, -118vh) scale(1.3); }
}
#title-ship-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tm-prompt {
  grid-area: prompt;
  font: 800 15px/1 var(--tm-mono);
  letter-spacing: 3px;
  color: #ffe3f4;
  text-shadow: 0 0 10px var(--tm-pink);
}
.tm-cur { color: #00f3ff; text-shadow: 0 0 10px #00f3ff; animation: tm-blink 1s steps(1) infinite; }
@keyframes tm-blink { 50% { opacity: 0; } }

/* Mode cards: each one launches its mode. */
.tm-modes { grid-area: modes; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(12px, 1.8vw, 28px); }
.tm-mode {
  --mc: #00f3ff;
  --mc-rgb: 0, 243, 255;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 6px;
  min-height: clamp(150px, 25vh, 250px);
  padding: clamp(14px, 1.6vw, 24px) clamp(16px, 1.8vw, 26px);
  text-align: left;
  color: var(--tm-text);
  font: inherit;
  cursor: pointer;
  border-radius: 18px;
  border: 2px solid rgba(var(--mc-rgb), 0.34);
  background: linear-gradient(160deg, rgba(var(--mc-rgb), 0.14), var(--tm-card) 55%);
  transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.35), border-color 0.18s;
}
.tm-mode.mode-hardcore { --mc: #ff2a55; --mc-rgb: 255, 42, 85; }
.tm-mode.mode-blitz { --mc: #ffcc00; --mc-rgb: 255, 204, 0; }
/* The glow is its own layer, faded with opacity (compositor only). */
.tm-mode::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 40px rgba(var(--mc-rgb), 0.16), 0 0 0 1px rgba(var(--mc-rgb), 0.5);
  opacity: 0;
  transition: opacity 0.18s;
}
.tm-mode:hover, .tm-mode:focus-visible, .tm-mode.gp-focus, .tm-mode.selected { border-color: var(--mc); outline: none; }
.tm-mode:hover, .tm-mode:focus-visible, .tm-mode.gp-focus { transform: translateY(-6px); }
.tm-mode:hover::after, .tm-mode:focus-visible::after, .tm-mode.gp-focus::after, .tm-mode.selected::after { opacity: 1; }
.tm-mode:active { transform: translateY(-2px) scale(0.985); transition-duration: 0.06s; }
.tm-mode-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tm-mode-glyph { width: clamp(26px, 2.6vw, 40px); height: clamp(26px, 2.6vw, 40px); flex: none; color: var(--mc); filter: drop-shadow(0 0 7px rgba(var(--mc-rgb), 0.8)); }
.tm-mode-glyph svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.tm-mode-name { font-size: clamp(24px, 2.7vw, 44px); letter-spacing: 0.04em; min-width: 0; }
.tm-mode-tag { font: 800 clamp(10px, 0.9vw, 14px)/1.1 var(--tm-mono); letter-spacing: 2.5px; color: var(--mc); }
.tm-mode-blurb { color: var(--tm-dim); font-size: clamp(12px, 0.95vw, 15px); line-height: 1.4; max-width: 36ch; }
.tm-mode-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.tm-mode-best { font-family: var(--tm-mono); font-variant-numeric: tabular-nums; }
.tm-mode-best small { display: block; font-size: 10px; letter-spacing: 2.5px; color: var(--tm-dim); font-weight: 700; }
.tm-mode-best b { font-size: clamp(16px, 1.6vw, 26px); color: #fff; font-weight: 800; }
.tm-mode-go {
  font: 800 12px/1 var(--tm-mono);
  letter-spacing: 1.5px;
  color: #07020f;
  background: var(--mc);
  border-radius: 999px;
  padding: 7px 12px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.16s, transform 0.16s;
}
.tm-mode:hover .tm-mode-go, .tm-mode:focus-visible .tm-mode-go, .tm-mode.gp-focus .tm-mode-go { opacity: 1; transform: none; }
.tm-mode-last {
  position: absolute;
  top: 14px;
  right: 14px;
  font: 700 10px/1 var(--tm-mono);
  letter-spacing: 1.5px;
  color: var(--mc);
  border: 1px solid rgba(var(--mc-rgb), 0.55);
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(7, 2, 15, 0.6);
}
/* Ignition: a short, cancellable launch sweep in the mode's colour. */
.tm-ign { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--mc); transform-origin: 0 50%; transform: scaleX(0); pointer-events: none; }
.tm-ign-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  text-align: center;
  background: rgba(7, 2, 15, 0.9);
  font-family: var(--tm-mono);
  opacity: 0;
  pointer-events: none;
}
.tm-ign-label b { font-size: clamp(16px, 1.7vw, 26px); letter-spacing: 4px; color: var(--mc); text-shadow: 0 0 12px var(--mc); }
.tm-ign-label span { font-size: 11px; letter-spacing: 2px; color: var(--tm-text); }
.tm-mode.igniting { border-color: var(--mc); transform: translateY(-6px) scale(1.02); }
.tm-mode.igniting::after { opacity: 1; }
.tm-mode.igniting > :not(.tm-ign):not(.tm-ign-label) { opacity: 0.12; transition: opacity 0.12s; }
.tm-mode.igniting .tm-ign { animation: tm-ign var(--tm-ign-ms, 1520ms) cubic-bezier(0.45, 0, 0.85, 0.6) forwards; }
.tm-mode.igniting .tm-ign-label { opacity: 1; transition: opacity 0.1s; }
@keyframes tm-ign { to { transform: scaleX(1); } }
.tm-modes.launching .tm-mode:not(.igniting) { opacity: 0.45; transition: opacity 0.2s; }

/* Second tier: Armory and Leaderboard. Visible and inviting, quieter than the cards. */
.tm-tiles { grid-area: tiles; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(12px, 1.8vw, 28px); }
.tm-tile {
  --tc: #b565ff;
  --tc-rgb: 181, 101, 255;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 16px;
  min-height: 76px;
  padding: 10px 18px 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(var(--tc-rgb), 0.42);
  background: var(--tm-card);
  color: var(--tm-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.tm-tile-board { --tc: #00f3ff; --tc-rgb: 0, 243, 255; }
.tm-tile:hover, .tm-tile:focus-visible, .tm-tile.gp-focus { border-color: var(--tc); background: rgba(var(--tc-rgb), 0.1); transform: translateY(-2px); outline: none; }
.tm-tile:active { transform: scale(0.98); }
.tm-tile-ico { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 12px; background: rgba(var(--tc-rgb), 0.14); color: var(--tc); }
.tm-tile-ico svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tm-tile-ico .tm-fill { fill: currentColor; stroke: none; }
.tm-tile-text { display: grid; gap: 4px; min-width: 0; }
.tm-tile-name { font: 900 17px/1.1 'Segoe UI', system-ui, sans-serif; letter-spacing: 2px; }
.tm-tile-line { color: var(--tm-dim); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-tile-stat { display: grid; justify-items: end; gap: 5px; font-family: var(--tm-mono); font-variant-numeric: tabular-nums; }
.tm-tile-stat b { font-size: 19px; color: var(--tc); font-weight: 800; white-space: nowrap; }
.tm-tile-sub { font-size: 10px; letter-spacing: 1.5px; color: var(--tm-dim); white-space: nowrap; }
.tm-ready { font: 800 10px/1 var(--tm-mono); letter-spacing: 1px; color: #04140c; background: #00ff88; border-radius: 999px; padding: 3px 8px; white-space: nowrap; }
.tm-tile-arrow { font: 900 24px/1 system-ui, sans-serif; color: var(--tc); }

.tm-hint { grid-area: hint; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font: 600 12px/1.6 var(--tm-mono); letter-spacing: 1px; color: var(--tm-dim); }
.tm-hint kbd { font-family: inherit; color: var(--tm-text); border: 1px solid #45507a; border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; }
.tm-hint b { color: var(--tm-text); }
body.touch-mode .tm-hint { display: none; }

/* ---------- Sub-pages (Armory, Leaderboard, Settings) ---------- */
.tm-rail {
  grid-area: rail;
  display: none;
  flex-direction: column;
  gap: 8px;
  align-self: start;
  width: 92px;
  margin: 24px 22px 0 0;
  padding: 10px 5px;
  border-radius: 18px;
  background: rgba(8, 12, 28, 0.55);
  border: 1px solid rgba(0, 243, 255, 0.14);
}
#title-modal:not([data-page="home"]) .tm-rail { display: flex; }
.tm-rail button {
  display: grid;
  justify-items: center;
  gap: 7px;
  min-height: 62px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #cfe3ff;
  font: 800 10.5px/1 'Segoe UI', system-ui, sans-serif;
  letter-spacing: 1.5px;
  cursor: pointer;
  align-content: center;
  transition: background 0.14s;
}
.tm-rail-ico { font-size: 17px; line-height: 1; }
.tm-c-violet { color: #c79bff; }
.tm-c-gold { color: #ffcc00; }
.tm-c-pink { color: #ff4f9a; }
.tm-c-green { color: #00ff88; }
.tm-rail button:hover, .tm-rail button:focus-visible, .tm-rail button.gp-focus { background: rgba(0, 243, 255, 0.1); outline: none; }
.tm-rail button[aria-current="page"] { background: rgba(181, 101, 255, 0.2); color: #fff; box-shadow: inset 0 0 0 1px rgba(199, 155, 255, 0.6); }

.tm-sub {
  grid-template-rows: auto auto auto minmax(0, 1fr);
  align-content: start;
  gap: 16px;
  padding: 14px 0 0;
  max-width: 1400px;
  width: 100%;
}
.tm-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.tm-head-text { flex: 1; min-width: 220px; }
.tm-title { margin: 0; font-size: clamp(28px, 3vw, 42px); letter-spacing: 0.08em; }
.tm-sub-line { margin: 4px 0 0; font: 600 14px/1.35 'Segoe UI', system-ui, sans-serif; color: var(--tm-dim); }
.tm-back, .tm-callsign, .tm-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(238, 246, 255, 0.25);
  background: transparent;
  color: #dfe8fb;
  font: 800 12.5px/1 'Segoe UI', system-ui, sans-serif;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}
.tm-back:hover, .tm-callsign:hover, .tm-pill:hover,
.tm-back:focus-visible, .tm-callsign:focus-visible, .tm-pill:focus-visible,
.tm-back.gp-focus, .tm-callsign.gp-focus, .tm-pill.gp-focus { border-color: #00f3ff; background: rgba(0, 243, 255, 0.1); outline: none; }
.tm-back:active, .tm-callsign:active, .tm-pill:active { transform: scale(0.96); }
.tm-key { color: var(--tm-dim); font-weight: 700; letter-spacing: 0; }
.tm-callsign { border-color: rgba(0, 243, 255, 0.45); }
.tm-callsign small { color: var(--tm-dim); font-size: 10px; }
.tm-cores-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: rgba(181, 101, 255, 0.12);
  border: 1px solid rgba(181, 101, 255, 0.5);
  font: 800 16px/1 'Segoe UI', system-ui, sans-serif;
}
.tm-cores-pill small { color: #b9a6dc; font-size: 10.5px; letter-spacing: 2px; }
.tm-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(0, 243, 255, 0.4) transparent; padding-right: 6px; }
.tm-sub > .tm-scroll { grid-row: 2 / -1; }

/* Armory page: the shared armory renderer (Game.renderArmory), laid out as big cards. */
#title-modal #armory-grid {
  grid-auto-rows: max-content;
  grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
  gap: 16px;
  max-height: none;
  min-height: 0;
  align-content: start;
  padding-bottom: 12px;
}
#title-modal .armory-tabs { gap: 8px; padding: 2px 0 10px; background: transparent; position: static; }
#title-modal .armory-tab {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border-color: rgba(238, 246, 255, 0.18);
  background: rgba(10, 4, 24, 0.6);
  color: #cfdaf0;
  font-size: 11.5px;
  letter-spacing: 2px;
}
#title-modal .armory-tab.active { border-color: #00f3ff; background: rgba(0, 243, 255, 0.16); color: #fff; }
#title-modal .armory-tab:hover, #title-modal .armory-tab.gp-focus { border-color: #00f3ff; }
#title-modal .armory-progress { min-height: 36px; display: inline-flex; align-items: center; padding: 0 14px; border: 1px solid rgba(0, 255, 136, 0.4); border-radius: 999px; font-size: 11px; letter-spacing: 2px; color: #7dffc0; }
#title-modal .armory-refund-btn { min-height: 40px; padding: 0 14px; border-radius: 999px; font-size: 11px; letter-spacing: 2px; }
#title-modal .armory-early { font-size: 12px; color: var(--tm-dim); }
#title-modal .armory-card {
  min-height: 210px;
  padding: 18px;
  gap: 8px;
  border-radius: 18px;
  background: rgba(8, 12, 28, 0.78);
  border: 1px solid rgba(238, 246, 255, 0.14);
}
#title-modal .armory-card.affordable { border-color: rgba(181, 101, 255, 0.6); }
#title-modal .armory-card.affordable:hover, #title-modal .armory-card:has(.gp-focus) { border-color: #fff; transform: translateY(-3px); box-shadow: none; }
#title-modal .armory-name { font-size: 16px; line-height: 1.2; }
#title-modal .armory-rank { font-size: 11px; font-family: var(--tm-mono); }
#title-modal .armory-desc { font-size: 13px; color: #b8c6e0; }
#title-modal .armory-value { font-size: 13px; }
#title-modal .armory-bar { height: 6px; border-radius: 3px; }
#title-modal .armory-buy-btn { min-height: 44px; border-radius: 12px; font-size: 14px; }

/* Leaderboard page */
.tm-board-bar { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; }
#title-modal .board-tabs { padding: 4px; border-radius: 26px; background: rgba(238, 246, 255, 0.06); gap: 6px; }
#title-modal .board-tab { min-height: 40px; padding: 0 20px; border-radius: 22px; font-size: 12px; letter-spacing: 2px; }
#title-modal .board-versions { margin: 0; gap: 6px; }
#title-modal .board-versions button { min-height: 40px; padding: 0 14px; border-radius: 22px; font-size: 11.5px; }
#title-modal .board-status { margin: 0; justify-content: flex-start; gap: 12px; }
#title-modal .board-note { font-size: 12px; }
#title-modal #highscore-list {
  max-height: none;
  min-height: 0;
  height: 100%;
  border-radius: 18px;
  background: rgba(8, 12, 28, 0.78);
  border: 1px solid rgba(255, 204, 0, 0.22);
  padding: 0 14px 10px; /* no top padding: the pinned column head sits flush with the panel's top */
}
#title-modal .hs-row { font-size: 15px; min-height: 44px; }

/* Settings page */
.tm-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  align-content: start;
  padding-bottom: 12px;
}
.tm-card {
  --cc: #00f3ff;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 22px;
  border-radius: 18px;
  background: rgba(8, 12, 28, 0.78);
  border: 1px solid color-mix(in srgb, var(--cc) 28%, transparent);
  min-width: 0;
}
.tm-card-gold { --cc: #ffcc00; }
.tm-card-blue { --cc: #5aa8ff; }
.tm-card-violet { --cc: #c79bff; }
.tm-card h3 { margin: 0; font: 900 14px/1 'Segoe UI', system-ui, sans-serif; letter-spacing: 4px; color: var(--cc); }
.tm-card p { margin: 0; font-size: 13.5px; line-height: 1.45; color: #b8c6e0; }
.tm-card .name-entry-bar { margin: 0; justify-content: flex-start; }
.tm-card .name-input { min-height: 44px; }
.tm-card .consent-row { margin: 0; flex-direction: column; align-items: stretch; gap: 8px; }
.tm-card .consent-check { min-height: 44px; display: flex; align-items: center; gap: 10px; font-size: 14px; text-align: left; }
.tm-card .consent-check input { width: 20px; height: 20px; flex: none; accent-color: #ffcc00; }
.tm-slider-row { display: grid !important; grid-template-columns: 86px minmax(0, 1fr) 52px; gap: 12px; align-items: center; margin: 0 !important; width: 100%; padding: 0 !important; border: 0 !important; background: none !important; box-shadow: none !important; }
.tm-slider-row input[type="range"] { width: 100%; min-height: 36px; accent-color: #00f3ff; }
.tm-slider-name { font: 800 12px/1 'Segoe UI', system-ui, sans-serif; letter-spacing: 2px; color: #cfdaf0; }
.tm-slider-row > span:last-child { font-family: var(--tm-mono); color: #00ff88; text-align: right; }
.tm-pill-row { display: flex; gap: 10px; flex-wrap: wrap; }
.tm-pill { align-self: flex-start; }
.tm-controls { grid-column: 1 / -1; }
.controls-list { margin: 0; display: grid; grid-template-columns: minmax(130px, max-content) minmax(0, 1fr); gap: 8px 18px; font-size: 14px; }
.controls-list dt { font: 900 13px/1.4 'Segoe UI', system-ui, sans-serif; color: #fff; letter-spacing: 0.5px; }
.controls-list dd { margin: 0; color: #b8c6e0; line-height: 1.4; }

#title-modal .cloud-callout { grid-column: 1 / -1; position: relative; z-index: 2; margin: 0 auto 8px; max-width: 900px; }

/* ---------- Short screens (phone landscape) ---------- */
@media (max-height: 560px) {
  .tm-ui { padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)); }
  .tm-top { min-height: 44px; }
  .tm-nav { font-size: 11.5px; padding: 0 10px; letter-spacing: 1.2px; }
  .tm-mark { width: 24px; height: 24px; }
  .tm-home { row-gap: 8px; column-gap: 16px; padding: 0; grid-template-rows: minmax(54px, 1fr) auto auto auto; grid-template-areas: "logo ship" "prompt prompt" "tiles tiles" "modes modes"; }
  .tm-logo .tm-chrome { font-size: min(var(--tm-logo-fit, 15.5cqi), 17vh, 120px); }
  .tm-prompt { font-size: 11px; letter-spacing: 2px; }
  .tm-hint { display: none; }
  .tm-modes { gap: 10px; }
  .tm-mode { min-height: clamp(104px, 31vh, 170px); padding: 10px 14px; gap: 2px; border-radius: 16px; }
  .tm-mode-name { font-size: clamp(20px, 3vw, 30px); }
  .tm-mode-glyph { width: 24px; height: 24px; }
  .tm-mode-blurb { display: none; }
  .tm-mode-go { display: none; }
  .tm-mode-best small { font-size: 9px; }
  .tm-mode-best b { font-size: 16px; }
  .tm-mode-last { top: auto; bottom: 10px; right: 12px; font-size: 9px; padding: 3px 7px; }
  .tm-mode:hover, .tm-mode:focus-visible, .tm-mode.gp-focus { transform: translateY(-3px); }
  .tm-tiles { gap: 10px; }
  .tm-tile { min-height: 50px; padding: 4px 12px 4px 8px; column-gap: 10px; border-radius: 12px; }
  .tm-tile-ico { width: 36px; height: 36px; border-radius: 9px; }
  .tm-tile-ico svg { width: 20px; height: 20px; }
  .tm-tile-name { font-size: 13px; }
  .tm-tile-line { font-size: 11.5px; }
  .tm-tile-stat { gap: 2px; }
  .tm-tile-stat b { font-size: 14px; }
  .tm-tile-sub, .tm-ready { font-size: 9px; }
  .tm-tile-arrow { font-size: 18px; }
  .tm-rail { width: 70px; margin: 8px 12px 0 0; padding: 6px 4px; gap: 4px; }
  .tm-rail button { min-height: 46px; gap: 4px; font-size: 9px; letter-spacing: 1px; }
  .tm-rail-ico { font-size: 14px; }
  .tm-sub { gap: 10px; padding-top: 4px; }
  .tm-head { gap: 10px; }
  .tm-title { font-size: 26px; }
  .tm-sub-line { font-size: 12px; }
  .tm-sub-line { display: none; }
  .tm-cores-pill, .tm-callsign { min-height: 40px; font-size: 13px; }
  #title-modal .armory-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; min-height: max-content; }
  #title-modal .armory-tab, #title-modal .armory-refund-btn { min-height: 36px; flex: none; }
  #title-modal .armory-progress { flex: none; min-height: 32px; }
  #title-modal #armory-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
  #title-modal .armory-card { min-height: 160px; padding: 12px; }
}
@media (min-height: 400px) and (max-height: 560px) and (min-width: 900px) {
  .tm-mode-blurb { display: block; font-size: 11.5px; line-height: 1.3; }
}

/* ---------- Narrow portrait screens ---------- */
@media (max-width: 700px) and (min-height: 561px) {
  .tm-ui { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "rail" "view"; }
  .tm-top { flex-wrap: wrap; row-gap: 0; }
  #title-modal .version-tag { display: none; }
  .tm-top > .tm-icon, .tm-top > .tm-vol-wrap { order: 1; }
  .tm-top > .tm-icon.tm-fs { margin-left: auto; }
  .tm-spacer { order: 2; flex-basis: 100%; height: 0; }
  .tm-top > #btn-title-unlocks, .tm-top > #btn-title-guide, .tm-top > .tm-range { order: 3; }
  .tm-nav { font-size: 11px; padding: 0 8px; letter-spacing: 1px; }
  .tm-home { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(90px, 1fr) auto auto auto; grid-template-areas: "logo" "ship" "prompt" "modes" "tiles"; padding: 0 0 4px; row-gap: 10px; overflow-y: auto; overscroll-behavior: contain; }
  .tm-logo .tm-chrome { font-size: min(var(--tm-logo-fit, 15.5cqi), 12vh, 110px); }
  .tm-hint { display: none; }
  .tm-modes { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .tm-mode { min-height: 74px; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; padding: 10px 16px; }
  .tm-mode-head { grid-column: 1; }
  .tm-mode-tag { grid-column: 1; }
  .tm-mode-blurb, .tm-mode-go { display: none; }
  .tm-mode-foot { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .tm-mode-last { top: 8px; right: 10px; font-size: 9px; padding: 2px 6px; }
  .tm-mode-name { font-size: 24px; }
  .tm-tiles { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .tm-tile { min-height: 64px; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "ico text arrow" "ico stat arrow"; row-gap: 4px; padding: 8px 14px 8px 10px; }
  .tm-tile-ico { grid-area: ico; width: 42px; height: 42px; }
  .tm-tile-text { grid-area: text; }
  .tm-tile-stat { grid-area: stat; display: flex; justify-items: start; align-items: center; gap: 8px; }
  .tm-tile-stat b { font-size: 14px; }
  .tm-tile-arrow { grid-area: arrow; }
  .tm-tile-name { font-size: 14px; }
  .tm-tile-line { font-size: 12.5px; white-space: normal; }
  .tm-rail { flex-direction: row; width: auto; margin: 4px 0; padding: 4px; overflow-x: auto; }
  .tm-rail button { flex: 1 0 64px; min-height: 52px; font-size: 9px; }
  .tm-settings { grid-template-columns: minmax(0, 1fr); }
  .tm-sub { gap: 10px; padding-top: 4px; }
  .tm-sub-line { display: none; }
  .tm-head { gap: 10px; }
  .tm-head-text { min-width: 0; }
  .tm-title { font-size: 26px; }
  .tm-back { padding: 0 14px; }
  .tm-board-bar { gap: 8px 12px; }
}

/* ---------- Narrow screens (small phones, either way up) ---------- */
@media (max-width: 760px) {
  .tm-wide { display: none; }
  #title-modal .version-tag { display: none; }
  .tm-nav { padding: 0 8px; letter-spacing: 1px; }
  .tm-mode { container-type: inline-size; }
  .tm-mode-name { font-size: clamp(16px, 12cqi, 28px); }
  .tm-mode-tag { letter-spacing: 1.2px; }
  .tm-tile-ico { display: none; }
  .tm-tile { grid-template-columns: minmax(0, 1fr) auto auto; }
  .tm-tile-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; letter-spacing: 1px; }
  .tm-tile { column-gap: 8px; padding-right: 10px; }
}
@media (max-width: 640px) and (max-height: 560px) {
  .tm-tile-board .tm-tile-sub { display: none; }
}
@media (max-width: 700px) and (min-height: 561px) {
  .tm-tile-ico { display: grid; }
  .tm-tile { grid-template-columns: auto minmax(0, 1fr) auto; }
}

@media (prefers-reduced-motion: reduce) {
  .tm-cur { animation: none; }
  .tm-view.tm-enter { animation: none; }
  .tm-mode, .tm-mode-go, .tm-tile { transition: none; }
  .tm-ship.tm-ship-launch { animation: none; }
}

/* BETA: a small chrome-edged chip under the end of the wordmark (it adds no width, so fitWordmark is
   unchanged and it can never push the wordmark off its cell), and a tiny one in the version pill. */
.tm-word { display: inline-grid; justify-items: end; max-width: 100%; }
.tm-word .tm-chrome { justify-self: start; }
.tm-beta {
  margin-top: -0.2em;
  margin-right: 0.35em;
  padding: 4px 12px 4px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: linear-gradient(rgba(12, 0, 32, 0.92), rgba(12, 0, 32, 0.92)) padding-box, var(--tm-chrome) border-box;
  color: #ffe3f4;
  font: 900 clamp(10px, 0.9vw, 14px)/1 var(--tm-mono);
  letter-spacing: 0.45em;
  text-shadow: 0 0 8px rgba(255, 42, 138, 0.9);
  box-shadow: 0 0 14px rgba(255, 42, 138, 0.25);
  white-space: nowrap;
}
#title-modal .version-pill { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--tm-line); border-radius: 999px; margin-right: 4px; }
#title-modal .version-pill .version-tag { border: 0; margin: 0; padding-right: 6px; }
.beta-mini { font: 900 9.5px/1 var(--tm-mono); letter-spacing: 1.5px; color: #07020f; background: #ff2a8a; border-radius: 999px; padding: 3px 7px; margin-right: 4px; }
.tm-feedback { color: #ffd1e6; }
@media (max-height: 560px) {
  .tm-beta { font-size: 9px; padding: 3px 9px; margin-top: -0.15em; }
}
@media (max-width: 760px) {
  #title-modal .version-pill { display: none; }
}
/* Mid-width (small laptops, phone landscape): the top bar keeps every button, so the longer extras step
   aside: FEEDBACK shows as its icon and the version pill leaves (BETA stays by the wordmark). */
@media (max-width: 1000px) {
  .tm-feedback .tm-wide { display: none; }
}
@media (max-width: 900px) {
  #title-modal .version-pill { display: none; }
}
/* Narrow cards: the LAST PLAYED chip would sit on the best score. */
@media (max-width: 640px) and (max-height: 560px) {
  .tm-mode-last { display: none; }
}
