/* ORYTHM — base.css
   Bright Pop Arcade design system. See DESIGN.md for the full token rationale.
   The web fonts below are loaded once per page; pages that import this stylesheet
   inherit the entire system. Class names match the names referenced from JS so
   no JavaScript needs to change.
*/

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800;900&family=Space+Grotesk:wght@500;700&family=Bagel+Fat+One&display=swap');

/* ----- THEME TOKENS ------------------------------------------------------ */

:root {
  /* DAY (default) — warm peach paper, ink-violet text */
  --surface-paper: oklch(98% 0.012 60);
  --surface-1:     oklch(96% 0.018 50);
  --surface-2:     oklch(92% 0.025 45);
  --surface-pop:   oklch(99.5% 0.01 80);
  --ink:           oklch(20% 0.04 295);
  --ink-soft:      oklch(40% 0.03 295);
  --ink-faint:     oklch(58% 0.02 295);
  --line:          oklch(86% 0.025 50);
  --line-strong:   oklch(74% 0.035 45);

  /* Roles — stay equally vivid in both themes */
  --pop-pink:    oklch(70% 0.24 0);
  --pop-pink-2:  oklch(60% 0.26 5);
  --pop-yellow:  oklch(88% 0.18 95);
  --pop-yellow-2:oklch(78% 0.20 75);
  --pop-mint:    oklch(78% 0.18 165);
  --pop-mint-2:  oklch(68% 0.20 168);
  --pop-grape:   oklch(65% 0.22 295);
  --pop-grape-2: oklch(55% 0.24 295);
  --pop-coral:   oklch(68% 0.24 25);
  --pop-coral-2: oklch(58% 0.26 25);
  --pop-sky:     oklch(78% 0.16 230);
  --pop-sky-2:   oklch(68% 0.18 232);

  /* Judgement (game-feedback colors stay constant across themes) */
  --judge-perfect: oklch(86% 0.20 92);
  --judge-great:   oklch(78% 0.16 230);
  --judge-good:    oklch(78% 0.18 165);
  --judge-late:    oklch(80% 0.18 65);
  --judge-miss:    oklch(68% 0.24 25);

  /* Compatibility shims for legacy JS that already reads these names */
  --accent-1: var(--pop-pink);
  --accent-2: var(--pop-grape);
  --accent-3: var(--pop-yellow);
  --good:     var(--pop-mint);
  --warn:     var(--pop-yellow-2);
  --bad:      var(--pop-coral);
  --bg-0:     var(--surface-paper);
  --bg-1:     var(--surface-1);
  --bg-2:     var(--surface-2);
  --panel:           var(--surface-1);
  --panel-strong:    var(--surface-pop);
  --border:          var(--line);
  --text:            var(--ink);
  --text-dim:        var(--ink-soft);
  --shadow:          0 18px 40px oklch(20% 0.04 295 / .14);
  --glow-1:          0 0 22px oklch(70% 0.24 0 / .35);
  --glow-2:          0 0 22px oklch(65% 0.22 295 / .30);
  --radius:    22px;
  --radius-sm: 14px;

  /* New radius family */
  --r-sticker: 22px;
  --r-tile:    14px;
  --r-chip:    999px;
  --r-pop:     28px;

  /* Elevation — double-edge sticker recipe */
  --lift-1:   0 1px 0 oklch(100% 0 0 / .9), 0 6px 18px oklch(20% 0.04 295 / .12);
  --lift-2:   0 2px 0 oklch(100% 0 0 / .9), 0 14px 36px oklch(20% 0.04 295 / .18);
  --lift-pop: 0 3px 0 oklch(100% 0 0 / .9), 0 22px 48px oklch(20% 0.04 295 / .22);

  /* Motion. One easing scale, three duration buckets. The spring used to
     overshoot 50% which read as cartoony — softened to ~30% so transforms
     settle confidently without jiggling. */
  --tx:         cubic-bezier(.16, 1, .3, 1);          /* ease-out-quart  — default state changes */
  --ease-out:   cubic-bezier(.16, 1, .3, 1);          /* alias */
  --ease-quint: cubic-bezier(.22, 1, .36, 1);         /* sharper ease-out for fast transitions */
  --ease-expo:  cubic-bezier(.16, 1, .3, 1.0);        /* exponential out, longer settle */
  --spring:     cubic-bezier(.22, 1.3, .36, 1);       /* gentle 30% overshoot, settle clean */
  --spring-soft:cubic-bezier(.34, 1.15, .5, 1);       /* even softer spring for big surfaces */
  --t-fast:     180ms;     /* hover / micro feedback */
  --t-base:     280ms;     /* default state change */
  --t-slow:     480ms;     /* entrances + exits */
  --t-stage:    720ms;     /* set-pieces (podium, level-up) */
  --quality:    1;
  --motion-on:  1;
}

[data-theme="night"] {
  --surface-paper: oklch(14% 0.025 295);
  --surface-1:     oklch(20% 0.04 290);
  --surface-2:     oklch(26% 0.05 285);
  --surface-pop:   oklch(28% 0.05 285);
  --ink:           oklch(96% 0.014 80);
  --ink-soft:      oklch(78% 0.02 280);
  --ink-faint:     oklch(60% 0.018 280);
  --line:          oklch(36% 0.04 285);
  --line-strong:   oklch(50% 0.04 285);
  --shadow:        0 22px 50px oklch(8% 0.02 295 / .55);
  --lift-1:   0 1px 0 oklch(38% 0.04 290 / .9), 0 8px 22px oklch(6% 0.02 295 / .55);
  --lift-2:   0 2px 0 oklch(40% 0.04 290 / .9), 0 18px 40px oklch(6% 0.02 295 / .65);
  --lift-pop: 0 3px 0 oklch(46% 0.06 290 / .95), 0 28px 56px oklch(6% 0.02 295 / .8);
}

/* ----- BASE -------------------------------------------------------------- */

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

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--surface-paper);
  color: var(--ink);
  font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Fluid root font-size: every rem in the design (typography, padding,
   gaps, most layout sizing) scales linearly with viewport width.
   Calibrated so 1440px viewport → 16px (the original default),
   smoothly down to ~12px around 768px, and capped at 16px on wider
   screens so the design never looks bigger than its 1440p baseline
   (which is what the layout was tuned against). */
html {
  font-size: clamp(11px, 0.65vw + 6.7px, 16px);
}

/* Body stays locked at 100vh / overflow hidden — that's what the in-game
   `.game-page { position: absolute; inset: 0 }` depends on to fill the
   viewport. Scrolling for content-flow pages (Options, About, Scoreboard,
   etc) lives on the `main` element instead so the game stage is never
   affected by body overflow rules. */

body {
  position: relative;
  background:
    radial-gradient(ellipse 60% 45% at 18% 8%,  oklch(88% 0.18 95 / .22),  transparent 60%),
    radial-gradient(ellipse 70% 50% at 90% 95%, oklch(70% 0.24 0  / .18),  transparent 60%),
    radial-gradient(ellipse 50% 40% at 8% 95%,  oklch(65% 0.22 295 / .14), transparent 65%),
    radial-gradient(ellipse 50% 40% at 95% 12%, oklch(78% 0.18 165 / .14), transparent 60%),
    var(--surface-paper);
  background-attachment: fixed;
}

[data-theme="night"] body {
  background:
    radial-gradient(ellipse 60% 45% at 18% 8%,  oklch(88% 0.18 95 / .14),  transparent 60%),
    radial-gradient(ellipse 70% 50% at 90% 95%, oklch(70% 0.24 0  / .22),  transparent 60%),
    radial-gradient(ellipse 50% 40% at 8% 95%,  oklch(65% 0.22 295 / .28), transparent 65%),
    radial-gradient(ellipse 50% 40% at 95% 12%, oklch(78% 0.18 165 / .12), transparent 60%),
    var(--surface-paper);
}

body::before {
  content: ''; position: fixed; inset: -10%;
  background:
    radial-gradient(circle at 25% 38%, oklch(70% 0.24 0 / .10),  transparent 32%),
    radial-gradient(circle at 75% 65%, oklch(65% 0.22 295 / .10), transparent 32%),
    radial-gradient(circle at 50% 18%, oklch(88% 0.18 95 / .08), transparent 28%);
  filter: blur(50px);
  z-index: -2;
  animation: drift calc(60s / var(--quality)) ease-in-out infinite alternate;
  pointer-events: none;
}

/* Faint sticker-paper grain — replaces the cyber-grid */
body::after {
  content: ''; position: fixed; inset: 0;
  background-image: radial-gradient(oklch(20% 0.04 295 / .055) 1px, transparent 1px);
  background-size: 22px 22px;
  z-index: -1; pointer-events: none;
  opacity: calc(0.6 * var(--quality));
  mix-blend-mode: multiply;
}
[data-theme="night"] body::after {
  background-image: radial-gradient(oklch(96% 0.014 80 / .07) 1px, transparent 1px);
  mix-blend-mode: screen;
}

@keyframes drift {
  from { transform: translate(0, 0) rotate(0deg); }
  to   { transform: translate(2%, -1.5%) rotate(1.5deg); }
}

/* ----- TYPE -------------------------------------------------------------- */

h1, h2, h3, h4 {
  margin: 0 0 0.4em;
  font-weight: 800;
  letter-spacing: -0.005em;
  color: var(--ink);
}
h1 { font-size: clamp(2rem, 4vw, 3.4rem); font-family: 'Bagel Fat One', 'Outfit', sans-serif; font-weight: 400; letter-spacing: 0.005em; line-height: 1; }
h2 { font-size: clamp(1.4rem, 2.6vw, 2.1rem); }
h3 {
  font-size: 0.78rem; font-weight: 800;
  color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.18em;
}
h4 { font-size: 1rem; }

