:root {
  --bg: #0b0b12;
  --bg-2: #13131f;
  --panel: #181826;
  --panel-2: #1f1f31;
  --line: #262638;
  --line-soft: rgba(255,255,255,.05);
  --ink: #eceaf7;
  --ink-dim: #a6a3b8;
  --ink-faint: #6d6a82;
  --accent: #c8ff4d;
  --accent-2: #8a7bff;
  --danger: #ff5d73;
  --warn: #ffba49;
  --ok: #7bf2b0;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --shadow-lg: 0 30px 80px rgba(138,123,255,.18);
  --glow: 0 0 0 4px rgba(200,255,77,.18);
  --font: "Space Grotesk", "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(.2,.8,.2,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    /* dotted grid */
    radial-gradient(circle at 1.5px 1.5px, rgba(255,255,255,.035) 1px, transparent 0),
    /* diagonal warm tint */
    linear-gradient(135deg, rgba(255,140,210,.04) 0%, transparent 40%, transparent 60%, rgba(77,214,255,.04) 100%),
    /* existing radial glows */
    radial-gradient(1100px 650px at 85% -10%, rgba(138,123,255,.16), transparent 60%),
    radial-gradient(900px 550px at -10% 110%, rgba(200,255,77,.09), transparent 60%),
    var(--bg);
  background-size: 28px 28px, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }

