/* ═══════════════════════════════════════════════════════════
   HEXLAND Online — Lobby Styles  Phase 5.4
   ═══════════════════════════════════════════════════════════ */

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

/* ── Accessibility: honour "reduce motion" globally ───────────
   Near-zero (not 0) durations so JS that waits on transitionend/animationend
   (e.g. mg-tab-pulse, badge-shake, the .*-pop menus) still fires its callbacks,
   while ambient/looping motion effectively stops for users who ask for calm. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Theme variables ──────────────────────────────────────── */
:root {
  --ink-rgb: 255, 255, 255;
  --inset-rgb: 0, 0, 0;
  /* Heights of the fixed lobby header + announcement ticker. Used to butt the
     ticker against the header and to offset sticky panel headers below them.
     Header grows to 86px on mobile (overridden in the ≤540px media query). */
  --lobby-header-h: 70px;
  --lobby-ticker-h: 30px;
  --page-grad-1: rgba(77, 196, 245, .18);
  --page-grad-2: rgba(120, 80, 220, .18);
  --page-base: #12101e;
  --body-bg: #1a1228;
  --lobby-hex: url('Lobby/bg/lobby-hex-dark-desktop.svg');
  --text-strong: #fff;
  --text-cream: #f5e8c0;
  --text-input: #f0eada;
  --text-cool: #e8edf4;
  --text-cool-2: #d7deea;
  --modal-backdrop: rgba(8, 6, 16, .62);
  --modal-bg: rgba(22, 18, 36, .98);
  --msg-backdrop: rgba(0, 0, 0, .55);
  --msg-bg: #1c2530;
  --gc-backdrop: rgba(0, 0, 0, .65);
  --gc-bg: #1e1830;
  --option-bg: #2a2722;
  --gc-option-bg: #1e1830;
  --text-amber: #f0a060;
  --text-red: #ff7070;
  --text-red-2: #ff9090;
  --text-tan-link: #c8a96e;
  --text-muted-grey: #cdd6e0;
  --text-grey: #ccc;
  --avatar-ring: #888;
  --text-mode-tideport: #7ec8f0;
  --text-mode-space: #c09cf0;
  --text-header-rgb: 245, 232, 192;

  /* ── Motion system (Lobby Vision §4) ───────────────────────
     ONE easing + three speeds for the whole lobby. "Everything settles,
     nothing snaps": a gentle ease-out with no overshoot (calm, not bouncy).
       micro    — taps, presses, toggles (tactile confirmation)
       standard — panels, cards entering, hover elevation
       ambient  — breathing background / looping atmosphere (subconscious) */
  --ease-settle: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-micro: 120ms;
  --dur-standard: 240ms;
  --dur-ambient: 6s;
  --elev-shadow: 0 6px 20px rgba(0, 0, 0, .28);
  --focus-ring: #f0a030;   /* amber — matches the existing .rooms-cdd-trigger focus */

  /* ── Ambient background system (Step 5) ────────────────────
     Token-driven so any future theme (Classic / Tideport / Space / seasonal)
     restyles the living backdrop by overriding these — no structural change.
     Colours reuse the (previously unused) theme page-accents, so light/dark and
     future themes inherit automatically. Breathing is deliberately slow enough
     to stay subconscious. */
  --ambient-glow-1: var(--page-grad-1);
  --ambient-glow-2: var(--page-grad-2);
  --ambient-breath-dur: 14s;
  --ambient-opacity-min: .55;
  --ambient-opacity-max: .9;
  --ambient-layer:
    radial-gradient(60% 50% at 22% 18%, var(--ambient-glow-1), transparent 70%),
    radial-gradient(55% 45% at 82% 86%, var(--ambient-glow-2), transparent 72%);
}

/* Light theme: the amber focus ring is low-contrast on the pale background, so
   deepen it there (same token, light-only override — no global colour change). */
:root[data-theme="light"] {
  --focus-ring: #b5560a;
}

/* Per-world ambient tint (B2) — overrides only the ambient glow colours; the
   layer composition/animation is unchanged. Classic keeps the default accents.
   Driven by data-lobby-world on <html> (set from the player's recent game). */
:root[data-lobby-world="tideport"] {
  --ambient-glow-1: rgba(38, 152, 160, .16);
  --ambient-glow-2: rgba(20, 90, 140, .14);
}
:root[data-lobby-world="space"] {
  --ambient-glow-1: rgba(120, 90, 220, .16);
  --ambient-glow-2: rgba(70, 60, 150, .14);
}

/* New-player "start here" hint (A1) — calm, dismissible, uses the shared entrance
   and token styling; the ✕ inherits Step 2 press/focus as a <button>. */
.start-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid rgba(var(--ink-rgb), .16);
  border-radius: 10px;
  background: rgba(var(--ink-rgb), .05);
  animation: mo-in var(--dur-standard) var(--ease-settle) both;
}
.start-hint-text { flex: 1 1 auto; font-size: .86rem; color: var(--text-cool); }
.start-hint-text strong { color: var(--text-strong); }
.start-hint-x {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted-grey);
  font-size: 1rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background var(--dur-micro) var(--ease-settle);
}
.start-hint-x:hover { background: rgba(var(--ink-rgb), .1); }

:root[data-theme="light"] {
  --ink-rgb: 32, 36, 50;
  --inset-rgb: 255, 255, 255;
  --page-grad-1: rgba(77, 196, 245, .12);
  --page-grad-2: rgba(120, 80, 220, .10);
  --page-base: #e8ecf4;
  --body-bg: #dde2ec;
  --lobby-hex: url('Lobby/bg/lobby-hex-light-desktop.svg');
  --text-strong: #20243a;
  --text-cream: #5c4424;
  --text-input: #2a2a38;
  --text-cool: #23293c;
  --text-cool-2: #4a5568;
  --modal-backdrop: rgba(40, 44, 60, .35);
  --modal-bg: #fbf9f5;
  --msg-backdrop: rgba(40, 44, 60, .3);
  --msg-bg: #f3f1ec;
  --gc-backdrop: rgba(40, 44, 60, .35);
  --gc-bg: #f7f2ea;
  --option-bg: #f5f0e8;
  --gc-option-bg: #f5f0e8;
  --text-amber: #a8631e;
  --text-red: #c23b3b;
  --text-red-2: #d65050;
  --text-tan-link: #8a6a30;
  --text-muted-grey: #5a6270;
  --text-grey: #6a6f7a;
  --avatar-ring: #aab0bd;
  --text-mode-tideport: #1f6fa8;
  --text-mode-space: #7a4ec2;
  --text-header-rgb: 92, 68, 36;
}

/* The colours below were tuned for the dark palette's near-black
   backgrounds and read as washed-out pastels on the light palette's pale
   page/panel backgrounds. Darken/desaturate each one while keeping its hue
   so category badges stay distinguishable. This generic rule must come
   before the "whose turn" override below so the --myturn modifier (same
   specificity, later in source) keeps winning for its own colour. */
:root[data-theme="light"] .rejoin-status-badge {
  color: var(--text-mode-tideport);
}

/* The "whose turn" player chip / status badge use a pale green (#8be0aa /
   #7de0a0) that reads fine on the dark theme's near-black background but is
   too low-contrast on light theme's pale background — match the other
   players' (ink) text colour. */
:root[data-theme="light"] .rejoin-pl-turn,
:root[data-theme="light"] .rc-pl-chip.lg-pl-turn .rc-pl-name,
:root[data-theme="light"] .rejoin-status-badge--myturn {
  color: rgba(var(--ink-rgb), .85);
}

:root[data-theme="light"] .greeting-headline strong {
  color: var(--text-amber);
}

:root[data-theme="light"] .rooms-count {
  color: #1f7a45;
}

:root[data-theme="light"] #player-list-empty,
:root[data-theme="light"] .rooms-empty {
  color: rgba(var(--ink-rgb), .6);
}

:root[data-theme="light"] .ai-pill-active {
  background: rgba(168, 99, 30, .12);
  border-color: var(--text-amber);
  color: var(--text-amber);
}

/* These badges sit on tinted player-card backgrounds, so a near-opaque
   inset background gives the darkened text a consistent light surface. */
:root[data-theme="light"] .wp-mode-mobile {
  background: rgba(var(--inset-rgb), .7);
  color: #1f7a45;
}

:root[data-theme="light"] .wp-ai,
:root[data-theme="light"] .wp-mode-ai {
  background: rgba(var(--inset-rgb), .7);
  color: var(--text-mode-space);
}

:root[data-theme="light"] .wp-mode-desktop {
  background: rgba(var(--inset-rgb), .7);
  color: var(--text-mode-tideport);
}

:root[data-theme="light"] .wp-mode-android {
  background: rgba(var(--inset-rgb), .7);
  color: #2f7a1f;
}

:root[data-theme="light"] .wp-mode-ios {
  background: rgba(var(--inset-rgb), .7);
  color: #3a4048;
}

/* Host / You / reconnecting badges: same opaque-inset treatment so their
   tinted text stays legible on the light player-card background. */
:root[data-theme="light"] .wp-badge {
  background: rgba(var(--inset-rgb), .7);
  color: var(--text-amber);
}

:root[data-theme="light"] .wp-you {
  background: rgba(var(--inset-rgb), .7);
  color: var(--text-mode-tideport);
}

:root[data-theme="light"] .wp-reconnecting {
  background: rgba(var(--inset-rgb), .7);
  color: #b06a14;
}

:root[data-theme="light"] .rejoin-status-badge--setup {
  color: var(--text-amber);
}

:root[data-theme="light"] .rejoin-status-badge--ended {
  color: rgba(var(--ink-rgb), .65);
}

:root[data-theme="light"] .rejoin-players,
:root[data-theme="light"] .rc-meta {
  color: rgba(var(--ink-rgb), .65);
}

:root[data-theme="light"] .btn-rejoin-remove {
  background: rgba(var(--ink-rgb), .06);
  color: #8a3a3a;
}

:root[data-theme="light"] .set-account-link a {
  color: var(--text-mode-tideport);
}

:root[data-theme="light"] .set-danger-label {
  color: var(--text-red);
}

:root[data-theme="light"] .set-danger-text {
  color: rgba(var(--ink-rgb), .65);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  /* Hexagon-chain artwork lives here (moved off .lobby-bg) so .lobby-bg no longer
     needs a stacking context — that isolation trapped the Settings/Pro-Upgrade
     modals under the fixed header. Self-contained SVG (baked-in body colour +
     corner glows), pinned to the viewport; --lobby-hex + the orientation media
     query still select the right art. --page-base is the solid beneath it. */
  background:
    var(--lobby-hex) center center / cover no-repeat fixed,
    var(--page-base);
}

/* ── Lobby intro video overlay ───────────────────────────── */
.lobby-intro {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity .6s ease;
}

.lobby-intro[hidden] {
  display: none;
}

.lobby-intro.is-hiding {
  opacity: 0;
  pointer-events: none;
}

/* Animated SVG splash (an <object>): fills the overlay on every screen. The
   inner SVG self-slices (preserveAspectRatio="xMidYMid slice") and keeps its
   action centred, so the element just needs to fill. pointer-events:none so it
   never traps clicks meant for the Skip button. */
.lobby-intro-media {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  pointer-events: none;
  user-select: none;
}

/* On phones the <object> fills the whole overlay so the SVG's xMidYMid slice
   covers the screen — the hex-grid background reaches every edge with no
   letterbox. The emblem would blow up at that cover scale, so it's shrunk
   *inside* the SVG instead (see lobby-intro.svg's `@media (max-width:540px)`,
   which scales #fg-logo down): the background fills the height while the logo
   stays a calm size. overflow:hidden clips the cover crop cleanly. */
@media (max-width: 540px) {
  .lobby-intro {
    overflow: hidden;
  }
  .lobby-intro-media {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }
}

.lobby-intro-skip {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  right: 20px;
  padding: 9px 16px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background var(--dur-micro) var(--ease-settle), border-color var(--dur-micro) var(--ease-settle);
}

.lobby-intro-skip:hover {
  background: rgba(0, 0, 0, .7);
  border-color: rgba(255, 255, 255, .6);
}

/* ── Full-page ocean background ──────────────────────────── */
.lobby-bg {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* Clear the fixed header (70px) AND the fixed ticker butted flush below it
     (top:70px + height:30px = bottom at 100px). No gap, so the underlined tabs
     butt flush against the bottom of the ticker. */
  padding: 100px 16px 24px;
  /* Transparent and deliberately NOT a stacking context: the hex artwork moved
     to <body>, and the ambient layer below uses a root-level z-index:-1. This
     keeps modals inside .lobby-bg (settings, pro-upgrade, invite banner) at the
     root z-order so they cover the fixed header correctly. */
}

/* ── Ambient background layer ──────────────────────────────────────────────
   The first implementation of the ambient system: a gentle "breathing light".
   Pinned to the viewport, purely decorative (pointer-events:none), composed
   from the --ambient-layer token and animated on OPACITY ONLY (compositor-
   friendly — the gradient is painted once). With .lobby-bg not a stacking
   context, this z-index:-1 resolves at the root: it paints ABOVE the <body> hex
   artwork and BELOW all UI (content, header, modals). Reduced-motion users get
   the Step 1 global guard, which freezes it to a calm static glow. A future
   theme can restyle it by overriding the --ambient-* tokens. */
.lobby-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--ambient-layer);
  opacity: var(--ambient-opacity-min);
  animation: ambient-breathe var(--ambient-breath-dur) ease-in-out infinite;
}

@keyframes ambient-breathe {
  0%, 100% { opacity: var(--ambient-opacity-min); }
  50%      { opacity: var(--ambient-opacity-max); }
}

/* Portrait viewports get the tall (9:16) artwork so the side chains survive the
   `cover` crop; landscape keeps the wide (16:9) default set in :root. */
@media (max-aspect-ratio: 1 / 1) {
  :root { --lobby-hex: url('Lobby/bg/lobby-hex-dark-mobile.svg'); }
  :root[data-theme="light"] { --lobby-hex: url('Lobby/bg/lobby-hex-light-mobile.svg'); }
}

/* ── Central column ──────────────────────────────────────── */
.lobby-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 50px;
}

/* ── Logo / header ───────────────────────────────────────── */
.lobby-header {
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: -150px;
}

.lobby-icon {
  font-size: 2.6rem;
  filter: drop-shadow(0 2px 8px rgba(255, 200, 80, .6));
}

.lobby-logo-img {
  height: 90px;
  width: auto;
  margin-top: 24px;
  margin-bottom: -25px;
  object-fit: contain;
  filter: drop-shadow(0 2px 12px rgba(255, 200, 80, .5));
}

.lobby-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-cream);
  letter-spacing: 2px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .6);
}

.lobby-title span {
  color: #f0a030;
}

/* ── DRAFT A: Bottom tab bar (Option B layout #1) ───────────
   App-style fixed bar pinned to the bottom of the viewport. */
.lobby-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  gap: 2px;
  padding: 6px 4px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--body-bg);
  border-top: 1px solid rgba(var(--ink-rgb), .14);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .35);
  backdrop-filter: blur(12px);
}

.tabbar-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  min-width: 0;
  padding: 6px 1px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text-cool-2);
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease-settle), color var(--dur-micro) var(--ease-settle);
}

.tabbar-item:hover {
  background: rgba(var(--ink-rgb), .06);
}

.tabbar-icon {
  font-size: 1.3rem;
  line-height: 1;
  filter: grayscale(.4);
  opacity: .8;
  transition: filter var(--dur-micro) var(--ease-settle), opacity var(--dur-micro) var(--ease-settle);
}

.tabbar-label {
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.05;          /* tight rows so a 2-word label fits the column */
  max-width: 100%;
  text-align: center;
  white-space: normal;        /* allow two-word labels to wrap to two rows */
  overflow-wrap: break-word;
}

.tabbar-item.is-active {
  color: #f0a030;
}

.tabbar-item.is-active .tabbar-icon {
  filter: none;
  opacity: 1;
}

/* The bottom tab bar (A) is the MOBILE nav; the underlined tabs (C) show at all
   widths. On mobile, keep page content clear of the fixed bottom bar. */
@media (max-width: 540px) {
  .lobby-wrap {
    padding-bottom: 84px;
    /* Tighter vertical rhythm than the 50px desktop gap, so the Resume banner
       and Quick Match sit higher / more fits above the fold on small screens. */
    gap: 28px;
  }
  /* Comfortable thumb targets for the two primary actions on small screens. */
  .primary-actions .btn-lobby { min-height: 50px; }
}

/* On desktop the bottom bar is removed — the underlined tabs are the nav there. */
@media (min-width: 541px) {
  .lobby-tabbar {
    display: none;
  }
}

/* ── DRAFT C: Underlined tabs (Option B layout #3) ──────────
   Flat text tabs across the top; active one carries an underline. */
.lobby-uline {
  align-self: center;
  /* Desktop menu bar sits at the very top of .lobby-wrap; the Resume / Your Turn
     banner (first in DOM) then falls directly beneath it. No effect on mobile,
     where this bar is display:none and the banner stays at the top of content. */
  order: -1;
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-wrap: nowrap;        /* one row; items flex-share the width (see below) */
  gap: 2px;
  padding: 0 4px;
  /* Vertically mirrored bar: gradient, rounded corners, rule line and shadow all
     flipped top↔bottom so the flat top edge butts seamlessly against the ticker
     and the bar rounds off at the bottom. */
  background: linear-gradient(180deg, rgba(var(--ink-rgb), .1), rgba(var(--ink-rgb), .2));
  border-radius: 0 0 12px 12px;
  border-top: 1px solid rgba(var(--ink-rgb), .18);
  box-shadow: 0 -6px 16px rgba(0, 0, 0, .22);
}

.uline-item {
  flex: 1 1 0;             /* equal columns → all six always fit the bar */
  position: relative;
  padding: 10px 6px;
  margin-bottom: -1px;
  border: none;
  border-radius: 0 0 8px 8px;
  background: transparent;
  color: var(--text-cool-2);
  font-size: .88rem;
  font-weight: 600;
  white-space: nowrap;
  text-align: center;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--dur-micro) var(--ease-settle), background var(--dur-micro) var(--ease-settle), border-color var(--dur-micro) var(--ease-settle);
}

.uline-item:hover {
  color: var(--text-cool);
  background: rgba(var(--ink-rgb), .05);
}