p { margin: 0 0 0.8em; max-width: 65ch; }
small { font-size: 0.78rem; color: var(--ink-soft); }
.dim { color: var(--ink-soft); }
.tiny { font-size: 0.78rem; }

a {
  color: var(--pop-grape);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 1.5px solid transparent;
  transition: border-color 180ms var(--tx), color 180ms var(--tx);
}
a:hover {
  color: var(--pop-pink);
  border-bottom-color: currentColor;
}

/* Hero brand mark — solid color, NO gradient text */
.brand {
  font-family: 'Bagel Fat One', 'Outfit', sans-serif;
  font-weight: 400;
  font-size: 2.2rem;
  letter-spacing: 0.005em;
  color: var(--pop-grape);
  filter: drop-shadow(0 4px 0 var(--pop-pink)) drop-shadow(0 8px 18px oklch(20% 0.04 295 / .25));
  display: inline-block;
  line-height: 1;
}

/* Numeric / score readouts */
.num, .score, .pts, .total {
  font-family: 'Space Grotesk', 'Outfit', sans-serif;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* ----- BUTTONS ----------------------------------------------------------- */

button, .btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  border: 1.5px solid var(--line-strong);
  background: var(--surface-pop);
  color: var(--ink);
  padding: 0.7em 1.4em;
  border-radius: var(--r-sticker);
  cursor: pointer;
  letter-spacing: 0.01em;
  position: relative;
  transition:
    transform 220ms var(--spring),
    background 180ms var(--tx),
    box-shadow 200ms var(--tx),
    border-color 180ms var(--tx);
  box-shadow: var(--lift-1);
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
}
button:hover, .btn:hover {
  transform: translateY(-2px) scale(1.012);
  background: var(--surface-2);
  box-shadow: var(--lift-2);
  border-color: var(--ink-soft);
}
button:active, .btn:active {
  transform: translateY(2px) scale(0.99);
  box-shadow: var(--lift-1);
  transition-duration: 80ms;
}
button:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--pop-grape);
  outline-offset: 3px;
}
button:disabled, .btn:disabled, button[disabled], .btn[disabled] {
  opacity: 0.45; cursor: not-allowed;
  transform: none; box-shadow: var(--lift-1);
}

button.primary, .btn.primary {
  background: var(--pop-pink);
  color: oklch(20% 0.04 295);
  border-color: var(--pop-pink-2);
}
button.primary:hover, .btn.primary:hover {
  background: oklch(74% 0.24 0);
  border-color: var(--pop-pink-2);
  box-shadow: var(--lift-pop), 0 0 0 4px oklch(70% 0.24 0 / .22);
}

button.danger, .btn.danger {
  background: var(--pop-coral);
  color: oklch(99% 0.01 80);
  border-color: var(--pop-coral-2);
}
button.danger:hover, .btn.danger:hover {
  background: oklch(72% 0.26 25);
  box-shadow: var(--lift-2), 0 0 0 4px oklch(68% 0.24 25 / .22);
  border-color: var(--pop-coral-2);
}

button.ghost, .btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--ink-soft);
}
button.ghost:hover, .btn.ghost:hover {
  background: var(--surface-2);
  border-color: var(--line);
  box-shadow: var(--lift-1);
  color: var(--ink);
}

button.success, .btn.success {
  background: var(--pop-mint);
  color: oklch(18% 0.04 200);
  border-color: var(--pop-mint-2);
}

button.warm, .btn.warm {
  background: var(--pop-yellow);
  color: oklch(20% 0.04 70);
  border-color: var(--pop-yellow-2);
}

/* small variant for inline actions */
button.sm, .btn.sm { font-size: 0.82rem; padding: 0.45em 0.9em; border-radius: var(--r-tile); }
button.lg, .btn.lg { font-size: 1.15rem; padding: 0.95em 1.7em; }

/* ----- INPUTS ----------------------------------------------------------- */

input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  background: var(--surface-pop);
  color: var(--ink);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-tile);
  padding: 0.75em 1em;
  outline: none;
  width: 100%;
  font-weight: 600;
  transition: border-color 180ms var(--tx), box-shadow 200ms var(--tx), background 180ms var(--tx);
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / .8);
}
[data-theme="night"] input,
[data-theme="night"] textarea,
[data-theme="night"] select {
  box-shadow: inset 0 1px 0 oklch(38% 0.04 290 / .9);
}
input:hover, textarea:hover, select:hover { border-color: var(--ink-soft); }
input:focus, textarea:focus, select:focus {
  border-color: var(--pop-grape);
  box-shadow: 0 0 0 4px oklch(65% 0.22 295 / .22), inset 0 1px 0 oklch(100% 0 0 / .8);
  background: var(--surface-pop);
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); font-weight: 500; }
input[type="checkbox"], input[type="radio"] { width: auto; }

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.35em;
}

/* range / slider */
input[type=range] {
  -webkit-appearance: none;
  height: 8px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 0; width: 100%;
  box-shadow: inset 0 1px 2px oklch(20% 0.04 295 / .12);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--pop-pink);
  border: 2.5px solid var(--surface-pop);
  cursor: pointer;
  box-shadow: var(--lift-1), 0 0 0 0 oklch(70% 0.24 0 / .35);
  transition: box-shadow 180ms var(--tx), transform 200ms var(--spring);
}
input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.12);
  box-shadow: var(--lift-2), 0 0 0 6px oklch(70% 0.24 0 / .22);
}
input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--pop-pink);
  border: 2.5px solid var(--surface-pop);
  cursor: pointer;
  box-shadow: var(--lift-1);
}

/* toggle */
.toggle {
  position: relative;
  width: 54px; height: 30px;
  background: var(--surface-2);
  border: 1.5px solid var(--line-strong);
  box-shadow: inset 0 1px 3px oklch(20% 0.04 295 / .15);
  border-radius: 999px;
  cursor: pointer;
  transition: background 200ms var(--tx), border-color 200ms var(--tx), box-shadow 200ms var(--tx);
  flex-shrink: 0;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px;
  background: var(--surface-pop);
  border-radius: 50%;
  box-shadow: var(--lift-1);
  transition: transform 220ms var(--spring), background 200ms var(--tx);
}
.toggle.on {
  background: var(--pop-mint);
  border-color: var(--pop-mint-2);
  box-shadow: 0 0 0 4px oklch(78% 0.18 165 / .22);
}
.toggle.on::after { transform: translateX(24px); background: var(--surface-pop); }

/* ----- LAYOUT PRIMITIVES ------------------------------------------------- */

.row { display: flex; gap: 0.6rem; align-items: center; }
.col { display: flex; flex-direction: column; gap: 0.6rem; }

.center-screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}

.panel {
  background: var(--surface-1);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sticker);
  box-shadow: var(--lift-1);
}
.panel.pop {
  background: var(--surface-pop);
  box-shadow: var(--lift-pop);
  border-color: var(--line-strong);
}

/* ----- TOAST ------------------------------------------------------------- */

.toast {
  position: fixed; left: 50%; top: 1.5rem;
  transform: translateX(-50%);
  padding: 0.85em 1.4em;
  background: var(--surface-pop);
  color: var(--ink);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-chip);
  box-shadow: var(--lift-pop);
  font-weight: 700;
  z-index: 9999;
  animation: toastIn 3s var(--ease-out) forwards;
  will-change: transform, opacity;
}
.toast.error {
  background: var(--pop-coral);
  color: oklch(99% 0.01 80);
  border-color: var(--pop-coral-2);
}
.toast.ok {
  background: var(--pop-mint);
  color: oklch(18% 0.04 200);
  border-color: var(--pop-mint-2);
}
@keyframes toastIn {
  0%        { opacity: 0; transform: translate(-50%, -16px) scale(0.92); }
  10%, 90%  { opacity: 1; transform: translate(-50%, 0)     scale(1); }
  100%      { opacity: 0; transform: translate(-50%, -10px) scale(0.96); }
}

/* ----- AVATAR ------------------------------------------------------------ */

.avatar {
  display: inline-block;
  width: 40px; height: 40px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, oklch(88% 0.16 95 / .9) 0%, transparent 50%),
    linear-gradient(135deg, var(--pop-pink), var(--pop-grape));
  border: 2.5px solid var(--surface-pop);
  background-size: cover;
  background-position: center;
  box-shadow: var(--lift-1);
  flex-shrink: 0;
  position: relative;
}
.avatar.lg { width: 72px; height: 72px; border-width: 3px; }
.avatar.xl { width: 120px; height: 120px; border-width: 4px; }
.avatar.sm { width: 28px; height: 28px; border-width: 2px; }

/* ----- ONLINE DOT -------------------------------------------------------- */

.online-dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--pop-mint);
  box-shadow:
    0 0 0 2px var(--surface-paper),
    0 0 8px oklch(78% 0.18 165 / .65);
  flex-shrink: 0;
}
.online-dot.off {
  background: var(--ink-faint);
  box-shadow: 0 0 0 2px var(--surface-paper);
}

/* ----- ROLE TAG BADGE ---------------------------------------------------- */

.role-tag-badge {
  position: relative;
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 20px; height: 20px;
  margin-left: 0.4em;       /* breathing room when sitting next to a name */
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  flex-shrink: 0;
  cursor: help;
  user-select: none;
  box-shadow: var(--lift-1);
}
.role-tag-badge.gold,
.role-tag-badge.silver,
.role-tag-badge.bronze {
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 2px 4px oklch(20% 0.04 295 / .25));
}
.role-tag-badge.admin {
  background: var(--pop-coral);
  color: oklch(99% 0.01 80);
  border: 1.5px solid var(--pop-coral-2);
  position: relative;
}
/* Pulsing ring drawn as a pseudo-element scaling out, instead of an
   animated box-shadow (which repaints the entire badge every frame).
   Toned down (smaller max scale, lower opacity) so it doesn't smudge
   against bright/colored backgrounds like the gold podium card. */