/* ---------- background scene (drifting sprites) ---------- */
.bg-scene {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.bg-sprite {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  will-change: transform, opacity;
  filter: drop-shadow(0 2px 10px rgba(0,0,0,.35));
  user-select: none;
  line-height: 1;
}
@keyframes drift-a {
  0%   { transform: translate(-14vw, 0) rotate(-12deg); opacity: 0; }
  12%  { opacity: var(--sprite-op, .14); }
  50%  { transform: translate(50vw, -28px) rotate(174deg); }
  88%  { opacity: var(--sprite-op, .14); }
  100% { transform: translate(114vw, 0) rotate(360deg); opacity: 0; }
}
@keyframes drift-b {
  0%   { transform: translate(114vw, 0) rotate(8deg); opacity: 0; }
  12%  { opacity: var(--sprite-op, .12); }
  50%  { transform: translate(50vw, 26px) rotate(-180deg); }
  88%  { opacity: var(--sprite-op, .12); }
  100% { transform: translate(-14vw, 0) rotate(-360deg); opacity: 0; }
}
@keyframes drift-c {
  0%   { transform: translate(-14vw, 18px) rotate(0); opacity: 0; }
  15%  { opacity: var(--sprite-op, .16); }
  50%  { transform: translate(50vw, -18px) rotate(90deg); }
  85%  { opacity: var(--sprite-op, .16); }
  100% { transform: translate(114vw, 18px) rotate(180deg); opacity: 0; }
}
@keyframes drift-d {
  0%   { transform: translate(114vw, -20px) rotate(20deg); opacity: 0; }
  15%  { opacity: var(--sprite-op, .13); }
  50%  { transform: translate(50vw, 20px) rotate(-90deg); }
  85%  { opacity: var(--sprite-op, .13); }
  100% { transform: translate(-14vw, -20px) rotate(-200deg); opacity: 0; }
}
/* keep content above the bg scene */
main, .footer, .live-strip { position: relative; z-index: 1; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }
.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.small { font-size: 12px; }
.up-label { text-transform: uppercase; letter-spacing: .14em; font-weight: 600; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: var(--mono); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(11,11,18,.7);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: -0.02em; font-size: 18px;
  color: var(--ink);
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent);
  animation: breathe 3.2s ease-in-out infinite;
}
.brand small { color: var(--ink-faint); font-weight: 400; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  transition: transform .12s var(--ease), background .18s ease, border-color .18s ease, box-shadow .2s ease, color .15s ease;
  font-weight: 600;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.btn::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120px 60px at var(--mx,50%) var(--my,50%), rgba(255,255,255,.08), transparent 60%);
  opacity: 0; transition: opacity .2s ease;
  pointer-events: none;
}
.btn:hover::before { opacity: 1; }
.btn:hover { background: var(--panel-2); border-color: #3a3a55; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.ghost { background: transparent; }
.btn.primary {
  background: var(--accent); color: #0b0b12; border-color: transparent;
  box-shadow: 0 10px 24px rgba(200,255,77,.25);
}
.btn.primary:hover { filter: brightness(1.06); box-shadow: 0 14px 30px rgba(200,255,77,.35); }
.btn.violet { background: var(--accent-2); color: #0b0b12; border-color: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(255,93,115,.35); }
.btn.danger:hover { background: rgba(255,93,115,.12); }
.btn.warn { color: var(--warn); border-color: rgba(255,186,73,.35); }
.btn.warn:hover { background: rgba(255,186,73,.12); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.btn.icon { padding: 8px; width: 34px; height: 34px; }
.btn.big { padding: 18px 26px; font-size: 17px; border-radius: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.flashed {
  animation: flash .55s var(--ease);
}
@keyframes flash {
  0%   { box-shadow: 0 0 0 0 rgba(200,255,77,.6); }
  60%  { box-shadow: 0 0 0 14px rgba(200,255,77,0); }
  100% { box-shadow: 0 0 0 0 rgba(200,255,77,0); }
}

.glow-btn { box-shadow: 0 14px 30px rgba(200,255,77,.28); }
.glow-btn .arrow {
  width: 22px; height: 22px; display: inline-grid; place-items: center;
  background: #0b0b12; color: var(--accent); border-radius: 999px;
  transition: transform .2s var(--ease);
}
.glow-btn:hover .arrow { transform: translateX(5px); }

/* ---------- inputs ---------- */
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input:focus { border-color: var(--accent); box-shadow: var(--glow); background: var(--panel-2); }
.input.mono { font-family: var(--mono); letter-spacing: .18em; text-transform: uppercase; text-align: center; font-size: 18px; }
label.field { display: block; font-size: 12px; color: var(--ink-dim); margin-bottom: 6px; }

/* ---------- panel ---------- */
.panel {
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent) var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel.pad { padding: 20px; }

/* ---------- home ---------- */
.hero {
  min-height: calc(100vh - 64px);
  display: flex; align-items: center; justify-content: center;
  padding: 60px 24px;
}
.hero-inner { text-align: center; max-width: 760px; }
.hero h1 {
  font-size: clamp(56px, 11vw, 140px);
  line-height: 1;
  margin: 0 0 24px;
  letter-spacing: -0.04em;
  font-weight: 800;
  background: linear-gradient(180deg, #ffffff 0%, #b7b2d1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: riseIn .7s var(--ease) both;
}
.hero h1 .dot { color: var(--accent); -webkit-text-fill-color: var(--accent); animation: blink 2.4s ease-in-out infinite; }
.hero .tag {
  color: var(--ink-dim); font-size: 18px;
  margin: 0 auto 36px; max-width: 520px;
  animation: riseIn .7s .1s var(--ease) both;
}
.play-btn {
  display: inline-flex; align-items: center; gap: 14px;
  padding: 20px 34px;
  font-size: 20px; font-weight: 700;
  border-radius: 999px;
  background: var(--accent);
  color: #0b0b12;
  border: none; cursor: pointer;
  box-shadow: 0 20px 50px rgba(200,255,77,.28), inset 0 0 0 1px rgba(0,0,0,.08);
  transition: transform .18s var(--ease), box-shadow .25s ease, filter .2s ease;
  animation: riseIn .7s .2s var(--ease) both;
}
.play-btn:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.06); box-shadow: 0 26px 60px rgba(200,255,77,.38), inset 0 0 0 1px rgba(0,0,0,.08); }
.play-btn:active { transform: translateY(0) scale(.99); }
.play-btn .arrow {
  width: 22px; height: 22px; display: inline-grid; place-items: center;
  background: #0b0b12; color: var(--accent); border-radius: 999px;
  transition: transform .2s var(--ease);
}
.play-btn:hover .arrow { transform: translateX(6px); }

.chips { display: flex; gap: 8px; justify-content: center; margin-top: 22px; flex-wrap: wrap; animation: riseIn .7s .3s var(--ease) both; }
.chip {
  font-size: 12px; padding: 6px 10px; border-radius: 999px;
  background: rgba(255,255,255,.04); color: var(--ink-dim);
  border: 1px solid var(--line);
}

.footer { text-align: center; color: var(--ink-faint); padding: 20px; font-size: 12px; }

/* home live badge */
.live-strip {
  display: flex; justify-content: center; gap: 14px;
  padding: 18px 20px 4px; flex-wrap: wrap;
  animation: riseIn .6s .4s var(--ease) both;
}
.live-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-dim);
  font-size: 13px;
  text-decoration: none;
  transition: border-color .15s ease, color .15s ease, background .15s ease, transform .12s var(--ease);
}
.live-pill:hover { color: var(--ink); border-color: #3a3a55; background: rgba(255,255,255,.05); transform: translateY(-1px); text-decoration: none; }
.live-pill strong { color: var(--ink); font-weight: 700; }
.live-pill .pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(123,242,176,.7);
  animation: pulseDot 1.8s ease-out infinite;
}
@keyframes pulseDot {
  0%   { box-shadow: 0 0 0 0 rgba(123,242,176,.55); }
  70%  { box-shadow: 0 0 0 10px rgba(123,242,176,0); }
  100% { box-shadow: 0 0 0 0 rgba(123,242,176,0); }
}

/* stats page */
.stats-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.live-ind {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(123,242,176,.10);
  border: 1px solid rgba(123,242,176,.3);
  color: var(--ok);
  font-size: 12px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700;
}
.live-ind .ld {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  animation: pulseDot 1.8s ease-out infinite;
}
.live-ind.stale { color: var(--warn); background: rgba(255,186,73,.1); border-color: rgba(255,186,73,.3); }
.live-ind.stale .ld { background: var(--warn); animation: none; }

.stats-cards {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin-bottom: 20px;
}
@media (max-width: 640px) { .stats-cards { grid-template-columns: 1fr; } }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200,255,77,.10), transparent 70%);
  pointer-events: none;
}
.stat-num {
  font-size: 44px; font-weight: 800; letter-spacing: -0.02em;
  font-family: var(--mono);
  color: var(--ink);
  transition: transform .25s var(--ease), color .25s ease;
}
.stat-num.bump { transform: translateY(-2px); color: var(--accent); }
.stat-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--ink-dim); font-weight: 600; margin-top: 2px;
}
.stat-sub { font-size: 12px; color: var(--ink-faint); margin-top: 10px; }

