/* Squid Arena — Dark Glassmorphism UI (Mobile 100dvh & PC 3-Column Parity) */

:root {
  --bg: #0a100e;
  --bg-elevated: #0f1916;
  --card: rgba(16, 26, 23, 0.78);
  --card-strong: rgba(12, 21, 18, 0.92);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.35);
  --pink: #f43f5e;
  --pink-glow: rgba(244, 63, 94, 0.35);
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.35);
  --gold: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.35);
  --slate: #64748b;
  --radius: 14px;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', 'Plus Jakarta Sans', sans-serif;
}

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

/* Global Typography & Elements */
button, input, select, textarea {
  font-family: inherit;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  color: #ffffff;
}

/* Global Cyber Scrollbar */
html {
  scrollbar-width: thin;
  scrollbar-color: rgba(6, 182, 212, 0.4) rgba(10, 16, 14, 0.95);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(10, 16, 14, 0.95);
}

::-webkit-scrollbar-thumb {
  background: rgba(6, 182, 212, 0.35);
  border-radius: 999px;
  border: 2px solid rgba(10, 16, 14, 0.95);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(6, 182, 212, 0.6);
}

body.modal-open {
  overflow: hidden !important;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 15% 12%, rgba(99, 102, 241, 0.14), transparent 45%),
    radial-gradient(circle at 85% 18%, rgba(244, 63, 94, 0.12), transparent 42%),
    radial-gradient(circle at 50% 90%, rgba(6, 182, 212, 0.10), transparent 48%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

/* Mobile Viewport Lock during active match */
.arena-locked {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Glass Card & Controls */
.glass-card {
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Anti-Nested Cards: Bỏ khung lồng khung triệt để */
.glass-card .glass-card {
  background: rgba(255, 255, 255, 0.025);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Background Canvas */
.bg-canvas,
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

.btn {
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.26);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: rgba(16, 185, 129, 0.7);
  color: #04120d;
  font-weight: 700;
  box-shadow: 0 6px 22px var(--emerald-glow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #34d399, #10b981);
  border-color: #6ee7b7;
}

.btn-pink {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  border-color: rgba(244, 63, 94, 0.7);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 6px 22px var(--pink-glow);
}

.btn-cyan {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  border-color: rgba(6, 182, 212, 0.7);
  color: #041318;
  font-weight: 700;
  box-shadow: 0 6px 20px var(--cyan-glow);
}

.btn-gold {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: rgba(245, 158, 11, 0.7);
  color: #1a0f02;
  font-weight: 700;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
  border-radius: 10px;
}

.btn-lg {
  padding: 14px 22px;
  font-size: 16px;
  width: 100%;
}

.input,
.select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: rgba(7, 13, 11, 0.85);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input:focus,
.select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.18);
}

.select option {
  background: #0d1714;
  color: var(--text);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
}

.badge-emerald {
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.14);
}

.badge-cyan {
  color: #67e8f9;
  border-color: rgba(6, 182, 212, 0.45);
  background: rgba(6, 182, 212, 0.14);
}

.badge-pink {
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.45);
  background: rgba(244, 63, 94, 0.14);
}

.badge-gold {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.14);
}

/* Screen Containers */
.screen {
  width: 100%;
  min-height: 100dvh;
}

.center-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
}

.join-card {
  width: 100%;
  max-width: 390px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.join-card .input,
.join-card .select {
  padding: 5px 9px;
  font-size: 12.5px;
  border-radius: 8px;
}

.join-card .pin-input {
  padding: 4px 8px;
  font-size: 18px;
  letter-spacing: 0.22em;
}

.join-card .auth-mode-tabs {
  margin-bottom: 4px;
  padding: 2px;
}

.join-card .auth-tab-btn {
  padding: 5px 8px;
  font-size: 11.5px;
}

.join-card .btn-lg {
  padding: 8px 14px;
  font-size: 13px;
}

.brand-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1px;
}

.brand-logo {
  width: 68px;
  height: auto;
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.35));
}