.role-tag-badge.admin::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 1.5px solid oklch(68% 0.24 25 / .55);
  animation: badgePulseRing 2.4s var(--ease-out) infinite;
  pointer-events: none;
  will-change: transform, opacity;
}
@keyframes badgePulseRing {
  0%   { opacity: 0.6; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.35); }
}
/* In tight name-and-tag contexts, kill the pulse entirely so it can't
   bleed into surrounding text. The badge itself is still clearly the
   admin coral pill — just no halo. */
.sb-podium-name .role-tag-badge.admin::before,
.fp-name-row   .role-tag-badge.admin::before,
.fp-name       .role-tag-badge.admin::before,
.mb-name       .role-tag-badge.admin::before { display: none; }
.role-tag-badge.mod {
  background: var(--pop-sky);
  color: oklch(18% 0.04 230);
  border: 1.5px solid var(--pop-sky-2);
}
.role-tag-badge::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  padding: 0.4em 0.8em;
  border-radius: var(--r-chip);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  background: var(--surface-pop);
  color: var(--ink);
  border: 1.5px solid var(--line-strong);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 4px) scale(0.85);
  transition: opacity 180ms var(--tx), transform 220ms var(--spring);
  z-index: 50;
  box-shadow: var(--lift-2);
}
.role-tag-badge.admin::after { color: var(--pop-coral); border-color: var(--pop-coral-2); }
.role-tag-badge.mod::after   { color: var(--pop-sky-2); border-color: var(--pop-sky-2); }
.role-tag-badge.gold::after,
.role-tag-badge.silver::after,
.role-tag-badge.bronze::after { color: var(--pop-yellow-2); border-color: var(--pop-yellow-2); }
.role-tag-badge:hover::after { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* roleAdminPulse — replaced with transform-based badgePulseRing above */

/* ----- LVL BADGE --------------------------------------------------------- */

.lvl-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  padding: 0.2em 0.7em;
  border-radius: var(--r-chip);
  background: var(--pop-grape);
  color: oklch(98% 0.012 60);
  border: 1.5px solid var(--pop-grape-2);
  font-family: 'Outfit', system-ui, sans-serif;
  white-space: nowrap;
  box-shadow: var(--lift-1);
  line-height: 1;
}
.lvl-badge-label {
  font-size: 0.65em;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: oklch(98% 0.012 60 / .85);
  text-transform: uppercase;
}
.lvl-badge-num {
  font-family: 'Space Grotesk', 'Outfit', sans-serif;
  font-size: 1.05em;
  font-weight: 700;
  color: var(--pop-yellow);
  font-variant-numeric: tabular-nums;
}
.lvl-badge.sm { font-size: 0.8rem; padding: 0.16em 0.55em; }
.lvl-badge.lg { font-size: 1.1rem; padding: 0.28em 0.85em; }

/* ----- STICKER CHIPS ----------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.25em 0.75em;
  border-radius: var(--r-chip);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: var(--surface-2);
  color: var(--ink);
  border: 1.5px solid var(--line-strong);
  box-shadow: var(--lift-1);
  white-space: nowrap;
}
.chip.pink   { background: var(--pop-pink);   color: oklch(20% 0.04 295); border-color: var(--pop-pink-2); }
.chip.yellow { background: var(--pop-yellow); color: oklch(20% 0.04 70);  border-color: var(--pop-yellow-2); }
.chip.mint   { background: var(--pop-mint);   color: oklch(18% 0.04 200); border-color: var(--pop-mint-2); }
.chip.grape  { background: var(--pop-grape);  color: oklch(98% 0.012 60); border-color: var(--pop-grape-2); }
.chip.coral  { background: var(--pop-coral);  color: oklch(99% 0.01 80);  border-color: var(--pop-coral-2); }
.chip.sky    { background: var(--pop-sky);    color: oklch(18% 0.04 230); border-color: var(--pop-sky-2); }

/* ----- FADE / ENTRANCE --------------------------------------------------- */

.fade-in { animation: fadeIn 320ms var(--tx) both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.pop-in { animation: popIn 420ms var(--spring) both; }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}

/* ----- SCROLLBAR --------------------------------------------------------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 2.5px solid var(--surface-paper);
}
::-webkit-scrollbar-thumb:hover { background: var(--pop-grape); }

/* ----- FRIENDS RAIL ------------------------------------------------------ */

.friends-rail {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 64px;
  background:
    linear-gradient(270deg, var(--surface-1) 0%, oklch(from var(--surface-1) l c h / .4) 100%);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border-left: 1.5px solid var(--line);
  transition: width 320ms var(--spring);
  z-index: 100;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: -10px 0 30px oklch(20% 0.04 295 / .08);
}
.friends-rail:hover, .friends-rail.expanded { width: 320px; }

.friends-rail .top {
  padding: 0.7rem 0.5rem;
  border-bottom: 1.5px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
}
.friends-rail .top .me-avatar {
  width: 44px; height: 44px;
  cursor: pointer;
  border-color: var(--pop-pink);
  box-shadow: var(--lift-2), 0 0 0 3px oklch(70% 0.24 0 / .25);
  transition: transform 240ms var(--spring);
}
.friends-rail .top .me-avatar:hover { transform: scale(1.08) rotate(-3deg); }
.friends-rail .top .me-col {
  display: none; flex-direction: column; align-items: flex-start; gap: 0.25rem; min-width: 0;
}
.friends-rail:hover .top .me-col,
.friends-rail.expanded .top .me-col { display: flex; }
.friends-rail .top .me-name {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--pop-grape);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.friends-rail .me-stats-line {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.78rem;
  white-space: nowrap;
}
.friends-rail .me-op {
  display: inline-flex; align-items: baseline; gap: 0.2rem;
}
.friends-rail .me-op-value {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800;
  color: var(--pop-pink);
}
.friends-rail .me-op-label {
  font-size: 0.68rem; font-weight: 800;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}
/* Hidden in the collapsed icon-only rail. */
.friends-rail:not(.expanded):not(:hover) .me-stats-line { display: none; }
.friends-rail:hover .top, .friends-rail.expanded .top {
  flex-direction: row;
  flex-wrap: wrap;
  padding: 0.9rem 0.9rem 0.7rem;
  gap: 0.7rem;
}
.friends-rail:hover .top .me-name,
.friends-rail.expanded .top .me-name { display: block; }
.friends-rail .top input { display: none; flex: 1; min-width: 0; padding: 0.5em 0.8em; font-size: 0.85rem; }
.friends-rail:hover .top input,
.friends-rail.expanded .top input { display: block; }

.friends-rail .pinned-icon {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.15rem;
  color: var(--pop-grape);
}
.friends-rail .pinned-icon .pinned-label {
  font-size: 0.55rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  white-space: nowrap;
}
.friends-rail .pinned-icon .pinned-count {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--pop-grape);
  line-height: 1;
}
.friends-rail:hover .pinned-icon,
.friends-rail.expanded .pinned-icon { display: none; }

.friends-rail .list { flex: 1; overflow-y: auto; padding: 0.5rem; }

.friend-item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.5rem;
  border-radius: var(--r-tile);
  cursor: pointer;
  transition: background 160ms var(--tx), transform 220ms var(--spring);
}
.friend-item:hover {
  background: var(--surface-2);
  transform: translateX(2px);
}
.friend-item .name {
  display: flex; align-items: center; gap: 0.35rem;
  flex: 1; min-width: 0;
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.friends-rail:not(.expanded):not(:hover) .friend-item .name,
.friends-rail:not(.expanded):not(:hover) .friend-item .meta,
.friends-rail:not(.expanded):not(:hover) .friend-item .online-dot,
.friends-rail:not(.expanded):not(:hover) .friend-item .lvl-badge,
.friends-rail:not(.expanded):not(:hover) .top h3,
.friends-rail:not(.expanded):not(:hover) .section-h,
.friends-rail:not(.expanded):not(:hover) .friend-actions,
.friends-rail:not(.expanded):not(:hover) .placeholder,
.friends-rail:not(.expanded):not(:hover) .bottom .bottom-label,
.friends-rail:not(.expanded):not(:hover) .top .me-lvl { display: none; }
.friends-rail:not(.expanded):not(:hover) .friend-item {
  justify-content: center;
  padding: 0.35rem;
}

.friend-item.role-admin .name { color: var(--pop-coral-2); }
.friend-item.role-mod   .name { color: var(--pop-sky-2); }

.friend-medal {
  font-size: 0.95rem;
  filter: drop-shadow(0 2px 4px oklch(20% 0.04 295 / .25));
  pointer-events: none;
  flex-shrink: 0;
}

/* Pending-requests block, anchored above Settings.
   Visible in both collapsed and expanded rail states — the contents
   differ:
     • collapsed: only `.requests-collapsed-indicator` shows (icon + count)
     • expanded:  header, the 3 newest preview rows, and "View all" */
.friends-rail .requests-block {
  display: none;
  flex-direction: column; gap: 0.25rem;
  padding: 0.4rem 0.5rem 0.55rem;
  border-top: 1.5px solid var(--line);
  background: oklch(from var(--surface-1) l c h / .55);
  flex-shrink: 0;
}
.friends-rail .requests-block.has-requests { display: flex; }
.friends-rail .requests-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.35rem 0.4rem 0.2rem;
}
.friends-rail .requests-count {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800; font-size: 0.78rem;
  background: var(--pop-coral); color: oklch(99% 0.01 80);
  padding: 0.1em 0.55em; border-radius: var(--r-chip);
  letter-spacing: 0;
}