.stats-table-wrap { overflow: hidden; }
.stats-table-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.stats-table .srow {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(100px, 1fr) 70px;
  gap: 12px; padding: 12px 20px;
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  animation: fadeIn .18s ease;
}
.stats-table .srow:last-child { border-bottom: 0; }
.stats-table .srow.head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--ink-faint); background: var(--bg-2);
}
.stats-table .scell { display: flex; align-items: center; min-width: 0; }
.stats-table .lobby-cell { gap: 10px; min-width: 0; }
.stats-table .lobby-cell .uname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.stats-table .lobby-cell .code {
  font-size: 11px; letter-spacing: .18em; color: var(--ink-faint);
  background: var(--bg-2); padding: 2px 6px; border-radius: 6px;
  flex-shrink: 0;
}
.stats-table .lobby-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px rgba(200,255,77,.45);
  flex-shrink: 0;
}
.stats-table .ppl { font-family: var(--mono); font-size: 14px; }
@media (max-width: 640px) {
  .stats-table .srow { grid-template-columns: minmax(0, 1.6fr) 70px 60px; }
  .stats-table .srow > :nth-child(2) { display: none; } /* hide game col */
}


/* ---------- games/hub page ---------- */
.page { padding: 40px 24px 80px; }
.center-stage { min-height: calc(100vh - 120px); display: grid; place-items: center; }

.gate {
  max-width: 520px; width: 100%; padding: 28px;
}
.gate h2 { font-size: 28px; margin: 0 0 8px; letter-spacing: -0.02em; }
.gate p { color: var(--ink-dim); margin: 0 0 18px; }

.hub-card {
  width: min(560px, 92vw);
  padding: 32px;
  display: grid; gap: 24px;
}
.hub-me {
  display: flex; align-items: center; gap: 16px;
  padding-bottom: 20px; border-bottom: 1px solid var(--line);
}
.hub-me .hub-name { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 2px 0 8px; }
.hub-actions { display: flex; flex-direction: column; gap: 14px; }
.hub-actions .btn.big { width: 100%; }
.or {
  display: grid; place-items: center; position: relative; color: var(--ink-faint); font-size: 12px;
}
.or::before, .or::after {
  content: ""; position: absolute; top: 50%; width: 42%; height: 1px; background: var(--line);
}
.or::before { left: 0; } .or::after { right: 0; }
.or span { background: var(--panel); padding: 0 10px; text-transform: uppercase; letter-spacing: .2em; }
.join-row { display: flex; gap: 8px; }
.join-row .input { flex: 1; }

