:root {
  --bg: #0a0d1f;
  --panel: rgba(16, 20, 44, 0.72);
  --panel-border: rgba(160, 180, 255, 0.16);
  --text: #eef1ff;
  --muted: #9aa3c7;
  --me: #3fc8ff;
  --opp: #ff5f9e;
  --gold: #ffc53d;
  --lose: #ff6b6b;
  --draw: #9fb2ff;
  --radius: 18px;
  --font: "Rubik", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --banner-h: 0px;
  --top: calc(max(16px, env(safe-area-inset-top)) + var(--banner-h));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: var(--top) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.screen[hidden] { display: none !important; }

.panel {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(400px, calc(100% - 32px));
  padding: 28px 24px 24px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  animation: panel-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes panel-in {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}


.sub { margin: -6px 0 6px; color: var(--muted); font-size: 15px; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field span, .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0;
}

input {
  font: inherit;
  font-size: 17px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  width: 100%;
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus { border-color: var(--me); box-shadow: 0 0 0 3px rgba(63, 200, 255, 0.2); }
input::placeholder { color: rgba(154, 163, 199, 0.7); }


.btn {
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 13px 18px;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.14); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, #ffcf4a, #ff8a3d);
  color: #231400;
  border-color: transparent;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.icon { padding: 10px; display: grid; place-items: center; }



.code-row { display: flex; align-items: center; justify-content: center; gap: 14px; }
.big-code {
  font-size: clamp(48px, 16vw, 72px);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--gold);
  text-shadow: 0 0 28px rgba(255, 197, 61, 0.35);
  user-select: all;
  padding-left: 0.14em;
}

.waiting { margin: 0; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 500; }
.pulse-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--opp);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}
.hint { margin: 0; color: var(--muted); font-size: 14px; }

/* Game HUD */
.game { position: absolute; inset: 0; padding: inherit; }