/* Collapsed-rail indicator — small "Requests" label on top, envelope
   icon with count badge below. Mirrors the top-of-rail Friends/N stack
   so the rail reads symmetrically. Clicking opens the modal. */
.friends-rail .requests-collapsed-indicator {
  display: flex; flex-direction: column; align-items: center; gap: 0.45rem;
  padding: 0.4rem 0 0.2rem;
  cursor: pointer;
  color: var(--ink-soft);
}
.friends-rail .requests-collapsed-indicator .rci-label {
  font-size: 0.55rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.friends-rail .requests-collapsed-indicator .rci-icon-wrap {
  position: relative;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  transition: transform 220ms var(--spring), border-color 160ms var(--tx), color 160ms var(--tx);
}
.friends-rail .requests-collapsed-indicator:hover .rci-icon-wrap {
  transform: scale(1.08);
  border-color: var(--pop-coral);
  color: var(--pop-coral);
}
.friends-rail .requests-collapsed-indicator:hover .rci-label {
  color: var(--pop-coral);
}
.friends-rail .requests-collapsed-indicator .rci-icon {
  font-size: 1.05rem;
  font-weight: 700;
}
.friends-rail .requests-collapsed-indicator .rci-count {
  position: absolute;
  top: -4px; right: -6px;
  min-width: 20px; height: 18px;
  padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800; font-size: 0.68rem;
  background: var(--pop-coral); color: oklch(99% 0.01 80);
  border: 2px solid var(--surface-1);
  border-radius: 999px;
  line-height: 1;
  letter-spacing: 0;
}

/* Collapsed: hide expanded contents, show only the indicator. */
.friends-rail:not(.expanded):not(:hover) .requests-block .requests-h,
.friends-rail:not(.expanded):not(:hover) .requests-block .friend-item,
.friends-rail:not(.expanded):not(:hover) .requests-block .requests-viewall {
  display: none;
}
/* Expanded: hide the indicator, show the full list. */
.friends-rail:hover .requests-block .requests-collapsed-indicator,
.friends-rail.expanded .requests-block .requests-collapsed-indicator {
  display: none;
}
.friends-rail .requests-viewall {
  background: transparent;
  border: 1.5px dashed var(--line);
  color: var(--ink-soft);
  font-size: 0.78rem; font-weight: 700;
  padding: 0.45rem 0.5rem;
  border-radius: var(--r-tile);
  cursor: pointer;
  margin-top: 0.2rem;
  transition: color 160ms var(--tx), border-color 160ms var(--tx), background 160ms var(--tx);
}
.friends-rail .requests-viewall:hover {
  color: var(--pop-pink);
  border-color: var(--pop-pink);
  background: oklch(from var(--pop-pink) l c h / .07);
}

/* Requests modal — searchable full list, opens from "View all". */
.requests-card {
  width: min(520px, 92vw);
  max-height: 80vh;
  display: flex; flex-direction: column; gap: 0.7rem;
  padding: 1.6rem 1.6rem 1.4rem;
}
.requests-modal-h {
  display: flex; align-items: baseline; gap: 0.7rem;
}
.requests-modal-title { margin: 0; }
.requests-search {
  width: 100%;
  padding: 0.55em 0.85em;
  font-size: 0.9rem;
}
.requests-modal-list {
  flex: 1; min-height: 0;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 0.2rem;
  margin-right: -0.4rem;        /* let scrollbar live in card padding */
  padding-right: 0.4rem;
}
.requests-modal-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem; align-items: center;
  padding: 0.55rem 0.7rem;
  background: var(--surface-1);
  border: 1.5px solid var(--line);
  border-radius: var(--r-tile);
}
.requests-modal-row.role-admin .rmr-name { color: var(--pop-coral-2); }
.requests-modal-row.role-mod   .rmr-name { color: var(--pop-sky-2); }
.requests-modal-row .rmr-meta { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.requests-modal-row .rmr-name {
  font-weight: 800;
  display: flex; align-items: center; gap: 0.35rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.friends-rail .bottom {
  padding: 0.7rem 0.9rem;
  border-top: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem; cursor: pointer;
  color: var(--ink-soft);
  font-weight: 700;
  white-space: nowrap;
  transition: color 180ms var(--tx);
}
.friends-rail:hover .bottom,
.friends-rail.expanded .bottom { justify-content: flex-start; }
.friends-rail .bottom:hover { color: var(--pop-pink); }
.friends-rail .bottom .bottom-icon { font-size: 1.1rem; }
.friends-rail .section-h {
  font-size: 0.7rem; color: var(--ink-soft);
  font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.12em;
  padding: 0.7rem 0.6rem 0.3rem;
  white-space: nowrap;
}
.friend-actions { display: flex; gap: 0.3rem; }
.friend-actions .btn { font-size: 0.7rem; padding: 0.3em 0.6em; border-radius: var(--r-tile); }

/* Make `main` and its grandparent `#app` proper height-bounded scroll
   containers. body has overflow:hidden (locked for game stage). Pages
   scroll inside main using viewport units so height resolves correctly
   even when #app has no explicit size. */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}
main {
  display: block;
  flex: 1 1 0;
  min-height: 0;             /* lets flex children shrink below content size */
  height: 100vh;             /* fallback if not in a flex chain */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;   /* iOS momentum drag-scroll */
  overscroll-behavior: contain;        /* don't bounce-scroll the body */
  padding-right: 64px;
}
@media (max-width: 700px) {
  .friends-rail { display: none; }
  main { padding-right: 0; }
}
body.in-game .friends-rail { display: none; }
body.in-game main {
  padding-right: 0;
  overflow: hidden;     /* lock scroll during gameplay */
}

/* ----- CHAT WIDGET ------------------------------------------------------- */

.chat-widget {
  position: fixed;
  z-index: 150;
  display: flex; flex-direction: column;
  /* rem so the widget rides the fluid root font: ~300px at 1440p and
     scales smoothly down with the window instead of pinning to a 220px
     floor like the old vw-clamp did. */
  width: 18.75rem;
  /* Bottom-anchored everywhere now: that way collapse/expand is a clean
     height transition without the widget teleporting between center and
     corner. Discord-style placement reads more naturally too. */
  bottom: 1rem;
  /* Animate height + width for smooth collapse/expand */
  transition:
    height 380ms cubic-bezier(.16, 1, .3, 1),
    width 320ms cubic-bezier(.16, 1, .3, 1),
    bottom 280ms cubic-bezier(.16, 1, .3, 1);
  will-change: height, width;
}
body:not(.in-game) .chat-widget { left: 1.4rem; height: min(60vh, 32.5rem); }
body.in-game .chat-widget {
  left: calc(50% + min(43vh, 43vw, 34.4rem) + 1rem);
  height: min(78vh, 78vw, 33.75rem);
}
@media (max-width: 1100px) {
  body.in-game .chat-widget { left: auto; right: 1rem; width: 16.25rem; }
}

.chat-panel {
  width: 100%; height: 100%;
  background: var(--surface-1);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sticker);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--lift-2);
}
.chat-widget.embedded .chat-panel {
  background: transparent; border: 0; box-shadow: none; border-radius: 0;
}
.chat-header {
  padding: 0.7rem 1rem;
  border-bottom: 1.5px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 800; font-size: 0.92rem;
  color: var(--pop-grape);
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  background: var(--surface-2);
}

/* Context label inside the chat header: globe icon + scope text + pill */
.chat-context-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}
.chat-context-icon { font-size: 1.05rem; line-height: 1; }
.chat-context-text {
  font-weight: 800;
  font-size: 0.92rem;
  white-space: nowrap;
}
.chat-context-pill {
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  padding: 0.18em 0.55em;
  border-radius: var(--r-chip);
  background: var(--pop-pink);
  color: oklch(20% 0.04 295);
  border: 1.5px solid var(--pop-pink-2);
  white-space: nowrap;
}
.chat-context-pill.lobby {
  background: var(--pop-mint);
  border-color: var(--pop-mint-2);
  color: oklch(18% 0.04 200);
}

/* Hide the scope pill when the chat is collapsed — the icon + label is
   enough at that size, the pill just makes the header crowded. */
.chat-widget.collapsed .chat-context-pill {
  max-width: 0;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  opacity: 0;
  margin: 0;
  overflow: hidden;
}
.chat-context-pill {
  transition:
    max-width 280ms cubic-bezier(.16, 1, .3, 1),
    padding 280ms cubic-bezier(.16, 1, .3, 1),
    opacity 200ms ease-in-out,
    border-width 200ms ease-in-out;
  max-width: 200px;
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
}

/* Whole-widget tinting so the header band reads at a glance */
.chat-widget.chat-global .chat-header {
  background: linear-gradient(90deg, oklch(70% 0.24 0 / .15), var(--surface-2) 60%);
  border-bottom-color: var(--pop-pink);
  color: var(--pop-pink-2);
}
.chat-widget.chat-lobby .chat-header {
  background: linear-gradient(90deg, oklch(78% 0.18 165 / .15), var(--surface-2) 60%);
  border-bottom-color: var(--pop-mint);
  color: var(--pop-mint-2);
}
.chat-widget.chat-global .chat-panel { border-color: var(--pop-pink); }
.chat-widget.chat-lobby  .chat-panel { border-color: var(--pop-mint); }

@media (max-width: 600px) {
  .chat-context-pill { display: none; }
  .chat-context-text { font-size: 0.85rem; }
}
.chat-toggle {
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0 0.2rem;
  cursor: pointer;
  margin: 0;
  border-radius: var(--r-tile);
  /* Smooth chevron flip when toggling collapsed state */
  transition: transform 320ms cubic-bezier(.16, 1, .3, 1), color 200ms ease-in-out;
  display: inline-block;
}
.chat-widget.collapsed .chat-toggle { transform: rotate(180deg); }
.chat-toggle:hover { color: var(--pop-pink); box-shadow: none; background: transparent; }