/* ---------- game cards (used in picker now) ---------- */
.game-picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px; margin-top: 8px;
}
.game-card.pick {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: transform .12s var(--ease), border-color .15s ease, background .15s ease;
}
.game-card.pick:hover { transform: translateY(-2px); border-color: #3a3a55; background: var(--panel-2); }
.game-card.pick.active { border-color: var(--accent); box-shadow: var(--glow); }
.game-card.pick .tag {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent);
}
.game-card.pick h4 { margin: 2px 0; font-size: 15px; letter-spacing: -0.01em; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,5,10,.6);
  backdrop-filter: blur(6px);
  display: grid; place-items: center; z-index: 100;
  animation: fadeIn .15s ease;
}
.modal-backdrop.closing { animation: fadeOut .12s ease forwards; }
.modal {
  width: min(520px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  animation: popIn .18s var(--ease);
}
.modal h3 { margin: 0 0 12px; font-size: 20px; letter-spacing: -0.01em; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- lobby ---------- */
.lobby-wrap {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  gap: 16px;
  padding: 20px;
  max-width: 1280px; margin: 0 auto;
  min-height: calc(100vh - 64px);
  animation: fadeIn .25s ease;
}
@media (max-width: 960px) { .lobby-wrap { grid-template-columns: 1fr; } }
.side { display: flex; flex-direction: column; gap: 14px; }

.lobby-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
}
.lobby-header .code {
  font-family: var(--mono); letter-spacing: .22em; font-size: 17px;
  background: var(--bg-2); padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--line); color: var(--accent);
  margin-top: 4px; display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: all;
  transition: background .15s ease, border-color .15s ease, transform .12s var(--ease);
  font-weight: 600;
}
.lobby-header .code:hover { background: var(--panel-2); border-color: rgba(200,255,77,.4); }
.lobby-header .code:active { transform: translateY(1px); }
.lobby-header .code::after {
  content: "📋";
  font-size: 11px; opacity: .5;
  transition: opacity .15s ease, transform .12s var(--ease);
}
.lobby-header .code:hover::after { opacity: 1; transform: scale(1.1); }

.stage-wrap { display: grid; }
.stage {
  display: flex; flex-direction: column;
  min-height: 560px;
  overflow: hidden;
}
.game-header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.game-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-family: var(--mono); font-size: 20px; color: var(--ink-faint);
  transition: all .25s var(--ease);
}
.game-icon.set { background: rgba(200,255,77,.1); color: var(--accent); border-color: rgba(200,255,77,.35); box-shadow: var(--glow); }
.game-icon.small { width: 36px; height: 36px; font-size: 16px; flex-shrink: 0; }
.game-title { font-weight: 700; font-size: 19px; letter-spacing: -0.01em; margin-top: 2px; transition: color .2s ease; }

.game-stage {
  flex: 1; padding: 40px 28px; display: grid; place-items: center;
  background:
    radial-gradient(500px 200px at 50% 0%, rgba(138,123,255,.06), transparent 70%);
}
.game-empty, .game-placeholder { text-align: center; color: var(--ink-dim); }
.floaty { font-size: 56px; margin-bottom: 10px; animation: floaty 3.4s ease-in-out infinite; display: inline-block; }

/* members */
.member-list { display: flex; flex-direction: column; gap: 6px; }
.member {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid transparent;
  transition: border-color .15s ease, background .15s ease, transform .2s var(--ease);
}
.member:hover { border-color: var(--line); }
.member .name {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 14px;
  min-width: 0;
}
.member .name .uname {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member .role-badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  padding: 2px 6px; border-radius: 999px;
  background: rgba(255,255,255,.06); color: var(--ink-dim);
  flex-shrink: 0;
}
.member.owner .role-badge { background: rgba(200,255,77,.15); color: var(--accent); }
.member.admin .role-badge { background: rgba(138,123,255,.18); color: var(--accent-2); }
.member.viewer .role-badge { background: rgba(255,186,73,.15); color: var(--warn); }

