/* Menu UI: blue-night base, one ember accent for primary actions, level (sky blue) and rarity colours.
   Game canvas/HUD styles live with the game. Every colour the menus use is a token below: tune the palette here. */
:root {
  /* base: deep night slate, lightest at the panels */
  --bg: #070b14;
  --bg-2: #0b1220;
  --panel: #0e1626;
  --panel-2: #152034;
  --panel-3: #1b2940;          /* hovered secondary buttons, selected tiles */
  --panel-glass: rgba(13, 20, 34, 0.88);
  --field-bg: #0a111e;         /* inputs, stat tiles, wells */
  --line: #233250;
  --line-2: #34486b;
  --line-3: #4a6290;           /* hovered borders */
  --text: #ecf1fa;
  --text-strong: #ffffff;
  --muted: #a3b2c9;
  --dim: #8796b0;              /* 5:1 on --panel */

  /* the one accent: ember orange, for primary actions only */
  --accent: #ff7a2e;
  --accent-2: #ffa05a;
  --accent-3: #ffc08a;         /* light end of gradients, link text */
  --accent-ink: #1c0c02;       /* text on the accent */
  --accent-glow: rgba(255, 122, 46, 0.45);
  --accent-soft: rgba(255, 122, 46, 0.14);

  /* progression: level / experience */
  --level: #4cc7ff;
  --level-2: #7c8dff;
  --level-glow: rgba(76, 199, 255, 0.35);

  /* attributes (lobby tiles) */
  --attr-strength: #ff7466;
  --attr-agility: #5ed493;
  --attr-dexterity: #ffcf5a;
  --attr-constitution: #6aaeff;

  /* rarity (matches shared/unlocks.js RARITY_COLOR) */
  --rarity-common: #b8c0c8;
  --rarity-uncommon: #5fbf5a;
  --rarity-rare: #4c9be0;
  --rarity-epic: #a855f7;
  --rarity-legendary: #f2a33d;

  --moss: #5ed493;             /* success green (loading dots, legacy name) */
  --ok: #5ed493;
  --warn: #ffcf5a;
  --danger: #ff6b6b;
  --focus: #9fd8ff;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 255, 255, 0.04) inset;

  /* type: condensed display face for titles and numbers, a neutral sans for body text */
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Oswald", "Bahnschrift", "DIN Condensed", "Arial Narrow", "Roboto Condensed", var(--font);

  /* the menu backdrop: the key art recoloured to blue night (the colour layer keeps its light and silhouettes),
     a cool sky glow, a low ember glow, and a scrim that is darkest where text sits */
  --scene-layers:
    linear-gradient(180deg, rgba(5, 9, 18, 0.30) 0%, rgba(5, 9, 18, 0.58) 42%, rgba(4, 7, 14, 0.94) 100%),
    radial-gradient(55% 45% at 82% -5%, rgba(76, 199, 255, 0.22), transparent 70%),
    radial-gradient(50% 40% at 18% 85%, rgba(255, 122, 46, 0.16), transparent 70%),
    linear-gradient(180deg, #2a4f8f 0%, #22406f 45%, #101c33 100%),
    url("/b/918dca705fdb1ea2/assets/brand/key_art_1920x1080.jpg") center / cover no-repeat,
    var(--bg);
  --scene-blend: normal, screen, screen, color, normal, normal;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(76, 199, 255, 0.10), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(255, 122, 46, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 60%);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* While playing, the game owns the viewport. */
body.is-playing { overflow: hidden; background: #000; }
#game-root { position: fixed; inset: 0; display: none; }
body.is-playing #game-root { display: block; }
#game-root canvas { display: block; width: 100%; height: 100%; }
body.is-playing #app { position: fixed; inset: 0; }
body.is-playing #app:empty { pointer-events: none; }

.noscript { padding: 24px; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Layout */
.screen { min-height: 100vh; min-height: 100dvh; padding: 24px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; align-items: center; gap: 20px; }
.screen-center { justify-content: center; }
.topbar { width: 100%; max-width: 1040px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar-user { color: var(--muted); font-weight: 600; }
.topbar-user-link { text-decoration: none; }
.topbar-user-link:hover, .topbar-user-link:focus-visible { text-decoration: underline; text-underline-offset: 3px; }

/* Brand header. .brand-logo is a crop window over the wordmark PNG (1024x341; bow emblem + "BOW DOWN" at
   x76-947, y77-220, "SURVIVAL ARCHERY" + arrow strapline below at y229-258). Crops are padded 2px: x74-949.
   The compact header crops the strapline (y75-222), which is unreadable at topbar size; the hero shows the
   full lockup (y75-260). left/width are % of the crop box width (width = 1024/875). The compact image is
   centred vertically (crop centre y148.5 = 43.55% of the PNG), so if the topbar caps the box width on a
   narrow phone (the ~180px of topbar actions + gaps, so they don't wrap) the logo scales down instead of
   clipping; clip-path cuts the PNG at y226 so the strapline never peeks in below. */
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { display: block; position: relative; overflow: hidden; height: 44px; aspect-ratio: 875 / 147; flex: none; }
.brand-logo-img { position: absolute; left: -8.457%; top: 50%; transform: translateY(-43.55%); clip-path: inset(0 0 33.6% 0); width: 117.03%; height: auto; max-width: none; display: block; }
.topbar .brand-logo { max-width: calc(100vw - 224px); }
.brand-hero .brand-logo { height: auto; width: min(340px, 100%); aspect-ratio: 875 / 185; }
.brand-hero .brand-logo-img { top: -40.54%; transform: none; clip-path: none; }
.brand-fallback { display: none; align-items: center; gap: 10px; }
.brand-noimg .brand-logo { display: none; }
.brand-noimg .brand-fallback { display: inline-flex; }
.brand-hero { display: flex; filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.55)); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 6px; flex: none;
  background: var(--panel-2) url("/b/918dca705fdb1ea2/assets/brand/logo_icon_light.svg") center/86% no-repeat;
  border: 1px solid var(--line);
}
.brand-name { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; font-size: 18px; color: var(--text-strong); }
.topbar .brand { filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6)); }

/* Menu backdrop: a fixed layer (not background-attachment: fixed, which iOS ignores). */
.screen-auth, .screen-lobby, .screen-customise, .screen-center { position: relative; isolation: isolate; }
.screen-auth::before, .screen-lobby::before, .screen-customise::before, .screen-center::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background: var(--scene-layers);
  background-blend-mode: var(--scene-blend);
}
.screen-customise::before { /* cards cover most of the art here: dim it a little more */
  filter: brightness(0.82);
}
.screen-auth .tagline, .screen-auth .hero-points { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); }
.screen-auth .hero-points { color: #c9d4e6; }
.screen-lobby .topbar-user, .screen-customise .topbar-user, .topbar .btn-ghost { color: #c9d4e6; }
.topbar .btn-ghost:hover { color: var(--text); }

.card {
  width: 100%; max-width: 440px;
  background: linear-gradient(180deg, rgba(21, 32, 52, 0.94), rgba(12, 19, 33, 0.95));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  position: relative;
}
.card::before { /* lit top edge */
  content: ""; position: absolute; left: 16px; right: 16px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(159, 216, 255, 0.55), transparent); opacity: 0.8;
}
.card-title { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 22px; margin: 0 0 16px; }
.section-title { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.12em; font-size: 13px; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 0.16em; font-size: 12px; font-weight: 600; color: var(--dim); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Auth */
.screen-auth { justify-content: center; flex-direction: row; flex-wrap: wrap; gap: 40px; }
.auth-hero { max-width: 380px; }
.auth-hero .brand-name { font-size: 26px; }
.auth-hero .brand-mark { width: 40px; height: 40px; }
.auth-hero .tagline { margin-top: 14px; }
.tagline { font-size: 20px; line-height: 1.35; margin: 18px 0 14px; color: var(--text); font-family: var(--font-display); letter-spacing: 0.02em; }
.hero-points { list-style: none; padding: 0; margin: 0; color: var(--muted); }
.hero-points li { padding-left: 18px; position: relative; margin: 6px 0; }
.hero-points li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 8px; height: 2px; background: var(--accent); }

.tabs { display: flex; gap: 4px; margin: -8px 0 18px; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; background: none; border: 0; color: var(--muted); padding: 10px 8px; cursor: pointer;
  font: 600 13px var(--font); text-transform: uppercase; letter-spacing: 0.1em; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.auth-card .card-title { display: none; } /* tabs act as the title on login/register */
.auth-card:not(:has(.tabs)) .card-title { display: block; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: 0.02em; }
.field input {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--text);
  background: var(--field-bg); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field input:hover { border-color: var(--line-3); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.has-error input { border-color: var(--danger); }
.field-hint { margin: 0; font-size: 12px; color: var(--dim); }
.field-error { margin: 0; font-size: 13px; color: var(--danger); min-height: 0; }
.field-error:empty { display: none; }
.form-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.banner { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid; margin: 0 0 14px; }
.banner-error { background: rgba(255, 107, 107, 0.10); border-color: rgba(255, 107, 107, 0.5); color: #ffc2c2; }
.banner-ok { background: rgba(94, 212, 147, 0.10); border-color: rgba(94, 212, 147, 0.5); color: #c4f0d6; }
.banner-info { background: rgba(76, 199, 255, 0.08); border-color: rgba(76, 199, 255, 0.4); color: #cdeeff; }
/* app.js signOutFailed(): the error and its Retry, under the lobby's top bar or in the holding screen's card */
.screen-alert { width: 100%; max-width: 1280px; }
.screen-alert:empty { display: none; }
.screen-alert .banner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin: 0; }
.card .screen-alert { margin-top: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; min-height: 42px; font: 600 14px var(--font); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.06s;
}
.btn:hover { background: var(--panel-3); border-color: var(--line-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-ink); border-color: #e5621a; }
.btn-primary:hover { background: linear-gradient(180deg, var(--accent-3), var(--accent-2)); border-color: var(--accent); box-shadow: 0 0 18px var(--accent-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); border-color: var(--line); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 4px; }
.link { background: none; border: 0; padding: 2px 0; color: var(--accent-3); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(255, 192, 138, 0.4); }
.link:hover { text-decoration-color: currentColor; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.field input:focus-visible { outline: none; }

/* Preview */
.preview {
  position: relative; width: 100%; aspect-ratio: 3 / 4; min-height: 260px;
  background:
    radial-gradient(60% 45% at 50% 82%, rgba(76, 199, 255, 0.16), transparent 70%),
    radial-gradient(80% 60% at 50% 30%, rgba(124, 141, 255, 0.10), transparent 70%),
    linear-gradient(180deg, #111c30, #0a111e);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.preview-stage { position: absolute; inset: 0; }
.preview-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.preview-stage canvas:active { cursor: grabbing; }
.preview-placeholder { width: 100%; height: 100%; padding: 8% 20%; }

/* Customise */
.customise-card { max-width: 900px; }
.customise-head .card-title { margin-bottom: 4px; }
.customise-head p { margin: 0 0 18px; }
.customise-body { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 24px; align-items: start; }
.customise-form { display: flex; flex-direction: column; gap: 18px; }
.chips { border: 0; padding: 0; margin: 0; min-width: 0; }
.chips legend { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.12em; font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 8px; font-weight: 600; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.chip-input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.chip-label {
  padding: 8px 14px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--field-bg);
  font-size: 14px; font-weight: 600; color: var(--muted); transition: all 0.12s; user-select: none;
}
.chip:hover .chip-label { color: var(--text); border-color: var(--line-3); }
.chip-input:checked + .chip-label, .chip-input:checked + .swatch + .chip-label { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.chip-input:focus-visible ~ .chip-label, .chip-input:focus-visible ~ .swatch { outline: 2px solid var(--focus); outline-offset: 2px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, 0.5); box-shadow: 0 0 0 1px var(--line-2); transition: box-shadow 0.12s, transform 0.12s; }
.chip:hover .swatch { transform: scale(1.06); }
.chip-input:checked + .swatch { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.customise-form .banner { margin: 0; }
.customise-form { min-width: 0; }
.chips[hidden] { display: none; }
.btn[hidden] { display: none; }
a.btn { text-decoration: none; }
.chips-note { margin: -2px 0 8px; }
/* Body / Face / Gear tabs (customise.js createTabs) */
.customise-tabset { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.customise-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.customise-tab {
  flex: 1 1 0; min-width: 0; background: none; border: 0; color: var(--muted); padding: 10px 6px; cursor: pointer;
  font: 600 13px var(--font); text-transform: uppercase; letter-spacing: 0.1em; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.customise-tab:hover { color: var(--text); }
.customise-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.customise-panel { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.customise-panel[hidden] { display: none; }

kbd { font: 600 12px var(--font); background: var(--field-bg); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 3px; padding: 1px 6px; color: var(--text); }

.preview-col { display: flex; flex-direction: column; gap: 10px; }
.toggle { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.toggle-input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.toggle label { cursor: pointer; }

.preview-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.gender-pick { border: 0; margin: 0; padding: 0; min-width: 0; }
.gender-row { display: flex; gap: 6px; }
.gender-sym { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line-2); background: var(--field-bg); color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s; }
.gender-sym .chip-input { position: absolute; opacity: 0; pointer-events: none; }
.gender-sym:hover { color: var(--text); border-color: var(--accent); }
.gender-sym:has(.chip-input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.gender-sym:has(.chip-input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.gender-sym[hidden] { display: none; }
.gender-alien { font-size: 16px; color: #a855f7; }
.gender-alien:has(.chip-input:checked) { background: rgba(6, 182, 212, 0.22); border-color: #22d3ee; color: #a5f3fc; box-shadow: 0 0 10px rgba(34, 211, 238, 0.4); }

/* Picture-only chips (hair styles) */
.chip-tile { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--field-bg); transition: border-color 0.12s, background 0.12s; }
.chip-tile img { width: 56px; height: 56px; object-fit: contain; }
.chip:hover .chip-tile { border-color: var(--line-3); }
.chip-input:checked + .chip-tile { border-color: var(--accent); background: var(--panel-3); box-shadow: 0 0 0 1px var(--accent); }
.chip-input:focus-visible ~ .chip-tile { outline: 2px solid var(--focus); outline-offset: 2px; }
.chips-note-preview { display: flex; align-items: center; gap: 12px; margin: 4px 0 10px; }

/* =====================================================================================================================
   Lobby (lobby.js)
   Layout: hero column (identity, account call to action, character stage, crates) beside the main column (play,
   profile, record). On phones the two columns dissolve into one stack ordered identity > account > play > stage.
   ================================================================================================================== */
.screen-lobby { padding: 20px max(24px, env(safe-area-inset-right)) 48px max(24px, env(safe-area-inset-left)); gap: 18px; }
.screen-lobby .topbar { max-width: 1280px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* drifting embers over the backdrop: a dozen composited dots, transform/opacity only */
.lobby-fx { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.lobby-fx::after { /* vignette */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(2, 4, 10, 0.65) 100%);
}
.ember {
  position: absolute; bottom: -12px; left: var(--x); width: var(--s); height: var(--s); border-radius: 50%;
  background: radial-gradient(circle, #ffe2b8 0%, var(--accent) 45%, transparent 72%);
  opacity: 0; will-change: transform, opacity;
  animation: ember-rise var(--d) linear var(--delay) infinite;
}
.ember.is-cool { background: radial-gradient(circle, #e6f7ff 0%, var(--level) 45%, transparent 72%); }
@keyframes ember-rise {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  12% { opacity: var(--o, 0.8); }
  70% { opacity: calc(var(--o, 0.8) * 0.6); }
  100% { transform: translate3d(var(--dx), -100vh, 0); opacity: 0; }
}

.lobby-layout {
  width: 100%; max-width: 1280px; display: grid; gap: 20px; align-items: start;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
}
.lobby-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.lobby-main-cards { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }

/* lobby panels: near-opaque (no backdrop blur: the embers move behind them and a blur would re-run every frame) */
.panel {
  position: relative; min-width: 0; padding: 20px;
  background: linear-gradient(180deg, rgba(22, 33, 54, 0.92), rgba(11, 18, 32, 0.94));
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.panel::before { /* lit top edge */
  content: ""; position: absolute; left: 18px; right: 18px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(159, 216, 255, 0.5), transparent);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin: 0 0 14px; }
.panel-title { margin: 0; font-family: var(--font-display); font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em; font-size: 14px; color: var(--muted); }

/* identity: who is signed in */
.lobby-identity-card { padding: 18px 20px; }
.lobby-identity { display: flex; align-items: center; gap: 14px; margin: 8px 0 0; min-width: 0; }
.lobby-identity .player-name { margin: 0; min-width: 0; }
.lobby-portrait { flex: none; display: inline-flex; border-radius: 50%; box-shadow: 0 0 0 2px var(--line-2), 0 0 22px rgba(76, 199, 255, 0.18); }
.player-name {
  font-family: var(--font-display); font-size: clamp(28px, 3.2vw, 40px); font-weight: 700; line-height: 1.05;
  margin: 2px 0 16px; letter-spacing: 0.03em; overflow-wrap: anywhere; color: var(--text-strong);
}
.player-name .name-title { display: block; font-size: 0.46em; letter-spacing: 0.06em; margin-top: 4px; }
.identity-level { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.identity-level b { font-family: var(--font-display); font-size: 15px; letter-spacing: 0.04em; color: var(--level); }

/* character stage: the 3D preview stands on a lit floor, framed lightly so it reads as part of the scene */
.screen-lobby .lobby-stage { padding: 0; overflow: hidden; }
.lobby-stage .preview {
  border: 0; border-radius: 0; aspect-ratio: 4 / 5; min-height: 0;
  background:
    radial-gradient(42% 14% at 50% 84%, rgba(76, 199, 255, 0.30), transparent 70%),
    radial-gradient(70% 55% at 50% 40%, rgba(124, 141, 255, 0.16), transparent 70%),
    linear-gradient(180deg, rgba(20, 34, 58, 0.6), rgba(8, 13, 24, 0.9));
}
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); background: rgba(8, 13, 24, 0.6); }
.stage-hint { margin: 0; font-size: 12px; color: var(--dim); }
.lobby-customise { flex: none; }

/* play: the one big action */
.play-card {
  padding: 22px;
  background:
    radial-gradient(80% 120% at 0% 0%, rgba(255, 122, 46, 0.12), transparent 60%),
    linear-gradient(180deg, rgba(24, 36, 60, 0.94), rgba(11, 18, 32, 0.95));
  border-color: #2e4166;
}
.play-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap; margin-bottom: 14px; }
.play-kicker { margin: 0; display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ok); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: live-pulse 2s ease-out infinite; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(94, 212, 147, 0.6); } 70%, 100% { box-shadow: 0 0 0 8px rgba(94, 212, 147, 0); } }
.play-map { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-strong); }
.play-map .muted { font-family: var(--font); font-size: 13px; font-weight: 400; letter-spacing: 0; text-transform: none; margin-right: 6px; }
.play-row { display: flex; align-items: stretch; gap: 14px; flex-wrap: wrap; }
.play-card .banner { margin: 0 0 14px; }

.btn-play {
  position: relative; overflow: hidden; flex: 1 1 260px; min-width: 0; min-height: 76px; padding: 12px 28px;
  justify-content: space-between; gap: 16px;
  font: 700 30px/1 var(--font-display); letter-spacing: 0.22em; color: var(--accent-ink);
  background: linear-gradient(180deg, #ffb070 0%, var(--accent-2) 30%, var(--accent) 100%);
  border: 0; border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(255, 190, 140, 0.5) inset, 0 -3px 0 rgba(120, 40, 0, 0.35) inset, 0 10px 30px var(--accent-glow);
  transition: transform 0.12s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.btn-play::before { /* sheen that sweeps across on hover */
  content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 30%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: skewX(-18deg) translateX(-120%); transition: transform 0.6s ease;
}
.btn-play:hover {
  background: linear-gradient(180deg, #ffc08a 0%, #ffad6b 30%, #ff8840 100%);
  box-shadow: 0 0 0 1px rgba(255, 210, 170, 0.7) inset, 0 -3px 0 rgba(120, 40, 0, 0.35) inset, 0 14px 40px rgba(255, 122, 46, 0.6);
  transform: translateY(-2px);
}
.btn-play:hover::before { transform: skewX(-18deg) translateX(560%); }
.btn-play:active { transform: translateY(1px) scale(0.99); box-shadow: 0 0 0 1px rgba(255, 190, 140, 0.5) inset, 0 2px 0 rgba(120, 40, 0, 0.35) inset, 0 4px 14px var(--accent-glow); }
.btn-play:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.btn-play:disabled { opacity: 1; filter: saturate(0.6) brightness(0.85); transform: none; cursor: progress; }
.btn-play-label { position: relative; padding-left: 0.22em; }
.btn-play-icon { position: relative; flex: none; width: 34px; height: 34px; transition: transform 0.18s ease; }
.btn-play:hover .btn-play-icon { transform: translateX(4px); }
.btn-play:disabled .btn-play-icon { display: none; }

/* server + ping beside Play (single server: lobby.js; several: ui/servers.js picker below the row) */
.server-chip {
  flex: 0 1 220px; min-width: 0; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; column-gap: 10px; row-gap: 2px;
  align-content: center; padding: 10px 14px; border-radius: 12px; background: var(--field-bg); border: 1px solid var(--line);
}
.server-chip[hidden] { display: none; }
.server-chip-label { grid-column: 1 / -1; font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.server-chip-name { grid-column: 1 / -1; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-chip-meta { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ping { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.ping::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ping-good { color: var(--ok); } .ping-mid { color: var(--warn); } .ping-bad { color: var(--danger); } .ping-unknown { color: var(--dim); }
.screen-lobby .server-box { margin-top: 14px; }
.screen-lobby .server-box[hidden] { display: none; }
.screen-lobby .server-box .server-picker { margin: 0; background: var(--field-bg); border-color: var(--line); border-radius: 12px; }
.screen-lobby .server-box .sp-good { color: var(--ok); }
.screen-lobby .server-box .sp-mid { color: var(--warn); }

/* account call to action slot (guest accounts module mounts into it; empty = no space taken) */
.account-slot:empty { display: none; }
.account-slot {
  position: relative; padding: 18px 20px; border-radius: var(--radius-lg);
  background:
    radial-gradient(90% 140% at 100% 0%, rgba(255, 122, 46, 0.16), transparent 60%),
    linear-gradient(180deg, rgba(30, 40, 64, 0.95), rgba(14, 22, 38, 0.96));
  border: 1px solid rgba(255, 160, 90, 0.38);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 122, 46, 0.08);
}
.account-slot > .card, .account-slot > .panel { max-width: none; padding: 0; background: none; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.account-slot > .card::before, .account-slot > .panel::before { display: none; }
.account-slot :is(h2, h3, .card-title) { margin: 0 0 6px; font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-strong); }
.account-slot p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.account-slot .btn-primary { min-height: 44px; }
.account-slot .form { margin-top: 10px; }
/* ui/guest.js bar inside the slot: the slot is the card, so the bar drops its own frame */
.account-slot > .gb-bar { margin: 0; padding: 0; border: 0; background: none; gap: 12px 16px; }
.account-slot > .gb-bar + .gb-bar { margin-top: 12px; }
.account-slot .gb-bar-text { font-size: 15px; color: var(--text); }
.account-slot .gb-bar-text b { color: var(--accent-3); }
.account-slot .gb-bar-actions .btn-primary { min-height: 40px; padding: 8px 16px; }

/* crates row under the stage */
.crate-box { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: linear-gradient(180deg, rgba(22, 33, 54, 0.92), rgba(11, 18, 32, 0.94)); box-shadow: var(--shadow); }
.crate-box[hidden] { display: none; }
.crate-box.has-crates {
  border-color: rgba(242, 163, 61, 0.7);
  background: radial-gradient(80% 140% at 0% 50%, rgba(242, 163, 61, 0.18), transparent 70%), linear-gradient(180deg, rgba(22, 33, 54, 0.92), rgba(11, 18, 32, 0.94));
  box-shadow: 0 0 0 1px rgba(242, 163, 61, 0.2), 0 0 24px rgba(242, 163, 61, 0.18), var(--shadow);
}
.crate-box-art { width: 44px; height: 44px; flex: none; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5)); }
.crate-box.has-crates .crate-box-art { animation: crate-box-bob 2.4s ease-in-out infinite; }
@keyframes crate-box-bob { 0%, 100% { transform: rotate(0); } 8% { transform: rotate(-6deg); } 16% { transform: rotate(6deg); } 24% { transform: rotate(0); } }
.crate-box-text { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--muted); }
.crate-box.has-crates .crate-box-text { color: var(--text); }
.crate-box-btn { flex: none; min-height: 40px; }
.crate-box.has-crates .crate-box-btn { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-ink); border-color: #e5621a; }

/* profile: level + experience, attributes */
.level-row { display: flex; align-items: center; gap: 16px; }
.level-badge {
  flex: none; width: 64px; height: 70px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: linear-gradient(160deg, var(--level) 0%, var(--level-2) 100%);
  line-height: 1; position: relative;
}
.level-badge::before { /* inner face */
  content: ""; position: absolute; inset: 3px; clip-path: inherit;
  background: radial-gradient(circle at 50% 30%, #1d3354, #0b1426);
}
/* letter-spacing trails after the last letter: padding-left balances it so the label sits on the centre line */
.level-badge-label { position: relative; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; padding-left: 0.08em; margin-bottom: 3px; color: var(--level); }
.level-badge-num { position: relative; font-family: var(--font-display); font-weight: 700; font-size: 26px; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.level-body { flex: 1; min-width: 0; }
.level-title { margin: 0 0 8px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: 0.04em; color: var(--text-strong); }
.level-title .small { font-family: var(--font); font-weight: 400; letter-spacing: 0; color: var(--muted); }
.xp-bar { position: relative; height: 10px; border-radius: 999px; overflow: hidden; background: rgba(159, 216, 255, 0.10); border: 1px solid var(--line); }
.xp-bar-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--level-2), var(--level)); border-radius: 999px; box-shadow: 0 0 12px var(--level-glow); transition: width 0.4s ease; }
.xp-text { margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.attr-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin: 20px 0 10px; }
.attr-head .section-title { margin: 0; }
.attr-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.attrs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0; }
.attr {
  --attr: var(--level);
  position: relative; overflow: hidden; background: var(--field-bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 10px 14px; min-width: 0;
}
.attr::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--attr); }
.attr-strength { --attr: var(--attr-strength); }
.attr-agility { --attr: var(--attr-agility); }
.attr-dexterity { --attr: var(--attr-dexterity); }
.attr-constitution { --attr: var(--attr-constitution); }
.attr dt { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--attr); }
.attr dd { margin: 0; display: flex; flex-direction: column; gap: 5px; }
.attr-val { font-family: var(--font-display); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; color: var(--text-strong); }
.attr-bar { display: block; height: 4px; border-radius: 2px; background: rgba(159, 216, 255, 0.10); overflow: hidden; }
.attr-bar > span { display: block; height: 100%; background: var(--attr); }
.attr-effect { font-size: 12px; color: var(--dim); line-height: 1.3; }

/* record: per-browser stats */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 0; }
.stat { background: var(--field-bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; min-width: 0; }
.stat dt { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); line-height: 1.3; }
.stat dd { margin: 4px 0 0; font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.stats-main .stat-kd dd { color: var(--level); }
.stats-more { margin-top: 10px; }
.stats-more .stat { padding: 8px 12px; background: rgba(10, 17, 30, 0.6); }
.stats-more .stat dd { font-size: 18px; color: var(--text); }

/* wide screens: profile and record side by side under Play */
@media (min-width: 1500px) {
  .lobby-layout { grid-template-columns: 400px minmax(0, 1fr); gap: 24px; }
  .lobby-main-cards { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: stretch; }
  .stats-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-main .stat:last-child { grid-column: 1 / -1; }
  .stats-more { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1700px) {
  .screen-lobby .topbar, .lobby-layout { max-width: 1440px; }
}

/* lobby chat (ui/lobbyChat.js): text only, newest at the bottom */
.lobby-chat .panel-head { margin-bottom: 10px; }
.lchat-online { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lchat-log { height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 10px 12px;
  background: var(--field-bg); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 14px; line-height: 1.4; }
.lchat-empty { margin: auto; color: var(--dim); font-size: 13px; }
.lchat-row { overflow-wrap: anywhere; color: var(--text); }
.lchat-name { font-weight: 700; color: var(--accent-3); margin-right: 8px; }
.lchat-row.mine .lchat-name { color: var(--level); }
.lchat-row.sys { color: var(--dim); font-style: italic; }
.lchat-status { margin: 8px 0 0; font-size: 13px; color: var(--dim); }
.lchat-form { display: flex; gap: 8px; margin-top: 10px; }
.lchat-input { flex: 1; min-width: 0; padding: 9px 12px; font: inherit; color: var(--text); background: var(--field-bg);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); }
.lchat-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lchat-input:disabled { opacity: 0.6; }

/* tablets and phones: one column; Play right after who you are (landscape phones keep two columns: see the end) */
@media (max-width: 900px) and (min-height: 521px), (max-width: 560px) {
  .lobby-layout { display: flex; flex-direction: column; align-items: stretch; max-width: 640px; gap: 14px; }
  .lobby-col { display: contents; }
  .lobby-identity-card { order: 1; }
  .account-slot { order: 2; }
  .play-card { order: 3; }
  .lobby-stage { order: 4; }
  .crate-box { order: 5; }
  .lobby-main-cards { order: 6; display: contents; }
  .profile-card { order: 6; }
  .record-card { order: 7; }
  .lobby-chat { order: 8; }
  .lchat-log { height: 180px; }
  .lobby-stage .preview { aspect-ratio: auto; height: min(62vw, 360px); }
}

@media (max-width: 760px) {
  .preview-col { max-width: 320px; width: 100%; margin: 0 auto; }
  .screen-auth { flex-direction: column; gap: 24px; justify-content: flex-start; padding-top: 32px; }
  .auth-hero { text-align: left; width: 100%; max-width: 440px; }
  .hero-points { display: none; }
  .brand-hero .brand-logo { width: min(260px, 100%); }
  .topbar .brand-logo { height: 38px; }
  .customise-body { grid-template-columns: 1fr; }
  .chips-swatch .swatch { width: 30px; height: 30px; }
  .preview { max-width: 320px; margin: 0 auto; aspect-ratio: 1 / 1; min-height: 220px; }
  .lobby-stage .preview { max-width: none; min-height: 0; }
  .card { padding: 18px; }
}
@media (max-width: 560px) {
  .screen-lobby { padding: 14px 16px 40px; gap: 14px; }
  .panel { padding: 16px; border-radius: 14px; }
  .play-card { padding: 16px; }
  .btn-play { flex-basis: 100%; min-height: 68px; font-size: 26px; }
  .server-chip { flex: 1 1 100%; grid-template-columns: 1fr auto; }
  .server-chip-label { grid-column: 1; }
  .server-chip-name { grid-column: 1; }
  .server-chip-meta { grid-column: 2; grid-row: 1 / span 2; justify-content: flex-end; }
  .play-map { font-size: 19px; }
  .attrs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-main .stat:last-child { grid-column: 1 / -1; }
  .stats-more { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-more .stat { padding: 6px 8px; }
  .stats-more .stat dt { letter-spacing: 0.04em; }
  .level-badge { width: 56px; height: 62px; }
  .stage-hint { display: none; }
  .stage-bar { justify-content: center; }
  .topbar .brand-logo { height: 32px; }
  .topbar-actions { gap: 2px; }
  .topbar-actions .btn { padding: 6px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .ember { display: none; }
  .live-dot { animation: none; }
  .btn-play::before { display: none; }
}

/* Loading screen (ui/loading.js): from Play until the game is welcomed / queued. Sits above the game's fixed
   root (z-index 1000) so the canvas and the hud's own overlays stay hidden until it fades. */
.loading-screen {
  position: fixed; inset: 0; z-index: 1100; display: flex; align-items: flex-end; justify-content: center;
  padding: 24px max(16px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); color: var(--text);
  background:
    linear-gradient(180deg, rgba(5, 9, 18, 0.35) 0%, rgba(5, 9, 18, 0.25) 35%, rgba(5, 9, 18, 0.78) 72%, rgba(4, 7, 14, 0.94) 100%),
    radial-gradient(55% 45% at 82% -5%, rgba(76, 199, 255, 0.22), transparent 70%),
    linear-gradient(180deg, #2a4f8f 0%, #22406f 45%, #101c33 100%),
    var(--loading-bg, none) center / cover no-repeat,
    var(--bg);
  background-blend-mode: normal, screen, color, normal, normal; /* the warm art recoloured to blue night, as --scene-layers */
  opacity: 0; transition: opacity 0.45s ease; pointer-events: auto; cursor: progress;
}
.loading-screen.is-in { opacity: 1; }
.loading-screen.is-out { opacity: 0; pointer-events: none; }
.loading-inner { width: 100%; max-width: 560px; display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; }
.loading-screen .brand-hero .brand-logo { width: min(380px, 82vw); }
.loading-progress { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.loading-stage {
  margin: 0; font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.16em;
  font-size: 14px; font-weight: 600; color: var(--text); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.loading-bar { position: relative; width: 100%; height: 3px; border-radius: 2px; overflow: hidden; background: rgba(236, 241, 250, 0.16); }
.loading-bar-fill {
  position: absolute; top: 0; bottom: 0; left: 0; width: 34%; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-3), var(--accent), transparent);
  animation: loading-sweep 1.4s ease-in-out infinite;
}
@keyframes loading-sweep { from { transform: translateX(-110%); } to { transform: translateX(310%); } }
.loading-dots { display: flex; gap: 8px; }
.loading-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(236, 241, 250, 0.22); transition: background 0.3s, transform 0.3s; }
.loading-dot.is-done { background: var(--moss); }
.loading-dot.is-on { background: var(--accent); transform: scale(1.25); }
.loading-tip {
  width: 100%; padding: 12px 16px; border-radius: var(--radius);
  background: rgba(11, 18, 32, 0.66); border: 1px solid rgba(159, 216, 255, 0.14);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.loading-tip-label { margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.18em; font-size: 12px; color: var(--accent-2); font-weight: 700; }
.loading-tip-text { margin: 0; min-height: 2.9em; font-size: 15px; line-height: 1.45; color: #dfe6f2; }
.loading-tip-text.is-new { animation: loading-tip-in 0.35s ease-out; }
@keyframes loading-tip-in { from { opacity: 0.15; } to { opacity: 1; } }
@media (max-width: 760px) {
  .loading-inner { gap: 18px; }
  .loading-tip-text { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .loading-bar-fill { animation: none; left: 0; width: 100%; opacity: 0.6; }
  .loading-tip-text.is-new { animation: none; }
}

/* Version tag on the sign-in and lobby screens; hover shows the deploy time. */
.version-tag { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); font-size: 12px; letter-spacing: 0.03em; color: var(--muted);
  opacity: 0.75; cursor: pointer; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  background: none; border: 0; padding: 6px 0 6px 8px; margin: -6px 0 -6px; font-family: inherit; line-height: inherit; -webkit-tap-highlight-color: transparent; }
.version-tag:hover, .version-tag.show-date { opacity: 1; }
.version-tag:focus-visible { outline: 1px solid var(--muted); outline-offset: 2px; border-radius: 3px; }
.version-tag:empty { display: none; }

@media (prefers-reduced-motion: reduce) { .crate-box.has-crates .crate-box-art { animation: none; } }

/* Customise on phones: the preview is a short band that stays in view while the options scroll under it, the tabs
   stay under the preview, and Save / Randomise / Cancel stay pinned at the bottom of the screen. */
@media (max-width: 560px) {
  .screen-customise { padding: 12px 12px 0; gap: 10px; }
  .screen-customise .topbar .brand-logo { height: 30px; }
  .customise-card.card { padding: 0 14px; }
  .customise-head { padding-top: 14px; }
  .customise-head .card-title { font-size: 19px; }
  .customise-head p { font-size: 13px; margin: 0 0 8px; }
  .customise-body { gap: 0; }
  .screen-customise .preview-col { position: sticky; top: 0; z-index: 3; max-width: none; margin: 0 -14px; padding: 8px 14px 0;
    flex-direction: row; align-items: stretch; gap: 8px; background: var(--panel); }
  .screen-customise .preview { flex: 1; max-width: none; margin: 0; aspect-ratio: auto; height: min(34vh, 230px); min-height: 160px; }
  .screen-customise .preview-tools { flex-direction: column; justify-content: flex-start; }
  .screen-customise .gender-row { flex-direction: column; }
  .customise-form { gap: 12px; }
  .customise-tabset { gap: 12px; }
  .customise-tabs { position: sticky; top: calc(min(34vh, 230px) + 8px); z-index: 2; margin: 0 -14px; padding: 0 14px; background: var(--panel); }
  .customise-tab { padding: 11px 4px; letter-spacing: 0.06em; }
  .customise-panel { gap: 14px; }
  .chips legend { margin-bottom: 6px; font-size: 12px; }
  .chip-row { gap: 6px; }
  .chip-label { padding: 7px 12px; font-size: 13px; }
  .chip-tile { width: 56px; height: 56px; }
  .chip-tile img { width: 46px; height: 46px; }
  .customise-form .actions { position: sticky; bottom: 0; z-index: 3; margin: 6px -14px 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: var(--panel); border-top: 1px solid var(--line); flex-wrap: nowrap; }
  .customise-form .actions .btn { flex: 1 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; }
}

/* Narrow phones: "Create account" stays on one line in the auth tabs. */
@media (max-width: 400px) {
  .tab { font-size: 12px; letter-spacing: 0.05em; padding-left: 4px; padding-right: 4px; }
}

/* Touch screens: small buttons and text links on the menu screens are at least 40px tall to tap. */
@media (pointer: coarse) {
  :is(.screen-lobby, .screen-auth, .screen-center, .gb-card, .gb-toast) .btn-sm { min-height: 40px; }
  :is(.screen-lobby, .screen-auth, .gb-card) .link { min-height: 40px; }
  .form-links { margin-top: 8px; row-gap: 0; }
}

/* Landscape phones (short and wide, e.g. 667x375 to 932x430): two columns with Play on the first screen, compact
   chrome, insets clear of the notch. */
@media (max-height: 520px) and (min-width: 561px) {
  .screen-lobby { padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: max(28px, env(safe-area-inset-bottom)); gap: 10px; }
  .screen-lobby .topbar .brand-logo { height: 30px; }
  .lobby-layout { grid-template-columns: minmax(230px, 300px) minmax(0, 1fr); gap: 14px; }
  .lobby-col { gap: 12px; }
  .lobby-identity-card { padding: 12px 16px; }
  .lobby-identity { margin-top: 6px; }
  .lobby-identity .player-name { font-size: 26px; }
  .account-slot { padding: 14px 16px; }
  .account-slot .gb-bar-text { font-size: 14px; }
  .lobby-stage .preview { aspect-ratio: auto; max-width: none; min-height: 0; height: min(calc(100dvh - 130px), 300px); }
  .stage-bar { padding: 8px 12px; }
  .screen-lobby .panel:not(.lobby-stage) { padding: 16px; }
  .play-card { padding: 16px; }
  .play-head { margin-bottom: 10px; }
  .play-map { font-size: 19px; }
  .btn-play { flex-basis: 100%; min-height: 60px; font-size: 26px; }
  .server-chip { flex: 1 1 100%; }

  .screen-auth { flex-direction: row; flex-wrap: nowrap; align-items: flex-start; justify-content: center; gap: 24px;
    padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .auth-hero { flex: 0 1 250px; min-width: 0; padding-top: 12px; }
  .brand-hero .brand-logo { width: min(230px, 100%); }
  .auth-hero .tagline { font-size: 17px; margin-top: 10px; }
  .screen-auth .hero-points { display: none; }
  .auth-card { flex: 1 1 360px; max-width: 420px; padding: 16px 20px; }
  .auth-card .form { gap: 10px; }

  .loading-screen { align-items: center; padding-top: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .loading-inner { gap: 12px; }
  .loading-screen .brand-hero .brand-logo { width: min(260px, 50vw); }
}

/* landscape phones up to ~860px wide: the main column is narrow, so attributes and stats wrap as on portrait phones */
@media (max-height: 520px) and (min-width: 561px) and (max-width: 860px) {
  .attrs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-main .stat:last-child { grid-column: 1 / -1; }
  .stats-more { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-more .stat { padding: 6px 8px; }
  .stats-more .stat dt { letter-spacing: 0.04em; }
  .level-badge { width: 56px; height: 62px; }
}

/* Customise on landscape phones (from the customise owner, tested at 812x375): the preview stays beside the options. */
@media (max-height: 520px) and (min-width: 561px) {
  .screen-customise { padding-top: 10px; gap: 8px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .screen-customise .topbar .brand-logo { height: 30px; }
  .customise-head p { margin-bottom: 8px; font-size: 13px; }
  .customise-body { grid-template-columns: minmax(180px, 34%) 1fr; gap: 16px; }
  .screen-customise .preview-col { position: sticky; top: 8px; max-width: none; flex-direction: row; align-items: flex-start; gap: 8px; }
  .screen-customise .preview { flex: 1; max-width: none; margin: 0; aspect-ratio: auto; min-height: 0; height: calc(100dvh - 16px); max-height: 340px; }
  .screen-customise .preview-tools { flex-direction: column; }
  .screen-customise .gender-row { flex-direction: column; }
  .customise-form .actions { position: sticky; bottom: 0; z-index: 3; padding: 8px 0; background: var(--panel); }
}

/* Narrowest phones (360px): RANDOMISE fits inside its button in the pinned customise actions. */
@media (max-width: 380px) {
  .customise-form .actions .btn { padding-inline: 12px; letter-spacing: 0.04em; }
}