/* Collapse animation: messages + input fade their height and opacity to 0,
   the panel's flex layout naturally shrinks the widget. We don't use
   display:none — display can't transition. max-height + padding + opacity
   all animate together. */
.chat-messages,
.chat-input {
  transition:
    max-height 380ms cubic-bezier(.16, 1, .3, 1),
    opacity 220ms ease-in-out,
    padding 380ms cubic-bezier(.16, 1, .3, 1),
    border-color 220ms ease-in-out;
  overflow: hidden;
  max-height: 1000px;          /* "expanded" cap (large enough for any chat) */
}
.chat-widget.collapsed {
  height: auto !important;
  width: 15rem;
}
.chat-widget.collapsed .chat-header {
  border-bottom-color: transparent;
}
.chat-widget.collapsed .chat-messages,
.chat-widget.collapsed .chat-input {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-color: transparent;
  pointer-events: none;
}

/* Chat pulse — single transform-driven ring instead of growing box-shadow */
.chat-widget.chat-pulse .chat-panel { position: relative; }
.chat-widget.chat-pulse .chat-panel::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid oklch(70% 0.24 0 / .55);
  animation: chatPulseRing 1.1s var(--ease-out) forwards;
  pointer-events: none;
  will-change: transform, opacity;
}
@keyframes chatPulseRing {
  0%   { opacity: 0.9; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.08); }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  line-height: 1.45;
}
.chat-msg { margin-bottom: 0.3rem; word-wrap: break-word; word-break: break-word; }
.chat-msg.system {
  color: var(--pop-yellow-2); font-style: italic;
  background: oklch(88% 0.18 95 / .14);
  padding: 0.2em 0.5em; border-radius: var(--r-tile);
  border-left: none;
}
.chat-msg .chat-from {
  font-weight: 800;
  color: var(--ink-soft);
  margin-right: 0.4rem;
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
}
.chat-msg.role-admin .chat-from { color: var(--pop-coral); }
.chat-msg.role-mod   .chat-from { color: var(--pop-sky-2); }
.chat-msg .role-tag-badge { margin-right: 0.1rem; }
.chat-msg .chat-text { color: var(--ink); }

/* @-mention pill — slightly yellow with a faint bg, never as bold as
   the role chips. */
.chat-mention {
  color: var(--pop-yellow-2);
  background: oklch(88% 0.18 95 / .18);
  border: 1px solid oklch(88% 0.18 95 / .35);
  border-radius: 5px;
  padding: 0 0.32em;
  font-weight: 800;
}

/* Whole-message tint when *I* am the one being mentioned, plus a subtle
   left rule so the row stands out in a long scrollback. */
.chat-msg.mentions-me {
  background: oklch(88% 0.18 95 / .12);
  border-radius: var(--r-tile);
  padding: 0.25em 0.45em;
  margin: 0.1rem -0.2rem 0.3rem;
  position: relative;
}
.chat-msg.mentions-me::before {
  content: '';
  position: absolute;
  left: -0.55em; top: 0.25em; bottom: 0.25em;
  width: 3px; border-radius: 2px;
  background: var(--pop-yellow);
}

.chat-input {
  border: none;
  border-top: 1.5px solid var(--line);
  border-radius: 0;
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  background: var(--surface-pop);
  box-shadow: none;
}
.chat-input:focus {
  box-shadow: 0 -2px 0 var(--pop-grape) inset;
  border-color: var(--line);
}

@media (max-width: 700px) {
  .chat-widget { width: calc(100vw - 2rem); height: 50vh; }
}

/* ----- STICKER ICONS (inline svg helpers) ------------------------------- */

.sticker {
  display: inline-flex;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px oklch(20% 0.04 295 / .15));
}
.sticker svg { display: block; }

/* ----- GUEST WARNING BANNER --------------------------------------------- */
/* Strip across the top of every menu page when the current user is a
   guest. Slides down on entry, dwells, then slides up and unmounts via
   JS. Hidden during gameplay so it doesn't fight with the game stage. */