/* chat */
.chat { display: flex; flex-direction: column; border-top: 1px solid var(--line); min-height: 220px; max-height: 300px; }
.chat .log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.chat .log .entry { font-size: 14px; line-height: 1.45; }
.chat .log .entry .who { color: var(--accent); font-weight: 700; margin-right: 6px; }
.chat .log .entry.system { color: var(--ink-faint); font-style: italic; }
.chat .compose { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat .compose .input { flex: 1; padding: 10px 12px; }

.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .15em;
  color: var(--ink-faint); margin: 0 0 10px; font-weight: 600;
}

/* ---------- avatar ---------- */
.avatar {
  width: 52px; height: 52px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--bg-2);
  flex-shrink: 0;
  transition: transform .2s var(--ease);
}
.avatar.sm { width: 34px; height: 34px; border-radius: 8px; }
.avatar.lg { width: 88px; height: 88px; border-radius: 18px; }
.avatar svg { display: block; }

.avatar-editor { display: grid; grid-template-columns: 1fr; gap: 14px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatch {
  aspect-ratio: 1; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent;
  transition: transform .12s var(--ease), border-color .12s ease, box-shadow .12s ease;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(255,255,255,.08); }
.faces { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.face-btn {
  padding: 6px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line);
  cursor: pointer; display: grid; place-items: center;
  transition: border-color .12s ease, transform .12s var(--ease);
}
.face-btn:hover { transform: translateY(-2px); }
.face-btn.active { border-color: var(--accent); box-shadow: var(--glow); }

/* ---------- segmented control ---------- */
.segmented {
  display: flex;
  gap: 4px;
  background: var(--bg-2);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.seg-btn {
  flex: 1;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.seg-btn.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.seg-btn:hover:not(.active) { color: var(--ink); }

/* visibility badges */
.chip.vis-public {
  background: rgba(200,255,77,.12);
  border-color: rgba(200,255,77,.35);
  color: var(--accent);
}
.chip.vis-private {
  background: rgba(138,123,255,.12);
  border-color: rgba(138,123,255,.35);
  color: var(--accent-2);
}

/* owner-controls sections + danger zone */
.oc-section + .oc-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.oc-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--ink-faint); font-weight: 600; margin-bottom: 8px;
}
.oc-label.danger { color: var(--danger); }
.danger-zone {
  border-top: 1px dashed rgba(255,93,115,.3) !important;
}

/* ---------- audio popover ---------- */
.audio-wrap { position: relative; }
.audio-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 80;
  animation: popIn .15s var(--ease);
}
.audio-row + .audio-row { margin-top: 14px; }
.audio-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--ink-dim); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .12em; font-weight: 600;
}
.mute-btn {
  background: transparent; border: 1px solid var(--line);
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-dim);
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.mute-btn:hover { color: var(--ink); border-color: #3a3a55; background: var(--bg-2); }
.mute-btn .ico-off { display: none; }
.mute-btn.muted-on { color: var(--danger); border-color: rgba(255,93,115,.35); }
.mute-btn.muted-on .ico-on { display: none; }
.mute-btn.muted-on .ico-off { display: block; }

#btn-audio.muted-on { color: var(--ink-faint); }

/* range sliders */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: transparent; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px; background: var(--line);
}
input[type=range]::-moz-range-track {
  height: 4px; border-radius: 4px; background: var(--line);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0b0b12;
  margin-top: -5px;
  box-shadow: 0 0 0 0 rgba(200,255,77,.0);
  transition: box-shadow .15s ease, transform .12s var(--ease);
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.1); box-shadow: 0 0 0 4px rgba(200,255,77,.18); }
input[type=range]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0b0b12;
}

/* ---------- game info card (lobby stage) ---------- */
.game-info {
  width: 100%; max-width: 620px;
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 18px;
  padding: 8px;
}
.game-info-head {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line-soft);
}
.game-info-body {
  display: grid; gap: 14px;
}
.instruction-list {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 6px;
}
.instruction-list li {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 14px; color: var(--ink-dim);
  line-height: 1.45;
  padding: 8px 10px;
  background: var(--bg-2);
  border-radius: 10px;
  border: 1px solid var(--line-soft);
}
.instruction-list li::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0; margin-top: 8px;
}
.game-info-cta { display: flex; justify-content: center; }
.game-info-cta .btn.big { padding: 14px 32px; }