.brand-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, #f8fafc, #6ee7b7, #67e8f9);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pin-input {
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.24em;
  font-variant-numeric: tabular-nums;
}

.form-error {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.45);
  color: #fda4af;
  font-size: 13px;
}

/* Lobby Screen */
.lobby-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lobby-hero {
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pin-pill {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--emerald);
  text-shadow: 0 0 18px var(--emerald-glow);
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 820px) {
  .lobby-grid {
    grid-template-columns: 1.1fr 0.9fr;
  }
}

.panel-box {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.player-chip {
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.32);
  color: #cffafe;
}

.player-chip.is-me {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.65);
  color: #a7f3d0;
}

.round-roadmap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.roadmap-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  font-size: 13px;
}

.roadmap-item.is-active {
  border-color: rgba(6, 182, 212, 0.6);
  background: rgba(6, 182, 212, 0.1);
}

/* Countdown Overlay */
.countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(6, 11, 9, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.countdown-card {
  width: 100%;
  max-width: 460px;
  padding: 32px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.countdown-number {
  font-size: 84px;
  font-weight: 900;
  line-height: 1;
  color: var(--emerald);
  text-shadow: 0 0 32px var(--emerald-glow);
  animation: countdownPulse 0.85s ease-out infinite;
}

@keyframes countdownPulse {
  0% { transform: scale(0.86); opacity: 0.65; }
  45% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 0.95; }
}

.countdown-briefing-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
}

.briefing-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.briefing-icon {
  font-size: 15px;
  line-height: 1.4;
}