.uline-item.is-active {
  color: #f0a030;
  background: rgba(240, 160, 48, .09);
  border-bottom-color: #f0a030;
}

/* Mobile: the bottom tab bar is the nav here, so hide the underlined tabs. */
@media (max-width: 540px) {
  .lobby-uline {
    display: none;
  }
}

/* Tablet/narrow desktop: shrink + allow wrapping so all six labels still fit
   their equal columns instead of overflowing the bar. */
@media (min-width: 541px) and (max-width: 720px) {
  .uline-item {
    padding: 8px 3px;
    font-size: .78rem;
    white-space: normal;
    line-height: 1.05;
  }
}

/* ── Cards ───────────────────────────────────────────────── */
.lobby-card {
  background: rgba(var(--ink-rgb), .05);
  border: 1px solid rgba(var(--ink-rgb), .12);
  border-radius: 16px;
  padding: 28px 28px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Light mode: give the Room Creator flow (create + waiting room + matchmaking) a
   subtle indigo tint + border so it reads as distinct from the otherwise-neutral
   lobby cards around it. Dark mode unchanged. */
:root[data-theme="light"] #screen-join,
:root[data-theme="light"] #screen-wait,
:root[data-theme="light"] #screen-matchmaking {
  background: rgba(76, 62, 120, .18);
  border-color: rgba(76, 62, 120, .38);
}

/* The sub-panels revealed inside the Room Creator (Quick Match / Create Room
   options) inherit the same indigo family as their parent card in light mode,
   rather than the neutral grey inset they'd otherwise show — so the opened flow
   reads as one continuous creator surface. Sits atop the card's .18, so a lower
   alpha here lands as a slightly deeper indigo well. Dark mode keeps the base
   white tint. Labels/explainer text nudged a touch darker for legibility. */
:root[data-theme="light"] #screen-join .mm-options,
:root[data-theme="light"] #screen-join .create-options {
  background: rgba(76, 62, 120, .12);
  border-color: rgba(76, 62, 120, .28);
}

:root[data-theme="light"] #screen-join .panel-explain,
:root[data-theme="light"] #screen-join .field-label {
  color: rgba(var(--ink-rgb), .62);
}

:root[data-theme="light"] #screen-join .mm-pref-label {
  color: rgba(var(--ink-rgb), .68);
}

/* Friends & Player List panels — stacked on mobile, side by side on desktop
   (see the @media (min-width: 600px) block below). */
.social-row {
  display: flex;
  flex-direction: column;
  gap: 50px;
}

/* The Friends/Players wrapper is a persistent flex child of .lobby-wrap — only its
   inner cards are toggled, never the row itself. When neither card is the active
   nav view the empty row would still occupy a slot and inject a phantom 50px column
   gap, pushing the panels after it (Open Rooms, Live, My Games) one gap further from
   the tabs/ticker than the Room Creator base. Collapse it unless a card is showing. */
.social-row:not(:has(> .lobby-card:not([style*="none"]))) {
  display: none;
}

/* ── Guest welcome message ───────────────────────────────── */
.lobby-welcome {
  text-align: center;
}

.lobby-welcome-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-strong);
}

.lobby-welcome-body {
  font-size: .84rem;
  color: rgba(var(--ink-rgb), .5);
  line-height: 1.55;
}

.lobby-welcome-body a {
  color: var(--text-tan-link);
  text-decoration: none;
}

.lobby-welcome-body a:hover {
  text-decoration: underline;
}

/* ── Short "what can I do here?" blurb shown at the top of a
   sub-panel (Quick Match, Create Room, …) ──────────────────── */
.panel-explain {
  font-size: .84rem;
  color: rgba(var(--ink-rgb), .5);
  line-height: 1.55;
  text-align: center;
}

/* ── Signed-in greeting ──────────────────────────────────── */
.player-greeting {
  text-align: center;
  margin-top: 20px;
}

.greeting-headline {
  font-family: 'Quicksand', 'Segoe UI', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-cream);
  letter-spacing: .3px;
}

.greeting-headline strong {
  color: #f0a030;
}

.greeting-sub {
  margin-top: 8px;
  font-size: .85rem;
  line-height: 1.55;
  color: rgba(var(--ink-rgb), .55);
}

.panel-name {
  font-family: 'Quicksand', 'Segoe UI', sans-serif;
  font-weight: 700;
  color: var(--text-cream);
  text-decoration: underline;
  text-decoration-color: rgba(var(--ink-rgb), .25);
  text-underline-offset: 2px;
}

.panel-name:hover {
  text-decoration-color: var(--text-cream);
}

/* Brief highlight pulse on a lobby panel after a scroll-link jumps to it. */
@keyframes panel-flash {

  0%,
  100% {
    box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
  }

  25% {
    box-shadow: 0 8px 32px rgba(0, 0, 0, .4), 0 0 0 3px rgba(77, 196, 245, .6);
  }
}

.panel-flash {
  animation: panel-flash 1.2s ease-out;
}

/* ── Fields ──────────────────────────────────────────────── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: .8rem;
  font-weight: 600;
  color: rgba(var(--ink-rgb), .5);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.field-input {
  padding: 11px 14px;
  border-radius: 8px;
  border: 1.5px solid rgba(var(--ink-rgb), .15);
  background: rgba(var(--ink-rgb), .08);
  color: var(--text-cream);
  font-size: 1rem;
  outline: none;
  transition: border-color var(--dur-standard) var(--ease-settle);
}

.field-input::placeholder {
  color: rgba(var(--ink-rgb), .3);
}

.field-input:focus {
  border-color: #f0a030;
  background: rgba(var(--ink-rgb), .12);
}

/* Inline validation message, shown directly under the field it belongs to.
   Hidden via the `hidden` attribute, so an empty slot takes no space at all. */
.field-error {
  margin: 0;
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.35;
  color: #ef6a5a;
  display: flex;
  align-items: flex-start;
  gap: 5px;
}
.field-error[hidden] { display: none; }
.field-error::before { content: "⚠"; flex-shrink: 0; }