/* ---------- Snake Royal fullscreen overlay ---------- */
body.sr-open { overflow: hidden; }
body.sr-open .bg-scene,
body.sr-open .topbar,
body.sr-open main,
body.sr-open .live-strip,
body.sr-open .footer { display: none !important; }

.sr-root {
  position: fixed; inset: 0;
  background: #07080f;
  z-index: 500;
  overflow: hidden;
  color: var(--ink);
  cursor: crosshair;
  animation: fadeIn .18s ease;
}
.sr-root.sr-in-storm::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 100% at 50% 50%, transparent 55%, rgba(255,70,100,.35) 100%);
  animation: stormPulse 1.4s ease-in-out infinite;
  z-index: 4;
}
@keyframes stormPulse {
  0%, 100% { opacity: .6; }
  50% { opacity: 1; }
}
#sr-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  z-index: 1;
}

/* HUD */
.sr-hud {
  position: absolute; z-index: 10;
  display: flex; gap: 12px;
  pointer-events: none;
}
.sr-hud-top { top: 16px; left: 50%; transform: translateX(-50%); }
.sr-hud-bottom { bottom: 16px; left: 50%; transform: translateX(-50%); align-items: flex-end; }

.sr-hud-item {
  background: rgba(11,11,18,.75);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 14px;
  backdrop-filter: blur(8px);
  text-align: center;
  min-width: 90px;
}
.sr-label {
  display: block; font-size: 10px; letter-spacing: .16em; font-weight: 700;
  color: var(--ink-faint); text-transform: uppercase;
}
.sr-val {
  display: block; font-family: var(--mono); font-weight: 700; font-size: 17px; color: var(--ink);
  margin-top: 2px;
}

.sr-boost {
  background: rgba(11,11,18,.75);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  backdrop-filter: blur(8px);
  width: 220px;
  text-align: center;
}
.sr-boost-label {
  font-size: 10px; letter-spacing: .16em; font-weight: 700;
  color: var(--ink-faint); text-transform: uppercase;
}
.sr-boost-label .sr-hint { color: var(--ink-faint); font-weight: 500; margin-left: 4px; }
.sr-boost-bar {
  margin-top: 6px; height: 6px; border-radius: 4px; background: var(--line); overflow: hidden;
}
.sr-boost-fill {
  height: 100%; width: 100%; background: var(--accent);
  transition: width .15s linear, background .2s ease;
}
.sr-boost-fill.active { background: #ffffff; box-shadow: 0 0 14px rgba(255,255,255,.6); }
.sr-boost-fill.cd { background: var(--warn); }
.sr-boost-state { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); margin-top: 4px; }