.hud {
  pointer-events: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-width: 640px;
  margin: 0 auto;
}
.score {
  font-size: 28px;
  font-weight: 800;
  min-width: 1.2em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.score.bump { animation: bump 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.4); }
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.5); color: var(--gold); }
  100% { transform: scale(1); }
}
.round-box { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.round { font-weight: 700; font-size: 15px; }
.goal { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }

.opp-flag {
  position: absolute;
  left: 50%;
  top: calc(var(--top) + 76px);
  transform: translateX(-50%);
  background: rgba(255, 95, 158, 0.18);
  border: 1px solid rgba(255, 95, 158, 0.5);
  color: #ffd0e2;
  font-weight: 700;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  animation: flag-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
.opp-flag[hidden] { display: none; }
@keyframes flag-in {
  from { opacity: 0; transform: translate(-50%, -8px) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.center {
  position: absolute;
  left: 0; right: 0;
  top: calc(var(--top) + 96px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  text-align: center;
}
.beat {
  font-size: clamp(44px, 13vw, 88px);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
  min-height: 1.1em;
  line-height: 1.1;
}
.beat.pop { animation: beat-pop 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
@keyframes beat-pop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}
.beat.win { color: var(--gold); }
.beat.lose { color: var(--lose); }
.beat.draw { color: var(--draw); }
.status {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  background: rgba(10, 13, 31, 0.55);
  padding: 7px 14px;
  border-radius: 999px;
  min-height: 1em;
}
.status:empty { display: none; }

.picks {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.pick {
  position: relative;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 14px 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.14s, background 0.15s, border-color 0.15s, opacity 0.2s;
  touch-action: manipulation;
}
.pick svg { width: 46px; height: 46px; }
.pick[data-choice="rock"] svg { color: #aeb7c4; }
.pick[data-choice="paper"] svg { color: #f4efe2; }
.pick[data-choice="scissors"] svg { color: #ff6b7d; }
.pick-label { font-weight: 700; font-size: 17px; }
.pick kbd {
  position: absolute;
  top: 8px; right: 10px;
  font: inherit;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 1px 6px;
}
.pick:not(:disabled):hover { transform: translateY(-4px); border-color: rgba(63, 200, 255, 0.6); }
.pick:not(:disabled):active { transform: scale(0.96); }
.pick:disabled { opacity: 0.4; cursor: default; }
.pick.chosen { opacity: 1; border-color: var(--me); background: rgba(63, 200, 255, 0.18); }

body[data-phase="over"] .picks { display: none; }

.over { z-index: 2; }
.over h2 { margin: 0; font-size: clamp(40px, 12vw, 56px); font-weight: 800; }
.over.win h2 { color: var(--gold); }
.over.lose h2 { color: var(--lose); }
.final { margin: 0; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.note { margin: 0; color: var(--muted); min-height: 1.3em; }

.toast {
  position: absolute;
  left: 50%;
  top: var(--top);
  transform: translate(-50%, -140%);
  max-width: calc(100% - 32px);
  background: rgba(40, 14, 26, 0.92);
  border: 1px solid rgba(255, 107, 107, 0.55);
  color: #ffe1e1;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.3s;
  opacity: 0;
  z-index: 5;
  text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.info { background: rgba(14, 26, 44, 0.92); border-color: rgba(63, 200, 255, 0.55); color: #dff4ff; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.btn.small { font-size: 14px; padding: 8px 12px; border-radius: 10px; }

/* Announcements */
.banners {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: max(8px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}
.banners:empty { display: none; }
.banner {
  pointer-events: auto;
  width: min(720px, 100%);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(63, 200, 255, 0.45);
  background: rgba(12, 30, 52, 0.88);
  color: #dff4ff;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: flag-in-top 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.banner.warn { border-color: rgba(255, 169, 77, 0.6); background: rgba(52, 30, 8, 0.9); color: #ffe6c7; }
.banner-text {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.banner-close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  margin: -4px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  opacity: 0.75;
  cursor: pointer;
}
.banner-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.1); }
@keyframes flag-in-top {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

/* Account corner */
.account {
  pointer-events: auto;
  position: absolute;
  top: var(--top);
  right: max(16px, env(safe-area-inset-right));
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
body:not([data-phase="menu"]):not([data-phase="rooms"]) .account { display: none; }
.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 14px;
  font-size: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.account-name { font-weight: 700; max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-link {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 4px 6px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}
.account-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }

.role-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(63, 200, 255, 0.5);
  color: #bfeaff;
  background: rgba(63, 200, 255, 0.12);
  line-height: 1.4;
}
.role-badge[data-role="admin"] { border-color: rgba(255, 197, 61, 0.6); color: var(--gold); background: rgba(255, 197, 61, 0.14); }

.wait-me { margin: 0; display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 500; flex-wrap: wrap; }
.wait-me:empty { display: none; }

.guest-note {
  margin: 0;
  font-size: 14px;
  color: #ffe0b8;
  background: rgba(255, 169, 77, 0.12);
  border: 1px solid rgba(255, 169, 77, 0.4);
  border-radius: 12px;
  padding: 10px 12px;
}
.linkish {
  font: inherit;
  font-weight: 700;
  color: var(--gold);
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}

/* Pick timer */
.timer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
  transition: opacity 0.2s;
}
.timer-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.timer-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3fc8ff, #7cf0a8);
  transform-origin: left center;
}
.timer-text {
  min-width: 1.4em;
  font-weight: 800;
  font-size: 18px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
.timer.warn .timer-fill { background: linear-gradient(90deg, #ff6b6b, #ffa94d); }
.timer.warn .timer-text { color: var(--lose); animation: pulse 0.5s ease-in-out infinite; }
.timer.done { opacity: 0.45; }

/* Prank mode */
.prank {
  pointer-events: auto;
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  top: calc(var(--top) + 76px);
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: rgba(10, 13, 31, 0.5);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 5px 10px;
  opacity: 0.55;
  cursor: pointer;
  touch-action: manipulation;
}
.prank:hover { opacity: 0.9; }
.prank-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.prank.on { opacity: 1; color: #8ff3ff; border-color: rgba(143, 243, 255, 0.5); }
.prank.on .prank-dot { opacity: 1; box-shadow: 0 0 8px currentColor; }
.peek-label {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  top: calc(var(--top) + 108px);
  font-size: 12px;
  font-weight: 500;
  color: #8ff3ff;
  background: rgba(20, 60, 70, 0.45);
  border: 1px solid rgba(143, 243, 255, 0.35);
  border-radius: 999px;
  padding: 5px 10px;
  opacity: 0.85;
}
body[data-phase="over"] .prank, body[data-phase="over"] .peek-label { display: none; }

/* Chat */
.chat {
  pointer-events: auto;
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  top: calc(var(--top) + 90px);
  z-index: 3;
  width: 300px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
body[data-phase="wait"] .chat { top: var(--top); }
.chat.collapsed { width: auto; border-radius: 999px; }
.chat.collapsed .chat-body { display: none; }
.chat-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: 0;
  padding: 10px 14px;
  cursor: pointer;
  touch-action: manipulation;
}
.chat-title { flex: 1; text-align: left; }
.chat-badge {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--opp);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.chat-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--panel-border);
}
.chat-list {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  height: min(240px, calc(100vh - var(--top) - 330px));
  min-height: 110px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  line-height: 1.35;
}
.chat-list li { overflow-wrap: anywhere; }
.chat-list li:first-child { margin-top: auto; }
.chat-name { font-weight: 700; margin-right: 6px; }
.chat-list .mine .chat-name { color: var(--me); }
.chat-list .theirs .chat-name { color: var(--opp); }
.chat-list .sys {
  align-self: center;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 3px 10px;
}
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--panel-border); }
.chat-form input { font-size: 16px; padding: 8px 12px; border-radius: 10px; }

/* Auth modal */
.modal { position: fixed; inset: 0; z-index: 10; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 16, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-card { text-align: left; }
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
}
.tab {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  padding: 10px;
  cursor: pointer;
}
.tab.active { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form .hint { text-align: left; font-size: 13px; }
.hint:empty, .form-error:empty { display: none; }
.form-error { margin: 0; color: #ffa3a3; font-size: 14px; }

/* Ban screen */
.banned {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #08040c;
}
.banned-card { max-width: 440px; text-align: center; }
.banned-card h2 { margin: 0 0 14px; font-size: clamp(28px, 8vw, 36px); font-weight: 800; color: var(--lose); }
.banned-reason { margin: 0 0 8px; font-size: 17px; overflow-wrap: anywhere; }
.banned-until { margin: 0; color: var(--muted); }

@media (max-width: 720px) {
  .chat, body[data-phase="wait"] .chat { top: auto; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 128px); }
  body[data-phase="wait"] .chat, body[data-phase="over"] .chat { bottom: max(16px, env(safe-area-inset-bottom)); }
  .chat:not(.collapsed) { left: max(16px, env(safe-area-inset-left)); width: auto; }
  .chat-list { height: min(260px, 38vh); }
  .peek-label { top: calc(var(--top) + 94px); }
  .prank { top: calc(var(--top) + 64px); }
}

@media (max-width: 480px) {
  .panel { padding: 22px 18px 18px; }
  .hud { padding: 8px 10px; gap: 6px; }
  .score { font-size: 24px; }
  .picks { gap: 8px; }
  .pick { padding: 12px 4px 10px; }
  .pick svg { width: 38px; height: 38px; }
  .pick kbd { display: none; }
  .hud .role-badge { font-size: 0; width: 8px; height: 8px; padding: 0; border-width: 0; background: #3fc8ff; }
  .hud .role-badge[data-role="admin"] { background: var(--gold); }
  .opp-flag { top: calc(var(--top) + 64px); }
  .center { top: calc(var(--top) + 100px); }
}

@media (max-height: 520px) and (orientation: landscape) {
  .pick { flex-direction: row; padding: 8px 10px; }
  .pick svg { width: 30px; height: 30px; }
  .center { top: calc(var(--top) + 64px); }
  .beat { font-size: 40px; }
  .opp-flag { top: calc(var(--top) + 58px); }
}


/* Scrollable centred panels */
.panel { max-height: calc(100% - var(--top) - max(16px, env(safe-area-inset-bottom))); overflow-y: auto; overscroll-behavior: contain; }
.btn.big { font-size: 19px; padding: 16px 20px; border-radius: 14px; }

/* Main menu */
.menu { width: min(440px, calc(100% - 32px)); gap: 16px; }
.logo-icons { display: flex; justify-content: center; gap: 14px; }
.logo-icon {
  display: grid;
  place-items: center;
  width: 54px; height: 54px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: logo-float 3.6s ease-in-out infinite;
}
.logo-icon svg { width: 34px; height: 34px; }
.logo-icon.rock { color: #aeb7c4; transform: rotate(-8deg); }
.logo-icon.paper { color: #f4efe2; animation-delay: -1.2s; }
.logo-icon.scissors { color: #ff6b7d; transform: rotate(8deg); animation-delay: -2.4s; }
@keyframes logo-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -6px; }
}
.logo {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: clamp(40px, 12vw, 60px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.035em;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
}
.logo span { background-clip: text; -webkit-background-clip: text; color: transparent; -webkit-text-fill-color: transparent; padding: 0 0.04em; }
.logo .w1 { background-image: linear-gradient(180deg, #eef2f8, #8e98a8); translate: -0.55em 0; }
.logo .w2 { background-image: linear-gradient(180deg, #fff7e0, #ffc53d 70%, #ff9a3d); }
.logo .w3 { background-image: linear-gradient(180deg, #ffb3bd, #ff4f6d); translate: 0.5em 0; }
.menu .sub { margin: -4px 0 0; }
.member-note { margin: 0; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 16px; flex-wrap: wrap; }

.invite {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px 10px 10px 14px;
  border-radius: 14px;
  background: rgba(255, 197, 61, 0.1);
  border: 1px solid rgba(255, 197, 61, 0.4);
}
.invite p { margin: 0; flex: 1; font-size: 14px; }
.invite .label { display: block; margin-bottom: 2px; }
.invite-code { font-weight: 800; letter-spacing: 0.14em; color: var(--gold); }

.bg-section { display: block; text-align: left; order: 2; }
.bg-section[hidden] { display: none; }
.bg-section summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.bg-section summary::-webkit-details-marker { display: none; }
.bg-section summary:hover { background: rgba(255, 255, 255, 0.08); }
.bg-section summary:focus-visible { outline: 2px solid var(--me); outline-offset: 2px; }
.bg-section summary::after {
  content: '';
  margin-left: auto;
  width: 7px; height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  rotate: 45deg;
  translate: 0 -2px;
  transition: rotate 0.2s, translate 0.2s;
}
.bg-section[open] summary::after { rotate: -135deg; translate: 0 2px; }
.bg-current { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bg-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.bg-chip {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
}
.bg-chip:hover { background: rgba(255, 255, 255, 0.1); }
.bg-chip[aria-checked="true"] { border-color: var(--gold); background: rgba(255, 197, 61, 0.14); box-shadow: 0 0 0 1px var(--gold) inset; }
.bg-chip.locked { opacity: 0.62; cursor: not-allowed; }
.bg-tier { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; }
.bg-tier svg { width: 12px; height: 12px; }
.tier-silver .bg-tier { color: #d6deea; }
.tier-gold .bg-tier { color: var(--gold); }
.tier-diamond .bg-tier { color: #8ff3ff; }

/* Lobby */
.rooms {
  width: min(880px, calc(100% - 32px));
  top: calc(var(--top) + 64px);
  bottom: max(16px, env(safe-area-inset-bottom));
  max-height: none;
  transform: translateX(-50%);
  text-align: left;
  gap: 12px;
  overflow: hidden;
  animation-name: rooms-in;
}
@keyframes rooms-in {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.rooms-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rooms-head .btn.icon { padding: 6px; margin-left: -6px; }
.rooms-title { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.rooms-head .btn.primary { margin-left: auto; }
.online { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #7cf0a8; box-shadow: 0 0 8px #7cf0a8; }
.code-join { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.code-join input {
  width: 96px;
  font-size: 15px;
  padding: 7px 10px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-weight: 700;
  text-align: center;
}
.code-join input::placeholder { letter-spacing: 0.22em; font-weight: 400; }
.rooms-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -8px; padding: 4px 8px 8px; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.room-grid:empty { display: none; }
.room-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.room-card:hover { transform: translateY(-2px); border-color: rgba(160, 180, 255, 0.32); background: rgba(255, 255, 255, 0.07); }
.room-head { display: flex; align-items: flex-start; gap: 8px; }
.room-title { margin: 0; flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 700; }
.room-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-lock { display: inline-grid; place-items: center; color: var(--gold); flex-shrink: 0; }
.room-state {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  color: #b9ffd4;
  background: rgba(124, 240, 168, 0.14);
  border: 1px solid rgba(124, 240, 168, 0.4);
}
.state-playing .room-state { color: #ffd9b0; background: rgba(255, 169, 77, 0.14); border-color: rgba(255, 169, 77, 0.45); }
.state-over .room-state { color: var(--muted); background: rgba(255, 255, 255, 0.06); border-color: var(--panel-border); }
.room-players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.room-players li { min-width: 0; display: flex; }
.empty-slot { color: var(--muted); font-style: italic; opacity: 0.8; }
.room-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.room-code { font-size: 12px; font-weight: 700; letter-spacing: 0.18em; color: var(--muted); }
.rooms-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 16px; text-align: center; color: var(--muted); }
.rooms-empty svg { opacity: 0.6; }
.empty-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--text); }
.rooms-loading { text-align: center; padding: 30px 0; }

/* Names and VIP tiers */
.who { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; vertical-align: middle; }
.who-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.vip-silver:not(.vip-badge),
.vip-gold:not(.vip-badge),
.vip-diamond:not(.vip-badge) {
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.vip-silver:not(.vip-badge) { background-image: linear-gradient(180deg, #ffffff 0%, #d3dbe8 45%, #8f9db4 100%); }
.vip-gold:not(.vip-badge) {
  background-image: linear-gradient(100deg, #d99a22 0%, #e8b340 38%, #fff4c2 50%, #e8b340 62%, #d99a22 100%);
  background-size: 300% 100%;
  animation: vip-shimmer 2.8s linear infinite;
}
.vip-diamond:not(.vip-badge) {
  background-image: linear-gradient(90deg, #7df9ff, #b9a4ff, #ff8adf, #7df9ff, #b9a4ff, #ff8adf, #7df9ff);
  background-size: 200% 100%;
  animation: vip-flow 3.6s linear infinite;
  filter: drop-shadow(0 0 6px rgba(125, 249, 255, 0.55));
}
@keyframes vip-shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0% 0; }
}
@keyframes vip-flow {
  from { background-position: 0% 0; }
  to { background-position: 100% 0; }
}

.vip-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.4;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.vip-badge.vip-silver { color: #1d2533; background: linear-gradient(180deg, #f4f7fb, #a9b6ca); }
.vip-badge.vip-gold {
  color: #3a2400;
  background: linear-gradient(100deg, #d99a22 0%, #ffd34d 38%, #fff4c2 50%, #ffd34d 62%, #d99a22 100%) 0 0 / 300% 100%;
  animation: vip-shimmer 2.8s linear infinite;
}
.vip-badge.vip-diamond {
  color: #16102c;
  background: linear-gradient(90deg, #7df9ff, #b9a4ff, #ff8adf, #7df9ff, #b9a4ff, #ff8adf, #7df9ff) 0 0 / 200% 100%;
  box-shadow: 0 0 10px rgba(125, 249, 255, 0.5);
  animation: vip-flow 3.6s linear infinite;
}

.account-vip {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.account-vip span { font-weight: 800; }

.toast.vip {
  background: rgba(40, 30, 8, 0.94);
  border-color: rgba(255, 197, 61, 0.7);
  color: #fff1c9;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 24px rgba(255, 197, 61, 0.25);
}

/* Waiting room */
.wait-title { margin: 0; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 19px; font-weight: 700; overflow-wrap: anywhere; }
.wait-title:empty { display: none; }

/* Modals */
.modal-title { margin: 0; font-size: 22px; font-weight: 800; }
.pass-room { margin: -4px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.pass-room strong { color: var(--text); }
.field .pass-row { position: relative; display: flex; font-size: inherit; text-transform: none; letter-spacing: 0; color: inherit; }
.pass-row input { padding-right: 48px; }
.pass-eye {
  position: absolute;
  right: 6px; top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.pass-eye:hover, .pass-eye[aria-pressed="true"] { color: var(--text); background: rgba(255, 255, 255, 0.08); }

/* Global chat */
.gchat {
  pointer-events: auto;
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  top: var(--top);
  z-index: 3;
  width: 320px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.gchat.collapsed { width: auto; border-radius: 999px; }
.gchat.collapsed .chat-body { display: none; }
body[data-phase="menu"] .gchat:not(.collapsed),
body[data-phase="rooms"] .gchat:not(.collapsed) { bottom: max(16px, env(safe-area-inset-bottom)); }
body[data-phase="game"] .gchat, body[data-phase="over"] .gchat { top: calc(var(--top) + 146px); }
.gchat .chat-body { flex: 1; }
.gchat-list { flex: 1; height: auto; min-height: 120px; }
body[data-phase="wait"] .gchat-list,
body[data-phase="game"] .gchat-list,
body[data-phase="over"] .gchat-list { flex: none; height: min(260px, calc(100vh - var(--top) - 360px)); }
.gchat-list li { display: flex; flex-direction: column; gap: 1px; padding: 4px 6px; border-radius: 10px; }
.gchat-list li.mine { background: rgba(63, 200, 255, 0.08); }
.g-meta { display: flex; align-items: center; gap: 6px; min-width: 0; }
.g-who { font-size: 13px; }
.g-time { margin-left: auto; flex-shrink: 0; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.g-text { margin: 0; overflow-wrap: anywhere; }
.gchat-locked {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
}
.gchat-locked p { margin: 0; font-weight: 500; color: var(--text); }
.gchat-off { margin: 0; padding: 8px 12px; font-size: 13px; color: #ffe0b8; border-top: 1px solid var(--panel-border); }
.gchat-count { align-self: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gchat-count.full { color: var(--lose); }
.chat-form input:disabled { opacity: 0.55; }

body.gchat-docked .panel.shift { left: calc(50% + 168px); }
body.gchat-docked .rooms { width: min(880px, calc(100% - 384px)); }

@media (max-width: 720px) {
  .rooms { top: var(--top); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 56px); padding: 16px 14px 14px; }
  body[data-phase="rooms"] .account { display: none; }
  .rooms-title { font-size: 22px; }
  .room-grid { grid-template-columns: 1fr; }
  .menu {
    top: calc(var(--top) + 46px);
    max-height: calc(100% - var(--top) - 46px - 64px);
    transform: translateX(-50%);
    animation-name: rooms-in;
  }
  .gchat, body[data-phase="game"] .gchat, body[data-phase="over"] .gchat {
    top: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  body[data-phase="game"] .gchat { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 128px); }
  .gchat:not(.collapsed),
  body[data-phase="menu"] .gchat:not(.collapsed),
  body[data-phase="rooms"] .gchat:not(.collapsed) {
    top: auto;
    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));
    width: auto;
    z-index: 4;
  }
  .gchat-list,
  body[data-phase="wait"] .gchat-list,
  body[data-phase="game"] .gchat-list,
  body[data-phase="over"] .gchat-list { flex: none; height: min(300px, 42vh); }
}

@media (max-width: 480px) {
  .hud .vip-badge { display: none; }
  .logo-icon { width: 46px; height: 46px; }
  .logo-icon svg { width: 28px; height: 28px; }
  .code-join label { display: none; }
  .rooms-head .btn.primary { padding: 8px 10px; }
}

@media (max-height: 700px) {
  .logo-icons { display: none; }
  .logo { font-size: clamp(36px, 10vw, 48px); }
  .menu { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .vip-gold, .vip-diamond, .logo-icon { animation: none !important; }
}

/* v4: account corner */
.account-chip { padding: 5px 8px 5px 5px; }
.account-avatar {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}
.account-avatar:focus-visible { outline: 2px solid var(--me); outline-offset: 2px; }
.account-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.account-name .who-name { max-width: 11em; }
.account-name a { color: inherit; text-decoration: none; }
.account-name a.who-name:hover { text-decoration: underline; }
.account-sub { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.account-rank, .account-jeton { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.account-rank:empty { display: none; }
.account-jeton { color: #ffe6a6; font-weight: 700; }
.account-jeton[hidden] { display: none; }

/* v4: lobby */
.mode-tabs { display: flex; gap: 4px; padding: 4px; background: rgba(0, 0, 0, 0.22); border-radius: 12px; align-self: flex-start; }
.mode-tabs[hidden] { display: none; }
.mode-tab {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 9px;
  padding: 6px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mode-tab.active { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.mode-count { font-size: 11px; font-weight: 700; opacity: 0.7; font-variant-numeric: tabular-nums; }
.mode-count:empty { display: none; }

.room-meta { display: flex; align-items: center; gap: 8px; margin-top: -4px; }
.room-mode {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  color: #bfeaff;
  background: rgba(63, 200, 255, 0.12);
  border: 1px solid rgba(63, 200, 255, 0.4);
  line-height: 1.4;
}
.room-mode.mode-2v2 { color: #ffd0e2; background: rgba(255, 95, 158, 0.12); border-color: rgba(255, 95, 158, 0.45); }
.room-spec { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.room-players li { align-items: center; gap: 6px; }
.room-players .pg-avatar { flex-shrink: 0; }
.room-teams { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.room-teams .room-players { padding-left: 8px; border-left: 3px solid var(--me); }
.room-teams .room-players.team-1 { border-left-color: var(--opp); }
.room-btns { display: flex; gap: 6px; }
.room-btns .btn { display: inline-flex; align-items: center; gap: 5px; }
.room-pin { display: inline-grid; place-items: center; color: #8ff3ff; flex-shrink: 0; }
.room-card.host-gold { border-color: rgba(255, 197, 61, 0.75); box-shadow: 0 0 0 1px rgba(255, 197, 61, 0.35) inset, 0 6px 22px rgba(255, 197, 61, 0.12); }
.room-card.host-diamond {
  border-color: rgba(143, 243, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(143, 243, 255, 0.35) inset, 0 0 26px rgba(120, 200, 255, 0.35);
  animation: diamond-glow 3.2s ease-in-out infinite;
}
@keyframes diamond-glow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(143, 243, 255, 0.35) inset, 0 0 20px rgba(120, 200, 255, 0.28); }
  50% { box-shadow: 0 0 0 1px rgba(214, 160, 255, 0.45) inset, 0 0 32px rgba(190, 140, 255, 0.4); }
}

.mode-pick { border: 0; padding: 0; margin: 0; }
.mode-pick[hidden] { display: none; }
.mode-pick legend { padding: 0; margin-bottom: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field .mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-transform: none; letter-spacing: 0; color: inherit; font-size: inherit; }
.mode-option { position: relative; cursor: pointer; }
.mode-option input { position: absolute; opacity: 0; pointer-events: none; }
.mode-option > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 800;
  font-size: 18px;
}
.mode-option small { font-size: 12px; font-weight: 500; color: var(--muted); }
.mode-option input:checked + span { border-color: var(--me); background: rgba(63, 200, 255, 0.14); box-shadow: 0 0 0 1px var(--me) inset; }
.mode-option input:focus-visible + span { outline: 2px solid var(--me); outline-offset: 2px; }

/* v4: waiting room */
.wait-title .room-mode { margin-left: 4px; }
.wait-me .pg-avatar { margin-left: 4px; }
.wait-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.wait-btns .btn[hidden] { display: none; }
.seat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.seat-grid[hidden] { display: none; }
.seat-team { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.seat-team-name { margin: 0; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--me); }
.seat-team.team-1 .seat-team-name { color: var(--opp); }
.seat {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(63, 200, 255, 0.35);
  background: rgba(63, 200, 255, 0.08);
  min-width: 0;
}
.seat-team.team-1 .seat { border-color: rgba(255, 95, 158, 0.38); background: rgba(255, 95, 158, 0.08); }
.seat.mine { box-shadow: 0 0 0 2px var(--gold) inset; }
.seat-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; font-size: 14px; }
.seat-title { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-you { font-size: 11px; font-weight: 800; color: var(--gold); }
.seat.empty {
  font: inherit;
  color: var(--muted);
  border-style: dashed;
  background: transparent;
  cursor: pointer;
  justify-content: center;
}
.seat.empty:not(:disabled):hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.seat.empty:disabled { cursor: default; opacity: 0.7; }
.seat-plus { font-size: 20px; font-weight: 800; line-height: 1; }
.seat-empty-text { font-size: 13px; }

/* v4: score bar */
.team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.team.opp { justify-content: flex-end; }
.team.me .chips { order: 0; }
.team.me .team-top { order: 1; }
.team-top { display: flex; align-items: center; gap: 8px; }
.team-name { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.team-name[hidden] { display: none; }
.me .team-name { color: var(--me); }
.opp .team-name { color: var(--opp); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.chip { position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; pointer-events: auto; }
.opp .chip { flex-direction: row-reverse; }
.chip .pg-avatar { flex-shrink: 0; transition: box-shadow 0.2s; border-radius: 50%; }
.chip .who { min-width: 0; }
.me .chip .who-name:not([class*="ns-"]):not([class*="vip-"]):not(.name-admin) { color: var(--me); }
.opp .chip .who-name:not([class*="ns-"]):not([class*="vip-"]):not(.name-admin) { color: var(--opp); }
.chip a { text-decoration: none; }
.chip-empty { color: var(--muted); font-style: italic; }
.chip-lock {
  display: none;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #7cf0a8;
  color: #0a2016;
  flex-shrink: 0;
}
.chip.locked .chip-lock { display: inline-grid; animation: bump 0.4s ease-out; }
.chip.locked .pg-avatar { box-shadow: 0 0 0 2px #7cf0a8; }
body.mode-2v2 .team { flex-direction: column; align-items: flex-start; gap: 4px; }
body.mode-2v2 .team.opp { align-items: flex-end; }
body.mode-2v2 .team.me .team-top { order: 0; }
body.mode-2v2 .team.me .chips { order: 1; }
body.mode-2v2 .chip { font-size: 13px; }
body.mode-2v2 .center { top: calc(var(--top) + 150px); }
body.mode-2v2 .opp-flag { display: none; }
body.mode-2v2 .peek-label { top: calc(var(--top) + 132px); }

.emote-bubble {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 2;
  padding: 5px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  color: #fff;
  background: linear-gradient(135deg, var(--em-a, #3a4fd8), var(--em-b, #16213f));
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  animation: bubble 2.4s ease-out forwards;
}
.opp .emote-bubble { left: auto; right: 0; }
@keyframes bubble {
  0% { opacity: 0; transform: translateY(-6px) scale(0.8); }
  10% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(4px); }
}

/* v4: spectator */
.spec-bar {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  top: calc(var(--top) + 76px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 5px 14px;
  border-radius: 999px;
  background: rgba(16, 20, 44, 0.85);
  border: 1px solid rgba(143, 243, 255, 0.45);
  font-size: 14px;
  white-space: nowrap;
}
.spec-bar[hidden] { display: none; }
.spec-live { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: #8ff3ff; }
.spec-count { color: var(--muted); font-size: 13px; }
.spec-count:empty { display: none; }
body.mode-2v2 .spec-bar { top: calc(var(--top) + 110px); }
body.spectating .center { top: calc(var(--top) + 124px); }
body.spectating.mode-2v2 .center { top: calc(var(--top) + 160px); }
body.spectating .pick { display: none; }
.chat.readonly .chat-list { border-bottom: 0; }

/* v4: emote wheel */
.emotes {
  pointer-events: auto;
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 132px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.emotes[hidden] { display: none; }
body[data-phase="over"] .emotes { bottom: max(16px, env(safe-area-inset-bottom)); }
.emote-btn {
  position: relative;
  overflow: hidden;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  min-width: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(135deg, var(--em-a, #3a4fd8), var(--em-b, #16213f));
  cursor: pointer;
  transition: transform 0.12s, opacity 0.2s;
}
.emote-btn:not(:disabled):hover { transform: translateX(-3px); }
.emote-btn:disabled { opacity: 0.5; cursor: default; }
.emote-btn kbd { font: inherit; font-size: 10px; opacity: 0.75; padding: 1px 5px; border-radius: 5px; background: rgba(0, 0, 0, 0.3); }
.emotes.cooling .emote-btn::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: rgba(255, 255, 255, 0.7);
  transform-origin: left;
  animation: emote-cd var(--em-cd, 2000ms) linear forwards;
}
@keyframes emote-cd { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* v4: result gains */
.over-gain { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.over-gain[hidden], .over-gain p[hidden] { display: none; }
.over-rating, .over-jeton { margin: 0; display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.over-rating .delta { font-size: 20px; font-weight: 800; }
.over-rating .delta.up { color: #7cf0a8; }
.over-rating .delta.down { color: var(--lose); }
.over-tier { color: var(--muted); font-weight: 500; }
.over-jeton { color: #ffe6a6; }
.btn[hidden] { display: none; }

/* v4: chat tabs */
.gchat-tabs { display: flex; gap: 4px; padding: 8px 10px 0; }
.gchat-tabs[hidden] { display: none; }
.gchat-tab {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.gchat-tab.active { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.chat-list[hidden] { display: none; }
.chat-list .chat-name { display: inline-flex; margin-right: 6px; }
.chat-list .team-0 .who-name:not([class*="ns-"]):not([class*="vip-"]):not(.name-admin) { color: var(--me); }
.chat-list .team-1 .who-name:not([class*="ns-"]):not([class*="vip-"]):not(.name-admin) { color: var(--opp); }
.chat-list a, .gchat-list a { text-decoration: none; }

/* v4: invites */
.invite-toasts {
  position: absolute;
  left: 50%;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px);
  transform: translateX(-50%);
  z-index: 6;
  width: min(420px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.invite-toast {
  pointer-events: auto;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(14, 20, 44, 0.95);
  border: 1px solid rgba(255, 197, 61, 0.55);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  animation: panel-rise 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes panel-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.invite-toast-text { margin: 0 0 10px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.invite-toast-text .who { vertical-align: baseline; }
.invite-toast-btns { display: flex; justify-content: flex-end; gap: 8px; }
.friend-picker .modal-card { gap: 10px; }
.fp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: min(360px, 50vh); overflow-y: auto; }
.fp-row { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); }
.fp-row:not(.online) { opacity: 0.6; }
.fp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fp-status { font-size: 12px; color: var(--muted); }

@media (max-width: 720px) {
  .emotes { flex-direction: row; left: max(16px, env(safe-area-inset-left)); right: auto; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 124px); }
  .emote-btn { min-width: 0; padding: 6px 8px; }
  .emote-btn kbd { display: none; }
  body[data-phase="game"] .chat { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 170px); }
}

@media (max-width: 480px) {
  .chip { font-size: 12px; }
  .chip .who-name { max-width: 7.5em; }
  body.mode-2v2 .chip .pg-avatar { display: none; }
  .seat-grid { gap: 6px; }
  .seat { padding: 6px; gap: 6px; }
  .seat .pg-avatar { display: none; }
  .account-sub { gap: 6px; }
  .spec-bar { font-size: 13px; }
}

/* Main menu hub */
.menu-main { display: contents; }
.hub { order: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; text-align: left; }
.tile {
  --ac: #3fc8ff;
  --tile-bg: rgba(18, 22, 48, 0.9);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-height: 124px;
  min-width: 0;
  padding: 14px 14px 13px;
  font: inherit;
  color: var(--text);
  text-align: left;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--ac) 42%, transparent);
  background:
    radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--ac) 34%, transparent), transparent 62%),
    var(--tile-bg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 4px 0 color-mix(in srgb, var(--ac) 34%, #04050d),
    0 14px 28px rgba(0, 0, 0, 0.38);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.3), box-shadow 0.16s, border-color 0.16s;
}
.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 36%, rgba(255, 255, 255, 0.18) 50%, transparent 64%);
  transform: translateX(-130%);
}
@media (hover: hover) {
  .tile:hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--ac) 75%, transparent);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.18),
      0 7px 0 color-mix(in srgb, var(--ac) 40%, #04050d),
      0 20px 36px rgba(0, 0, 0, 0.42),
      0 0 30px color-mix(in srgb, var(--ac) 22%, transparent);
  }
  .tile:hover::after { transform: translateX(130%); transition: transform 0.75s ease; }
}
.tile:active {
  transform: translateY(3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 1px 0 color-mix(in srgb, var(--ac) 34%, #04050d),
    0 6px 14px rgba(0, 0, 0, 0.35);
  transition-duration: 0.06s;
}
.tile:focus-visible { outline: 2px solid var(--ac); outline-offset: 3px; }

.t-profil { --ac: #3fc8ff; }
.t-rank { --ac: #ff9a3d; }
.t-vip { --ac: #ffc53d; }
.t-vip.tier-silver { --ac: #cfd8e6; }
.t-vip.tier-diamond { --ac: #8ff3ff; }
.t-inv { --ac: #b98bff; }
.t-shop { --ac: #ff5f9e; }
.t-clan { --ac: #ff6b5a; }
.t-friends { --ac: #4fe39a; }

.tile-art {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  flex-shrink: 0;
  border-radius: 15px;
  color: color-mix(in srgb, var(--ac) 14%, #fff);
  background: linear-gradient(150deg, color-mix(in srgb, var(--ac) 70%, #fff) -20%, var(--ac) 40%, color-mix(in srgb, var(--ac) 55%, #000) 120%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.2), 0 6px 14px color-mix(in srgb, var(--ac) 30%, transparent);
}
.tile-art.has-custom { background: none; box-shadow: none; width: auto; height: auto; min-width: 48px; min-height: 48px; }
.tile-custom { display: grid; place-items: center; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4)); }
.tile-mark {
  position: absolute;
  right: -18px;
  bottom: -22px;
  z-index: -1;
  color: var(--ac);
  opacity: 0.13;
  rotate: -14deg;
  pointer-events: none;
}
.tile-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; width: 100%; margin-top: auto; }
.tile-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
  white-space: nowrap;
}
.tile-title .who { min-width: 0; }
.tile-detail {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 8px;
  min-width: 0;
  min-height: 18px;
  font-size: 13px;
  line-height: 1.3;
  color: color-mix(in srgb, var(--text) 70%, transparent);
}
.tile-detail .pg-tier-emblem, .tile-detail svg { flex-shrink: 0; }
.tile-ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tile-num { font-variant-numeric: tabular-nums; }
.tile-strong { font-size: 15px; font-weight: 800; color: var(--text); }
.tile-coin { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: #ffe6a6; font-variant-numeric: tabular-nums; }
.tile-online { display: inline-flex; align-items: center; gap: 6px; color: #aef5c9; font-weight: 600; }
.tile-dot { width: 8px; height: 8px; border-radius: 50%; background: #4fe39a; box-shadow: 0 0 0 3px rgba(79, 227, 154, 0.2); }
.tile-lock { display: inline-flex; color: var(--muted); }
.tile-lock svg { width: 13px; height: 13px; }
.tile-clantag { font-weight: 900; letter-spacing: 0.02em; flex-shrink: 0; }
.tile-title .tile-ellip { font-size: 15px; font-weight: 600; }
.tile-tier { font-weight: 800; }
.tile-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: #ff3b5c;
  box-shadow: 0 0 0 2px rgba(10, 13, 31, 0.9), 0 4px 10px rgba(255, 59, 92, 0.45);
}
.tile-badge[hidden] { display: none; }

.tile.wide {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  min-height: 88px;
}
.tile.wide .tile-text { margin-top: 0; }
.tile.wide .tile-mark { display: none; }

.tile.locked { --tile-bg: rgba(18, 22, 48, 0.82); }
.tile.locked .tile-art { filter: saturate(0.55) brightness(0.9); }
.tile.locked .tile-title { color: color-mix(in srgb, var(--text) 82%, transparent); }

.t-vip.is-vip {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 4px 0 color-mix(in srgb, var(--ac) 38%, #04050d),
    0 14px 28px rgba(0, 0, 0, 0.38),
    0 0 26px color-mix(in srgb, var(--ac) 26%, transparent);
}
.t-vip .tile-title .vip-silver, .t-vip .tile-title .vip-gold, .t-vip .tile-title .vip-diamond { padding-right: 0.05em; }

@media (min-width: 980px) and (min-height: 620px) {
  .menu {
    width: min(960px, calc(100% - 64px));
    display: grid;
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    align-items: center;
    gap: 22px;
    padding: 6px 6px 10px;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  body.gchat-docked .menu { width: min(960px, calc(100% - 400px)); }
  .menu-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 28px 24px 24px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  }
  .hub { gap: 14px; }
  .tile { min-height: 132px; padding: 16px; }
  .tile-art { width: 52px; height: 52px; border-radius: 16px; }
}

@media (max-width: 720px) {
  .menu .logo-icons { display: none; }
  /* The VIP tile carries the same line, and the pill would sit on top of the logo. */
  body[data-phase="menu"] .account-vip { display: none; }
}

@media (max-width: 480px) {
  .hub { gap: 10px; }
  .tile { min-height: 112px; padding: 12px; gap: 8px; border-radius: 18px; }
  .tile-art { width: 42px; height: 42px; border-radius: 13px; }
  .tile-art > svg:not(.tile-mark) { width: 26px; height: 26px; }
  .tile-title { font-size: 16px; }
  .tile-detail { font-size: 12px; }
  .tile.wide { min-height: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile::after { display: none; }
  .tile:hover, .tile:active { transform: none; }
}

/* v4.1: tier badges, admin styling, online counter */
.badge-icon { display: inline-block; flex-shrink: 0; vertical-align: middle; overflow: visible; }
.badge-icon-gold { filter: drop-shadow(0 0 3px rgba(255, 201, 51, 0.45)); }
.badge-icon-diamond { filter: drop-shadow(0 0 4px rgba(125, 249, 255, 0.55)); }
.badge-icon-admin { filter: drop-shadow(0 0 4px rgba(255, 59, 92, 0.7)); }
.who-admin { gap: 5px; }

.who-name.name-admin {
  font-weight: 800;
  background-image: linear-gradient(100deg, #ff3b5c 0%, #ff7a59 22%, #ffd966 45%, #fff2c4 50%, #ffd966 55%, #ff7a59 78%, #ff3b5c 100%);
  background-size: 260% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 4px rgba(255, 45, 85, 0.75));
  animation: admin-sheen 3.2s linear infinite, admin-glow 2.4s ease-in-out infinite;
}
@keyframes admin-sheen {
  from { background-position: 100% 0; }
  to { background-position: 0% 0; }
}
@keyframes admin-glow {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(255, 45, 85, 0.6)); }
  50% { filter: drop-shadow(0 0 8px rgba(255, 45, 85, 0.95)) drop-shadow(0 0 2px rgba(255, 217, 102, 0.7)); }
}

.role-badge.admin-pill,
.admin-pill {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.4;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  color: #ffe38a;
  background: linear-gradient(180deg, #d81e45, #7d0a22);
  border: 1px solid #ffcf4d;
  box-shadow: 0 0 10px rgba(255, 45, 85, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  text-shadow: 0 1px 0 rgba(60, 0, 10, 0.6);
}

.chat-list li.from-admin,
.gchat-list li.from-admin {
  background: linear-gradient(90deg, rgba(224, 49, 79, 0.2), rgba(224, 49, 79, 0.06));
  border-left: 3px solid #e0314f;
  box-shadow: inset 0 0 0 1px rgba(255, 207, 77, 0.12);
}
.chat-list li.from-admin { padding: 3px 6px; border-radius: 0 8px 8px 0; }
.gchat-list li.from-admin { border-radius: 0 10px 10px 0; }

.account-chip.is-admin {
  border-color: rgba(255, 90, 116, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 207, 77, 0.18), 0 0 18px rgba(224, 49, 79, 0.3);
}

.online-pill {
  gap: 7px;
  padding: 4px 10px 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #c8f7da;
  background: rgba(40, 160, 90, 0.14);
  border: 1px solid rgba(124, 240, 168, 0.3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.online-pill[hidden] { display: none; }
.online-pill .online-dot { position: relative; width: 7px; height: 7px; box-shadow: 0 0 6px #7cf0a8; }
.online-pill .online-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #7cf0a8;
  animation: online-ping 1.8s ease-out infinite;
}
@keyframes online-ping {
  from { transform: scale(1); opacity: 0.7; }
  to { transform: scale(2.8); opacity: 0; }
}
.online-pill.bump span:last-child { animation: online-bump 0.45s ease-out; }
@keyframes online-bump {
  0% { transform: translateY(0); color: #c8f7da; }
  35% { transform: translateY(-2px); color: #ffffff; }
  100% { transform: translateY(0); color: #c8f7da; }
}
.online-pill span:last-child { display: inline-block; }
.menu-top {
  align-self: center;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: -4px;
}

/* Language toggle: base rules shared by every place that mounts langSwitch(). */
.lang-switch {
  pointer-events: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
}
.lang-opt {
  min-width: 32px;
  min-height: 22px;
  padding: 2px 8px;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}
.lang-opt:hover { color: var(--text); }
.lang-opt[aria-pressed="true"] { color: var(--bg); background: var(--text); cursor: default; }
.lang-opt:focus-visible { outline: 2px solid var(--me); outline-offset: 1px; }

@media (max-width: 720px) {
  .hud .role-badge.admin-pill { font-size: 0; width: 8px; height: 8px; padding: 0; border-width: 0; background: #e0314f; box-shadow: 0 0 6px #e0314f; }
}
@media (max-width: 480px) {
  .rooms-head .online-pill { padding: 3px 8px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .who-name.name-admin { animation: none !important; filter: drop-shadow(0 0 5px rgba(255, 45, 85, 0.8)); }
  .online-pill .online-dot::after { animation: none !important; display: none; }
  .online-pill.bump span:last-child { animation: none !important; }
  .lang-opt { transition: none; }
}
@media (max-width: 480px) {
  .account-chip.is-admin #account-role { display: none; }
}

/* v4.2 polish: lobby diffing, names, live counter, back bars, notifications */
.room-card { min-width: 0; }
.room-players li { overflow: hidden; padding: 2px 0; }
.room-players { min-width: 0; }
.room-card.room-enter { animation: room-enter 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1); }
.room-card.room-leave { animation: room-leave 0.22s ease-in forwards; pointer-events: none; }
@keyframes room-enter {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes room-leave {
  to { opacity: 0; transform: scale(0.96); }
}

.who > * { flex-shrink: 0; }
.who > .who-name { flex: 0 1 auto; min-width: 1.5em; }
.who-compact { gap: 4px; }
.who-marks { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; }
.who-marks .badge-icon { display: block; }
.who-compact > .pg-clan-tag { flex: 0 4 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.86em; opacity: 0.9; }
.room-players li > .who { flex: 0 1 auto; }
.seat-main > .who, .pg-board-name > .who, .pg-member-main > .who, .g-meta > .who { max-width: 100%; }
.g-meta > .who { flex: 0 1 auto; }
.chat-list .chat-name { max-width: 100%; vertical-align: bottom; }
.chat-list .chat-name .who-name { max-width: 12em; }
.tile-title .who-name, .tile-detail .who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-detail .who { max-width: 100%; }
.invite-toast-text .who { max-width: 100%; }
.invite-toast-text .who-name { max-width: 10em; }

.live-count {
  --live: #5ff0a0;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 16px 7px 13px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: #d9fbe7;
  background:
    linear-gradient(180deg, rgba(95, 240, 160, 0.16), rgba(20, 90, 60, 0.18)),
    rgba(8, 20, 24, 0.55);
  border: 1px solid rgba(95, 240, 160, 0.42);
  box-shadow: 0 0 0 4px rgba(95, 240, 160, 0.06), 0 6px 22px rgba(40, 200, 120, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: live-breathe 3.2s ease-in-out infinite;
}
.live-count[hidden] { display: none; }
.live-dot { position: relative; width: 9px; height: 9px; border-radius: 50%; background: var(--live); box-shadow: 0 0 10px var(--live); flex-shrink: 0; }
.live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--live);
  animation: online-ping 1.8s ease-out infinite;
}
.live-num { display: inline-block; font-size: 18px; font-weight: 900; letter-spacing: -0.01em; line-height: 1; color: #fff; text-shadow: 0 0 12px rgba(95, 240, 160, 0.55); }
.live-label { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: #a9f2c9; }
.live-count.bump .live-num { animation: live-bump 0.5s ease-out; }
@keyframes live-bump {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-3px) scale(1.12); color: #eafff2; }
  100% { transform: none; }
}
@keyframes live-breathe {
  0%, 100% { box-shadow: 0 0 0 4px rgba(95, 240, 160, 0.06), 0 6px 22px rgba(40, 200, 120, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
  50% { box-shadow: 0 0 0 6px rgba(95, 240, 160, 0.1), 0 6px 28px rgba(40, 200, 120, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
}

.rooms-back { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px 6px 6px; font-weight: 700; flex-shrink: 0; }
.wait-head { align-self: stretch; display: flex; margin: -6px -4px 2px; }
.wait-back { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px 6px 6px; font-weight: 700; }
@media (max-width: 480px) {
  .rooms-back { padding: 6px 8px 6px 4px; }
  .rooms-back-text { font-size: 13px; }
}

.nt-bell {
  position: relative;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.nt-bell[hidden] { display: none; }
.nt-bell:hover { background: rgba(255, 255, 255, 0.12); }
.nt-bell:focus-visible { outline: 2px solid var(--me); outline-offset: 2px; }
.nt-bell[aria-expanded="true"] { background: rgba(63, 200, 255, 0.18); border-color: rgba(63, 200, 255, 0.5); }
.nt-bell .nt-ic { display: grid; transform-origin: 50% 10%; }
.nt-bell.ring .nt-ic { animation: nt-ring 0.8s ease-in-out; }
@keyframes nt-ring {
  0%, 100% { rotate: 0deg; }
  15% { rotate: 16deg; }
  30% { rotate: -14deg; }
  45% { rotate: 10deg; }
  60% { rotate: -6deg; }
  75% { rotate: 3deg; }
}
.nt-count {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  background: #ff3b5c;
  border: 2px solid #11152e;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 10px rgba(255, 59, 92, 0.6);
}
.nt-count[hidden] { display: none; }

.nt-backdrop { position: fixed; inset: 0; z-index: 18; background: transparent; }
.nt-backdrop[hidden] { display: none; }
.nt-panel {
  position: fixed;
  z-index: 19;
  width: min(380px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 90px));
  display: flex;
  flex-direction: column;
  background: rgba(14, 18, 40, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.18s ease, transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  font-family: var(--font);
  color: var(--text);
}
.nt-panel.open { opacity: 1; transform: none; }
.nt-panel[hidden] { display: none; }
.nt-head { display: flex; align-items: center; gap: 4px; padding: 12px 10px 10px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.nt-title { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.nt-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  min-width: 32px;
  justify-content: center;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
}
.nt-tool:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.nt-tool:disabled { opacity: 0.4; cursor: default; }
.nt-tool .nt-ic, .nt-toast-x .nt-ic { display: grid; }
.nt-mute[aria-pressed="true"] { color: #ffb4c0; }
.nt-close { display: none; }
.nt-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 8px 10px; }
.nt-day {
  position: sticky;
  top: -4px;
  z-index: 1;
  margin: 0;
  padding: 10px 8px 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: linear-gradient(180deg, rgba(14, 18, 40, 0.98) 70%, rgba(14, 18, 40, 0));
}
.nt-item {
  --tone: #8fa2ff;
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 10px 26px 10px 8px;
  border-radius: 12px;
  transition: background-color 0.15s;
}
.nt-item.clickable { cursor: pointer; }
.nt-item.clickable:hover, .nt-item:focus-visible { background: rgba(255, 255, 255, 0.06); outline: none; }
.nt-item.unread { background: rgba(63, 200, 255, 0.07); }
.nt-dot { position: absolute; top: 16px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: #3fc8ff; box-shadow: 0 0 8px #3fc8ff; }
.nt-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--tone) 38%, transparent);
}
.nt-avatar .nt-ic { display: grid; }
.tone-friend { --tone: #3fc8ff; }
.tone-room { --tone: #7cf0a8; }
.tone-win { --tone: #7cf0a8; }
.tone-loss { --tone: #ff7a8a; }
.tone-coin { --tone: #ffd166; }
.tone-vip { --tone: #c9a4ff; }
.tone-clan { --tone: #ff9f5a; }
.tone-system { --tone: #ffcf4d; }
.tone-muted { --tone: #9aa3c4; }
.nt-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.nt-text { margin: 0; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.nt-text .who { vertical-align: bottom; max-width: 100%; }
.nt-text .who-name { max-width: 11em; }
.nt-text strong { font-weight: 800; }
.nt-meta { margin: 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nt-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.nt-actions .btn { min-height: 30px; padding: 5px 12px; font-size: 13px; }
.nt-done { margin: 2px 0 0; font-size: 12px; font-weight: 700; color: #aef5c9; }
.nt-more { min-height: 8px; padding: 6px; text-align: center; font-size: 12px; color: var(--muted); }
.nt-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 38px 18px; text-align: center; color: var(--muted); }
.nt-empty .nt-ic { display: grid; opacity: 0.55; }
.nt-empty-title { margin: 4px 0 0; font-weight: 800; color: var(--text); }
.nt-empty-hint { margin: 0; font-size: 13px; }

.nt-toasts {
  position: fixed;
  z-index: 30;
  top: calc(var(--top, 16px) + 50px);
  right: max(16px, env(safe-area-inset-right));
  width: min(340px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.nt-toast {
  --tone: #8fa2ff;
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 10px;
  background: rgba(14, 18, 40, 0.95);
  border: 1px solid color-mix(in srgb, var(--tone) 45%, var(--panel-border));
  border-radius: 16px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-family: var(--font);
  color: var(--text);
  animation: nt-toast-in 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.nt-toast.clickable { cursor: pointer; }
.nt-toast.out { animation: nt-toast-out 0.22s ease-in forwards; }
.nt-toast .nt-text { font-size: 13px; }
.nt-toast-x { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; color: var(--muted); background: none; border: 0; border-radius: 8px; cursor: pointer; }
.nt-toast-x:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
@keyframes nt-toast-in {
  from { opacity: 0; transform: translateX(24px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes nt-toast-out {
  to { opacity: 0; transform: translateX(24px) scale(0.97); }
}

@media (max-width: 720px) {
  .nt-panel {
    inset: 0;
    width: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(24px);
    transform-origin: center;
  }
  .nt-panel.open { transform: none; }
  .nt-backdrop { background: rgba(4, 6, 16, 0.5); }
  .nt-close { display: inline-flex; }
  .nt-all span { display: none; }
  .nt-head { padding: 12px 8px 10px 16px; }
  .nt-title { font-size: 19px; }
  .nt-item { padding: 12px 28px 12px 8px; }
  .nt-toasts { top: max(10px, env(safe-area-inset-top)); left: 50%; right: auto; transform: translateX(-50%); width: calc(100vw - 24px); }
  @keyframes nt-toast-in {
    from { opacity: 0; transform: translateY(-16px) scale(0.97); }
    to { opacity: 1; transform: none; }
  }
  @keyframes nt-toast-out {
    to { opacity: 0; transform: translateY(-16px) scale(0.97); }
  }
  .account-chip .nt-bell { width: 34px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .room-card.room-enter, .room-card.room-leave, .nt-toast, .nt-toast.out, .nt-bell.ring .nt-ic, .live-count, .live-dot::after, .live-count.bump .live-num { animation: none !important; }
  .room-card.room-leave { opacity: 0; }
  .nt-panel { transition: none; }
}

/* Platform shell: link from a game page back to the hub. */
.home-link {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  transition: background-color 0.15s, transform 0.15s;
}
.home-link svg { color: var(--gold); }
.home-link:hover { background: rgba(255, 255, 255, 0.13); }
.home-link:active { transform: scale(0.97); }
.home-link:focus-visible { outline: 2px solid var(--me); outline-offset: 2px; }
@media (max-width: 480px) {
  .home-link { padding: 7px 9px; }
  .home-link-text { display: none; }
}