/* A field called out by validation gets a matching border while it's wrong. */
[aria-invalid="true"].field-input { border-color: #ef6a5a; }
[aria-invalid="true"] .btn-np-pref { border-color: rgba(239, 106, 90, .55); }

.code-input {
  flex: 1;
  letter-spacing: 3px;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-lobby {
  padding: 13px 20px;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  transition: filter var(--dur-micro) var(--ease-settle),
              transform var(--dur-micro) var(--ease-settle),
              box-shadow var(--dur-standard) var(--ease-settle);
  letter-spacing: .5px;
}

.btn-lobby:active {
  transform: scale(.97);
}

.btn-lobby:disabled {
  opacity: .45;
  cursor: default;
  transform: none;
}

/* ── Interaction language (Step 2) — one shared press + focus treatment ─────
   Centralised here so any future control inherits the feel just by being a
   <button>/<a>, or by joining the focus list below. Hover-elevation is applied
   only to content cards (see .room-card) — full-width buttons and flat tabs
   deliberately keep their brightness/underline hover instead of shifting.
   `.btn-lobby:active` above already covers <a class="btn-lobby"> CTAs. */

/* Press: subtle tactile scale on every enabled button (nav tabs, pills, icon
   and close buttons are all <button>, so this one rule reaches them).
   .panel-info-btn is excluded: its tap-tooltip is an ::after anchored to the
   header (.rooms-hd), but a transform on the button re-roots that ::after to
   the 17px button itself for the frames the press-scale is active — so the
   tooltip flashes at the wrong spot before settling. No transform, no re-root. */
button:active:not(:disabled):not(.panel-info-btn) {
  transform: scale(.97);
}

/* Focus: a single keyboard-only ring (focus-visible never shows for mouse or
   touch), extending the existing amber .rooms-cdd-trigger convention. Designed
   text inputs (.field-input/.set-input/.gc-input/.gc-select) keep their own
   border-highlight focus and are intentionally left out. */
button:focus-visible,
a:focus-visible,
.room-card:focus-visible,
.rooms-search:focus-visible,
.rooms-mini-select:focus-visible,
.wait-search:focus-visible,
.gc-switch input:focus-visible + .gc-switch-track {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ── Transition framework (Step 3) — shared entrance motion ─────────────────
   ONE set of token-timed entrances reused by every overlay. opacity + transform
   only (never width/height/top/left). Reduced-motion users get the Step 1 global
   guard, which collapses all of these to instant. Two adoption paths:
     • CSS-only — add .mo-modal-in / .mo-backdrop-in / .mo-in (or the grouped
       migration rules below); the entrance plays once when the element is shown.
     • JS — moShow()/moHide() in lobby.js, for elements that re-render while
       visible (banners, lists), so the entrance fires only on a real
       hidden→shown edge and never restarts mid-display. */
@keyframes mo-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes mo-modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes mo-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Reusable utility classes — any future overlay adopts the system by class alone. */
.mo-in          { animation: mo-in var(--dur-standard) var(--ease-settle) both; }
.mo-modal-in    { animation: mo-modal-in var(--dur-standard) var(--ease-settle) both; }
.mo-backdrop-in { animation: mo-backdrop-in var(--dur-standard) var(--ease-settle) both; }

/* Migration — existing dialogs join the framework with no markup change:
   backdrops fade, their panels fade + settle. Replaces the old set-pop/ham-pop. */
.settings-backdrop,
.about-backdrop,
.gc-backdrop,
.msg-backdrop,
.pu-backdrop,
.profile-modal {
  animation: mo-backdrop-in var(--dur-standard) var(--ease-settle) both;
}
.settings-modal,
.about-card,
.gc-modal,
.pu-modal,
.msg-panel,
.profile-modal-inner {
  animation: mo-modal-in var(--dur-standard) var(--ease-settle) both;
}
/* The hamburger menu is a quick pop — lighter, faster entrance. */
.ham-menu {
  animation: mo-in var(--dur-micro) var(--ease-settle) both;
}

.btn-create {
  background: linear-gradient(135deg, #f0a030 0%, #d06020 100%);
  color: #fff;
  width: 100%;
  font-size: 1.05rem;
}

.btn-create:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-join {
  background: linear-gradient(135deg, #3878e0 0%, #1a50b0 100%);
  color: #fff;
  white-space: nowrap;
  padding: 11px 18px;
}

.btn-join:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-start {
  background: linear-gradient(135deg, #28b060 0%, #166038 100%);
  color: #fff;
  width: 100%;
  font-size: 1.05rem;
  margin-top: 4px;
}

.btn-start:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-copy {
  background: rgba(var(--ink-rgb), .1);
  border: 1px solid rgba(var(--ink-rgb), .2);
  color: var(--text-cream);
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: .8rem;
  transition: background var(--dur-micro) var(--ease-settle);
}

.btn-copy:hover {
  background: rgba(var(--ink-rgb), .18);
}

.btn-back {
  background: transparent;
  border: none;
  color: rgba(var(--ink-rgb), .4);
  cursor: pointer;
  font-size: .85rem;
  padding: 4px;
  text-align: center;
  transition: color var(--dur-micro) var(--ease-settle);
}

.btn-back:hover {
  color: rgba(var(--ink-rgb), .7);
}

/* ── Dividers ────────────────────────────────────────────── */

.or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(var(--ink-rgb), .3);
  font-size: .8rem;
}

.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(var(--ink-rgb), .12);
}

/* ── Join row ────────────────────────────────────────────── */
.join-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Error message ───────────────────────────────────────── */
.lobby-error {
  color: var(--text-red);
  font-size: .85rem;
  min-height: 1.1em;
  text-align: center;
  transition: opacity var(--dur-standard) var(--ease-settle);
}

/* ── Waiting room ────────────────────────────────────────── */
.room-name-row {
  text-align: center;
  padding: 6px 0 2px;
}

.room-name-value {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-strong);
  letter-spacing: 1px;
}

.wait-subtitle {
  text-align: center;
  color: rgba(var(--ink-rgb), .4);
  font-size: .85rem;
}

.wait-hint {
  text-align: center;
  color: rgba(var(--ink-rgb), .3);
  font-size: .78rem;
}

/* ── Player list ─────────────────────────────────────────── */
.wait-players {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
}

.wait-player {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(var(--ink-rgb), .06);
  border-radius: 8px;
  padding: 10px 14px;
}

.wp-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

/* Waiting-room avatar: seat-coloured ring, shows the profile picture or initial */
.wp-av {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 800;
  color: rgba(0, 0, 0, .6);
  border: 2px solid var(--avatar-ring);
  background-size: cover;
  background-position: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
}

.wp-name {
  color: var(--text-cream);
  font-weight: 600;
  font-size: .95rem;
}

/* Pushes the Host/You/reconnecting badges to the right edge, leaving the
   device (Android/Mobile/…) badge hugging the player name on the left. */
.wp-spacer {
  flex: 1;
}

.wp-badge {
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(240, 160, 48, .25);
  color: #f0a030;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.wp-you {
  background: rgba(77, 196, 245, .2);
  color: #4dc4f5;
}

.wp-disconnected {
  opacity: .45;
}

.wp-reconnecting {
  background: rgba(255, 200, 60, .18);
  color: #f0c030;
}

.wp-kick {
  margin-left: auto;
  background: transparent;
  border: none;
  color: rgba(var(--ink-rgb), .3);
  font-size: .8rem;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: color var(--dur-micro) var(--ease-settle), background var(--dur-micro) var(--ease-settle);
  flex-shrink: 0;
}

.wp-kick:hover {
  color: #e05050;
  background: rgba(224, 80, 80, .15);
}

/* ── Pill controls (theme picker; .ai-pill* class names retained) ───────── */
.theme-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.ai-pill {
  padding: 7px 10px;
  border-radius: 20px;
  border: 1.5px solid rgba(var(--ink-rgb), .18);
  background: rgba(var(--ink-rgb), .06);
  color: rgba(var(--ink-rgb), .55);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease-settle), border-color var(--dur-micro) var(--ease-settle), color var(--dur-micro) var(--ease-settle);
}

.ai-pill:hover {
  background: rgba(var(--ink-rgb), .12);
  color: rgba(var(--ink-rgb), .8);
}

.ai-pill-active {
  background: rgba(240, 160, 48, .2);
  border-color: #f0a030;
  color: #f0a030;
}

.wp-pers {
  font-size: .75rem;
  color: rgba(var(--ink-rgb), .38);
  font-style: italic;
}

.wp-ai {
  background: rgba(112, 64, 208, .28);
  color: #c090ff;
}

/* ── Platform (mode) badge ───────────────────────────────── */
.wp-mode {
  white-space: nowrap;
}

.wp-mode-ai {
  background: rgba(112, 64, 208, .28);
  color: #c090ff;
}

.wp-mode-mobile {
  background: rgba(40, 176, 96, .22);
  color: #6be0a0;
}

.wp-mode-desktop {
  background: rgba(56, 120, 224, .22);
  color: #88bbff;
}

.wp-mode-android {
  background: rgba(120, 200, 60, .22);
  color: #9ee066;
}

.wp-mode-ios {
  background: rgba(190, 195, 205, .2);
  color: #cfd4dc;
}

/* ── Auth bar — lives inside .site-header; keep only content styles ── */
.auth-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-bar--guest {}

.auth-bar-name {
  color: var(--text-strong);
  font-size: .9rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* Profile photo (or colour + initial) shown left of the username in the auth chip. */
.auth-bar-av {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 39.2px;
  height: 39.2px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  font-size: .91rem;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background-size: cover;
  background-position: center;
}

.auth-bar-av--img {
  border: 1px solid rgba(var(--ink-rgb), .35);
}

.auth-bar-av--color {
  border: 1px solid rgba(var(--ink-rgb), .25);
}

.auth-bar-link {
  color: var(--text-tan-link);
  font-size: .82rem;
  text-decoration: none;
}

.auth-bar-link:hover {
  text-decoration: underline;
}

/* ── Announcement ticker ─────────────────────────────────── */
.ticker-bar {
  position: fixed;
  /* Flush against the header so the two frosted bars merge into one continuous
     panel. --lobby-header-h tracks the header height (70px desktop, 86px mobile),
     so the ticker follows it automatically across breakpoints. */
  top: var(--lobby-header-h);
  left: 0;
  right: 0;
  z-index: 95;
  height: 30px;
  /* Frosted translucent fill matching .site-header (rgba(ink,.06) + blur), so the
     ticker reads as a seamless continuation of the header bar directly above it. */
  background: rgba(var(--ink-rgb), .06);
  border-bottom: 1px solid rgba(var(--ink-rgb), .1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
  display: flex;
  align-items: center;
}

.ticker-bar[hidden] {
  display: none;
}

/* Transform and duration are set entirely by JS (Web Animations API) after
   measuring the rendered text width, so the speed is always correct. */
.ticker-content {
  display: inline-block;
  flex-shrink: 0;
  white-space: nowrap;
  color: var(--text-amber);
  font-size: .79rem;
  font-weight: 600;
  letter-spacing: .01em;
}

/* Shared visual style for both count badges */
.msg-badge,
.ham-item-count {
  background: #d92828;
  color: #fff;
  border-radius: 10px;
  font-size: .70rem;
  font-weight: 700;
  line-height: 1.3;
  padding: 2px 7px;
  min-width: 22px;
  text-align: center;
  box-sizing: border-box;
}

/* Layout-specific overrides */
.msg-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 3px;
}

.msg-badge[hidden] {
  display: none;
}

/* ✉️ Messages button in the auth bar (with unread badge anchored top-right). */
.auth-bar-msg {
  position: relative;
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 2px;
  line-height: 1;
}

.auth-bar-msg .msg-badge {
  position: absolute;
  top: -7px;
  right: -9px;
  margin: 0;
}

/* ── Messages panel (two-pane inbox overlay) ─────────────── */
.msg-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--msg-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.msg-backdrop[hidden] {
  display: none;
}

.msg-panel {
  width: min(760px, 96vw);
  height: min(560px, 88vh);
  display: flex;
  flex-direction: column;
  background: var(--msg-bg);
  color: var(--text-cool);
  border: 1px solid rgba(var(--ink-rgb), .12);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .5);
}

.msg-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(var(--ink-rgb), .05);
  border-bottom: 1px solid rgba(var(--ink-rgb), .1);
}

.msg-title {
  order: 1;
  font-weight: 700;
  font-size: 1rem;
}

.msg-unread-pill {
  order: 1;
  background: #e05a5a;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 8px;
}

.msg-unread-pill[hidden] {
  display: none;
}

.msg-head-actions {
  order: 2;
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.msg-hd-btn {
  border: 1px solid rgba(var(--ink-rgb), .18);
  background: rgba(var(--ink-rgb), .08);
  color: var(--text-cool);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.msg-hd-btn:hover {
  background: rgba(var(--ink-rgb), .16);
}

.msg-close {
  order: 3;
  border: 0;
  background: none;
  color: rgba(var(--ink-rgb), .7);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
}

.msg-close:hover {
  color: var(--text-strong);
}

.msg-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.msg-senders {
  flex: 0 0 auto;
  width: max-content;
  min-width: 110px;
  max-width: 45%;
  overflow-y: auto;
  border-right: 1px solid rgba(var(--ink-rgb), .1);
  background: rgba(var(--inset-rgb), .18);
  padding: 6px;
}

.msg-sender {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: none;
  color: var(--text-cool-2);
  cursor: pointer;
  text-align: left;
  padding: 8px 9px;
  border-radius: 8px;
  font-size: .86rem;
}

.msg-sender:hover {
  background: rgba(var(--ink-rgb), .06);
}

.msg-sender-active {
  background: rgba(77, 196, 245, .16);
  color: var(--text-strong);
}

.msg-sender-ic {
  flex: 0 0 auto;
  font-size: 1rem;
}

.msg-sender-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-sender-badge {
  flex: 0 0 auto;
  background: #e05a5a;
  color: #fff;
  font-size: .66rem;
  font-weight: 700;
  border-radius: 9px;
  padding: 1px 6px;
}

.msg-thread {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.msg-thread-hd {
  padding: 10px 14px;
  font-weight: 700;
  font-size: .9rem;
  border-bottom: 1px solid rgba(var(--ink-rgb), .08);
  flex: 0 0 auto;
}

.msg-thread-hd a {
  color: #6fc6f2;
  text-decoration: none;
}

.msg-thread-hd a:hover {
  text-decoration: underline;
}

.msg-items {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-item {
  background: rgba(var(--ink-rgb), .04);
  border: 1px solid rgba(var(--ink-rgb), .08);
  border-radius: 9px;
  padding: 9px 11px;
}

.msg-item-unread {
  border-color: rgba(77, 196, 245, .45);
  background: rgba(77, 196, 245, .08);
}

.msg-item-hd {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.msg-item-subject,
.msg-item-from {
  font-weight: 700;
  font-size: .85rem;
  flex: 1 1 auto;
  min-width: 0;
}

.msg-item-date {
  font-size: .7rem;
  color: rgba(var(--ink-rgb), .45);
  flex: 0 0 auto;
}

/* Conversation bubbles: their messages on the left, mine on the right. */
.msg-item-mine,
.msg-item-theirs {
  max-width: 88%;
}

.msg-item-theirs {
  align-self: flex-start;
}

.msg-item-mine {
  align-self: flex-end;
  background: rgba(77, 196, 245, .12);
  border-color: rgba(77, 196, 245, .35);
}

.msg-item-mine .msg-item-from {
  text-align: right;
}

.msg-item-body {
  margin: 5px 0 7px;
  font-size: .85rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-item-actions {
  display: flex;
  gap: 6px;
}

.msg-mini {
  border: 1px solid rgba(var(--ink-rgb), .18);
  background: rgba(var(--ink-rgb), .07);
  color: var(--text-cool-2);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: .72rem;
  cursor: pointer;
}

.msg-mini:hover {
  background: rgba(var(--ink-rgb), .15);
}

/* Accept on a friend-request message — primary/affirmative accent. */
.msg-mini-accept {
  border-color: rgba(80, 200, 120, .5);
  background: rgba(80, 200, 120, .18);
  font-weight: 600;
}
.msg-mini-accept:hover {
  background: rgba(80, 200, 120, .3);
}

.msg-reply {
  border-top: 1px solid rgba(var(--ink-rgb), .1);
  padding: 9px 14px;
  flex: 0 0 auto;
  background: rgba(var(--inset-rgb), .15);
}

.msg-reply-hd {
  font-size: .76rem;
  color: rgba(var(--ink-rgb), .6);
  margin-bottom: 5px;
}

.msg-reply-text {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 90px;
  background: rgba(var(--inset-rgb), .3);
  border: 1px solid rgba(var(--ink-rgb), .15);
  border-radius: 7px;
  color: var(--text-input);
  padding: 7px 9px;
  font: inherit;
  font-size: .84rem;
}

.msg-reply-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.msg-reply-status {
  font-size: .76rem;
  color: rgba(var(--ink-rgb), .6);
  flex: 1 1 auto;
}

.msg-reply-status.ok {
  color: #6fd28a;
}

.msg-reply-status.err {
  color: #ff8a8a;
}

.msg-reply-send {
  margin-left: auto;
}

.msg-reply-note {
  padding: 12px 14px;
  font-size: .8rem;
  color: rgba(var(--ink-rgb), .5);
  flex: 0 0 auto;
  border-top: 1px solid rgba(var(--ink-rgb), .1);
}

.msg-empty {
  padding: 24px 16px;
  text-align: center;
  color: rgba(var(--ink-rgb), .5);
  font-size: .85rem;
}

.msg-empty-sm {
  padding: 12px;
  font-size: .8rem;
}

@media (max-width: 540px) {
  .msg-backdrop {
    padding: 0;
  }

  .msg-panel {
    height: 100%;
    width: 100%;
    border-radius: 0;
  }

  /* Header wraps to two rows: title + unread pill + close on row 1, the
     Contact Admin / Mark all read actions on their own row below. */
  .msg-head-actions {
    order: 3;
    flex: 1 1 100%;
    margin-left: 0;
  }

  .msg-close {
    order: 2;
    margin-left: auto;
  }
}

.auth-bar-btn {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid rgba(var(--ink-rgb), .2);
  background: rgba(var(--ink-rgb), .08);
  color: rgba(var(--ink-rgb), .8);
  font-size: .8rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background var(--dur-standard) var(--ease-settle);
}

.auth-bar-btn:hover {
  background: rgba(var(--ink-rgb), .15);
}

/* ── Primary actions row ─────────────────────────────────── */
.primary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Guests have no "Create Room" button — center the lone Quick Match button
   instead of leaving it stuck in the left grid column. */
.primary-actions.guest-single {
  grid-template-columns: minmax(0, 180px);
  justify-content: center;
}

/* ── Coming Soon placeholders (inert) ───────────────────── */
/* Tutorial spans the full width beneath the Quick Match / Create pair, dimmed. */
.btn-tutorial {
  grid-column: 1 / -1;
  background: rgba(var(--ink-rgb), .05);
  border: 1.5px dashed rgba(var(--ink-rgb), .2);
  color: rgba(var(--ink-rgb), .55);
  cursor: default;
}
.btn-tutorial:hover { background: rgba(var(--ink-rgb), .07); }
/* Shared "Coming Soon" badge (chooser button + Game Setup Custom Board row). */
.chooser-soon,
.gc-soon {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: #f0a030;
  background: rgba(240, 160, 48, .12);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
/* Custom Board placeholder row reads as unavailable. */
.gc-coming-soon { opacity: .6; }

/* Light mode: the amber #f0a030 badge text washes out on the pale background —
   darken it (and firm up the tint) so "Coming Soon" / "Required" stay legible. */
:root[data-theme="light"] .chooser-soon,
:root[data-theme="light"] .gc-soon,
:root[data-theme="light"] .field-group:has(#create-np-btns) .field-label::after {
  color: #a1560a;
  background: rgba(240, 160, 48, .2);
}

/* Mobile: when the Create Room panel is open, hide the Quick Match / Create Room
   action row above it so the panel takes the whole screen. */
@media (max-width: 540px) {
  #screen-join:has(#create-options:not([style*="none"])) #primary-actions,
  #screen-join:has(#mm-options:not([style*="none"])) #primary-actions {
    display: none;
  }
}

.btn-quickmatch {
  background: linear-gradient(135deg, #3878e0 0%, #1a50b0 100%);
  color: #fff;
}

.btn-quickmatch:hover:not(:disabled) {
  filter: brightness(1.1);
}

/* ── Create-room options panel ───────────────────────────── */
.create-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(var(--ink-rgb), .04);
  border: 1px solid rgba(var(--ink-rgb), .1);
  border-radius: 10px;
  padding: 14px;
  margin-top: 0;
}

/* Waiting-room card hosts the diagonal game-type ribbon. Relative + overflow
   anchor the ribbon firmly to the rounded corner (the band's ends are clipped);
   the top padding keeps it clear of the centred room-name header. */
#screen-wait {
  position: relative;
  overflow: hidden;
  padding-top: 40px;
}

/* Diagonal corner ribbon labelling the room's game type. A band rotated -45°
   across the top-left corner; the card's overflow:hidden clips its ends. */
.creator-ribbon {
  position: absolute;
  top: 0;
  left: 0;
  width: 112px;
  height: 112px;
  pointer-events: none;
  z-index: 3;
}

.creator-ribbon > span {
  position: absolute;
  top: 22px;
  left: -30px;
  width: 150px;
  padding: 5px 0;
  transform: rotate(-45deg);
  text-align: center;
  color: #fff;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}

.creator-ribbon--realtime > span { background: #0fa08c; }
.creator-ribbon--async    > span { background: #3878e0; }

/* "Room Creator" header label + its info "ⓘ" icon, kept snug together. */
.rcr-hd-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Info "ⓘ" icon — hidden on desktop (the explainer paragraph is shown instead),
   revealed only on mobile where the paragraph is removed to save space. The
   help text rides along as the button's `title`, surfaced via the shared
   tap-to-show tooltip system (.tip-open). */
.panel-info-btn {
  display: none;
}

/* The tooltip itself is defined by the shared .tip-open::after rules below
   (content-sized max-width bubble, popped down under the header). It must NOT
   use a left:0;right:0 stretch: for one frame after the tap the pseudo-element
   can resolve its containing block to the 17px button instead of .rooms-hd,
   and a stretched box then collapses to min-content — a one-word-per-line
   column that flashes before settling. A content-derived width can't collapse. */

.mm-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(var(--ink-rgb), .04);
  border: 1px solid rgba(var(--ink-rgb), .1);
  border-radius: 10px;
  padding: 14px;
  margin-top: 0;
}

.mm-options .mm-dm-row {
  margin-top: 10px;
}

.mm-options .btn-start-search {
  margin-top: 10px;
}

.mm-options .btn-back {
  margin-top: 8px;
  align-self: center;
}

.mode-toggle-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-toggle-opt {
  display: flex;
  flex-direction: column;
  flex: 1 1 140px;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid rgba(var(--ink-rgb), .15);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color var(--dur-micro) var(--ease-settle), background var(--dur-micro) var(--ease-settle);
}

.mode-toggle-opt:has(input:checked) {
  border-color: #3878e0;
  background: rgba(56, 120, 224, .08);
}

/* Visually hidden but still focusable & screen-reader accessible (was display:none,
   which made the native Pace radios keyboard-unreachable). :has(input:checked)
   styling below keeps working since the radios stay checked. */
.mode-toggle-opt input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
/* Visible focus indicator on the card when its hidden radio is keyboard-focused. */
.mode-toggle-opt:has(input:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.mode-toggle-opt span {
  font-weight: 600;
  font-size: .88rem;
}

.mode-toggle-opt small {
  font-size: .75rem;
  color: var(--text-grey);
}

/* Game-mode description moved to a tooltip (title) + tappable "i" info icon. */
.mode-toggle-opt { position: relative; }
.mode-info-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(var(--ink-rgb), .3);
  background: transparent;
  color: rgba(var(--ink-rgb), .5);
  font: italic 700 .72rem/1 Georgia, serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mode-info-btn:hover {
  color: rgba(var(--ink-rgb), .9);
  border-color: rgba(var(--ink-rgb), .6);
}

.btn-create-confirm {
  background: linear-gradient(135deg, #f0a030 0%, #d06020 100%);
  color: #fff;
  width: 100%;
  padding: 11px;
  font-size: .95rem;
}

.btn-create-confirm:hover:not(:disabled) {
  filter: brightness(1.1);
}

/* ── Public rooms section ────────────────────────────────── */
.rooms-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.rooms-hd {
  position: relative; /* anchors the create-panel info tooltip within the card */
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 30px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(var(--ink-rgb), .1);
}

/* Groups the label + count so they always sit together on one line. */
.rooms-hd-main {
  display: flex;
  align-items: center;
  gap: 30px;
}

/* Filter/collapse buttons — pushed to the far right, dropping to their own
   row only if the label + count don't leave them enough space. */
.rooms-hd-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* When a header has no filter button, push the collapse toggle to the far
   right instead — keeps the count right next to the label like panels that
   do have a filter button (which already use margin-left: auto). */
.rooms-count+.rooms-collapse-toggle {
  margin-left: auto;
}

.rooms-hd-label {
  font-size: .95rem;
  font-weight: 700;
  color: rgba(var(--text-header-rgb), .85);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Custom tooltip for [title] elements — toggled via .tip-open (tap/click
   in lobby.js) instead of the slow/inconsistent native title tooltip. Plain
   :hover isn't used because touch devices get "stuck" hover after a tap that
   tapping the same element (or its tooltip) doesn't clear. Shared by panel
   header labels, room-card param chips, the delete timer, and the rejoin
   meta line. */
.rooms-hd-label[title],
.rejoin-players[title] {
  position: relative;
  cursor: help;
}

.rooms-hd-label[title].tip-open::after,
.rc-param[title].tip-open::after,
.rc-delete-timer[title].tip-open::after,
.panel-info-btn[title].tip-open::after,
.rejoin-players[title].tip-open::after {
  content: attr(title);
  position: absolute;
  left: 0;
  background: var(--modal-bg);
  border: 1px solid rgba(var(--ink-rgb), .15);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: .75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  text-align: left;
  width: max-content;
  max-width: 240px;
  color: var(--text-cool);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  z-index: 50;
  pointer-events: auto;
}

/* Header label + rejoin meta line sit near the top of their box — pop the
   tooltip down below them. */
.rooms-hd-label[title].tip-open::after,
.panel-info-btn[title].tip-open::after,
.rejoin-players[title].tip-open::after {
  top: 100%;
  margin-top: 6px;
}

/* Param chips + delete timer are pinned to the card's bottom edge — pop the
   tooltip up above them instead, so it doesn't run off the card. */
.rc-param[title].tip-open::after,
.rc-delete-timer[title].tip-open::after {
  bottom: 100%;
  margin-bottom: 6px;
}

.rooms-count {
  font-size: .85rem;
  color: #28b060;
  font-weight: 600;
}

.live-hd-stats {
  font-size: .82rem;
}

.live-stalled-count {
  color: rgba(var(--ink-rgb), .45);
  font-weight: 600;
}

@media (max-width: 540px) {
  #screen-live .rooms-hd-main {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  #screen-live .live-hd-stats {
    flex-basis: 100%;
  }
}

/* Status dot in front of the "Live Games" label and on each live-game card —
   colour shows status, blink speed shows activity (set via JS: no class = empty,
   .blink-slow = a few, .blink-normal = lots). */
.rooms-hd-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.rooms-hd-dot-live {
  background: #28b060;
  box-shadow: 0 0 6px rgba(40, 176, 96, .8);
}

/* Still dot for a live-game card whose real players have all disconnected. */
.rooms-hd-dot-idle {
  background: rgba(var(--ink-rgb), .25);
}

@keyframes rooms-hd-dot-blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .2;
  }
}

.rooms-hd-dot.blink-slow {
  animation: rooms-hd-dot-blink 3s ease-in-out infinite;
}

.rooms-hd-dot.blink-normal {
  animation: rooms-hd-dot-blink 1.2s ease-in-out infinite;
}

.public-rooms-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* ── Empty states (Step 6) — one calm, inviting pattern for every list ──────
   Icon + one-line message + at most one clear next action. Shared by rooms,
   live games, social and player lists so they never read as an error. */
.rooms-empty,
.social-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: rgba(var(--ink-rgb), .5);
  font-size: .84rem;
  padding: 22px 12px;
  grid-column: 1 / -1;   /* span the full width when the list is a grid */
}
.lobby-empty-icon { font-size: 1.55rem; line-height: 1; opacity: .7; }
.lobby-empty-text { color: rgba(var(--ink-rgb), .58); max-width: 34ch; }
.lobby-empty-cta {
  margin-top: 4px;
  padding: 7px 16px;
  border: 1px solid rgba(var(--ink-rgb), .18);
  border-radius: 8px;
  background: rgba(var(--ink-rgb), .06);
  color: var(--text-strong);
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease-settle);
}
.lobby-empty-cta:hover { background: rgba(var(--ink-rgb), .12); }

/* ── Skeleton loaders (Step 6) — game-like placeholders while lists load ────
   Calm opacity pulse reusing a motion token; the Step 1 guard freezes it for
   reduced-motion users. Decorative only (aria-hidden in markup). Overwritten by
   the first render, so no JS lifecycle beyond the render itself. */
.lobby-skel {
  display: grid;
  gap: 10px;
  padding: 4px 0;
  grid-column: 1 / -1;
}
.lobby-skel-row {
  height: 62px;
  border-radius: 9px;
  background: rgba(var(--ink-rgb), .06);
  border: 1px solid rgba(var(--ink-rgb), .05);
  animation: lobby-skel-pulse var(--dur-ambient) ease-in-out infinite;
}
.lobby-skel-row.is-sm { height: 44px; }
@keyframes lobby-skel-pulse {
  0%, 100% { opacity: .45; }
  50%      { opacity: .8; }
}

/* ── My Games sub-tabs (Active / Waiting / Finished) ─────────────────────── */
.mg-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border-radius: 12px;
  /* Pin the tab header below the fixed lobby header + ticker so it never slides
     under (or overlaps) them as the card list grows and scrolls. The card list
     scrolls with the page beneath this bar. z-index keeps it above the scrolling
     cards but below the fixed header/ticker (z 95+), which it never reaches
     anyway thanks to the top offset. The opaque fill (page base + the same .05
     ink tint the card uses) hides cards passing underneath — the tabs and cards
     share the card's content-box width, so there's no side gutter to leak. */
  position: sticky;
  top: calc(var(--lobby-header-h) + var(--lobby-ticker-h));
  z-index: 20;
  /* Rounded segmented-control track: a subtle ink tint sitting on an opaque
     page-base backdrop (drawn by ::before) so cards scrolling under the sticky
     bar never show through — the ::before is a full rectangle, so even the
     track's rounded corners stay opaque. */
  background: rgba(var(--ink-rgb), .06);
}

.mg-tabs::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--page-base);
}

.mg-tab {
  flex: 1 1 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-cool-2);
  font-size: .88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-micro) var(--ease-settle), background var(--dur-micro) var(--ease-settle), box-shadow var(--dur-micro) var(--ease-settle);
}

.mg-tab:hover {
  color: var(--text-cool);
  background: rgba(var(--ink-rgb), .06);
}

/* Active tab: a raised orange pill with near-black text. The soft shadow lifts
   the selected segment off the track; dark ink on the orange accent clears WCAG
   AAA (~9:1) in both themes while keeping the brand colour as the selection cue. */
.mg-tab.is-active {
  color: #1a1205;
  background: #f0a030;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .14), 0 3px 8px rgba(240, 160, 48, .32);
}

/* Per-tab item counter — a quiet pill that always reflects the bucket size. */
.mg-tab-count {
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(var(--ink-rgb), .1);
  color: rgba(var(--ink-rgb), .6);
  font-size: .74rem;
  font-weight: 700;
  line-height: 1.5;
}

/* On the active (orange) tab the pill inverts to a dark translucent chip with
   near-black text — high contrast against the orange fill in both themes. */
.mg-tab.is-active .mg-tab-count {
  background: rgba(0, 0, 0, .24);
  color: #1a1205;
}

/* Red-star turn indicator — subtle but clearly noticeable; persists while it's
   the player's turn in any active game. */
.mg-tab-star {
  position: absolute;
  top: 4px;
  right: 6px;
  color: #ff2828;
  font-size: .72rem;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 0 3px rgba(255, 40, 40, .55));
  animation: mg-star-in .2s ease-out;
}