.sr-pills {
  display: flex; gap: 6px;
  pointer-events: auto;
}
.sr-pill {
  background: rgba(11,11,18,.75);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  padding: 8px 12px; border-radius: 10px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; backdrop-filter: blur(8px);
  transition: color .12s, border-color .12s, background .12s;
}
.sr-pill:hover { color: var(--ink); border-color: #3a3a55; background: rgba(40,40,60,.8); }
.sr-pill.active { color: #0b0b12; background: var(--accent); border-color: transparent; }
.sr-pill.danger { color: var(--danger); }
.sr-pill.danger:hover { background: rgba(255,93,115,.15); border-color: rgba(255,93,115,.5); }

/* center overlay (countdown / results / pause) */
.sr-center {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
  z-index: 20;
}
.sr-center > * { pointer-events: auto; }
.sr-countdown {
  font-size: clamp(120px, 20vw, 240px);
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 10px 60px rgba(200,255,77,.5);
  animation: cdPop .9s cubic-bezier(.2,.8,.2,1);
  font-family: var(--mono);
}
@keyframes cdPop {
  from { transform: scale(.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.sr-pause {
  text-align: center;
  padding: 30px 60px;
  background: rgba(11,11,18,.8);
  border: 1px solid rgba(255,186,73,.4);
  border-radius: 18px;
  backdrop-filter: blur(8px);
}
.sr-pause-title {
  font-size: 40px; font-weight: 800; letter-spacing: -0.02em; color: var(--warn);
}
.sr-pause-sub { color: var(--ink-dim); margin-top: 4px; font-size: 13px; }
.sr-died {
  text-align: center;
  padding: 24px 40px;
  background: rgba(11,11,18,.85);
  border: 1px solid rgba(255,93,115,.4);
  border-radius: 18px;
  animation: popIn .25s var(--ease);
}
.sr-died-title { font-size: 34px; font-weight: 800; color: var(--danger); letter-spacing: -0.02em; }
.sr-died-sub { color: var(--ink-dim); margin-top: 4px; font-size: 13px; }

/* results / podium */
.sr-results {
  text-align: center;
  padding: 36px 40px;
  background: rgba(11,11,18,.88);
  border: 1px solid var(--line);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
  animation: popIn .3s var(--ease);
  max-width: 640px;
}
.sr-results-title {
  font-size: clamp(26px, 3.4vw, 36px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
  margin-bottom: 28px;
  text-shadow: 0 6px 30px rgba(200,255,77,.3);
}
.sr-podium {
  display: flex; justify-content: center; align-items: flex-end; gap: 18px; margin-bottom: 24px;
}
.sr-podi {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-width: 120px;
}
.sr-podi-1 { border-color: rgba(200,255,77,.5); box-shadow: 0 12px 30px rgba(200,255,77,.25); transform: translateY(-10px); }
.sr-podi-2 { border-color: rgba(200,200,220,.3); }
.sr-podi-3 { border-color: rgba(205,133,63,.4); }
.sr-podi-rank {
  font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-faint);
}
.sr-podi-1 .sr-podi-rank { color: var(--accent); }
.sr-podi-avatar { width: 64px; height: 64px; border-radius: 12px; background: var(--bg-2); padding: 4px; }
.sr-podi-1 .sr-podi-avatar { width: 84px; height: 84px; }
.sr-podi-name { font-weight: 700; font-size: 14px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-podi-kills { font-size: 11px; color: var(--ink-dim); font-family: var(--mono); }
.sr-podi-empty { color: var(--ink-faint); font-size: 18px; padding: 12px; }
.sr-results-sub { color: var(--ink-dim); font-size: 13px; }

/* joystick */
.sr-joy {
  position: absolute; left: 30px; bottom: 100px;
  width: 150px; height: 150px;
  border-radius: 50%;
  background: rgba(11,11,18,.55);
  border: 2px solid rgba(255,255,255,.2);
  z-index: 12;
  touch-action: none;
  backdrop-filter: blur(6px);
}
.sr-joy-knob {
  position: absolute; top: 50%; left: 50%;
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  transition: transform .06s ease-out;
}

@media (max-width: 640px) {
  .sr-hud-top { top: 10px; flex-wrap: wrap; justify-content: center; }
  .sr-hud-item { min-width: 72px; padding: 6px 10px; }
  .sr-hud-bottom { flex-direction: column; align-items: center; gap: 8px; bottom: 10px; }
  .sr-boost { width: 180px; }
  .sr-podium { gap: 10px; }
  .sr-podi { min-width: 90px; padding: 10px 8px; }
  .sr-joy { width: 120px; height: 120px; left: 16px; bottom: 140px; }
}

/* ---------- toast ---------- */
.toast-stack {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 16px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: slideIn .22s var(--ease);
  max-width: 320px; font-size: 14px;
}
.toast.err { border-color: rgba(255,93,115,.4); color: #ffc1c9; }
.toast.ok { border-color: rgba(123,242,176,.3); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a3e; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a55; }

/* ---------- animations ---------- */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes fadeOut { from { opacity: 1 } to { opacity: 0 } }
@keyframes popIn {
  from { opacity: 0; transform: translateY(10px) scale(.97) }
  to   { opacity: 1; transform: translateY(0) scale(1) }
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px) }
  to   { opacity: 1; transform: translateY(0) }
}
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0 }
  to   { transform: none; opacity: 1 }
}
@keyframes floaty {
  0%,100% { transform: translateY(0) }
  50%     { transform: translateY(-8px) }
}
@keyframes breathe {
  0%,100% { box-shadow: 0 0 12px var(--accent); transform: scale(1) }
  50%     { box-shadow: 0 0 22px var(--accent); transform: scale(1.08) }
}
@keyframes blink {
  0%,100% { opacity: 1 }
  50%     { opacity: .4 }
}
.fade-in { animation: fadeIn .25s ease both; }
.pop-in  { animation: popIn .22s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