.guest-banner {
  position: fixed; top: 0; left: 0; right: 64px;
  z-index: 90;
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.55rem 1rem;
  background: linear-gradient(90deg, oklch(85% 0.15 60), oklch(90% 0.16 80));
  color: oklch(22% 0.06 60);
  font-size: 0.84rem;
  border-bottom: 1.5px solid oklch(70% 0.18 60);
  box-shadow: 0 4px 12px oklch(0% 0 0 / .15);
  will-change: transform, opacity;
}
.guest-banner.sliding-in {
  animation: guestBannerIn 480ms cubic-bezier(0.22, 1.4, 0.36, 1) both;
}
.guest-banner.sliding-out {
  animation: guestBannerOut 380ms cubic-bezier(0.5, -0.05, 0.5, 1) both;
}
@keyframes guestBannerIn {
  0%   { transform: translateY(-110%); opacity: 0; }
  60%  { transform: translateY(4px);   opacity: 1; }   /* tiny overshoot */
  100% { transform: translateY(0);     opacity: 1; }
}
@keyframes guestBannerOut {
  0%   { transform: translateY(0);    opacity: 1; }
  100% { transform: translateY(-110%); opacity: 0; }
}
.guest-banner-icon { font-size: 1.05rem; }
.guest-banner-text { flex: 1; line-height: 1.3; }
.guest-banner-text strong { font-weight: 800; }
.guest-banner-link {
  white-space: nowrap;
  background: #5865F2; border-color: #4752C4; color: #fff;
}
.guest-banner-link:hover { background: #4752C4; }
/* The banner is a brief 5-second flyover, not a persistent strip — so
   we don't push content down. It overlays the top edge during its
   slide-in / dwell / slide-out, then unmounts. Anything important
   right at top:0 gets briefly covered, which is acceptable since the
   banner has a clear "Link" CTA and disappears on its own. */
@media (max-width: 700px) {
  .guest-banner { right: 0; flex-wrap: wrap; padding: 0.5rem 0.7rem; gap: 0.5rem; }
}
body.in-game .guest-banner { display: none; }

/* `.mobile-only` blocks render only inside the mobile media query
   (mobile.css un-hides them). Convenient for sections that exist on
   the home page only on phones. */
.mobile-only { display: none; }

/* DESKTOP DEFAULT 150% — make the entire site render 1.5× larger on PC
   without forcing the user to set browser zoom. Mobile (<1024px) stays
   at native 1× because its layout is already finger-sized.
   Implementation: bump the root rem AND scale the pixel-defined
   surfaces (avatars, rails, fixed widths) by 1.5× so vector text,
   bitmap images, SVGs, and pixel chrome all grow uniformly. Bumping
   font-size alone would scale text but leave avatars + rails the
   original size, which looks lopsided. */
@media (min-width: 1024px) {
  html {
    font-size: 24px;             /* 16 × 1.5 — drives every rem-based sizing */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }
  img, .avatar { image-rendering: auto; }    /* let the browser pick its best resampler */

  /* Pixel-defined sizes scaled 1.5× to match. Anything left at its
     original px would look small next to rem-scaled siblings. */
  .avatar       { width: 60px;  height: 60px;  border-width: 4px; }
  .avatar.sm    { width: 42px;  height: 42px;  border-width: 3px; }
  .avatar.lg    { width: 108px; height: 108px; border-width: 5px; }
  .avatar.xl    { width: 180px; height: 180px; border-width: 6px; }

  .friends-rail { width: 96px; }
  .friends-rail:hover,
  .friends-rail.expanded { width: 480px; }
  .friends-rail .top .me-avatar { width: 66px; height: 66px; }
  .friends-rail .pinned-icon .pinned-count { font-size: 2.1rem; }

  /* Main reserves the rail strip — keep them in lock-step. */
  main { padding-right: 96px; }
  body.in-game main, body.has-guest-banner main { padding-right: 0; }

  /* Mini-board, lobby cards, podium, etc. that hard-code px. */
  .mini-board { width: 450px; }
  .mini-board.has-grow { right: calc(96px + 2.1rem); }
  .userchip { padding: 0.6rem 1.2rem 0.6rem 0.6rem; }

  /* Online dot stays a clean dot, just bigger. */
  .online-dot { width: 12px; height: 12px; border-width: 4px; }

  /* Game stage frame stays centered; play-area math is in PLAY_AREA_PX
     server-side and stays at 720 (server authoritative). The visual
     stage container scales naturally with rem-based wrapper sizes. */

  /* ----- Desktop 150% follow-up: targeted size fixes ----- */

  /* Chat header — context label was 0.92rem (read tiny next to the
     larger surrounding UI). Bump it. Widen the widget too so the
     header has room to breathe. */
  .chat-context-text { font-size: 1.05rem; }
  .chat-context-pill { font-size: 0.65rem; padding: 0.25em 0.7em; }
  body:not(.in-game) .chat-widget {
    width: clamp(320px, 24vw, 440px);
    height: min(72vh, 760px);
  }
  /* Collapsed state: keep the header band readable; clamp height so the
     pill doesn't get clipped. */
  .chat-widget.collapsed { height: auto; }
  .chat-widget.collapsed .chat-header { padding: 0.6rem 0.95rem; }

  /* Lobby counter — make 1, /, 8 the same prominent size; "players" is
     the only thing that should be smaller. Reads consistently now. */
  .lobby-counter-num,
  .lobby-counter-sep,
  .lobby-counter-max { font-size: 1.6rem; line-height: 1; font-weight: 800; }
  .lobby-counter-sep { color: var(--ink-soft); }
  .lobby-counter-max { color: var(--ink); }
  .lobby-counter-label { font-size: 0.85rem; margin-left: 0.5rem; }

  /* Hide the redundant lobby-header Leave button — top-center back-link
     already exits the lobby. Keeps header tidy. */
  .lobby-header-right > .ghost { display: none; }

  /* Mini-board (top-players widget). Width is now content-driven —
     min 520, max 760 — so the longest visible name decides the card
     width without truncation. Row gap is bumped so the avatar and
     the name don't kiss. */
  .mini-board {
    width: auto;
    min-width: 520px;
    max-width: 760px;
  }
  .mini-board-row {
    grid-template-columns: auto auto 1fr auto;
    gap: 0.95rem;
    padding: 0.55rem 0.85rem;
  }
  .mini-board-row .mb-name {
    font-size: 1rem;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    margin-left: 0.7rem;     /* extra breathing room from the avatar */
  }

  /* Settings — Account tab and other auth-tab labels were tiny because
     they used 0.85rem. Bump to match the page heading scale. */
  .auth-tab { font-size: 1rem; padding: 0.85em 1rem; }
  .options-tabs .auth-tab { font-size: 0.95rem; }

  /* In-game live accuracy board — make it readable from across the
     room. Move to the right side; chat goes to the left. */
  .picker-board {
    left: auto !important;
    right: 1rem;
    width: 320px;
    gap: 0.55rem;
  }
  .picker-board .picker-board-title { font-size: 0.78rem; }
  .picker-board-row {
    grid-template-columns: 36px 1fr auto auto;
    padding: 0.7rem 0.85rem;
    gap: 0.6rem;
  }
  .picker-board-row .name { font-size: 1rem; }
  .picker-board-row .pb-acc { font-size: 1rem; }
  .picker-board-row .score { font-size: 1.2rem; }

  /* In-game chat — move to the LEFT side and grow to match the
     accuracy board's prominence. The 1100px media-query rule below
     was overriding to right; counteract that. */
  body.in-game .chat-widget {
    left: 1rem !important;
    right: auto !important;
    width: clamp(320px, 26vw, 420px) !important;
    height: min(86vh, 86vw, 760px) !important;
  }

  /* Home actions — Play stays slim like the original (icon-on-left,
     wide label band). All three buttons are scaled up uniformly so
     they feel substantial without going chunky/square. About pushes
     further down naturally as a side effect. */
  .menu-cta.primary.lg {
    padding: 0.9rem 1.5rem;
    grid-template-columns: 56px 1fr;
    gap: 1rem;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
  }
  .menu-cta.lg .menu-cta-icon { width: 64px; height: 64px; font-size: 1.8rem; }
  .menu-cta.lg .menu-cta-label { font-size: 1.55rem; line-height: 1; }
  .menu-cta.lg .menu-cta-sub { font-size: 0.85rem; margin-top: 0.25rem; }

  .menu-cta-row { grid-template-columns: repeat(2, minmax(0, 340px)); gap: 1rem; }
  .menu-cta-row .menu-cta { padding: 1.2rem 1.2rem; }
  .menu-cta-row .menu-cta-icon { width: 64px; height: 64px; font-size: 1.7rem; }
  .menu-cta-row .menu-cta-label { font-size: 1.3rem; }

  /* Lobby room — pull the page up. The default 5rem top + 6.5rem
     bottom looked oversized after the 1.5x bump. */
  .lobby-page {
    padding-top: 2.6rem !important;
    padding-bottom: 2.6rem !important;
  }

  /* Lobby code centered in its purple box. The whole box is already
     clickable to copy, so the inline copy icon is redundant — hide
     it. Tighten letter-spacing so a 6-char code fits without
     overflowing the box edge. */
  .invite-code-row {
    justify-content: center !important;
    position: relative;
  }
  .invite-code-value {
    text-align: center;
    flex: none !important;
    letter-spacing: 0.16em !important;
  }
  .invite-code-copy { display: none; }

  /* Player card.
     - HOST pill + friend chip pinned to the top-right corner.
     - Avatar vertically centered on the left.
     - Role/medal tag sits inline directly in front of the name.
     - Name fits without truncation; OP under the name. */
  .player-card {
    position: relative;
    grid-template-columns: auto 1fr;
    grid-template-rows: 1fr;
    gap: 1rem;
    align-items: center;     /* vertical center for avatar + meta */
    padding: 1rem 1.1rem;
    min-height: 100px;       /* room for the floating top-right badges */
  }
  .player-card .pc-top {
    position: absolute;
    top: 0.55rem; right: 0.7rem;
    display: flex; align-items: center; gap: 0.4rem;
    pointer-events: none;    /* badges are decorative; don't intercept clicks */
  }
  .player-card .pc-top > * { pointer-events: auto; }
  .player-card > .avatar {
    align-self: center;
  }
  .player-card .meta {
    display: flex; flex-direction: column; gap: 0.25rem;
    justify-content: center;             /* vertically center the name + OP pair beside the avatar */
    min-width: 0;
  }
  .player-card .name-row {
    display: flex; align-items: center; gap: 0.35rem;
    flex-wrap: nowrap;
    min-width: 0;
  }
  .player-card .name {
    max-width: none;
    font-size: 0.85rem;       /* smaller again per request */
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
  }
  /* Role/medal badge sized down inside the player card so it sits
     next to the smaller name without dwarfing it. */
  .player-card .role-tag-badge {
    flex-shrink: 0;
    margin-left: 0;
    width: 16px;
    height: 16px;
    font-size: 0.6rem;
    border-radius: 5px;
  }
  .player-card .meta-row {
    flex-wrap: nowrap;
    gap: 0.5rem;
  }
  .player-card .meta-pts {
    font-size: 0.9rem;
    margin-left: 0;
    color: var(--pop-grape);
  }
  .player-card .player-actions { display: none; }
  .player-card.host .host-crown { top: -16px; left: 12px; }

  /* Friend-invite list — rows are now full-width buttons (no Invite
     button on the right). Names get the full width so nothing
     truncates. The "+" CTA on the right hints at the click action. */
  .invite-friend {
    display: grid !important;
    grid-template-columns: auto 1fr auto;
    gap: 0.7rem;
    align-items: center;
    width: 100%;
    padding: 0.7rem 0.85rem !important;
    background: var(--surface-1);
    border: 1.5px solid var(--line);
    border-radius: var(--r-tile);
    cursor: pointer;
    color: var(--ink);
    text-align: left;
    transition: transform 220ms var(--spring), border-color 200ms var(--tx), background 200ms var(--tx);
  }
  /* Online dot shown on hover only — we want the name to have all the
     room by default; the dot is decorative and surfaces on intent. */
  .invite-friend > .online-dot { display: none; }
  .invite-friend:hover {
    background: var(--surface-2);
    border-color: var(--pop-pink);
    transform: translateX(2px);
  }
  .invite-friend:active { transform: translateX(0); }
  .invite-friend.sent {
    background: oklch(78% 0.18 165 / 0.18);
    border-color: var(--pop-mint);
    cursor: default;
  }
  .invite-friend-name {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .invite-friend-cta {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px;
    background: var(--pop-pink);
    color: oklch(99% 0.01 80);
    border-radius: 50%;
    font-weight: 800;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
  }
  .invite-friend.sent .invite-friend-cta {
    background: var(--pop-mint);
    color: oklch(20% 0.04 200);
  }
  .invite-friend.sent .invite-friend-cta::after { content: '✓'; }
  .invite-friend.sent .invite-friend-cta { font-size: 0; }
  .invite-friend.sent .invite-friend-cta::after { font-size: 1rem; }
}

/* ----- LINK-DISCORD HARD WALL ------------------------------------------- */
/* Shown on every page until a legacy account links its first OAuth
   provider. Blocks the site (overflow:hidden on body) and routes the
   user through /auth/discord/start. */
.linkwall-overlay {
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 50% 30%, oklch(65% 0.22 295 / .45), transparent 60%),
    oklch(18% 0.04 295 / .96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 99999;
  display: grid; place-items: center;
  padding: 1.4rem;
  animation: resetFade 0.5s var(--tx);
}
.linkwall-card {
  max-width: 540px; width: 100%;
  padding: 2.4rem 2.2rem 2rem;
  background: var(--surface-1);
  border: 1.5px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: 0 30px 80px oklch(0% 0 0 / .5);
  display: flex; flex-direction: column; gap: 1rem;
  text-align: center;
}
.linkwall-eyebrow {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--pop-grape);
}
.linkwall-title { margin: 0; font-size: 1.7rem; }
.linkwall-body { margin: 0; color: var(--ink-soft); line-height: 1.5; }
.linkwall-actions {
  display: flex; flex-direction: column; gap: 0.55rem;
  margin-top: 0.6rem;
}
.linkwall-actions .btn { width: 100%; }
.linkwall-actions .btn.primary {
  background: #5865F2;       /* Discord brand purple */
  border-color: #4752C4;
  color: #fff;
}
.linkwall-actions .btn.primary:hover { background: #4752C4; }
.linkwall-actions .btn-icon { margin-right: 0.5em; }
.linkwall-foot { margin: 0.6rem 0 0; line-height: 1.5; }

/* ----- /reset OVERLAY (the nuclear MAJOR-UPDATE) ------------------------ */
.reset-overlay {
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 50% 35%, oklch(70% 0.24 0 / .55), transparent 65%),
    oklch(20% 0.04 295 / .96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 99999;
  display: grid; place-items: center;
  padding: 1.4rem;
  animation: resetFade 0.5s var(--tx);
}
@keyframes resetFade {
  from { opacity: 0; backdrop-filter: blur(0); }
  to   { opacity: 1; backdrop-filter: blur(18px); }
}
.reset-text {
  text-align: center;
  max-width: 540px;
  color: oklch(99% 0.01 80);
}
.reset-stamp {
  display: inline-block;
  font-family: 'Bagel Fat One', system-ui;
  font-weight: 400;
  font-size: 0.95rem;
  letter-spacing: 0.32em;
  padding: 0.4em 1.2em;
  background: var(--pop-coral);
  color: oklch(99% 0.01 80);
  border: 2px solid var(--pop-coral-2);
  border-radius: var(--r-chip);
  margin-bottom: 1.4rem;
  box-shadow: var(--lift-pop), 0 0 32px oklch(68% 0.24 25 / .55);
  animation: resetStampPulse 1.4s ease-in-out infinite alternate;
}
@keyframes resetStampPulse {
  0%   { transform: scale(1)    rotate(-1deg); }
  100% { transform: scale(1.06) rotate(2deg); }
}
.reset-title {
  font-family: 'Bagel Fat One', system-ui;
  font-weight: 400;
  font-size: clamp(2.4rem, 6vw, 4rem);
  color: var(--pop-yellow);
  letter-spacing: 0.04em;
  margin-bottom: 0.7rem;
  filter:
    drop-shadow(0 6px 0 oklch(28% 0.06 70))
    drop-shadow(0 16px 32px oklch(88% 0.18 95 / .55));
  animation: resetTitleIn 0.7s cubic-bezier(.2, 1.5, .35, 1);
}
@keyframes resetTitleIn {
  0%   { opacity: 0; transform: translateY(20px) scale(0.85) rotate(-3deg); }
  60%  { opacity: 1; transform: translateY(-8px) scale(1.05) rotate(2deg); }
  100% { opacity: 1; transform: translateY(0)   scale(1)    rotate(0); }
}
.reset-sub {
  font-size: 1.05rem;
  font-weight: 700;
  color: oklch(94% 0.01 80 / .85);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.reset-sub #reset-secs {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  color: var(--pop-yellow);
  margin: 0 0.18em;
  font-size: 1.2em;
}
.reset-foot {
  font-size: 0.85rem;
  font-weight: 600;
  color: oklch(85% 0.02 80 / .7);
  font-style: italic;
}

/* ----- /reload OVERLAY -------------------------------------------------- */
/* Full-screen banner shown when an admin pushes /reload — counts down a
   few seconds, then the page navigates to itself with ?_v=TIMESTAMP so
   no resource can be served from cache. Aggressive enough to bypass
   Brave's shields. */
.reload-overlay {
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 50% 35%, oklch(70% 0.24 0 / .35), transparent 65%),
    oklch(20% 0.04 295 / .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 99998;
  display: grid; place-items: center;
  padding: 1.4rem;
  animation: reloadFade 0.4s var(--tx);
}
.reload-text {
  text-align: center;
  color: oklch(99% 0.01 80);
  max-width: 420px;
}
.reload-title {
  font-family: 'Bagel Fat One', system-ui;
  font-weight: 400;
  font-size: clamp(2rem, 5vw, 3.2rem);
  color: var(--pop-yellow);
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
  filter: drop-shadow(0 5px 0 oklch(28% 0.06 70)) drop-shadow(0 12px 24px oklch(88% 0.18 95 / .5));
}
.reload-sub {
  font-size: 1rem;
  font-weight: 700;
  color: oklch(94% 0.01 80 / .85);
}
.reload-sub #reload-secs {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  color: var(--pop-yellow);
  margin: 0 0.18em;
}
@keyframes reloadFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ----- LOBBY INVITE POPUPS ---------------------------------------------- */
/* Stack of toast-shaped invitations in the bottom-right. Stays out of the
   way of the chat widget on phones via media query. */
.invite-popups {
  position: fixed;
  right: calc(64px + 1rem);
  bottom: 1.4rem;
  display: flex; flex-direction: column;
  gap: 0.6rem;
  z-index: 300;
  pointer-events: none;
  align-items: flex-end;
}
.invite-popup {
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: center;
  width: min(320px, calc(100vw - 2rem));
  padding: 0.7rem 0.85rem;
  background: var(--surface-pop);
  border: 1.5px solid var(--pop-pink);
  border-radius: var(--r-sticker);
  box-shadow: var(--lift-pop), 0 0 0 4px oklch(70% 0.24 0 / .2);
  animation: invitePopIn 0.45s var(--spring) both;
}
.invite-popup.leaving {
  animation: invitePopOut 0.26s var(--tx) forwards;
}
.invite-popup-avatar { width: 40px; height: 40px; border-width: 2px; }
.invite-popup-body { min-width: 0; line-height: 1.25; }
.invite-popup-title {
  font-weight: 800; font-size: 0.9rem; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.invite-popup-code {
  font-size: 0.78rem; color: var(--ink-soft); font-weight: 700;
}
.invite-popup-code span {
  font-family: 'Space Grotesk', monospace;
  letter-spacing: 0.16em;
  color: var(--pop-grape);
  margin-left: 0.25em;
}
.invite-popup-actions { display: flex; gap: 0.3rem; }
.invite-popup-actions .btn { padding: 0.4em 0.85em; font-size: 0.78rem; min-height: 32px; }
.invite-popup-actions .btn.ghost { padding: 0.4em 0.55em; }
@keyframes invitePopIn {
  0%   { opacity: 0; transform: translate(20px, 12px) scale(0.85); }
  60%  { opacity: 1; transform: translate(-2px, -2px) scale(1.04); }
  100% { opacity: 1; transform: translate(0, 0) scale(1); }
}
@keyframes invitePopOut {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(8px, 0) scale(0.96); }
}

/* Friends-rail invite section — the persistent "join later" surface. */
.rail-invites {
  display: flex; flex-direction: column;
  gap: 0.35rem;
  padding: 0.4rem;
  margin-bottom: 0.4rem;
  border: 1.5px solid var(--pop-pink);
  background: oklch(70% 0.24 0 / .08);
  border-radius: var(--r-tile);
}
.rail-invites.empty { display: none; }
.rail-invites-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.15rem 0.45rem 0.25rem;
}
.rail-invites-title {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pop-pink);
}
.rail-invites-count {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--pop-pink);
  background: var(--surface-pop);
  border: 1.5px solid var(--pop-pink);
  border-radius: var(--r-chip);
  padding: 0 0.45em;
}
.rail-invite {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.4rem 0.45rem;
  background: var(--surface-pop);
  border: 1.5px solid var(--line);
  border-radius: var(--r-tile);
}
.rail-invite-body { min-width: 0; line-height: 1.2; }
.rail-invite-name {
  font-weight: 800; font-size: 0.82rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-invite-code {
  font-family: 'Space Grotesk', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--pop-grape);
  letter-spacing: 0.14em;
}
.rail-invite .btn { padding: 0.28em 0.55em; min-height: 28px; font-size: 0.7rem; }
.rail-invite .btn.ghost { padding: 0.28em 0.4em; }
.friends-rail:not(.expanded):not(:hover) .rail-invites { display: none; }