.mg-tab-star[hidden],
.mg-tab-hint[hidden] {
  display: none;
}

/* Secondary-attention dot for a near-start waiting room (only shown when there's
   no higher-priority turn). Calmer than the red star. */
.mg-tab-hint {
  position: absolute;
  top: 5px;
  right: 7px;
  color: #f0a030;
  font-size: .6rem;
  line-height: 1;
  pointer-events: none;
}

/* On the active tab's orange fill the orange hint dot would vanish — darken it. */
.mg-tab.is-active .mg-tab-hint {
  color: #1a1205;
}

@keyframes mg-star-in {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* One-shot pulse when a new turn pulls Active Games to the front. */
.mg-tab-pulse {
  animation: mg-tab-pulse 1s ease-out 2;
}

@keyframes mg-tab-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(240, 160, 48, .5); }
  70%  { box-shadow: 0 0 0 8px rgba(240, 160, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(240, 160, 48, 0); }
}

.mg-panel[hidden] { display: none; }

/* Narrow screens: shrink the tab labels so all three fit one row. */
@media (max-width: 540px) {
  .mg-tab {
    flex-direction: column;
    gap: 4px;
    font-size: .78rem;
    padding: 8px 4px;
  }
  .mg-tab-count { padding: 0 6px; font-size: .7rem; }
}

/* ── Friends & recent players (P9) ───────────────────────── */
/* Each lobby panel grows to fit its full content — no internal scrollbar; the
   page scrolls as a whole instead. */
#social-body,
#player-list-body,
#rooms-body,
#live-body,
#screen-active-game .rooms-body {
  max-height: none;
  overflow-y: visible;
}

.social-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.friend-reqs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.friend-reqs:not(:empty) {
  margin-bottom: 6px;
}

/* Friends panel tabs (Friends / Requests). The Requests tab is hidden when
   there are no pending requests (toggled inline by renderSocial). */
.social-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(var(--ink-rgb), .1);
}

.social-tab {
  appearance: none;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  color: rgba(var(--ink-rgb), .45);
  padding: 6px 10px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.social-tab:hover {
  color: rgba(var(--ink-rgb), .7);
}

.social-tab.is-active {
  color: var(--text-cool);
  border-bottom-color: var(--text-cool);
}

.social-tab-badge {
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: 9px;
  background: #d24a3a;
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

.social-sub-hd {
  font-size: .72rem;
  font-weight: 700;
  color: rgba(var(--ink-rgb), .4);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 10px 0 2px;
}

.sc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(var(--ink-rgb), .04);
  border: 1px solid rgba(var(--ink-rgb), .07);
  border-radius: 9px;
  padding: 6px 9px;
}

.sc-id {
  display: flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  min-width: 0;
}

.sc-av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex: 0 0 auto;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sc-av-txt {
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-strong);
}

.sc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.sc-dot.sc-on {
  background: #28b060;
  box-shadow: 0 0 5px rgba(40, 176, 96, .8);
}

.sc-dot.sc-off {
  background: rgba(var(--ink-rgb), .22);
}

/* Presence dot inline in a Waiting-Rooms player chip. */
.rejoin-pl .sc-dot {
  display: inline-block;
  vertical-align: middle;
  margin: 0 4px 0 2px;
}

.sc-name {
  color: var(--text-cool);
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* User-entered names, room names, and message text may mix Persian/RTL with emoji
   or Latin text. `unicode-bidi: plaintext` derives each element's base direction
   from its own content (the CSS equivalent of dir="auto"), so a trailing emoji
   lands on the correct logical side instead of the page's LTR default — matching
   how the chat bubble already renders. English/pure-Persian text is unaffected. */
.sc-name, .rc-host, .rejoin-room, .jr-name, .rejoin-pl-link, .mm-player-chip,
.msg-sender-name, .msg-item-from, .msg-item-subject, .msg-item-body,
/* Waiting-room header + the Create Room field: same rule, so the name the host
   types, the name shown while waiting and the name on the room card all agree. */
.room-name-value, #inp-room-name {
  unicode-bidi: plaintext;
}

.sc-id:hover .sc-name {
  text-decoration: underline;
}

.sc-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.sc-req-lbl {
  font-size: .73rem;
  color: rgba(var(--ink-rgb), .4);
  font-style: italic;
}

/* Friend-request cards: action buttons crowd the name and truncate it, so wrap
   them onto their own row below the name/avatar instead of shrinking it. */
#friend-reqs .sc-row {
  flex-wrap: wrap;
}

#friend-reqs .sc-id {
  flex: 1 1 100%;
}

#friend-reqs .sc-actions {
  flex: 1 1 100%;
  justify-content: flex-end;
}

/* Incoming request: [avatar] + the FULL name (never ellipsised to "Dav…") + "wants
   to be friends" share the top line, then the Accept/Decline buttons sit below. */
.sc-req-row .sc-id {
  flex-wrap: wrap;
}

.sc-req-row .sc-id .sc-req-lbl {
  flex: 0 0 auto;
}