.briefing-content {
  flex: 1;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.briefing-text {
  margin-left: 4px;
}

/* Arena Permanent Left Guide Box */
.arena-guide-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-rows-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-item-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.guide-label-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.guide-item-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.btn-opt-quick {
  padding: 2px 7px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-opt-quick:hover {
  background: rgba(6, 182, 212, 0.18);
  border-color: var(--cyan);
  color: var(--cyan);
}

/* Arena Screen — Mobile First (< 960px) & PC 3-Column (>= 960px) */
.arena-screen {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.arena-hud {
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: rgba(10, 18, 15, 0.9);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 20;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hud-game-title {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-timer {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--cyan);
  padding: 2px 10px;
  border-radius: 10px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.35);
}

.hud-timer.is-urgent {
  color: #fda4af;
  background: rgba(244, 63, 94, 0.18);
  border-color: rgba(244, 63, 94, 0.65);
  animation: timerBlink 0.7s ease-in-out infinite;
}

@keyframes timerBlink {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.progress-strip {
  height: 4px;
  width: 100%;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.progress-strip-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--emerald));
  transition: width 0.2s ease;
}

.arena-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
}

.arena-left-col,
.arena-right-col {
  display: none;
}

.arena-center-col {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.game-stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.game-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.mobile-bottom-bar {
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: rgba(10, 18, 15, 0.92);
  border-top: 1px solid var(--border);
  z-index: 20;
}

.mobile-only {
  display: inline-flex;
}

/* PC 3-Column Layout (>= 960px) */
@media (min-width: 960px) {
  .arena-hud {
    padding: 0 24px;
    height: 58px;
  }

  .hud-game-title {
    font-size: 15px;
  }

  .arena-body {
    display: grid;
    grid-template-columns: 260px minmax(360px, 540px) 320px;
    justify-content: center;
    align-items: stretch;
    gap: 18px;
    padding: 16px 20px;
  }

  .arena-left-col,
  .arena-right-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    overflow-y: auto;
  }

  .arena-center-col {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: rgba(8, 14, 12, 0.85);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  }

  .mobile-bottom-bar,
  .mobile-only {
    display: none !important;
  }
}

/* Bottom Sheet Top Drawer (Mobile) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.top-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-height: 76dvh;
  border-radius: 20px 20px 0 0;
  background: var(--card-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-strong);
  padding: 14px 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform: translateY(105%);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
}

.top-drawer.is-open {
  transform: translateY(0);
}

.drawer-handle {
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  margin: 0 auto 4px;
}

/* Leaderboard & Stats */
.stats-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-tile {
  padding: 10px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-tile-label {
  font-size: 11px;
  color: var(--muted);
}

.stat-tile-val {
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

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

.lb-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}

.lb-row.is-me {
  border-color: rgba(16, 185, 129, 0.6);
  background: rgba(16, 185, 129, 0.12);
}

.lb-row.is-passed {
  border-color: rgba(16, 185, 129, 0.3);
}

.lb-row.is-eliminated {
  opacity: 0.55;
}

.lb-rank {
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.lb-row:nth-child(1) .lb-rank { color: var(--gold); }
.lb-row:nth-child(2) .lb-rank { color: #e2e8f0; }
.lb-row:nth-child(3) .lb-rank { color: #fb923c; }

.lb-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.lb-metric {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Memory 3D Card Flip CSS (also complements memory.canvas.js) */
.mem-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
}

.mem-grid {
  display: grid;
  gap: var(--mem-gap, 10px);
  width: var(--mem-grid-w, 100%);
  height: var(--mem-grid-h, auto);
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  perspective: 1000px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.mem-card {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 5;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  perspective: 900px;
}

.mem-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  border-radius: 12px;
}

.mem-card.is-flipped .mem-card-inner {
  transform: rotateY(180deg);
}

.mem-card.is-matched .mem-card-front {
  border-color: var(--emerald);
  box-shadow: 0 0 18px var(--emerald-glow);
}

.mem-card.is-mismatch {
  animation: memMismatchShake 0.36s ease-in-out;
}

@keyframes memMismatchShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Result / Spectator / Podium */
.result-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-banner {
  padding: 26px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.result-banner.is-passed {
  border-color: rgba(16, 185, 129, 0.55);
  box-shadow: 0 0 36px rgba(16, 185, 129, 0.18);
}

.result-banner.is-eliminated {
  border-color: rgba(244, 63, 94, 0.55);
  box-shadow: 0 0 36px rgba(244, 63, 94, 0.18);
}

.is-glitch {
  animation: eliminationGlitch 0.48s steps(2, end) 2;
}

/* Screen Shake Effect */
.is-shaking {
  animation: screenShake 0.38s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes screenShake {
  10%, 90% { transform: translate3d(-2px, 1px, 0); }
  20%, 80% { transform: translate3d(3px, -2px, 0); }
  30%, 50%, 70% { transform: translate3d(-3px, 2px, 0); }
  40%, 60% { transform: translate3d(3px, -1px, 0); }
}

/* Card Success Flash Glow */
.is-flashing {
  animation: cardFlashGlow 0.5s ease-out;
}

@keyframes cardFlashGlow {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  50% { box-shadow: 0 0 28px 4px rgba(16, 185, 129, 0.45); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Screen Transition Animation */
.screen:not(.hidden) {
  animation: screenFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes screenFadeIn {
  from {
    opacity: 0;
    transform: scale(0.985) translateY(4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Floating Sound & Music HUD Audio Panel with Volume Slider */
.hud-audio-panel {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-radius: 28px;
  background: rgba(10, 16, 14, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.hud-audio-panel:hover {
  border-color: rgba(6, 182, 212, 0.4);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.25);
}

.hud-sound-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.hud-sound-btn:hover {
  transform: scale(1.08);
  background: rgba(6, 182, 212, 0.15);
  border-color: var(--cyan);
  color: #fff;
}

.hud-sound-btn.is-muted {
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.hud-volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 2px;
}

.hud-volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 72px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

.hud-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.8);
  cursor: pointer;
  transition: transform 0.15s;
}

.hud-volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

.hud-volume-label {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  min-width: 32px;
  text-align: right;
  letter-spacing: -0.5px;
}

.hud-audio-panel.is-muted .hud-volume-label {
  color: var(--muted);
}
.hud-audio-panel.is-muted .hud-volume-slider {
  opacity: 0.4;
}

@media (max-width: 640px) {
  .hud-audio-panel {
    top: 10px;
    right: 10px;
    padding: 2px;
    gap: 4px;
  }
  .hud-sound-btn {
    width: 30px;
    height: 30px;
  }
  .hud-volume-slider {
    width: 46px;
  }
  .hud-volume-control {
    padding: 0 6px 0 0;
    gap: 6px;
  }
  .hud-volume-label {
    font-size: 10px;
    min-width: 26px;
  }
}

@keyframes eliminationGlitch {
  0% { transform: translate(0, 0); filter: hue-rotate(0deg); }
  20% { transform: translate(-4px, 2px); filter: drop-shadow(3px 0 #f43f5e); }
  40% { transform: translate(4px, -2px); filter: drop-shadow(-3px 0 #06b6d4); }
  60% { transform: translate(-3px, -1px); filter: hue-rotate(25deg); }
  80% { transform: translate(3px, 2px); }
  100% { transform: translate(0, 0); filter: none; }
}

/* Podium Top 10 */
.podium-stage {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 10px;
  margin: 8px 0 14px;
}

.podium-pillar {
  padding: 14px 10px;
  border-radius: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
}

.podium-pillar.rank-1 {
  order: 2;
  min-height: 168px;
  border-color: rgba(245, 158, 11, 0.75);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.22), rgba(16, 26, 23, 0.88));
  box-shadow: 0 0 28px var(--gold-glow);
  animation: podiumGlow 2.4s ease-in-out infinite;
}

.podium-pillar.rank-2 {
  order: 1;
  min-height: 138px;
  border-color: rgba(226, 232, 240, 0.45);
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.18), rgba(16, 26, 23, 0.88));
}

.podium-pillar.rank-3 {
  order: 3;
  min-height: 120px;
  border-color: rgba(251, 146, 60, 0.5);
  background: linear-gradient(180deg, rgba(251, 146, 60, 0.16), rgba(16, 26, 23, 0.88));
}

@keyframes podiumGlow {
  0%, 100% { box-shadow: 0 0 22px rgba(245, 158, 11, 0.28); }
  50% { box-shadow: 0 0 38px rgba(245, 158, 11, 0.52); }
}

.podium-medal {
  font-size: 24px;
  font-weight: 900;
}

.podium-name {
  font-size: 14px;
  font-weight: 700;
  word-break: break-word;
}

.podium-time {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.podium-rest {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  bottom: auto;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 28px));
  pointer-events: none;
}

.toast-item {
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(12, 22, 19, 0.95);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  animation: toastSlideIn 0.22s ease-out;
}

.toast-item.is-success { border-color: rgba(16, 185, 129, 0.65); color: #a7f3d0; }
.toast-item.is-error { border-color: rgba(244, 63, 94, 0.65); color: #fecdd3; }
.toast-item.is-warn { border-color: rgba(245, 158, 11, 0.65); color: #fde68a; }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Host Command Center */
.host-shell {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.host-topbar {
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.host-setup-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 820px) {
  .host-setup-grid {
    grid-template-columns: 360px 1fr;
    align-items: start;
  }
}

.host-setup-sidebar {
  position: sticky;
  top: 16px;
  background: rgba(10, 16, 14, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.host-setup-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.rounds-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 2px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rounds-config-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rounds-config-list::-webkit-scrollbar {
  width: 6px;
}
.rounds-config-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}
.rounds-config-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 4px;
}
.rounds-config-list::-webkit-scrollbar-thumb:hover {
  background: rgba(6, 182, 212, 0.4);
}

.round-config-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(16, 26, 22, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.round-config-card:hover {
  border-color: rgba(6, 182, 212, 0.35);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.round-config-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  align-items: start;
}

.jigsaw-upload-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px dashed rgba(6, 182, 212, 0.35);
}

.jigsaw-preview-img {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(6, 182, 212, 0.4);
  background: #070d0b;
}

/* ── COMMAND CENTER BALANCED 3-ZONE HEADER ── */
.host-command-header-grid {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: center;
  background: linear-gradient(135deg, rgba(14, 24, 20, 0.85) 0%, rgba(9, 15, 13, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}

@media (min-width: 860px) {
  .host-command-header-grid {
    grid-template-columns: 340px 1fr 410px;
    align-items: center;
    gap: 16px;
  }
}

.cmd-zone-left {
  display: flex;
  align-items: center;
}

.cmd-qr-wrap {
  position: relative;
  cursor: pointer;
  display: inline-block;
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.15s ease;
}

.cmd-qr-wrap:hover {
  transform: scale(1.04);
}

.cmd-qr-wrap:hover .qr-zoom-hint {
  opacity: 1;
}

.qr-zoom-hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 10px;
  text-align: center;
  padding: 2px 0;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.cmd-pin-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cmd-share-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.cmd-share-btn-row .btn {
  padding: 4px 10px;
  font-size: 11px;
}

.cmd-zone-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

.cmd-pulse-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cmd-timer-box {
  background: rgba(0, 0, 0, 0.45);
  padding: 6px 20px;
  border-radius: 12px;
  border: 1px solid rgba(6, 182, 212, 0.35);
  box-shadow: inset 0 0 16px rgba(6, 182, 212, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
}

.cmd-timer-box .hud-timer {
  font-size: 34px;
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(6, 182, 212, 0.65);
  line-height: 1;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
}

.cmd-game-current {
  font-size: 13px;
  font-weight: 700;
  color: var(--emerald);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cmd-zone-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  min-width: 360px;
}

.cmd-ops-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-ops-start {
  flex: 1.4;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
  height: 38px;
  padding: 0 10px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cmd-ops-row .btn:not(.btn-ops-start) {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 8px;
  font-size: 12px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cmd-ops-subrow {
  display: flex;
  gap: 6px;
  align-items: center;
}

.cmd-ops-subrow .btn {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

.host-pin-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.host-qr-img {
  width: 84px;
  height: 84px;
  border-radius: 10px;
  border: 1px solid rgba(16, 185, 129, 0.45);
  background: #0a100e;
  display: block;
}

.host-pin-huge {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--emerald);
  line-height: 1;
  text-shadow: 0 0 20px var(--emerald-glow);
}

.host-controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.host-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.host-live-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 960px) {
  .host-live-grid {
    grid-template-columns: 1.35fr 0.65fr;
    align-items: stretch;
  }
}

.host-live-grid > .panel-box {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 280px;
}

.matrix-canvas-wrap {
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 260px;
  border-radius: 12px;
  background: #070d0b;
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.matrix-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 5px;
}

/* Host V2: Custom Room Builder, Tabs, Matrix Hover, Modals, Player Table */
.tier-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tier-pill-btn {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tier-pill-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: var(--border-strong);
}

.tier-pill-btn.is-selected {
  background: rgba(16, 185, 129, 0.16);
  border-color: var(--emerald);
  color: #a7f3d0;
  box-shadow: 0 0 12px var(--emerald-glow);
}

.round-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.quota-mode-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.matrix-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 40;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(10, 16, 14, 0.95);
  border: 1px solid var(--emerald);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  backdrop-filter: blur(8px);
  transform: translate(12px, 12px);
  transition: opacity 0.1s ease;
}

.matrix-tooltip .tt-title {
  font-weight: 700;
  color: var(--emerald);
  margin-bottom: 2px;
}

.matrix-tooltip .tt-desc {
  font-size: 11px;
  color: var(--muted);
}

.host-tabs {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
}

.host-tab-btn {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 10px 10px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.host-tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.host-tab-btn.is-active {
  color: var(--emerald);
  background: rgba(16, 26, 23, 0.9);
  border-color: var(--border);
  border-bottom: 2px solid var(--emerald);
}

.host-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Modals */
.arena-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 8, 7, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.arena-modal-box {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius);
  background: var(--card-strong);
  border: 1px solid var(--border-strong);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 32px rgba(16, 185, 129, 0.15);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.arena-modal-box.modal-lg {
  max-width: 820px;
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.btn-modal-close:hover {
  color: var(--pink);
  background: rgba(244, 63, 94, 0.12);
}

/* White QR Card */
.white-qr-card {
  background: #ffffff;
  color: #0a100e;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.white-qr-img {
  width: 280px;
  height: 280px;
  max-width: 100%;
  border-radius: 10px;
  display: block;
}

.white-qr-pin {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: #0f172a;
  line-height: 1;
}

/* Player Directory Table */
.player-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(7, 13, 11, 0.6);
}

.player-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.player-table th {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.player-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.player-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.player-table tr:last-child td {
  border-bottom: none;
}

.player-avatar-mini {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: #ffffff;
  flex-shrink: 0;
}

.badge-purple {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
}

/* Inspector Details */
.inspector-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.inspector-avatar-huge {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 900;
  color: #ffffff;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.inspector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.inspector-field {
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.inspector-field-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.inspector-field-value {
  font-size: 14px;
  font-weight: 600;
  word-break: break-all;
}

.inspector-round-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.round-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}

/* ========================================================
   PLAYER APP V2: OAUTH, PROFILE, AVATARS & IN-GAME GUIDE
   ======================================================== */

/* OAuth Login Bar */
.oauth-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

/* Auth Mode Segmented Tabs */
.auth-mode-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 14px;
  gap: 4px;
}

.auth-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-tab-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.auth-tab-btn:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.auth-tab-pane {
  display: block;
}

.auth-tab-pane.hidden {
  display: none !important;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  filter: grayscale(0.6);
  box-shadow: none !important;
  transform: none !important;
}

.join-gate-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: color 0.2s ease;
}

.join-gate-hint.is-ready {
  color: var(--emerald);
}

.oauth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.oauth-divider::before,
.oauth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.oauth-btn-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.btn-oauth {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.btn-oauth:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.btn-oauth.google:hover { border-color: rgba(66, 133, 244, 0.55); box-shadow: 0 0 12px rgba(66, 133, 244, 0.25); }
.btn-oauth.facebook:hover { border-color: rgba(24, 119, 242, 0.55); box-shadow: 0 0 12px rgba(24, 119, 242, 0.25); }
.btn-oauth.discord:hover { border-color: rgba(88, 101, 242, 0.55); box-shadow: 0 0 12px rgba(88, 101, 242, 0.25); }

.oauth-connected-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 12px;
}

/* Avatar Selector & Upload */
.avatar-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.avatar-preview-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-preview-display {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--emerald);
  box-shadow: 0 0 16px var(--emerald-glow);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  max-height: 140px;
  overflow-y: auto;
}

@media (max-width: 600px) {
  .avatar-grid {
    grid-template-columns: repeat(4, 1fr);
    max-height: 160px;
  }
}

.avatar-option-btn {
  aspect-ratio: 1;
  padding: 4px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.avatar-option-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(1.05);
}

.avatar-option-btn.is-selected {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.16);
  box-shadow: 0 0 10px var(--emerald-glow);
}

.prize-info-box {
  padding: 6px 12px;
  border-radius: 0;
  background: transparent;
  border: none;
  border-left: 3px solid var(--cyan);
  font-size: 12px;
  color: #a5f3fc;
  line-height: 1.45;
}

/* Rich Lobby Additions */
.lobby-invite-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .lobby-invite-box {
    flex-direction: column;
    align-items: stretch;
  }
}

.invite-link-pill {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  font-family: monospace;
  font-size: 13px;
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roadmap-card-v2 {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease;
}

.roadmap-card-v2.is-current {
  border-color: rgba(6, 182, 212, 0.6);
  background: rgba(6, 182, 212, 0.08);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.12);
}

.roadmap-artwork-box {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

/* In-Game Guide Modal */
.guide-modal-shell {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.guide-card {
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 16px;
  background: rgba(10, 16, 14, 0.98);
  border: 1px solid rgba(6, 182, 212, 0.5);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.85), 0 0 30px rgba(6, 182, 212, 0.25), inset 0 0 15px rgba(6, 182, 212, 0.08);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalScaleUp 0.2s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(6, 182, 212, 0.4) transparent;
}

.guide-card::-webkit-scrollbar {
  width: 6px;
}

.guide-card::-webkit-scrollbar-track {
  background: transparent;
}

.guide-card::-webkit-scrollbar-thumb {
  background: rgba(6, 182, 212, 0.35);
  border-radius: 999px;
}

.guide-card::-webkit-scrollbar-thumb:hover {
  background: rgba(6, 182, 212, 0.6);
}

.guide-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.guide-text {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.55;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.guide-controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 540px) {
  .guide-controls-grid {
    grid-template-columns: 1fr;
  }
}

.guide-tab-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 36px !important;
  height: 36px !important;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e2e8f0;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.guide-tab-btn:hover {
  background: rgba(6, 182, 212, 0.2);
  border-color: rgba(6, 182, 212, 0.5);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.3);
}

.guide-tab-btn.active {
  background: var(--cyan) !important;
  border-color: var(--cyan) !important;
  color: #03110d !important;
  font-weight: 800 !important;
  box-shadow: 0 0 18px rgba(6, 182, 212, 0.6) !important;
}

.kbd-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-family: monospace;
  font-size: 11.5px;
  color: #e2e8f0;
}

/* Kicked Dialog */
.kicked-modal-shell {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.kicked-card {
  width: 100%;
  max-width: 440px;
  border-radius: 16px;
  background: rgba(20, 10, 14, 0.96);
  border: 1px solid rgba(244, 63, 94, 0.4);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(244, 63, 94, 0.2);
  padding: 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalScaleUp 0.2s ease;
}

/* Universal Tooltip System */
.sa-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 280px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(10, 16, 14, 0.94);
  border: 1px solid rgba(6, 182, 212, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 16px rgba(6, 182, 212, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: none;
  animation: fadeIn 0.15s ease-out;
}

.sa-tip-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sa-tip-body {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
}

/* Game Guide Modal */
.guide-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.guide-modal-sheet {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(6, 182, 212, 0.12);
}

.guide-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 21, 18, 0.95);
}

.guide-modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.guide-artwork-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.guide-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-section-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.guide-ctrl-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-ctrl-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}

.guide-ctrl-key {
  font-weight: 700;
  color: var(--gold);
  min-width: 130px;
  flex-shrink: 0;
}

.guide-ctrl-desc {
  color: var(--muted);
}

.guide-callout {
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-size: 13px;
  color: var(--text);
}

.guide-tips {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.guide-tips li {
  line-height: 1.5;
}

/* ── Mobile Compact & Expandable Optimization (<= 640px) ── */
@media (max-width: 640px) {
  body {
    padding: 8px !important;
  }

  .glass-card {
    padding: 12px 14px !important;
    border-radius: 12px !important;
  }

  .auth-mode-tabs {
    display: flex;
    gap: 4px;
  }

  .auth-tab-btn {
    padding: 8px 10px !important;
    font-size: 11.5px !important;
  }

  .oauth-btn-group {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .btn-oauth {
    padding: 9px 12px !important;
    font-size: 12.5px !important;
  }

  .field-row-2col {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  /* Collapsible / Expandable details support */
  .mobile-compact-details summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
    font-size: 12px;
  }

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

  .mobile-compact-details summary::after {
    content: '▼';
    font-size: 9px;
    color: var(--cyan);
    transition: transform 0.15s ease;
  }

  .mobile-compact-details[open] summary::after {
    transform: rotate(180deg);
  }

  .host-stats-row {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .stat-tile {
    padding: 8px 10px !important;
  }

  .stat-tile-val {
    font-size: 18px !important;
  }

  .host-recent-rooms-box {
    padding: 8px !important;
  }
}