/* ----- FRIEND PROFILE MODAL --------------------------------------------- */
.friend-profile-overlay {
  position: fixed; inset: 0;
  background: oklch(20% 0.04 295 / .55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 400;
  display: grid; place-items: center;
  padding: 1.4rem;
  animation: fpFade 0.22s var(--tx);
}
.friend-profile-overlay.leaving { animation: fpFadeOut 0.22s var(--tx) forwards; }
@keyframes fpFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fpFadeOut { from { opacity: 1; } to { opacity: 0; } }

.friend-profile-card {
  position: relative;
  width: min(420px, 100%);
  background: var(--surface-pop);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-pop);
  box-shadow: var(--lift-pop);
  padding: 2rem 1.8rem 1.4rem;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: fpCardIn 0.4s var(--spring) both;
  /* Expanded stats can push the modal taller than the viewport.
     Cap height + scroll inside so the user can always reach every
     control. The fp-close stays pinned to the top-right via
     position: sticky on the card edge — see .fp-close below. */
  max-height: calc(100vh - 2.8rem);
  overflow-y: auto;
}
.friend-profile-card.role-admin { border-color: var(--pop-coral); box-shadow: var(--lift-pop), 0 0 0 4px oklch(68% 0.24 25 / .14); }
.friend-profile-card.role-mod   { border-color: var(--pop-sky);   box-shadow: var(--lift-pop), 0 0 0 4px oklch(78% 0.16 230 / .14); }
@keyframes fpCardIn {
  0%   { opacity: 0; transform: translateY(20px) scale(0.92); }
  100% { opacity: 1; transform: translateY(0)    scale(1); }
}

.fp-close {
  /* Nuclear position lock — was rendering off-corner, possibly because
     of inherited transforms on hover. Inset shorthand + !important on
     all four sides defeats anything trying to override. */
  position: absolute !important;
  inset: 0.7rem 0.7rem auto auto !important;
  width: 32px !important; height: 32px !important;
  padding: 0 !important;
  margin: 0 !important;
  transform: none !important;
  border-radius: 50% !important;
  font-size: 0.9rem;
  min-height: auto;
  /* Explicit centering — U+2715 ✕ has an asymmetric bounding box and
     inherits parent line-height; without grid centering the glyph
     drifts. */
  display: grid !important;
  place-items: center !important;
  line-height: 1;
  z-index: 2;
}
.fp-close:hover {
  /* Defeat the global button:hover translateY(-2px) scale(1.012) which
     was nudging the close button off its anchor on hover. */
  transform: none !important;
}

.fp-avatar {
  width: 120px !important; height: 120px !important;
  border-width: 4px;
  box-shadow: var(--lift-pop);
}

.fp-name-row {
  display: flex; align-items: center; gap: 0.55rem;
  flex-wrap: wrap; justify-content: center;
}
.fp-name {
  font-family: 'Bagel Fat One', system-ui;
  font-weight: 400;
  font-size: clamp(1.6rem, 3.4vw, 2.1rem);
  color: var(--ink);
  letter-spacing: 0.005em;
  line-height: 1;
}
.friend-profile-card.role-admin .fp-name { color: var(--pop-coral-2); }
.friend-profile-card.role-mod   .fp-name { color: var(--pop-sky-2); }