.sc-req-row .sc-name {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.sc-btn {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font: inherit;
  font-size: .76rem;
  font-weight: 600;
  padding: 5px 9px;
  color: var(--text-cool);
  background: rgba(var(--ink-rgb), .1);
}

.sc-btn:hover {
  background: rgba(var(--ink-rgb), .18);
}

.sc-add,
.sc-accept,
.sc-invite {
  background: #1f7a45;
  color: #fff;
}

.sc-add:hover,
.sc-accept:hover,
.sc-invite:hover {
  background: #28b060;
}

.sc-invite-sent {
  background: #123a23;
  color: #7fb89a;
  cursor: default;
}

.sc-invite-locked {
  position: relative;
  background: rgba(var(--ink-rgb), .08);
  color: var(--text-cool);
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}
.sc-invite-locked::after {
  content: 'PRO';
  position: absolute;
  top: -7px;
  right: -8px;
  background: linear-gradient(135deg, #b8860b, #daa520);
  color: #1a1000;
  font-size: .48rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 4px;
  letter-spacing: .04em;
  line-height: 1.6;
  pointer-events: none;
}

.sc-decline,
.sc-remove,
.sc-cancel {
  background: rgba(255, 90, 90, .16);
  color: var(--text-red-2);
}

.sc-decline:hover,
.sc-remove:hover,
.sc-cancel:hover {
  background: rgba(255, 90, 90, .3);
}

/* Player List — search results show quick stats + reputation alongside the name */
.pl-row {
  flex-wrap: wrap;
}

.pl-row .sc-id {
  flex: 1 1 auto;
}

.pl-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.pl-stat {
  font-size: .76rem;
  color: rgba(var(--ink-rgb), .6);
  white-space: nowrap;
}

.pl-seen {
  font-size: .72rem;
  color: rgba(var(--ink-rgb), .35);
  white-space: nowrap;
}

.pl-rep {
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.pl-rep-trusted {
  background: rgba(40, 176, 96, .18);
  color: #5fd98a;
}

.pl-rep-good {
  background: rgba(var(--ink-rgb), .08);
  color: rgba(var(--ink-rgb), .6);
}

.pl-rep-neutral {
  background: rgba(var(--ink-rgb), .06);
  color: rgba(var(--ink-rgb), .4);
}

.pl-rep-low {
  background: rgba(255, 90, 90, .16);
  color: var(--text-red-2);
}

.wait-invite-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 6px;
}

/* ── Banner rail (Banner Manager — docs/lobby-banner-system-design.md) ──────────
   The SINGLE presentation container for every lobby banner. This is the one and only
   place banner spacing is defined: `gap` between banners, `margin-bottom` to the lobby
   content. Individual banners carry NO layout margins and NO adjacency rules — adding a
   new banner must never require a new CSS special case (that requirement is exactly why
   the old `.resume-banner[style*="flex"] + .invite-banner { margin-top:-36px }` hack,
   and its inline-style sniffing, are gone). Banner nodes are added/removed by the
   manager, so they never toggle `display` themselves. In-flow (never sticky), so the
   rail scrolls away and can't permanently eat mobile height. */
.lobby-banners {
  display: flex;                  /* toggled to none by the manager when the rail is empty */
  flex-direction: column;
  gap: 6px;                       /* ← the ONLY inter-banner spacing rule */
  width: min(96%, 620px);
  margin: 0 auto 14px;            /* ← the ONLY rail → content spacing rule */
}

/* ── System Status layer ──────────────────────────────────────────────────────
   Application/system health (connection lost / maintenance / forced update) renders ABOVE
   the user-action rail, in its OWN strip — a SEPARATE presentation layer, not part of the
   Banner Manager. Same in-flow layout contract as the rail — NOT sticky, NOT fixed, so it
   can never cover content or jump on scroll. Same single-`gap` spacing rule. */
.system-status {
  display: flex;                  /* toggled to none by the layer when empty */
  flex-direction: column;
  gap: 6px;
  width: min(96%, 620px);
  margin: 0 auto 8px;
}
.system-status [hidden] { display: none !important; }
.status-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--msg-bg);
  border: 1px solid rgba(214, 96, 72, .65);
  border-left: 4px solid #d66048;
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
}
.status-item .lb-icon { font-size: 1.1rem; color: #d66048; flex-shrink: 0; }
.status-item .lb-text { color: var(--text-cool); font-size: .9rem; flex: 1 1 auto; }
.status-item .lb-text strong { color: var(--text-strong); }

/* ── Height guard ─────────────────────────────────────────────────────────────
   Belt to the manager's braces: the manager measures the rail and collapses banners into
   "+N more" when large-text / accessibility scaling makes it too tall (see renderBanners
   step 3). These caps stop the rail from ever eating the viewport even mid-reflow, before
   that measurement lands. Long text WRAPS rather than clipping, and the expanded overflow
   list — the one place a deliberate pile-up can happen — scrolls INSIDE itself, so the page
   never scrolls sideways and the layout below never jumps. */
.lobby-banners,
.system-status { max-height: 60vh; }
.lobby-banners .lb-text,
.system-status .lb-text { overflow-wrap: anywhere; }

/* The banner skins set display:flex, which would beat the UA's [hidden]{display:none}. */
.lobby-banners [hidden] { display: none !important; }

/* ── Generic banner internals (Phase 2) ───────────────────────────────────────
   The Banner Manager renders EVERY banner with this one shape (icon · text · actions),
   so a new banner needs no markup and no CSS of its own — only a provider. The per-banner
   classes (.resume-banner / .invite-banner) are now nothing but a colour skin. */
.lobby-banners .lb-icon { font-size: 1.2rem; flex-shrink: 0; }
/* Two lines, hard ceiling. A banner is a one-glance cue, so it must not grow with
   the length of a player or room name — both are user-supplied and can reach 20 and
   30 characters. Without the clamp a long pair wrapped to three lines and made the
   banner taller than its neighbours; with it, an extreme case ellipsises instead
   (the full text is always on the card in My Games ▸ Invitations). min-width:0 lets
   the flex item shrink below its min-content width so the clamp can take effect. */
.lobby-banners .lb-text {
  color: var(--text-cool);
  font-size: .9rem;
  flex: 1 1 auto;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.lobby-banners .lb-text strong { color: var(--text-strong); }
.lobby-banners .lb-count { color: var(--text-muted-grey); font-size: .82rem; }
.lobby-banners .lb-link { color: var(--text-tan-link); font-weight: 700; text-decoration: none; }
.lobby-banners .lb-link:hover { text-decoration: underline; }
/* The action column is fixed-width, so every pixel it takes comes straight out of
   the text beside it. Tightened so a two-line message fits on a 360px phone. */
.lobby-banners .lb-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
/* The whole banner is a tap target that takes you to the card it describes, so it
   has to look like one. The action buttons sit above it and keep their own cursor. */
.lobby-banners .lb-tappable { cursor: pointer; }
.lobby-banners .lb-tappable:hover { border-color: rgba(40, 176, 96, .85); }
.lobby-banners .lb-tappable:focus-visible {
  outline: 2px solid var(--text-tan-link, #d8b978);
  outline-offset: 2px;
}
.lobby-banners .lb-tappable .lb-btn { cursor: pointer; }

/* The Turn banner keeps its green ▶ and slightly smaller glyph. */
.resume-banner .lb-icon { font-size: 1.05rem; color: #28b060; }

.lb-btn {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  padding: 7px 10px;
  flex-shrink: 0;
}
.lb-btn--primary { background: #28b060; color: #fff; }
.lb-btn--primary:hover { background: #34c873; }
/* Local-only dismiss (✕): hides the banner client-side; never declines anything. */
.lb-btn--close {
  background: transparent;
  color: var(--text-muted-grey);
  font-size: .9rem;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
}
.lb-btn--close:hover { background: rgba(var(--ink-rgb), .12); color: var(--text-strong); }

/* ── Bounded rail overflow: "+N more ▾" (expands in place; no notification centre) ── */
.lb-more {
  align-self: stretch;
  border: 1px dashed rgba(var(--ink-rgb), .22);
  background: transparent;
  color: var(--text-muted-grey);
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  padding: 6px 12px;
  transition: background var(--dur-micro) var(--ease-settle), color var(--dur-micro) var(--ease-settle);
}
.lb-more:hover,
.lb-more:focus-visible { background: rgba(var(--ink-rgb), .08); color: var(--text-strong); }

.lb-overflow {
  display: flex;
  flex-direction: column;
  gap: 6px;                       /* same single spacing rule, inside the expanded list */
  /* The expanded list is the one place many banners can stack at once. Cap it and scroll
     INSIDE it, so expanding never pushes the lobby off screen (in-flow, never sticky). */
  max-height: 42vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Incoming-invite banner — a skin only (colours/padding); the rail owns its layout. */
.invite-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--msg-bg);
  border: 1px solid rgba(40, 176, 96, .5);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
}

/* Resume / Your Turn banner — a skin only (colours/padding); the .lobby-banners rail owns
   its layout, spacing and ordering. Shares the invite-banner visual language. */
.resume-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--msg-bg);
  border: 1px solid rgba(40, 176, 96, .5);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
}

/* Minimal lobby toast */
.lobby-toast {
  position: fixed;
  left: 50%;
  bottom: 72px;
  transform: translateX(-50%) translateY(8px);
  z-index: 5001;
  background: var(--msg-bg);
  color: var(--text-cool);
  border: 1px solid rgba(var(--ink-rgb), .14);
  border-radius: 9px;
  padding: 9px 16px;
  font-size: .85rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-standard) var(--ease-settle), transform var(--dur-standard) var(--ease-settle);
}

.lobby-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Room card ───────────────────────────────────────────── */
.room-card {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  /* room name (top of the info column) stays top-left */
  align-content: flex-start;
  /* pack lines at the top — leftover height (from equal-
                                 height grid rows) collapses below, not between lines */
  gap: 10px;
  background: rgba(var(--ink-rgb), .06);
  border: 1px solid rgba(var(--ink-rgb), .09);
  border-radius: 9px;
  padding: 10px 12px 34px;
  /* bottom space reserved for the pinned .rc-params strip,
                               plus an 8px gap above it */
  transition: background var(--dur-micro) var(--ease-settle),
              transform var(--dur-standard) var(--ease-settle),
              box-shadow var(--dur-standard) var(--ease-settle);
}

.room-card:hover {
  background: rgba(var(--ink-rgb), .1);
  transform: translateY(-2px);
  box-shadow: var(--elev-shadow);
}

.rc-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rc-host {
  font-size: 1.155rem;
  font-weight: 700;
  color: var(--text-cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

/* Title row: shared base — full-width flex strip used by both open-room cards
   and rejoin cards. */
.rc-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  flex-basis: 100%;
  min-width: 0;
}

/* Open-room cards: badges row on top, room name on the line below. */
.room-card>.rc-title-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

/* Badge row inside the open-room title: Turn-Based · Waiting · Classic */
.rc-flags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}

/* Rejoin cards: badges on top, room name on the line below. */
.rejoin-card>.rc-title-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.rc-mode {
  flex: 0 0 auto;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.5;
  background: rgba(150, 150, 150, .18);
  color: var(--text-grey);
  border: 1px solid rgba(150, 150, 150, .3);
}

.rc-mode--tideport {
  background: rgba(30, 100, 160, .30);
  color: var(--text-mode-tideport);
  border-color: rgba(80, 160, 220, .4);
}

.rc-mode--space {
  background: rgba(80, 30, 140, .30);
  color: var(--text-mode-space);
  border-color: rgba(130, 70, 200, .4);
}

.rc-async-badge,
.rc-realtime-badge {
  flex: 0 0 auto;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.5;
}

.rc-async-badge {
  background: rgba(56, 120, 224, .18);
  color: #3878e0;
  border: 1px solid rgba(56, 120, 224, .35);
}

.rc-realtime-badge {
  background: rgba(15, 160, 140, .15);
  color: #0fa08c;
  border: 1px solid rgba(15, 160, 140, .35);
}

.rejoin-card-async {
  border-left: 3px solid #3878e0;
}

/* Player count / start-time line — full-width strip directly below the title
   row (like .rc-params), so the text gets the whole card's width and matches
   .rejoin-players' position. */
.rc-meta {
  flex-basis: 100%;
  font-size: .75rem;
  color: rgba(var(--ink-rgb), .4);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rc-players {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  margin-top: 2px;
}

.rc-pl-chip {
  display: flex;
  align-items: center;
  gap: 4px;
}

.rc-pl-av {
  width: 39.2px;
  height: 39.2px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .91rem;
  font-weight: 800;
  color: rgba(0, 0, 0, .65);
  background-size: cover;
  background-position: center;
}

.rc-pl-name {
  font-size: .75rem;
  color: rgba(var(--ink-rgb), .7);
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Player names that link to a profile (humans only — AI bots stay plain text).
   No `color: inherit` here — real player names should keep the same colour as
   AI player names (.rc-pl-name / .wp-name), not whatever colour their
   containing card happens to inherit. */
.rc-pl-link,
a.wp-name {
  text-decoration: none;
  cursor: pointer;
}

.rc-pl-link:hover,
a.wp-name:hover {
  text-decoration: underline;
}

/* Active Game player chip link: unlike the above, .rejoin-pl-link has no
   AI-name sibling class to borrow a colour from, so without `color: inherit`
   it fell back to the browser's default link blue/purple. Inheriting matches
   the AI player's plain-text colour (and the "you" highlight). */
.rejoin-pl-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.rejoin-pl-link:hover {
  text-decoration: underline;
}

.rc-pl-tag {
  font-size: .58rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.rc-pl-host {
  background: rgba(var(--ink-rgb), .13);
  color: rgba(var(--ink-rgb), .6);
}

.rc-pl-ai {
  background: rgba(100, 180, 255, .18);
  color: #80c8ff;
}

.rc-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  align-self: stretch;
  gap: 6px;
  flex-shrink: 0;
}

.rc-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.rc-status {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.5;
  background: rgba(var(--ink-rgb), .08);
  color: rgba(var(--ink-rgb), .45);
  border: 1px solid rgba(var(--ink-rgb), .13);
}

.rc-dots {
  display: flex;
  gap: 3px;
}

.rc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(var(--ink-rgb), .15);
}

.rc-dot-filled {
  background: #28b060;
}

.btn-rc-join {
  padding: 5px 14px;
  border-radius: 6px;
  background: linear-gradient(135deg, #28b060, #166038);
  color: #fff;
  /* Transparent 1px border reserves the same box the outlined .btn-rc-share adds,
     so the two are pixel-identical in height (a border always adds to an
     auto-height element, even under box-sizing:border-box). */
  border: 1px solid transparent;
  font-size: .8rem;
  font-weight: 700;
  /* Fixed line-height so emoji-bearing labels (👁 Watch, 🔗 Share) don't render
     taller than plain ones (Join) — keeps every compact card action the same height. */
  line-height: 1.4;
  cursor: pointer;
  transition: filter var(--dur-micro) var(--ease-settle), opacity var(--dur-micro) var(--ease-settle);
  white-space: nowrap;
}

.btn-rc-join:hover:not(:disabled) {
  filter: brightness(1.12);
}

.btn-rc-join:disabled {
  opacity: .45;
  cursor: default;
}

/* Pending state — amber */
.btn-rc-join.rc-pending {
  background: linear-gradient(135deg, #c07828, #7a4a10);
}

/* Share-room button — subtle outlined secondary action. The BASE style matches the
   compact card-action pills it sits beside (Join / Watch / Rejoin / View): same
   padding, radius, font-size and fixed line-height so they read as one button
   group. Per-context overrides below re-size it to the larger neighbours in the
   Waiting-Room and Invitation cards. box-sizing:border-box (global) means the 1px
   outline doesn't add height, so it lines up with the border-less neighbours. */
.btn-rc-share {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid rgba(var(--ink-rgb), .22);
  background: rgba(var(--ink-rgb), .05);
  color: rgba(var(--ink-rgb), .7);
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  transition: filter var(--dur-micro) var(--ease-settle),
              background var(--dur-micro) var(--ease-settle),
              border-color var(--dur-micro) var(--ease-settle);
}
.btn-rc-share:hover {
  background: rgba(var(--ink-rgb), .1);
  border-color: rgba(var(--ink-rgb), .35);
}
.btn-rc-share:active { filter: brightness(.95); }

/* Waiting-Room card: neighbour is the large "↩ Enter" (.btn-lobby) — match its
   padding / radius / font so the two stacked buttons are the same size. */
.rejoin-card-waiting .btn-rc-share {
  padding: 13px 20px;
  border-radius: 9px;
  font-size: 1rem;
  line-height: 1.25;   /* ≈ .btn-lobby's normal line-height, minus its own border, so heights match */
  letter-spacing: .5px;
}
/* Invitation card: neighbours are the medium Accept / Decline (.invite-actions
   .btn-lobby, min-width 104px) — match them so all three align in the column. */
.invite-actions .btn-rc-share {
  padding: 9px 14px;
  border-radius: 9px;
  font-size: .82rem;
  line-height: 1.2;
  letter-spacing: .5px;
  min-width: 104px;
}

/* In the host waiting-room header the Share button sits centered under the room
   name (its row is text-aligned centre) rather than in a card action column. */
.btn-share-wait {
  margin-top: 6px;
}

/* Cancel link below a pending card */
.rc-cancel-link {
  font-size: .72rem;
  color: rgba(var(--ink-rgb), .35);
  cursor: pointer;
  text-align: right;
  padding-right: 2px;
  text-decoration: underline;
  transition: color var(--dur-micro) var(--ease-settle);
  margin-top: 3px;
}

.rc-cancel-link:hover {
  color: var(--text-red-2);
}

/* Feedback message at the bottom of a specific room card (reject / ban / kick) */
.rc-card-msg {
  width: 100%;
  font-size: .76rem;
  color: var(--text-amber);
  text-align: center;
  padding: 5px 0 2px;
  line-height: 1.3;
}

/* AI-only / abandoned room — deletion countdown pinned to the card's bottom-left,
   so it stays anchored there even when the card is stretched taller (e.g. equal-
   height grid cells). The card reserves bottom padding via .rc-has-timer /
   .rejoin-has-timer so the absolute timer never overlaps the card's content. */
.rc-delete-timer {
  position: absolute;
  left: 12px;
  bottom: 8px;
  font-size: .76rem;
  color: var(--text-amber);
  text-align: left;
  line-height: 1.3;
  cursor: help;
}

.rc-delete-timer .rc-dt-val {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: .02em;
}

/* Waiting-room card meta: Created / Last activity / Expires. */
.wr-details {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 6px;
  font-size: .74rem;
  color: rgba(var(--ink-rgb), .55);
}
.wr-details .wr-detail-k {
  font-weight: 700;
  color: rgba(var(--ink-rgb), .4);
  margin-right: 3px;
}

/* Waiting-room expiry countdown — escalating severity colour (no animation).
   Default (>7 days) inherits the neutral amber above; these tighten as expiry
   approaches. Light-theme overrides keep the contrast readable. */
.wr-expire.wr-exp-warn   { color: #f0a030; }
.wr-expire.wr-exp-strong { color: #f07a30; font-weight: 700; }
.wr-expire.wr-exp-crit   { color: #f04040; font-weight: 800; }
:root[data-theme="light"] .wr-expire.wr-exp-warn   { color: #b06a14; }
:root[data-theme="light"] .wr-expire.wr-exp-strong { color: #b8480e; }
:root[data-theme="light"] .wr-expire.wr-exp-crit   { color: #c01818; }

.room-card.rc-has-timer {
  padding-bottom: 58px;
}

.rejoin-card.rejoin-has-timer {
  padding-bottom: 58px;
}

/* When a delete-timer is present, it takes the bottom-8px slot — push the
   pinned params strip up above it, with an 8px gap between the two. */
.room-card.rc-has-timer>.rc-params,
.rejoin-card.rejoin-has-timer>.rc-params {
  bottom: 32px;
}

/* Banned room card — greyed out */
.room-card.rc-banned {
  opacity: .45;
  filter: grayscale(.6);
  pointer-events: none;
}

/* ── Join-requests panel (host waiting room) ─────────────── */
.join-requests-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.join-requests-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.jr-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  background: rgba(var(--ink-rgb), .06);
  border: 1px solid rgba(var(--ink-rgb), .1);
  border-radius: 8px;
  padding: 9px 12px;
}

.jr-name {
  color: var(--text-cream);
  font-size: .9rem;
  font-weight: 600;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.jr-av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 800;
  color: rgba(0, 0, 0, .65);
  background-size: cover;
  background-position: center;
}

.jr-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-self: flex-end;
}

.btn-jr {
  padding: 5px 11px;
  border-radius: 6px;
  border: none;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter var(--dur-micro) var(--ease-settle);
}

.btn-jr:hover {
  filter: brightness(1.12);
}

.btn-jr-accept {
  background: linear-gradient(135deg, #28b060, #166038);
  color: #fff;
}

.btn-jr-reject {
  background: rgba(200, 80, 80, .3);
  border: 1px solid rgba(200, 80, 80, .5);
  color: var(--text-red-2);
}

.btn-jr-ban {
  background: rgba(120, 40, 40, .4);
  border: 1px solid rgba(200, 60, 60, .5);
  color: var(--text-red);
}

/* ── Banned-players panel ────────────────────────────────── */
.banned-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
}

.banned-label {
  font-size: .72rem;
  font-weight: 700;
  color: rgba(var(--ink-rgb), .35);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.banned-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.banned-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(120, 40, 40, .3);
  border: 1px solid rgba(200, 60, 60, .35);
  border-radius: 20px;
  padding: 3px 10px 3px 10px;
  font-size: .75rem;
  color: var(--text-red-2);
}

.btn-unban {
  background: none;
  border: none;
  color: rgba(255, 130, 130, .6);
  cursor: pointer;
  font-size: .75rem;
  padding: 0;
  line-height: 1;
  transition: color var(--dur-micro) var(--ease-settle);
}

.btn-unban:hover {
  color: var(--text-strong);
}

/* ── Quick Match preference screen ──────────────────────── */
.mm-pref-label {
  text-align: center;
  color: rgba(var(--ink-rgb), .55);
  font-size: .9rem;
}

/* Segmented-control pill groups (Quick Match player count + Pace, Create Room
   Players, Game Setup Players). One shared visual treatment; flex sizing is kept
   per-group below so each group keeps its current layout. Wraps so a 4th "Any"
   chip flows to a new row. */
.mm-pref-btns,
.mm-mode-btns,
.np-pref-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-mm-pref,
.btn-mm-mode,
.btn-np-pref {
  padding: 11px 8px;
  border-radius: 8px;
  border: 1.5px solid rgba(var(--ink-rgb), .15);
  background: rgba(var(--ink-rgb), .06);
  color: rgba(var(--ink-rgb), .6);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease-settle), border-color var(--dur-micro) var(--ease-settle), color var(--dur-micro) var(--ease-settle);
}

/* Flex sizing kept distinct: QM player count splits equally; Pace / Players use a
   72px basis + min-width so a 4th chip wraps cleanly. (Unchanged from before.) */
.btn-mm-pref {
  flex: 1;
}
.btn-mm-mode,
.btn-np-pref {
  flex: 1 1 72px;
  min-width: 72px;
}

.btn-mm-pref:hover,
.btn-mm-mode:hover,
.btn-np-pref:hover {
  background: rgba(var(--ink-rgb), .12);
  color: rgba(var(--ink-rgb), .85);
}

.btn-mm-pref.mm-pref-active,
.btn-mm-mode.mm-mode-active,
.btn-np-pref.np-pref-active {
  background: #3878e0;
  border-color: #3878e0;
  color: #fff;
}

/* Create Room Players is the one required choice — it gates the Create button —
   so this group alone gets extra weight vs the visually-identical Quick Match /
   Game Setup player pills. Scoped via :has() so no markup change is needed and
   the other two groups keep normal emphasis. */
.field-group:has(#create-np-btns) .field-label {
  color: rgba(var(--ink-rgb), .72);
}
.field-group:has(#create-np-btns) .field-label::after {
  content: "Required";
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: none;
  color: #f0a030;
  background: rgba(240, 160, 48, .12);
  vertical-align: middle;
}

/* Waiting-room player search */
.wait-search-wrap {
  margin: 4px 0 2px;
}
.wait-search {
  width: 100%;
}
.jr-empty {
  text-align: center;
  color: rgba(var(--ink-rgb), .5);
  font-size: .85rem;
  padding: 8px 4px;
}

.mm-dm-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(var(--ink-rgb), .55);
  font-size: .88rem;
  cursor: pointer;
  padding: 2px 0;
}

.mm-dm-row input[type=checkbox] {
  accent-color: #f0a030;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.btn-start-search {
  background: linear-gradient(135deg, #3878e0 0%, #1a50b0 100%);
  color: #fff;
  width: 100%;
  font-size: 1rem;
}

.btn-start-search:hover:not(:disabled) {
  filter: brightness(1.1);
}

/* ── DM tentative timer bar ──────────────────────────────── */
.mm-dm-timer-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mm-dm-timer-bar-bg {
  height: 4px;
  background: rgba(var(--ink-rgb), .1);
  border-radius: 3px;
  overflow: hidden;
}

.mm-dm-timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #f0a030, #d06020);
  border-radius: 3px;
  transition: width .3s linear;
}

.mm-dm-timer-text {
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-amber);
}

/* ── Matchmaking screen ──────────────────────────────────── */
.mm-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-cream);
  text-align: center;
}

.mm-players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  min-height: 36px;
}

.mm-player-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(56, 120, 224, .25);
  border: 1px solid rgba(56, 120, 224, .4);
  color: #88bbff;
  border-radius: 20px;
  padding: 4px 12px 4px 5px;
  font-size: .85rem;
  font-weight: 600;
}

/* Light theme: the pale-blue chip text washes out on the light card — darken it
   to the app's deep blue and firm up the chip fill for contrast. */
:root[data-theme="light"] .mm-player-chip {
  background: rgba(56, 120, 224, .14);
  border-color: rgba(56, 120, 224, .45);
  color: #1a50b0;
}

.mm-av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 800;
  color: rgba(0, 0, 0, .65);
  background-size: cover;
  background-position: center;
}

.mm-bar-wrap {
  height: 5px;
  background: rgba(var(--ink-rgb), .1);
  border-radius: 3px;
  overflow: hidden;
}

.mm-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3878e0, #28b060);
  border-radius: 3px;
  transition: width .25s linear;
}

.mm-status {
  text-align: center;
  color: rgba(var(--ink-rgb), .45);
  font-size: .85rem;
}

.btn-cancel-mm {
  background: rgba(var(--ink-rgb), .07);
  border: 1px solid rgba(var(--ink-rgb), .15);
  color: rgba(var(--ink-rgb), .5);
  border-radius: 8px;
  padding: 9px;
  font-size: .88rem;
  width: 100%;
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease-settle), color var(--dur-micro) var(--ease-settle);
}

.btn-cancel-mm:hover {
  background: rgba(255, 100, 100, .15);
  color: #ff8888;
}

/* ── Rejoin card ─────────────────────────────────────────── */
/* Container: stacks one .rejoin-card per active game */
.rejoin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 10;
}

/* Default (active game, NOT your turn): blue — distinct from the grey "ended"
   card, while the green "your turn" card still pops the most.
   Sized/structured to match .room-card (Live Games) — same flex-wrap row,
   padding and border-radius — so Active Game cards sit at the same density. */
.rejoin-card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  /* room name (top of the info column) stays top-left */
  align-content: flex-start;
  /* pack lines at the top — leftover height (from equal-
                                 height grid rows) collapses below, not between lines */
  gap: 10px;
  background: rgba(56, 120, 224, .13);
  border: 1px solid rgba(56, 120, 224, .34);
  border-left: 3px solid rgba(56, 120, 224, .65);
  border-radius: 9px;
  padding: 10px 12px 34px;
  /* bottom space reserved for the pinned .rc-params strip,
                               plus an 8px gap above it */
  position: relative;
  z-index: 10;
  transition: background var(--dur-micro) var(--ease-settle);
}

/* Gentle hover so game cards aren't "dead" beside room cards — a brighten in
   their own blue family, no lift (they're status cards, not selection tiles).
   The pulsing your-turn card keeps its glow; this only shifts the background. */
.rejoin-card:hover {
  background: rgba(56, 120, 224, .18);
}

.rejoin-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rejoin-room {
  font-size: 1.155rem;
  font-weight: 700;
  color: var(--text-cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

.rejoin-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  align-self: stretch;
  gap: 6px;
  flex-shrink: 0;
}

.rejoin-status-badge {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.5;
  background: rgba(56, 120, 224, .25);
  color: #90b8f0;
  border: 1px solid rgba(56, 120, 224, .45);
}

.rejoin-status-badge--myturn {
  background: rgba(40, 176, 96, .28);
  color: #7de0a0;
  border-color: rgba(40, 176, 96, .55);
}

.rejoin-status-badge--setup {
  background: rgba(200, 160, 0, .22);
  color: #e0c060;
  border-color: rgba(200, 160, 0, .4);
}

.rejoin-status-badge--ended {
  background: rgba(150, 150, 150, .15);
  color: rgba(var(--ink-rgb), .35);
  border-color: rgba(150, 150, 150, .25);
}

.rejoin-players {
  flex-basis: 100%;
  font-size: .75rem;
  color: rgba(var(--ink-rgb), .4);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rejoin-players[title] {
  cursor: help;
}

/* ── Waiting Room Invitation Workflow — pending-invitation cards + host status ──
   Reuses the async waiting-room card wholesale; only the accent, the "Invitation"
   badge, the Accept/Decline actions and the host status pills are new. */
.rejoin-card-invited { border-left-color: #e0a83c; }   /* amber accent vs async blue */

.rejoin-status-badge--invited {
  background: rgba(224, 168, 60, .22);
  color: #e6bd66;
  border-color: rgba(224, 168, 60, .42);
}
:root[data-theme="light"] .rejoin-status-badge--invited { color: var(--text-amber); }

/* A declined-but-still-open invitation: the card REMAINS (host's authorization is still
   valid) with a muted red accent + a "You declined this invitation" note; its primary
   action is Reaccept. Removed only by ✕ / host cancel / room lifecycle. */
.rejoin-card-declined { border-left-color: #c23b3b; }
.rejoin-card-declined .rejoin-status-badge--invited {
  background: rgba(194, 59, 59, .18);
  color: #d97a7a;
  border-color: rgba(194, 59, 59, .4);
}
.invite-declined-note { color: #d97a7a; font-weight: 700; }

/* ── Rematch request card + banner ──────────────────────────────────────────
   The same invitation-card shell with a distinct violet accent and a REMATCH
   badge, so a rematch is never mistaken for an ordinary room invitation (it does
   not join a room — it casts a vote). */
.rejoin-card-rematch { border-left-color: #8b6ce0; }

.rejoin-status-badge--rematch {
  background: rgba(139, 108, 224, .22);
  color: #b39ef0;
  border-color: rgba(139, 108, 224, .45);
  letter-spacing: .06em;
  font-weight: 800;
}
:root[data-theme="light"] .rejoin-status-badge--rematch { color: #5b3ec7; }

/* Per-player vote pips on the rematch cards (✓ accepted / ✕ declined / waiting). */
.wp-badge--ok { background: rgba(52, 192, 106, .2); color: #4fce85; border-color: rgba(52, 192, 106, .42); }
.wp-badge--no { background: rgba(194, 59, 59, .2); color: #d97a7a; border-color: rgba(194, 59, 59, .42); }
:root[data-theme="light"] .wp-badge--ok { color: #1f7a45; }
:root[data-theme="light"] .wp-badge--no { color: #a52a2a; }

/* The REQUESTER's outgoing card, in My Games ▸ Waiting Rooms. Same violet rematch
   identity, but dashed to say "not a room yet" — it holds no seats and cannot be
   entered until every player accepts. */
.rejoin-card-rematch-out {
  border-left-style: dashed;
  border-left-color: #8b6ce0;
}
.rejoin-card-rematch-out .rc-ephemeral-note { color: rgba(var(--ink-rgb), .55); }
/* Cancel is a withdrawal, not a destructive room action: quiet by default, red on
   intent. Matches the Decline button on the incoming card. */
.btn-rematch-cancel-req { background: rgba(var(--ink-rgb), .1); color: rgba(var(--ink-rgb), .72); }
.btn-rematch-cancel-req:hover:not(:disabled) { background: rgba(194, 59, 59, .18); color: var(--text-red-2, #d65050); }

/* ── Expired rematch waiting room ───────────────────────────────────────────
   EXPIRED IS NOT DELETED: the card stays so its host can delete it deliberately.
   It reads as unusable — red badge, muted body, dead Enter — while the ✕ stays
   fully legible, because acting on it is the only thing left to do here. */
.rejoin-status-badge--expired {
  background: rgba(194, 59, 59, .22);
  color: #e06a6a;
  border-color: rgba(194, 59, 59, .55);
  font-weight: 800;
}
:root[data-theme="light"] .rejoin-status-badge--expired { color: #a52a2a; }

.rejoin-card-expired { border-left-color: #c23b3b; }
/* Mute the room's details, but never the actions — the host still has to reach ✕. */
.rejoin-card-expired .rejoin-info,
.rejoin-card-expired .rejoin-players { opacity: .62; }
.rejoin-card-expired .btn-lobby:disabled {
  background: rgba(var(--ink-rgb), .07);
  color: rgba(var(--ink-rgb), .38);
  cursor: not-allowed;
}
/* Cancel = permanent deletion: quiet until hovered, then unmistakably destructive. */
.btn-cancel-waitroom { background: rgba(var(--ink-rgb), .1); color: rgba(var(--ink-rgb), .72); }
.btn-cancel-waitroom:hover:not(:disabled) { background: rgba(194, 59, 59, .22); color: var(--text-red-2, #d65050); }
.rejoin-card-expired .btn-cancel-waitroom { background: rgba(194, 59, 59, .16); color: #d97a7a; }
.rejoin-card-expired .btn-cancel-waitroom:hover:not(:disabled) { background: rgba(194, 59, 59, .3); color: #fff; }

/* The lobby banner variant — same layout as the invitation banner, violet accent. */
.rematch-banner { border-left-color: #8b6ce0; }
.rematch-banner .lb-icon { color: #b39ef0; }

/* Open Rooms card for a room I'm invited to — mirrors the Invitations card's Accept /
   Reaccept (never "Join"); same green affordance as a normal join. */
.btn-rc-join.btn-rc-invited { background: linear-gradient(135deg, #34c06a, #1f7a45); }

/* "Invited by X · Waiting for your response" — allow wrapping (the base
   .rejoin-players clamps to one line, which would truncate this longer text). */
.invite-by { white-space: normal; overflow: visible; color: rgba(var(--ink-rgb), .62); }
.invite-await { color: #cf9a3a; font-weight: 600; }
:root[data-theme="light"] .invite-await { color: var(--text-amber); }

/* Real-time invitation card only: the expiry countdown belongs to the INVITATION, so this
   says plainly that the ROOM is ephemeral (it dies with its host and is never restored on a
   restart) — a turn-based waiting room is persistent, a real-time one is not. */
.rc-ephemeral-note {
  margin-top: 4px;
  font-size: .78rem;
  line-height: 1.3;
  color: rgba(var(--ink-rgb), .55);
  white-space: normal;
}

/* Accept / Decline look and sit identically on an invitation card and a rematch
   card — only the handler behind them differs, so the classes are paired here
   rather than duplicated. (They cannot share ONE class: the card renderer wires
   its click handlers by class, and a rematch Accept must never reach
   acceptInvitation.) */
/* Pack the action column instead of inheriting .rejoin-right's space-between over
   a stretched column. That default spreads the buttons across whatever height the
   card happens to be, so an invitation card and a taller rematch card ended up with
   visibly different gaps for the same three buttons. Packing to the top makes the
   spacing a constant, so the two cards read as one family whatever their content. */
.invite-actions { justify-content: flex-start; align-self: flex-start; gap: 8px; }
.invite-actions .btn-lobby { padding: 9px 14px; font-size: .82rem; min-width: 104px; }
.btn-invite-accept,
.btn-rematch-card-accept { background: #1f7a45; color: #fff; }
.btn-invite-accept:hover:not(:disabled),
.btn-rematch-card-accept:hover:not(:disabled) { background: #28b060; }
.btn-invite-decline,
.btn-rematch-card-decline { background: rgba(var(--ink-rgb), .1); color: rgba(var(--ink-rgb), .72); }
.btn-invite-decline:hover:not(:disabled),
.btn-rematch-card-decline:hover:not(:disabled) { background: rgba(194, 59, 59, .18); color: var(--text-red-2, #d65050); }
/* An accepted rematch keeps the green identity but reads as done, not available. */
.btn-rematch-card-accept:disabled { background: rgba(31, 122, 69, .38); color: rgba(255, 255, 255, .82); }
.rejoin-card.invite-busy { opacity: .9; }

/* Host-side sent-invite status pills — reuse the .sc-invite-sent base shape. */
/* An OPEN invite's pill doubles as a Cancel (withdraw) button: interactive, and
   reddens on hover to signal removal. Terminal pills stay non-interactive. */
.sc-invite-cancel {
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease-settle), color var(--dur-micro) var(--ease-settle);
}
.sc-invite-cancel:hover,
.sc-invite-cancel:focus-visible {
  background: rgba(194, 59, 59, .22);
  color: #e58a8a;
}
.sc-invite-status--declined  { background: rgba(194, 59, 59, .16); color: #d97a7a; }
.sc-invite-status--accepted  { background: #123a23; color: #7fd8a2; }
.sc-invite-status--expired,
.sc-invite-status--cancelled { background: rgba(150, 150, 150, .14); color: rgba(var(--ink-rgb), .5); }

/* A resolved-external status (Declined/Expired) shown persistently beside a player that
   is ALSO the "invite again" affordance — keep the status colour (from the classes above),
   just make it clearly clickable. */
.sc-invite-redo {
  cursor: pointer;
  transition: filter var(--dur-micro) var(--ease-settle);
}
.sc-invite-redo:hover,
.sc-invite-redo:focus-visible { filter: brightness(1.18); }

/* Player chips inside the rejoin box */
.rejoin-pl-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.rejoin-pl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  color: rgba(var(--ink-rgb), .7);
  white-space: nowrap;
}

.rj-av {
  width: 39.2px;
  height: 39.2px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .91rem;
  font-weight: 800;
  color: rgba(0, 0, 0, .65);
  background-size: cover;
  background-position: center;
}

.rejoin-pl-you {
  font-weight: 700;
  color: var(--text-cream);
}

/* Only the player whose turn it is gets the pill/oval background — everyone
   else is plain text, so the active player stands out. No left padding/border
   so the avatar stays flush with the chip's left edge, aligned with the other
   players' avatars (an outset border or left padding here would shift it). */
.rejoin-pl-turn {
  padding: 2px 7px 2px 0;
  border-radius: 999px;
  background: rgba(40, 176, 96, .22);
  box-shadow: inset 0 0 0 1px rgba(40, 176, 96, .55);
  color: #8be0aa;
  font-weight: 700;
}

/* Highlight the whole card when it's the user's turn — green, glowing, pulsing. */
.rejoin-card-myturn {
  background: rgba(40, 176, 96, .18);
  border-color: rgba(40, 176, 96, .7);
  border-left: 3px solid #28b060;
  box-shadow: 0 0 0 1px rgba(40, 176, 96, .4), 0 0 18px rgba(40, 176, 96, .3);
  animation: rejoin-pulse 2s ease-in-out infinite;
}

.rejoin-card-myturn .rejoin-label {
  color: #34d076;
}

@keyframes rejoin-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(40, 176, 96, .4), 0 0 14px rgba(40, 176, 96, .25);
  }

  50% {
    box-shadow: 0 0 0 1px rgba(40, 176, 96, .6), 0 0 22px rgba(40, 176, 96, .45);
  }
}

@keyframes badge-shake {
  0% {
    transform: translateX(0);
  }

  12% {
    transform: translateX(-8px) rotate(-6deg);
  }

  25% {
    transform: translateX(8px) rotate(6deg);
  }

  37% {
    transform: translateX(-7px) rotate(-5deg);
  }

  50% {
    transform: translateX(7px) rotate(5deg);
  }

  62% {
    transform: translateX(-5px) rotate(-3deg);
  }

  75% {
    transform: translateX(5px) rotate(3deg);
  }

  87% {
    transform: translateX(-2px) rotate(-1deg);
  }

  100% {
    transform: translateX(0);
  }
}

.badge-shake {
  animation: badge-shake 0.65s ease-in-out;
  display: inline-block;
}

/* Inline "Status: …" badge next to the room code. */
.rejoin-status {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 6px;
}

.rejoin-status-live {
  background: rgba(56, 120, 224, .18);
  border: 1px solid rgba(56, 120, 224, .5);
  color: #9cc2ff;
}

/* Ended game: greyed-out, no glow — clearly "done", set apart from live cards. */
.rejoin-card-ended {
  background: rgba(60, 66, 80, .14);
  border-color: rgba(140, 150, 170, .22);
  border-left: 3px solid rgba(140, 150, 170, .4);
  opacity: .85;
}

.rejoin-card-ended .rejoin-room {
  color: var(--text-muted-grey);
}

.rejoin-card-ended .rejoin-label {
  color: rgba(170, 180, 200, .7);
}

/* The "Ended" title that replaces the "Active Game" label on finished cards. */
.rejoin-label-ended {
  color: var(--text-muted-grey) !important;
  letter-spacing: .12em;
}

/* Waiting (not your turn): muted slate button — sized to match .btn-rc-join
   (Live Games' "Watch" button) so Active Game cards stay just as compact. */
.btn-rejoin {
  background: linear-gradient(135deg, #5b6b86 0%, #3a455c 100%);
  color: #fff;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid transparent;   /* reserve the outlined Share's border box → equal height */
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.4;   /* match the Share pill it sits beside (emoji-independent height) */
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: filter var(--dur-micro) var(--ease-settle);
}

.btn-rejoin:hover:not(:disabled) {
  filter: brightness(1.1);
}

/* Your turn: green button to draw the eye. */
.rejoin-card-myturn .btn-rejoin {
  background: linear-gradient(135deg, #28b060 0%, #166038 100%);
}

/* Ended-card action stack: View Board (primary) + Remove (secondary). */
.rejoin-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

/* View Board / Remove — same compact pill shape as the other card action
   buttons (Rejoin / Watch), sized to fit each label. */
.btn-rejoin-view,
.btn-rejoin-remove {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid transparent;   /* .btn-rejoin-remove overrides with a visible border below */
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.4;   /* same fixed height as .btn-rejoin / .btn-rc-share */
  letter-spacing: normal;
  white-space: nowrap;
  flex-shrink: 0;
}

/* View the finished board — muted grayish-blue (calmer than the live actions). */
.btn-rejoin-view {
  background: linear-gradient(135deg, #5f7793 0%, #3e4f66 100%);
  color: #fff;
}

.btn-rejoin-view:hover:not(:disabled) {
  filter: brightness(1.1);
}

/* Remove (dismiss) button on ended cards — muted, red on hover. */
.btn-rejoin-remove {
  background: rgba(120, 70, 80, .25);
  border: 1px solid rgba(200, 90, 90, .4);
  color: #e8b7b7;
}

.btn-rejoin-remove:hover:not(:disabled) {
  background: linear-gradient(135deg, #c0504d 0%, #7a2f2f 100%);
  color: #fff;
}

/* ── Hamburger button (in auth bar) ──────────────────────── */
.ham-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
  transition: background var(--dur-micro) var(--ease-settle);
  color: inherit;
}

.ham-btn:hover {
  background: rgba(var(--ink-rgb), .1);
}

.ham-line {
  display: block;
  width: 20px;
  height: 2px;
  background: rgba(var(--ink-rgb), .75);
  border-radius: 2px;
}

.ham-turn-star {
  position: absolute;
  top: 2px;
  right: 2px;
  color: #ff2828;
  font-size: .72rem;
  line-height: 1;
  pointer-events: none;
}

.ham-turn-star[hidden] {
  display: none;
}

/* ── Hamburger menu dropdown ──────────────────────────────── */
.ham-menu {
  position: fixed;
  top: 74px;
  right: 10px;
  z-index: 200;
  background: var(--modal-bg);
  border: 1px solid rgba(var(--ink-rgb), .14);
  border-radius: 14px;
  padding: 6px 0;
  z-index: 200;
  min-width: 200px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
  backdrop-filter: blur(14px);
}

.ham-menu[hidden] {
  display: none;
}

.ham-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 11px 18px;
  gap: 0;
  background: none;
  border: none;
  color: rgba(var(--ink-rgb), .85);
  font: 600 .92rem/1.3 'Quicksand', sans-serif;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-micro) var(--ease-settle);
}

.ham-item:hover {
  background: rgba(var(--ink-rgb), .08);
}

.ham-item-label {
  flex: 1;
}

.ham-item-count {
  margin-left: auto;
}

.ham-item-count[hidden] {
  display: none;
}

.ham-item-signout {
  color: rgba(var(--ink-rgb), .5);
  border-top: 1px solid rgba(var(--ink-rgb), .08);
  margin-top: 4px;
}

/* ── Volume slider in Settings ───────────────────────────── */
.set-vol-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.set-vol-icon {
  font-size: 1.1rem;
  min-width: 22px;
  text-align: center;
}

.set-vol-slider {
  flex: 1;
  accent-color: #f0a030;
  cursor: pointer;
}

/* ── Settings modal ──────────────────────────────────────── */
.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--modal-backdrop);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}

.settings-backdrop[hidden] {
  display: none;
}

.settings-modal {
  width: 100%;
  max-width: 440px;
  background: var(--modal-bg);
  border: 1px solid rgba(var(--ink-rgb), .14);
  border-radius: 16px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .6);
  overflow: hidden;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(var(--ink-rgb), .1);
}

.settings-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-strong);
}

.settings-close {
  background: none;
  border: none;
  color: rgba(var(--ink-rgb), .6);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.settings-close:hover {
  background: rgba(var(--ink-rgb), .1);
  color: var(--text-strong);
}

/* ══════════════════════════════════════════════════════════
   About dialog — modern desktop-app style. Reuses the shared
   .settings-backdrop for the dimmed, scrollable overlay.
   ══════════════════════════════════════════════════════════ */
.about-backdrop {
  align-items: center;
}

.about-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--modal-bg);
  border: 1px solid rgba(var(--ink-rgb), .14);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
  padding: 30px 26px 22px;
  text-align: center;
}

.about-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: rgba(var(--ink-rgb), .55);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  padding: 6px 9px;
  border-radius: 8px;
}

.about-close:hover {
  background: rgba(var(--ink-rgb), .1);
  color: var(--text-strong);
}

.about-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.about-app-icon {
  width: 132px;
  height: 132px;
  object-fit: contain;
  margin-bottom: 6px;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .35));
}

.about-app-name {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: .5px;
  color: var(--text-strong);
}

.about-app-tagline {
  font-size: .82rem;
  color: rgba(var(--ink-rgb), .6);
}

.about-version {
  margin-top: 8px;
  font-size: .78rem;
  font-weight: 600;
  color: rgba(var(--ink-rgb), .7);
  background: rgba(var(--ink-rgb), .07);
  border: 1px solid rgba(var(--ink-rgb), .12);
  border-radius: 999px;
  padding: 3px 12px;
}

.about-desc {
  margin: 18px 2px 4px;
  font-size: .84rem;
  line-height: 1.6;
  color: rgba(var(--ink-rgb), .78);
}

.about-meta {
  margin: 16px 0 4px;
  border-top: 1px solid rgba(var(--ink-rgb), .1);
  border-bottom: 1px solid rgba(var(--ink-rgb), .1);
  padding: 6px 0;
}

.about-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  padding: 6px 2px;
}

.about-meta-k {
  color: rgba(var(--ink-rgb), .6);
}

.about-meta-v {
  font-weight: 600;
  color: var(--text-strong);
}

.about-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 6px;
}

.about-links .about-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  color: rgba(var(--ink-rgb), .75);
  background: rgba(var(--ink-rgb), .06);
  border: 1px solid rgba(var(--ink-rgb), .12);
  border-radius: 999px;
  padding: 6px 13px;
  transition: background var(--dur-micro) var(--ease-settle), border-color var(--dur-micro) var(--ease-settle), color var(--dur-micro) var(--ease-settle);
}

.about-links .about-link:hover {
  background: rgba(var(--ink-rgb), .12);
  border-color: rgba(var(--ink-rgb), .25);
  color: var(--text-strong);
}

.about-credit {
  margin-top: 14px;
  font-size: .8rem;
  color: rgba(var(--ink-rgb), .7);
}

.about-credit b {
  color: var(--text-strong);
}

.about-copyright {
  margin-top: 4px;
  font-size: .72rem;
  color: rgba(var(--ink-rgb), .5);
}

.about-footer {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(var(--ink-rgb), .1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.about-update-btn {
  font: inherit;
  font-size: .88rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  border: none;
  border-radius: 10px;
  padding: 10px 22px;
  cursor: pointer;
  transition: filter var(--dur-micro) var(--ease-settle), opacity var(--dur-micro) var(--ease-settle);
}

.about-update-btn:hover {
  filter: brightness(1.06);
}

.about-update-btn:disabled {
  opacity: .6;
  cursor: default;
}

.about-update-status {
  min-height: 1em;
  font-size: .78rem;
  color: rgba(var(--ink-rgb), .7);
}

.about-update-status.ok {
  color: #16a34a;
}

.about-update-status.err {
  color: #dc2626;
}

@media (max-width: 540px) {
  .about-card {
    padding: 26px 18px 18px;
    border-radius: 16px;
  }

  .about-app-icon {
    width: 112px;
    height: 112px;
  }

  .about-app-name {
    font-size: 1.3rem;
  }
}

.settings-body {
  padding: 4px 20px 16px;
}

.set-section {
  padding: 11px 0;
  border-bottom: 1px solid rgba(var(--ink-rgb), .07);
}

.set-section:last-child {
  border-bottom: none;
}

/* Username + Email: no divider, sit closer together */
.set-section-nodiv {
  padding-bottom: 4px;
  border-bottom: none;
}

.set-section-tight {
  padding-top: 0;
}

.set-label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: rgba(var(--ink-rgb), .55);
  margin-bottom: 6px;
}

/* Account header */
.set-account {
  display: flex;
  align-items: center;
  gap: 10px;
}

.set-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.set-account-meta {
  flex: 1;
  min-width: 0;
}

.set-account-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-strong);
}

.set-account-since {
  font-size: .74rem;
  color: rgba(var(--ink-rgb), .5);
}

/* Link to the Profile page (avatar / bio editing now lives there) */
.set-account-link {
  margin-top: 6px;
  font-size: .78rem;
}

.set-account-link a {
  color: #7fd4ff;
}

/* Rows + inputs */
.set-row {
  display: flex;
  gap: 8px;
}

.set-input {
  flex: 1;
  min-width: 0;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid rgba(var(--ink-rgb), .18);
  background: rgba(var(--ink-rgb), .06);
  color: var(--text-strong);
  font-size: .9rem;
}

.set-input:focus {
  outline: none;
  border-color: #4dc4f5;
  background: rgba(var(--ink-rgb), .1);
}

.set-input-block {
  width: 100%;
  display: block;
  margin-bottom: 6px;
}

.set-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #3878e0 0%, #1a50b0 100%);
  color: #fff;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.set-btn:hover {
  filter: brightness(1.1);
}

.set-btn-block {
  width: 100%;
}

.set-msg {
  font-size: .78rem;
  margin-top: 4px;
  min-height: 1em;
}

.set-msg.err {
  color: #ff8080;
}

.set-msg.ok {
  color: #62d68a;
}

/* ── Welcome modal (first login) ───────────────────────── */
.welcome-text {
  font-size: .9rem;
  color: rgba(var(--ink-rgb), .75);
  line-height: 1.5;
  margin-bottom: 6px;
}

.welcome-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.welcome-cta {
  width: 100%;
  text-align: center;
  text-decoration: none;
  display: block;
}

/* Secondary action in a welcome banner foot (e.g. "Change plan") — quieter than the CTA. */
.welcome-secondary {
  width: 100%;
  text-align: center;
  background: transparent;
  border: 1px solid rgba(255,255,255,.18);
  opacity: .85;
}
.welcome-secondary:hover { opacity: 1; }
[data-theme="light"] .welcome-secondary { border-color: rgba(0,0,0,.18); }

.set-pending {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(240, 160, 48, .12);
  border: 1px solid rgba(240, 160, 48, .35);
  font-size: .78rem;
  color: rgba(var(--ink-rgb), .8);
}

.set-pending[hidden] {
  display: none;
}

.set-pending a {
  color: #4dc4f5;
}

/* Privacy toggle */
.set-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: .86rem;
  color: rgba(var(--ink-rgb), .82);
  cursor: pointer;
}

.set-toggle input {
  width: 16px;
  height: 16px;
  accent-color: #3878e0;
  cursor: pointer;
}

/* Danger zone */
.set-danger-label {
  color: #ff8080;
}

.set-danger-text {
  font-size: .76rem;
  color: rgba(var(--ink-rgb), .5);
  margin: 0 0 8px;
  line-height: 1.35;
}

.set-btn-danger {
  background: linear-gradient(135deg, #c0504d 0%, #7a2f2f 100%);
}

/* Collapsible sections (Change password / Delete account) */
.set-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}

.set-summary::-webkit-details-marker {
  display: none;
}

.set-summary::after {
  content: '▾';
  font-size: 1.1rem;
  line-height: 1;
  color: rgba(var(--ink-rgb), .4);
  transition: transform var(--dur-micro) var(--ease-settle);
  margin-left: 8px;
}

.set-collapse[open]>.set-summary::after {
  transform: rotate(180deg);
}

.set-collapse[open]>.set-summary {
  margin-bottom: 8px;
}

.set-collapse-body {
  display: flex;
  flex-direction: column;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .lobby-card {
    padding: 20px 16px;
  }

  .lobby-title {
    font-size: 1.7rem;
  }

  .room-name-value {
    font-size: 1.2rem;
  }

  .primary-actions {
    grid-template-columns: 1fr;
  }

  .jr-btns {
    flex-wrap: wrap;
  }
}

@media (max-width: 540px) {
  /* Number-of-Players choices as a single equal-width row on phones (was a 2×2
     grid; earlier a lopsided 3+1 wrap for Create Room and 4 stacked rows for QM). */
  .mm-pref-btns,
  #create-np-btns {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  .mm-pref-btns .btn-mm-pref,
  #create-np-btns .btn-np-pref {
    min-width: 0;
    padding: 11px 2px;
    font-size: .8rem;
    white-space: nowrap;
  }

  /* My Games tabs on phones: keep all four in ONE symmetric row — widen the bar
     into the card's side padding (negative margins) and tighten each tab so the
     labels fit without overflowing. */
  .mg-tabs {
    margin-left: -14px;
    margin-right: -14px;
    gap: 3px;
  }
  .mg-tab {
    flex: 1 1 0;
    min-width: 0;
    gap: 4px;
    padding: 8px 5px;
    font-size: .74rem;
  }
  .mg-tab-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mg-tab-count {
    min-width: 0;
    padding: 1px 5px;
    font-size: .7rem;
  }

  .rc-pl-name {
    max-width: 50px;
  }

  .wp-kick {
    padding: 5px 10px;
    font-size: .85rem;
  }

  .auth-bar {
    gap: 6px;
  }

  .auth-bar-name {
    font-size: .82rem;
  }

  .auth-bar-av {
    width: 34px;
    height: 34px;
    font-size: .86rem;
  }

  .ham-menu {
    top: 100px;
    right: 10px;
  }

  /* Mobile header is taller (86px); bump the shared var so the ticker (top:
     var(--lobby-header-h)) and the sticky My Games header follow it in lockstep. */
  :root {
    --lobby-header-h: 86px;
  }

  /* Push the content (starting with the underlined tabs) down so there's clear
     space above the tabs, below the ticker (header 86 + ticker 30 + breathing room). */
  .lobby-bg {
    padding-top: 136px;
  }

  /* Settings modal: tighter padding */
  .settings-backdrop {
    padding: 16px 10px;
  }

  .settings-body {
    padding: 4px 14px 14px;
  }

  .greeting-headline {
    font-size: 1.25rem;
  }

  .greeting-sub {
    font-size: .85rem;
  }

  /* Player List row: when it wraps, push the action button(s) (e.g. "Add friend")
     onto their own right-aligned line instead of falling back to the start. */
  .pl-row .sc-actions {
    flex: 1 1 100%;
    justify-content: flex-end;
  }

  .rooms-hd {
    gap: 15px;
  }

  /* Drop the create-panel explainer paragraph on mobile; the info "ⓘ" icon
     after the "Room Creator" header carries the same text as a tooltip. */
  .create-options .panel-explain {
    display: none;
  }

  .panel-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    padding: 0;
    border: 1px solid rgba(var(--ink-rgb), .25);
    border-radius: 50%;
    background: rgba(var(--ink-rgb), .06);
    color: rgba(var(--ink-rgb), .6);
    font-size: 0.8rem;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
    cursor: help;
  }
}

/* ── Desktop rejoin / rooms grids ─────────────────────────────
   Mobile (≤540 px) keeps the single-column stack above.
   600 px+  → 2 columns
   900 px+  → 3 columns
   1200 px+ → 4 columns
   The form cards (.lobby-card) and header stay narrow and centred;
   the Open Rooms / Live Games panels widen to fit their grid instead.
   ─────────────────────────────────────────────────────────── */
@media (min-width: 600px) {
  .lobby-wrap {
    max-width: 900px;
  }

  .lobby-card,
  .lobby-header {
    align-self: center;
    width: 100%;
    max-width: 420px;
  }

  .rejoin-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #screen-rooms,
  #screen-live,
  #screen-active-game {
    max-width: 100%;
  }

  /* Friends + Player List: side by side, each taking half the row. */
  .social-row {
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
  }

  .social-row .lobby-card {
    flex: 1 1 0;
    max-width: none;
  }

  .public-rooms-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (min-width: 900px) {
  .lobby-wrap {
    max-width: 1060px;
  }

  .rejoin-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .public-rooms-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .lobby-wrap {
    max-width: 1360px;
  }

  .rejoin-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .public-rooms-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ═══════════════════════════════════════════════════════════
   Game Config modal
   ═══════════════════════════════════════════════════════════ */

.gc-backdrop {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: var(--gc-backdrop);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.gc-backdrop[hidden] {
  display: none;
}

.gc-modal {
  background: var(--gc-bg);
  border: 1px solid rgba(var(--ink-rgb), .15);
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  /* Stay within the viewport on short screens; the body scrolls, head/foot stay put. */
  max-height: 90vh;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gc-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 10px;
  border-bottom: 1px solid rgba(var(--ink-rgb), .08);
}

.gc-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-cream);
}

.gc-close {
  background: none;
  border: none;
  color: rgba(var(--ink-rgb), .5);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 5px;
  transition: color var(--dur-micro) var(--ease-settle);
}

.gc-close:hover {
  color: var(--text-strong);
}

.gc-body {
  flex: 1 1 auto;
  min-height: 0;            /* allow the flex child to shrink so overflow can scroll */
  overflow-x: hidden;       /* vertical scroll only — never a horizontal scrollbar */
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Sections (rounded cards) ───────────────────────────── */
.gc-section {
  background: rgba(var(--ink-rgb), .04);
  border: 1px solid rgba(var(--ink-rgb), .08);
  border-radius: 10px;
  padding: 0 12px 2px;
}

.gc-sec-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 4px;
}

.gc-sec-title {
  font-size: .67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(var(--ink-rgb), .5);
}

.gc-sec-pro {
  margin-left: auto;
  font-size: .55rem;
  font-weight: 800;
  letter-spacing: .5px;
  color: #1a1000;
  background: linear-gradient(135deg, #b8860b, #daa520);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── One setting per row: label left, control right, sub-text below ── */
.gc-set { padding: 6px 0; }
.gc-set + .gc-set { border-top: 1px solid rgba(var(--ink-rgb), .07); }

.gc-set-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
}

.gc-set-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-cream);
}

.gc-set-sub {
  margin-top: 1px;
  font-size: .7rem;
  line-height: 1.3;
  color: rgba(var(--ink-rgb), .42);
}
/* Inline parameter range shown next to the label (replaces the old .gc-set-sub
   line, saving a row of height per setting). */
.gc-range {
  font-size: .7rem;
  font-weight: 500;
  color: rgba(var(--ink-rgb), .4);
  white-space: nowrap;
}

.gc-lock { font-size: .74rem; opacity: .6; display: none; }

/* ── Compact connected stepper [ − | value | ＋ ] ───────── */
.gc-stepper {
  display: inline-flex;
  align-items: stretch;
  flex-shrink: 0;
  border: 1px solid rgba(var(--ink-rgb), .18);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(var(--ink-rgb), .06);
}

.gc-step {
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: var(--text-cream);
  font-size: .95rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-micro) var(--ease-settle);
}

.gc-step:hover { background: rgba(var(--ink-rgb), .12); }

.gc-input {
  width: 36px;
  height: 28px;
  padding: 0 2px;
  border: none;
  border-left: 1px solid rgba(var(--ink-rgb), .14);
  border-right: 1px solid rgba(var(--ink-rgb), .14);
  background: transparent;
  color: var(--text-cream);
  font-size: .85rem;
  font-weight: 600;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

.gc-input::-webkit-outer-spin-button,
.gc-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.gc-input:focus { background: rgba(240, 160, 48, .12); }

/* ── Select (board layout) ──────────────────────────────── */
.gc-select {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 62%;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid rgba(var(--ink-rgb), .18);
  background: rgba(var(--ink-rgb), .06);
  color: var(--text-cream);
  font-size: .84rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--dur-standard) var(--ease-settle);
}

.gc-select:focus { border-color: #f0a030; }

.gc-select option {
  background: var(--gc-option-bg);
  color: var(--text-cream);
}

/* ── Toggle switch (checkbox-backed) ────────────────────── */
.gc-switch {
  position: relative;
  display: inline-flex;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}

.gc-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.gc-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(var(--ink-rgb), .22);
  transition: background var(--dur-standard) var(--ease-settle);
}

.gc-switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
  transition: transform var(--dur-standard) var(--ease-settle);
}

.gc-switch input:checked + .gc-switch-track { background: linear-gradient(135deg, #f0a030, #d06020); }
.gc-switch input:checked + .gc-switch-track::after { transform: translateX(18px); }

/* ── Validation message + sticky footer ─────────────────── */
.gc-msg {
  font-size: .8rem;
  color: #f07070;
  text-align: center;
}

.gc-msg:empty { display: none; }

.gc-foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(var(--ink-rgb), .08);
}

.btn-gc-apply {
  width: 100%;
  background: linear-gradient(135deg, #f0a030 0%, #d06020 100%);
  color: #fff;
  padding: 9px 20px;
  font-weight: 700;
}

.btn-gc-apply:hover:not(:disabled) {
  filter: brightness(1.1);
}

/* ── Game Setup summary row (single entry point in create-options) ─────── */
.game-setup-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: 1.5px solid rgba(var(--ink-rgb), .18);
  border-radius: 10px;
  background: rgba(var(--ink-rgb), .06);
  color: var(--text-cream);
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease-settle), border-color var(--dur-micro) var(--ease-settle);
}
.game-setup-summary:hover {
  background: rgba(var(--ink-rgb), .1);
  border-color: rgba(var(--ink-rgb), .3);
}
.gss-icon { flex: 0 0 auto; font-size: 1.05rem; }
.gss-body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gss-title { font-size: .82rem; font-weight: 700; color: var(--text-cream); }
.gss-digest {
  font-size: .78rem;
  color: rgba(var(--ink-rgb), .6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gss-arrow { flex: 0 0 auto; color: rgba(var(--ink-rgb), .45); font-size: 1rem; }

/* ── Room params bar (waiting room) ─────────────────────── */
.room-params-bar {
  background: rgba(var(--ink-rgb), .04);
  border: 1px solid rgba(var(--ink-rgb), .1);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.rp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.rp-chip {
  font-size: .8rem;
  color: rgba(var(--ink-rgb), .7);
  background: rgba(var(--ink-rgb), .07);
  border: 1px solid rgba(var(--ink-rgb), .12);
  border-radius: 20px;
  padding: 3px 10px;
}

.rp-chip b {
  color: var(--text-cream);
}

.rp-edit-btn {
  background: rgba(var(--ink-rgb), .08);
  border: 1px solid rgba(var(--ink-rgb), .18);
  border-radius: 7px;
  color: rgba(var(--ink-rgb), .7);
  font-size: .8rem;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-micro) var(--ease-settle);
}

.rp-edit-btn:hover {
  background: rgba(var(--ink-rgb), .16);
  color: var(--text-strong);
}

/* ── Params-changed alert ────────────────────────────────── */
.params-changed-alert {
  background: rgba(240, 160, 48, .12);
  border: 1.5px solid rgba(240, 160, 48, .45);
  border-radius: 10px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pca-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.pca-text {
  font-size: .86rem;
  color: rgba(var(--ink-rgb), .85);
  flex: 1;
}

.pca-btns {
  display: flex;
  gap: 8px;
}

.btn-pca-dismiss {
  background: rgba(var(--ink-rgb), .1);
  border: 1px solid rgba(var(--ink-rgb), .2);
  border-radius: 6px;
  color: rgba(var(--ink-rgb), .7);
  font-size: .8rem;
  padding: 5px 12px;
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease-settle);
}

.btn-pca-dismiss:hover {
  background: rgba(var(--ink-rgb), .18);
}

.btn-pca-leave {
  background: rgba(220, 60, 60, .18);
  border: 1px solid rgba(220, 60, 60, .4);
  border-radius: 6px;
  color: #f08080;
  font-size: .8rem;
  padding: 5px 12px;
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease-settle);
}

.btn-pca-leave:hover {
  background: rgba(220, 60, 60, .3);
}

/* ── Room card: params strip, pinned to a fixed spot near the card's bottom
   (above the delete-timer, if present) — see .rc-has-timer / .rejoin-has-timer
   below for the timer-stacking offset. This keeps the strip at the same
   position in every card regardless of how much player-list content there is. */
.rc-params {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.rc-param {
  position: relative;
  font-size: .68rem;
  color: rgba(var(--ink-rgb), .5);
  background: rgba(var(--ink-rgb), .06);
  border: 1px solid rgba(var(--ink-rgb), .1);
  border-radius: 20px;
  padding: 2px 4px;
  white-space: nowrap;
  cursor: help;
}

/* Spectator eye chip — slightly bigger, centred SVG (blue eye / red strike-through). */
.rc-param-eye {
  display: inline-flex;
  align-items: center;
  padding: 1px 2px;
}

.rc-param-eye svg {
  display: block;
}

/* ── Open-rooms search/filter/sort + Live Games (slice 3) ── */
.rooms-filter-toggle {
  background: rgba(var(--ink-rgb), .08);
  border: 1px solid rgba(var(--ink-rgb), .15);
  color: rgba(var(--ink-rgb), .7);
  border-radius: 6px;
  cursor: pointer;
  padding: 2px 8px;
  font-size: .85rem;
}

.rooms-filter-toggle.active,
.rooms-filter-toggle:hover {
  background: rgba(var(--ink-rgb), .18);
}

/* Collapse / expand the whole panel body — open by default, ▾ flips to ▴ when collapsed */
.rooms-collapse-toggle {
  background: rgba(var(--ink-rgb), .08);
  border: 1px solid rgba(var(--ink-rgb), .15);
  color: rgba(var(--ink-rgb), .7);
  border-radius: 6px;
  cursor: pointer;
  padding: 2px 10px;
  font-size: 1.15rem;
  line-height: 1.2;
  transition: transform var(--dur-micro) var(--ease-settle), background var(--dur-micro) var(--ease-settle);
}

.rooms-collapse-toggle:hover {
  background: rgba(var(--ink-rgb), .18);
}

.rooms-collapse-toggle.collapsed {
  transform: rotate(180deg);
}

.rooms-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rooms-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: -10px 0 10px;
  padding: 8px;
  background: rgba(var(--inset-rgb), .18);
  border-radius: 8px;
}

.rooms-search-wrap {
  position: relative;
  display: flex;
  flex: 1 1 160px;
  min-width: 120px;
}

/* Player List filter bar has only a search box + 1 sort dropdown — shrink
   the search box's basis so the dropdown sits on the same line instead of
   wrapping to its own row. */
#player-list-body .rooms-search-wrap {
  flex: 1 1 90px;
  min-width: 70px;
}

.rooms-search {
  flex: 1;
  width: 100%;
  background: rgba(var(--inset-rgb), .3);
  border: 1px solid rgba(var(--ink-rgb), .15);
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  color: var(--text-input);
  font-size: .85rem;
}

.rooms-search-clear {
  display: none;
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  background: rgba(var(--ink-rgb), .1);
  border: none;
  border-radius: 50%;
  color: rgba(var(--ink-rgb), .6);
  font-size: .75rem;
  line-height: 1;
  cursor: pointer;
}

.rooms-search-clear:hover {
  background: rgba(var(--ink-rgb), .22);
  color: var(--text-strong);
}

.rooms-search-wrap.has-value .rooms-search-clear {
  display: flex;
}

.rooms-mini-select {
  background: rgba(var(--inset-rgb), .3);
  border: 1px solid rgba(var(--ink-rgb), .15);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text-input);
  font-size: .82rem;
}

/* The dropdown list (native <option> popup) inherits a see-through background from
   the control, which made the items hard to read. Force an opaque dark background
   with light text so the menu is legible. */
.rooms-mini-select option {
  background: var(--option-bg);
  color: var(--text-input);
}

.rooms-openseat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .8rem;
  color: rgba(var(--ink-rgb), .7);
  cursor: pointer;
}

/* ── Cascade dropdown — replaces the native <select> rendering for the
   sort/mode filters so the option list opens as an inline panel instead of
   the OS picker/overlay (a separate "modal" on mobile). ── */
.rooms-cdd-native {
  display: none;
}

.rooms-cdd {
  position: relative;
  flex: 0 0 auto;
}

.rooms-cdd-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(var(--inset-rgb), .3);
  border: 1px solid rgba(var(--ink-rgb), .15);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text-input);
  font-size: .82rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.rooms-cdd-trigger:hover {
  border-color: rgba(var(--ink-rgb), .3);
}

.rooms-cdd-trigger:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.rooms-cdd.open .rooms-cdd-trigger {
  border-color: #f0a030;
}

.rooms-cdd-arrow {
  font-size: .7em;
  opacity: .6;
  transition: transform var(--dur-micro) var(--ease-settle);
}

.rooms-cdd.open .rooms-cdd-arrow {
  transform: rotate(180deg);
}

.rooms-cdd-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--option-bg);
  border: 1px solid rgba(var(--ink-rgb), .15);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  min-width: max-content;
  max-height: 220px;
  overflow-y: auto;
  z-index: 60;
}

.rooms-cdd-menu[hidden] {
  display: none;
}

.rooms-cdd-option {
  padding: 7px 10px;
  border-radius: 6px;
  font-size: .82rem;
  color: var(--text-input);
  cursor: pointer;
  white-space: nowrap;
}

.rooms-cdd-option:hover,
.rooms-cdd-option.active {
  background: rgba(var(--ink-rgb), .1);
}

.rooms-cdd-option.selected {
  color: #7fd4ff;
  font-weight: 600;
}

.lg-card {
  border-left: 3px solid rgba(255, 90, 90, .55);
}

.lg-watch {
  background: #b0402a;
}

.lg-watch:hover {
  background: #c44a30;
}

.lg-watch-off {
  opacity: .5;
  cursor: not-allowed;
}

/* Live Games: highlight the player chip whose turn it currently is — same
   green "active" treatment as .rejoin-pl-turn on the Active Game card. No left
   padding/border so the avatar stays flush with the chip's left edge, aligned
   with the other players' avatars. */
.rc-pl-chip.lg-pl-turn {
  background: rgba(40, 176, 96, .18);
  box-shadow: inset 0 0 0 1px rgba(40, 176, 96, .5);
  border-radius: 999px;
  padding: 2px 8px 2px 0;
}

.rc-pl-chip.lg-pl-turn .rc-pl-name {
  color: #8be0aa;
  font-weight: 700;
}
/* ═══════════════════════════════════════════════════════════════
   Pro Account UI  (§Pro)
   ═══════════════════════════════════════════════════════════════ */

/* ── Pro-user CSS overrides (html.is-pro) ──────────────────── */
/* These rules fire synchronously from localStorage before any JS fetch,
   preventing any flash of the wrong UI state for Pro users. */
html.is-pro #btn-go-pro       { display: none !important; }
html.is-pro #btn-set-upgrade  { display: none !important; }
html.is-pro #gc-pro-header    { display: none !important; }
html.is-pro .pu-free-only     { display: none !important; }
/* Crown on the auth-bar avatar circle for Pro users */
html.is-pro .auth-bar-name    { position: relative; }
html.is-pro .auth-bar-name::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 20px;
  width: 21px;
  height: 21px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cdefs%3E%3ClinearGradient id='s' x1='.3' y1='0' x2='.7' y2='1'%3E%3Cstop offset='0' stop-color='%23fff2a8'/%3E%3Cstop offset='.5' stop-color='%23f7c945'/%3E%3Cstop offset='1' stop-color='%23c07d0c'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M12 1c.9 5.6 4.4 9.1 10 10-5.6.9-9.1 4.4-10 10-.9-5.6-4.4-9.1-10-10 5.6-.9 9.1-4.4 10-10z' fill='url(%23s)' stroke='%238a4f08' stroke-width='.6' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
  filter: drop-shadow(0 1px 1.5px rgba(120,70,0,.5));
  pointer-events: none;
  z-index: 3;
}

/* ── Go Pro header CTA ─────────────────────────────────────── */
.btn-go-pro {
  background: linear-gradient(135deg, #b8860b 0%, #daa520 60%, #f5c842 100%);
  color: #1a1000;
  border: none;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .03em;
  box-shadow: 0 2px 8px rgba(218,165,32,.45);
  transition: transform var(--dur-micro) var(--ease-settle), box-shadow var(--dur-micro) var(--ease-settle);
}
.btn-go-pro:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(218,165,32,.6); }
[data-theme="light"] .btn-go-pro { color: #1a1000; }

/* ── Pro badge (inline label) ──────────────────────────────── */
.pro-badge {
  display: inline-block;
  background: linear-gradient(135deg, #b8860b, #daa520);
  color: #1a1000;
  font-size: .6rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: .04em;
  vertical-align: middle;
  margin-left: 4px;
  line-height: 1.6;
}

/* ── Pro welcome modal ─────────────────────────────────────── */
.pro-welcome-modal { max-width: 420px; }
.pro-welcome-perks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.pro-welcome-perk {
  font-size: .88rem;
  color: var(--text-dim);
  padding: 6px 10px;
  background: var(--surface2);
  border-radius: var(--radius);
}
/* Pro window line under the congrats text — the expiry date (or "never expires"). */
.pro-welcome-expiry {
  margin-top: -4px;
  font-size: .86rem;
  color: var(--text-dim);
}
/* Pro expired win-back banner — deliberately calm (no gold party). The "ended on …" line
   reads as a neutral fact; Renew is the primary action, "Maybe later" a quiet secondary. */
.pro-expired-modal { max-width: 420px; }
.pro-expired-when { font-weight: 700; }
.pro-expired-foot {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.pro-expired-later {
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.pro-expired-later:hover { color: var(--text); }
/* Admin's grant note — a personal message shown to the player once, on their first
   Pro view. Gold-accented so it reads as a note rather than a system perk. */
.pro-welcome-note {
  margin: 14px 0;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(218, 165, 32, .16), rgba(218, 165, 32, .07));
  border: 1px solid rgba(218, 165, 32, .55);
  border-left: 3px solid #daa520;
  border-radius: var(--radius);
  box-shadow: 0 0 0 3px rgba(218, 165, 32, .08);
}
.pro-welcome-note-label {
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #daa520;
  margin-bottom: 4px;
}
.pro-welcome-note-text {
  font-size: .9rem;
  color: var(--text);
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
}

/* ── Game Config modal — Pro row lock ──────────────────────── */
.gc-pro-badge {
  display: inline-block;
  background: linear-gradient(135deg, #b8860b, #daa520);
  color: #1a1000;
  font-size: .58rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: .04em;
  vertical-align: middle;
  margin-left: 5px;
  line-height: 1.6;
}
.gc-pro-row.gc-locked .gc-stepper,
.gc-pro-row.gc-locked .gc-select,
.gc-pro-row.gc-locked .gc-switch {
  pointer-events: none;
  opacity: .4;
  user-select: none;
}
/* Subtle lock icon next to a locked setting (used where there's no section Pro chip). */
.gc-pro-row.gc-locked .gc-lock { display: inline; }
.gc-pro-row.gc-locked {
  position: relative;
  cursor: pointer;
}
.gc-pro-row.gc-locked::after {
  content: '';
  position: absolute;
  inset: -2px 0;
  cursor: pointer;
  border-radius: 6px;
  background: rgba(0,0,0,.03);
}
.gc-pro-header {
  background: rgba(218,165,32,.1);
  border: 1px solid rgba(218,165,32,.3);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: .82rem;
  color: #daa520;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.gc-pro-header-icon { font-size: 1rem; }
.gc-pro-upgrade-btn {
  margin-left: auto;
  background: linear-gradient(135deg, #b8860b, #daa520);
  color: #1a1000;
  border: none;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--dur-micro) var(--ease-settle);
}
.gc-pro-upgrade-btn:hover { opacity: .85; }

/* ── Settings panel — subscription section ─────────────────── */
.set-sub-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.set-sub-badge {
  display: inline-block;
  border-radius: 6px;
  padding: 2px 10px;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.set-sub-free {
  background: rgba(255,255,255,.12);
  color: var(--clr-text, #ccc);
}
.set-sub-pro {
  background: linear-gradient(135deg, #b8860b, #daa520);
  color: #1a1000;
}
.set-sub-detail {
  font-size: .8rem;
  opacity: .75;
}
.set-sub-expiry {
  font-size: .75rem;
  opacity: .6;
  margin-bottom: 8px;
}
.set-btn-pro {
  background: linear-gradient(135deg, #b8860b, #daa520) !important;
  color: #1a1000 !important;
  font-weight: 800 !important;
  border: none !important;
}
.set-btn-pro:hover { opacity: .88; }

/* ── Pro Upgrade Modal ─────────────────────────────────────── */
.pu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.pu-backdrop:not([hidden]) {
  display: flex;
}
.pu-modal {
  background: var(--clr-card, #1e2230);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  overflow: hidden;
}
.pu-head {
  display: flex;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.pu-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #daa520;
  flex: 1;
}
.pu-close {
  background: none;
  border: none;
  color: inherit;
  opacity: .55;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
}
.pu-close:hover { opacity: 1; }
.pu-body {
  padding: 18px 20px 22px;
  overflow-y: auto;
}
.pu-tagline {
  font-size: .9rem;
  font-weight: 600;
  margin: 0 0 6px;
  opacity: .9;
}
.pu-current {
  font-size: .78rem;
  opacity: .7;
  margin: 0 0 14px;
}
.pu-features {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
}
.pu-features li {
  font-size: .83rem;
  padding: 5px 0;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  opacity: .88;
}
.pu-check {
  color: #daa520;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}
.pu-plans {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}
.pu-plan {
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  padding: 14px 8px 12px;
  text-align: center;
  position: relative;
}
.pu-plan-current {
  border-color: #5a9;
  background: rgba(80,170,150,.08);
}
/* When the featured (Yearly) card is also the player's current plan, the "Current" tag
   wins the top slot — otherwise it and the "Best value" badge would overlap. */
.pu-plan-current .pu-plan-badge { display: none; }
.pu-plan-tag {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: #5a9;
  color: #05130f;
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.pu-plan-price b { font-size: .92rem; }
.pu-plan-price span { opacity: .7; }
.pu-plan-featured {
  border-color: #daa520;
  background: rgba(218,165,32,.07);
}
.pu-plan-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #daa520;
  color: #1a1000;
  font-size: .62rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.pu-plan-name {
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.pu-plan-price {
  font-size: .75rem;
  opacity: .6;
}
/* Free vs Pro comparison table. */
.pu-compare {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 16px;
  font-size: .78rem;
}
.pu-compare th,
.pu-compare td {
  padding: 7px 8px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-align: left;
}
.pu-compare thead th {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  opacity: .6;
}
.pu-compare th:nth-child(2), .pu-compare td:nth-child(2),
.pu-compare th:nth-child(3), .pu-compare td:nth-child(3) {
  text-align: center;
  width: 15%;
}
.pu-compare .pu-y { color: #4caf7d; font-weight: 800; }
.pu-compare .pu-n { opacity: .35; }
.pu-compare tbody tr:last-child td { border-bottom: none; }

/* FAQ — native disclosure, styled to match the modal. */
.pu-faq { margin: 4px 0 16px; }
.pu-faq details {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 8px 0;
}
.pu-faq details:last-child { border-bottom: 1px solid rgba(255,255,255,.08); }
.pu-faq summary {
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pu-faq summary::-webkit-details-marker { display: none; }
.pu-faq summary::after { content: '+'; opacity: .5; font-weight: 700; }
.pu-faq details[open] summary::after { content: '−'; }
.pu-faq p {
  margin: 8px 0 2px;
  font-size: .78rem;
  opacity: .78;
  line-height: 1.45;
}
.pu-note {
  font-size: .77rem;
  opacity: .6;
  text-align: center;
  margin: 0 0 14px;
}
.pu-contact-btn {
  display: block;
  text-align: center;
  background: linear-gradient(135deg, #b8860b, #daa520);
  color: #1a1000 !important;
  font-weight: 800;
  font-size: .85rem;
  padding: 10px 16px;
  border-radius: 10px;
  text-decoration: none;
  transition: opacity var(--dur-micro) var(--ease-settle);
}
.pu-contact-btn:hover { opacity: .88; }

/* Light theme overrides */
[data-theme="light"] .pu-modal { background: #fff; }
[data-theme="light"] .pu-plan { border-color: rgba(0,0,0,.12); }
[data-theme="light"] .pu-plan-featured { background: rgba(184,134,11,.06); }
[data-theme="light"] .pu-plan-current { background: rgba(80,170,150,.1); }
[data-theme="light"] .pu-compare th,
[data-theme="light"] .pu-compare td { border-bottom-color: rgba(0,0,0,.1); }
[data-theme="light"] .pu-faq details { border-top-color: rgba(0,0,0,.1); }
[data-theme="light"] .pu-faq details:last-child { border-bottom-color: rgba(0,0,0,.1); }
[data-theme="light"] .gc-pro-header { color: #8a6000; background: rgba(184,134,11,.07); }
[data-theme="light"] .set-sub-free { background: rgba(0,0,0,.07); color: #555; }
[data-theme="light"] .btn-go-pro { color: #1a1000; }

/* ── Profile iframe modal ─────────────────────────────────── */
/* Outer layer: semi-transparent backdrop that lets the lobby show through */
.profile-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: flex-end;       /* panel anchored to bottom */
  justify-content: center;
}
.profile-modal[hidden] { display: none; }

/* Inner panel: opaque card that slides up from the bottom */
.profile-modal-inner {
  width: 100%;
  max-width: 640px;
  height: 92vh;
  display: flex;
  flex-direction: column;
  background: #1e1a12;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  box-shadow: 0 -4px 32px rgba(0,0,0,.6);
}
.profile-modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 50px;
  background: rgba(0,0,0,.3);
  border-bottom: 1px solid rgba(200,169,110,.2);
  flex-shrink: 0;
}
.profile-modal-title {
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: #c8a96e;
}
.profile-modal-close {
  background: none;
  border: none;
  color: #e8dcc8;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  line-height: 1;
}
.profile-modal-close:hover { background: rgba(200,169,110,.12); }
.profile-iframe {
  flex: 1;
  border: none;
  width: 100%;
}
[data-theme="light"] .profile-modal-inner { background: #f5f0e8; }
[data-theme="light"] .profile-modal-hd { background: rgba(0,0,0,.06); }
[data-theme="light"] .profile-modal-close { color: #1e1a12; }