/* Bio rendered between the name row and stats grid in profile modals.
   White-space: pre-wrap so user line breaks survive. Wrapped in
   surface-2 so it stands out as a quote-like block. Auto height —
   if a user types a giant bio, the modal grows to fit; that's their
   choice. The stats grid is collapsible (see .me-stats-grid) so the
   default modal stays compact regardless. */
.fp-bio {
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-tile);
  padding: 0.7rem 0.95rem;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  width: 100%;
  text-align: left;
}

.fp-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  width: 100%;
}
.fp-stat {
  background: var(--surface-1);
  border: 1.5px solid var(--line);
  border-radius: var(--r-tile);
  padding: 0.55rem 0.7rem;
  text-align: center;
  box-shadow: var(--lift-1);
}
.fp-stat-label {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  margin-bottom: 0.2rem;
}
.fp-stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--pop-pink);
  line-height: 1;
}

.fp-actions {
  display: flex; gap: 0.5rem;
  width: 100%;
  margin-top: 0.4rem;
}
.fp-actions .btn { flex: 1; }

.fp-confirm {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.85rem 0.95rem;
  background: oklch(68% 0.24 25 / .12);
  border: 1.5px solid var(--pop-coral);
  border-radius: var(--r-tile);
  display: flex; flex-direction: column;
  gap: 0.6rem;
  animation: fpFade 0.2s var(--tx);
}
.fp-confirm-text {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.92rem;
  text-align: center;
}
.fp-confirm-actions {
  display: flex; gap: 0.5rem;
}
.fp-confirm-actions .btn { flex: 1; }

/* ----- ME PROFILE MODAL (bigger than friend modal, full stats) ---------- */
.me-profile-card {
  width: min(480px, 100%);
  padding: 1.6rem 1.5rem 1.2rem;
  gap: 0.7rem;
}
.me-profile-card .fp-avatar {
  width: 96px !important; height: 96px !important;
  border-width: 4px;
}

/* Stats toggle — collapses the heavy 12-cell stat grid behind a
   click to keep the default modal compact. */
.me-stats-toggle {
  width: 100%;
  background: var(--surface-1);
  border: 1.5px dashed var(--line-strong);
  color: var(--ink-soft);
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.55em 0.9em;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: var(--r-tile);
  display: flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 0;
}
.me-stats-toggle:hover {
  color: var(--pop-pink);
  border-color: var(--pop-pink);
  background: oklch(from var(--pop-pink) l c h / .07);
}
.me-stats-toggle .toggle-arrow {
  display: inline-block;
  transition: transform 200ms var(--tx);
}
.me-stats-toggle.expanded .toggle-arrow { transform: rotate(180deg); }
.me-stats-grid.collapsed { display: none; }

/* XP-to-next-level block */
.me-level-block {
  width: 100%;
  display: flex; flex-direction: column;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  background: var(--surface-1);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sticker);
}
.me-level-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.7rem;
}
.me-level-badge {
  display: inline-flex; align-items: baseline; gap: 0.4em;
  padding: 0.25em 0.85em;
  border-radius: var(--r-chip);
  background: var(--pop-grape);
  color: oklch(98% 0.012 60);
  border: 1.5px solid var(--pop-grape-2);
  box-shadow: var(--lift-1);
}
.me-level-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: oklch(98% 0.012 60 / .8);
}
.me-level-num {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--pop-yellow);
  line-height: 1;
}
.me-level-to-next {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--pop-pink);
  text-align: right;
}
.me-xp-bar {
  position: relative;
  height: 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px oklch(20% 0.04 295 / .15);
}
.me-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pop-mint), var(--pop-yellow), var(--pop-pink));
  border-radius: 999px;
  box-shadow: 0 0 12px oklch(70% 0.24 0 / .35);
  transition: width 360ms cubic-bezier(.16, 1, .3, 1);
}
.me-xp-nums {
  font-family: 'Space Grotesk', monospace;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-weight: 700;
  text-align: right;
}

/* Stats grid */
.me-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  width: 100%;
}
.me-stat {
  background: var(--surface-1);
  border: 1.5px solid var(--line);
  border-radius: var(--r-tile);
  padding: 0.6rem 0.7rem;
  text-align: center;
  box-shadow: var(--lift-1);
}
.me-stat-label {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin-bottom: 0.25rem;
}
.me-stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  white-space: nowrap;
}
.me-stat.gold  .me-stat-value { color: var(--pop-yellow-2); }
.me-stat.mint  .me-stat-value { color: var(--pop-mint-2); }
.me-stat.fruit .me-stat-value { color: var(--pop-pink); }
.me-stat.red   .me-stat-value { color: var(--pop-coral-2); }

.me-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.4rem;
}
.me-actions .btn {
  flex: none;
  white-space: nowrap;
  font-size: 0.95rem;
  padding: 0.7em 1em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 600px) {
  .me-profile-card {
    padding: 1.6rem 1.2rem 1.2rem;
    gap: 0.9rem;
  }
  .me-profile-card .fp-avatar { width: 110px !important; height: 110px !important; border-width: 4px; }
  .me-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
  .me-stat { padding: 0.45rem 0.55rem; }
  .me-stat-value { font-size: 0.92rem; }
  .me-actions { grid-template-columns: 1fr; }
  .me-level-row { flex-wrap: wrap; }
}

/* ----- MOBILE / PHONE LAYOUT -------------------------------------------- */
/* Phones in portrait. Friends rail is already hidden < 700px above; here
   we trim chrome that would otherwise crowd a small viewport, scale text
   to fit thumbs, and ensure tap targets stay ≥ 40px for accessibility. */
@media (max-width: 600px) {
  html, body { font-size: 15px; }
  main { padding-right: 0; }

  /* Buttons need a comfortable thumb tap target on touch screens */
  button, .btn { min-height: 42px; padding: 0.65em 1.15em; }
  button.sm, .btn.sm { min-height: 34px; padding: 0.4em 0.85em; }

  /* Inputs sized for thumbs, no auto-zoom on iOS */
  input, textarea, select { font-size: 16px; padding: 0.7em 0.95em; }

  /* Toast at top, fits the viewport width */
  .toast { left: 1rem; right: 1rem; transform: none; max-width: none; text-align: center; }
  .toast { animation-name: toastInPhone; }
  @keyframes toastInPhone {
    0%       { opacity: 0; transform: translateY(-12px); }
    10%, 90% { opacity: 1; transform: translateY(0); }
    100%     { opacity: 0; transform: translateY(-8px); }
  }

  /* Smaller scrollbar (touch users barely use it) */
  ::-webkit-scrollbar { width: 6px; height: 6px; }

  /* Chat widget sticks to bottom on phones — same anchor expanded or
     collapsed so the height transition is smooth. */
  .chat-widget,
  body.in-game .chat-widget,
  body:not(.in-game) .chat-widget {
    left: 0.7rem; right: 0.7rem; width: auto;
    bottom: 0.7rem;
    height: 42vh;
    max-height: 360px;
  }
  .chat-widget.collapsed {
    width: auto !important;
    height: auto !important;
  }

  /* Role-tag tooltip would overflow viewport on phone — hide and rely on
     the badge color/letter alone. */
  .role-tag-badge:hover::after { display: none; }

  /* Invite popups stack above the fixed chat dock on phones */
  .invite-popups {
    right: 0.7rem; bottom: calc(42vh + 1.4rem);
    align-items: stretch;
  }
  .invite-popup { width: calc(100vw - 1.4rem); }

  /* Profile modal full-bleed on phones */
  .friend-profile-card { padding: 1.6rem 1.2rem 1.2rem; }
  .fp-avatar { width: 96px !important; height: 96px !important; border-width: 3px; }
  .fp-stats { gap: 0.4rem; }
  .fp-stat { padding: 0.45rem 0.55rem; }
  .fp-stat-value { font-size: 0.92rem; }
}

/* ----- REDUCED MOTION ---------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 120ms !important;
    scroll-behavior: auto !important;
  }
  body::before, body::after { animation: none !important; }

  /* Gameplay-feedback animations are exempt — they're not decoration,
     they're how you read the moment. `revert` resets animation-duration
     to 0s (the user-agent default), so we re-state explicit durations
     here to override the universal `* { animation-duration: 0.01ms }`
     reset above. */
  .levelup-popup                    { animation-duration: 0.55s !important; }
  .levelup-popup.out                { animation-duration: 0.7s !important; }
  .levelup-popup-lvl.pop            { animation-duration: 0.7s !important; }
  .levelup-popup.flash              { animation-duration: 0.55s !important; }
  .countdown-num                    { animation-duration: 1s !important; }
  .judgement-pop                    { animation-duration: 0.85s !important; }
  .note-pop                         { animation-duration: 0.32s !important; }
  .juicy-pop                        { animation-duration: 0.95s !important; }
  .host-notice                      { animation-duration: 0.4s !important; }
  .round-banner                     { animation-duration: 0.5s !important; }
  .title-card                       { animation-duration: 0.6s !important; }
  .fruit                            { animation-duration: 3s !important; }
  .podium-headline                  { animation-duration: 0.8s !important; }
  .podium-base                      { animation-duration: 0.9s !important; }
  .pillar-1::before                 { animation-duration: 1.4s !important; }
  .pillar-1 .avatar                 { animation-duration: 0.85s !important; }
  .pillar-2 .avatar                 { animation-duration: 0.85s !important; }
  .pillar-3 .avatar                 { animation-duration: 0.85s !important; }
  .podium-pillar .podium-crown      { animation-duration: 0.9s !important; }
}
