:root {
  --bg-main: #070911;
  --bg-panel: #101425;
  --bg-card: #171c33;
  --bg-hover: #212747;
  --border: #272f52;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --purple: #7c3aed;
  --purple-bright: #a855f7;
  --purple-glow: rgba(139, 92, 246, 0.42);
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --cyan: #06b6d4;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-main);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: grid;
  grid-template-columns: 1fr 410px;
  min-height: 100vh;
}

/* LEFT STAGE */
.stage-col {
  display: flex;
  flex-direction: column;
  padding: 12px 16px 24px;
  gap: 12px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  flex-wrap: wrap;
}

.brand-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #4ade80;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 999px;
}
.live-pill.offline {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.console-title { font-size: 15px; font-weight: 800; }

.method-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(124, 58, 237, 0.16);
  border: 1px solid rgba(124, 58, 237, 0.4);
  color: #d8b4fe;
  font-weight: 600;
}

.stats-strip { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
.stat-item { display: flex; flex-direction: column; align-items: flex-end; }
.stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.stat-value { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-value.timer { color: #c084fc; font-size: 16px; }

/* SITE SCHEDULED MAINTENANCE / ADMIN OFFLINE BANNER */
.site-notice-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(124, 58, 237, 0.16));
  border: 1px solid rgba(250, 204, 21, 0.52);
  color: #fef08a;
}
.site-notice-banner.is-admin-off {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.24), rgba(16, 20, 38, 0.9));
  border-color: rgba(239, 68, 68, 0.6);
  color: #fecaca;
}
.site-notice-banner a { color: #38bdf8; text-decoration: underline; font-weight: 800; }

/* READY CHECK 3-MINUTE ACTIVATION BANNER */
.ready-check-banner {
  display: none;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(124, 58, 237, 0.28));
  border: 2px solid #f59e0b;
  border-radius: 14px;
  padding: 14px 18px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.25);
  animation: pulseBorder 1.8s infinite;
}
.ready-check-banner.show { display: flex; }

@keyframes pulseBorder {
  0%, 100% { border-color: #f59e0b; }
  50% { border-color: #fde047; }
}

/* LIVE SESSION BILLING BOX */
.billing-hud-panel {
  display: none;
  background: linear-gradient(135deg, rgba(16, 20, 38, 0.98), rgba(28, 22, 56, 0.96));
  border: 1px solid rgba(168, 85, 247, 0.55);
  border-radius: 14px;
  padding: 12px 16px;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 12px 32px rgba(124, 58, 237, 0.18);
}
.billing-hud-panel.show { display: flex; }

.billing-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.bill-cell {
  background: rgba(8, 10, 20, 0.65);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.bill-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.bill-val { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.bill-sub { font-size: 10px; color: #94a3b8; margin-top: 2px; }

/* VIDEO STAGE */
.video-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #04050a;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.video-stage video,
.video-stage iframe,
.video-stage canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border: 0;
}
.video-stage video {
  object-fit: contain;
  transform: translateZ(0);
  will-change: transform;
  background: #000;
}
.video-stage video.video-warming {
  display: block !important;
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}
.video-stage.stage-live-video-mode:not(:fullscreen) {
  aspect-ratio: 16 / 9 !important;
  height: auto;
  min-height: 0;
}
.video-stage canvas {
  touch-action: none;
}
.video-stage:fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #04050a;
  border: 0;
  border-radius: 0;
  width: 100vw;
  height: 100dvh;
}
.video-stage:fullscreen video {
  object-fit: contain;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* STATIC STANDBY SCREEN (DEFAULT WHEN XBOX OFFLINE/DEMO) */
.static-standby-screen {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 22% 30%, rgba(124, 58, 237, 0.32), transparent 52%),
    radial-gradient(circle at 78% 75%, rgba(6, 182, 212, 0.24), transparent 50%),
    linear-gradient(135deg, #070914 0%, #121631 55%, #090b18 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 22px 28px;
  gap: 12px;
  overflow-y: auto;
  z-index: 4;
}

.standby-grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
  background-size: 38px 38px;
  pointer-events: none;
}

.standby-content {
  position: relative;
  z-index: 2;
  max-width: 680px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.arcade-hub-content { max-width: 590px; }

.arcade-hub-main {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 12px;
  align-items: stretch;
}
.arcade-hub-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
}

.arcade-selector-wrap {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 2px;
}
.arcade-selector-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}
.arcade-game-chip {
  background: rgba(13, 18, 36, 0.84);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 11px;
  padding: 8px 6px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
  transition: all 0.15s;
}
.arcade-game-chip:hover {
  border-color: rgba(168, 85, 247, 0.72);
  background: rgba(124, 58, 237, 0.18);
  transform: translateY(-2px);
}
.arcade-game-chip.active {
  border-color: #fbbf24;
  background: linear-gradient(155deg, rgba(124, 58, 237, 0.36), rgba(15, 23, 42, 0.94));
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.25);
}
.arcade-chip-icon { font-size: 20px; line-height: 1.1; }
.arcade-chip-name { font-size: 11px; font-weight: 800; line-height: 1.2; color: #fff; }
.arcade-chip-pb { font-size: 9.5px; color: #fde047; font-weight: 700; white-space: nowrap; }

.arcade-exit-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: auto;
  left: auto;
  z-index: 9;
  background: rgba(10, 14, 28, 0.9) !important;
  border: 1px solid rgba(248, 113, 113, 0.58) !important;
  color: #fecaca !important;
  backdrop-filter: blur(6px);
  padding: 6px 11px !important;
  font-size: 11.5px !important;
}
.arcade-exit-btn:hover { background: rgba(220, 38, 38, 0.88) !important; color: #fff !important; }

/* Position HUD below Exit button when user explicitly enables Panel control during an Arcade mini-game */
.video-stage.stage-arcade-mode .hud-overlay {
  top: 44px;
}

@media (max-width: 820px) {
  .arcade-hub-main { grid-template-columns: 1fr; gap: 10px; }
  .arcade-selector-grid { grid-template-columns: repeat(3, 1fr); }
}

.standby-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  background: rgba(6, 182, 212, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.standby-title {
  font-size: 28px;
  font-weight: 900;
  line-height: 1.15;
  background: linear-gradient(90deg, #ffffff, #c084fc, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.standby-desc {
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.5;
}

.car-countdown-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 16, 0.55);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  z-index: 8;
  pointer-events: none;
}

.car-countdown-num {
  font-size: 92px;
  font-weight: 900;
  color: #fde047;
  text-shadow: 0 0 36px rgba(250, 204, 21, 0.75), 0 0 12px rgba(168, 85, 247, 0.8);
  line-height: 1;
}

.car-lb-card {
  background: rgba(10, 13, 25, 0.82);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(168, 85, 247, 0.38);
  border-radius: 10px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 300px;
}
.car-lb-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  gap: 10px;
}

.car-overlay-over {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 16, 0.8);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9;
  padding: 16px;
}
.car-over-card {
  background: var(--bg-panel);
  border: 2px solid #a855f7;
  border-radius: 16px;
  padding: 20px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* STAGE READY-CHECK ACTIVATION OVERLAY */
.stage-ready-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 18, 0.62);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
  padding: 18px;
}
.stage-ready-overlay.show { display: flex; }
.stage-ready-card {
  background: linear-gradient(135deg, rgba(16, 20, 38, 0.96), rgba(34, 24, 66, 0.95));
  border: 2px solid #f59e0b;
  border-radius: 16px;
  padding: 18px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 390px;
  width: 100%;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.65), 0 0 28px rgba(245, 158, 11, 0.25);
  animation: pulseBorder 1.8s infinite;
}

/* TELEMETRY METRICS OVERLAY (BOTTOM-RIGHT, DRAGGABLE, RESIZABLE, ZOOM & OPACITY-ADJUSTABLE) */
.telemetry-hud {
  position: absolute;
  bottom: 12px;
  right: 14px;
  left: auto;
  display: flex;
  flex-direction: column;
  z-index: 8;
  font-size: 11px;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  max-width: calc(100% - 16px);
  max-height: calc(100% - 16px);
  overflow: visible;
  background: transparent;
  border: 0;
  padding: 0;
}
.telemetry-hud.hidden { display: none; }
.hud-tool-surface {
  width: 100%;
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
  overflow: hidden;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.hud-zoom-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.telemetry-surface {
  background: rgba(10, 13, 24, 0.88);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.telemetry-hud.dragging .telemetry-surface,
.telemetry-hud.resizing .telemetry-surface {
  border-color: #c084fc;
  box-shadow: 0 0 28px rgba(168, 85, 247, 0.45);
}
.tm-body-row { display: flex; align-items: center; justify-content: center; gap: 13px; flex-wrap: wrap; width: 100%; }
.tm-cell { display: flex; flex-direction: column; gap: 1px; }
.tm-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); }
.tm-val { font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; color: #fff; }
.tm-qual { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font-weight: 700; font-size: 11px; width: fit-content; }
.tm-qual.excellent { background: rgba(34, 197, 94, 0.18); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.45); }
.tm-qual.good      { background: rgba(6, 182, 212, 0.18); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.45); }
.tm-qual.warn      { background: rgba(245, 158, 11, 0.18); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.45); }
.tm-qual.bad       { background: rgba(239, 68, 68, 0.18); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.45); }

/* FUTURISTIC DRAGGABLE & RESIZABLE CONTROLLER HUD OVERLAY */
.hud-overlay {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  user-select: none;
  z-index: 8;
  touch-action: none;
  max-width: calc(100% - 16px);
  max-height: calc(100% - 16px);
  overflow: visible;
  background: transparent;
  border: 0;
  padding: 0;
}
.hud-overlay.hidden { display: none; }
.hud-surface {
  background: linear-gradient(135deg, rgba(10, 14, 28, 0.92), rgba(22, 16, 44, 0.9));
  backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.38);
  border-radius: 14px;
  padding: 8px 12px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.hud-overlay.dragging .hud-surface,
.hud-overlay.resizing .hud-surface {
  border-color: #c084fc;
  box-shadow: 0 0 28px rgba(168, 85, 247, 0.45);
}

/* CENTERED OVERLAY EDIT BAR (NO HEIGHT GROWTH, UNAFFECTED BY TOOL OPACITY) */
.hud-controls-bar {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 14;
  opacity: 1 !important;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  width: max-content;
  max-width: min(340px, calc(100vw - 24px));
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(9, 13, 28, 0.82);
  backdrop-filter: blur(10px);
  border: 1.5px solid rgba(168, 85, 247, 0.78);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.62), 0 0 18px rgba(124, 58, 237, 0.35);
  pointer-events: auto;
}
.video-stage.edit-screen-mode .hud-controls-bar {
  display: inline-flex;
}
.video-stage.edit-screen-mode .hud-overlay .hud-surface,
.video-stage.edit-screen-mode .telemetry-hud .telemetry-surface,
.video-stage.edit-screen-mode .stage-chat-overlay .stage-chat-surface {
  border-color: rgba(168, 85, 247, 0.85);
  box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.4), 0 0 24px rgba(124, 58, 237, 0.3);
}

/* 8-DIRECTION RESIZE HANDLES (VERTICAL, HORIZONTAL & DIAGONAL — EDIT MODE ONLY) */
.hud-resize-handle {
  display: none;
  position: absolute;
  z-index: 12;
  touch-action: none;
  pointer-events: auto;
}
.video-stage.edit-screen-mode .hud-resize-handle { display: block; }
.hud-resize-handle.n  { top: -5px; left: 12px; right: 12px; height: 10px; cursor: ns-resize; }
.hud-resize-handle.s  { bottom: -5px; left: 12px; right: 12px; height: 10px; cursor: ns-resize; }
.hud-resize-handle.e  { right: -5px; top: 12px; bottom: 12px; width: 10px; cursor: ew-resize; }
.hud-resize-handle.w  { left: -5px; top: 12px; bottom: 12px; width: 10px; cursor: ew-resize; }
.hud-resize-handle.ne { top: -6px; right: -6px; width: 14px; height: 14px; cursor: nesw-resize; }
.hud-resize-handle.nw { top: -6px; left: -6px; width: 14px; height: 14px; cursor: nwse-resize; }
.hud-resize-handle.se { bottom: -6px; right: -6px; width: 14px; height: 14px; cursor: nwse-resize; }
.hud-resize-handle.sw { bottom: -6px; left: -6px; width: 14px; height: 14px; cursor: nesw-resize; }

.hud-resize-handle.ne::after,
.hud-resize-handle.nw::after,
.hud-resize-handle.se::after,
.hud-resize-handle.sw::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #c084fc;
  border: 1.5px solid #ffffff;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.9);
  opacity: 0.92;
  transition: transform 0.12s, background 0.12s;
}
.hud-resize-handle.ne:hover::after,
.hud-resize-handle.nw:hover::after,
.hud-resize-handle.se:hover::after,
.hud-resize-handle.sw:hover::after {
  transform: scale(1.25);
  background: #38bdf8;
}
.hud-resize-handle.n::after,
.hud-resize-handle.s::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 3px;
  border-radius: 999px;
  background: rgba(192, 132, 252, 0.72);
}
.hud-resize-handle.e::after,
.hud-resize-handle.w::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 24px;
  border-radius: 999px;
  background: rgba(192, 132, 252, 0.72);
}

/* ACTIVE PLAYER FLOATING ON-SCREEN CHAT OVERLAY (MOVABLE, RESIZABLE, ZOOM & OPACITY) */
.stage-chat-overlay {
  position: absolute;
  bottom: 14px;
  left: 14px;
  width: 300px;
  height: 220px;
  max-width: calc(100% - 16px);
  max-height: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  z-index: 8;
  user-select: none;
  touch-action: none;
  pointer-events: none;
  overflow: visible;
  background: transparent;
  border: 0;
  padding: 0;
}
.stage-chat-overlay.hidden { display: none; }
.stage-chat-surface {
  background: rgba(10, 14, 28, 0.84);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(168, 85, 247, 0.42);
  border-radius: 13px;
  padding: 7px 10px 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stage-chat-zoom-inner {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 6px;
  flex: 1;
  min-height: 0;
  height: 100%;
}
.stage-chat-overlay.dragging .stage-chat-surface,
.stage-chat-overlay.resizing .stage-chat-surface {
  border-color: #c084fc;
  box-shadow: 0 0 28px rgba(168, 85, 247, 0.5);
}
.video-stage.edit-screen-mode .stage-chat-overlay { pointer-events: auto; }
.stage-chat-header {
  font-size: 10.5px;
  font-weight: 800;
  color: #c4b5fd;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.stage-chat-lock-btn {
  background: transparent;
  border: 0;
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.12s, color 0.12s, background 0.12s;
}
.stage-chat-lock-btn:hover {
  background: rgba(124, 58, 237, 0.28);
  color: #fff;
  transform: scale(1.1);
}
.stage-chat-lock-btn.is-locked {
  color: #fbbf24;
}
.stage-chat-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  font-size: 11.5px;
  line-height: 1.35;
  padding-right: 4px;
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: #7c3aed #0a0e1d;
}
.stage-chat-line {
  background: rgba(15, 23, 42, 0.65);
  border-radius: 7px;
  padding: 4px 7px;
  word-break: break-word;
}
.stage-chat-line.system { color: #e9d5ff; background: rgba(124, 58, 237, 0.22); }
.stage-chat-line.gift {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.24), rgba(124, 58, 237, 0.28));
  border: 1px solid rgba(251, 191, 36, 0.55);
}

/* ANIMATED ON-SCREEN GIFT ALERT (SIDE OF STAGE FOR ACTIVE PLAYER / RECIPIENT) */
.stage-gift-stack {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(310px, calc(100% - 28px));
}
.stage-gift-toast {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(16, 20, 42, 0.94), rgba(44, 20, 74, 0.92));
  border: 2px solid var(--gift-c1, #fbbf24);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.65), 0 0 24px rgba(251, 191, 36, 0.35);
  animation: giftSlideIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.stage-gift-toast.leaving {
  animation: giftSlideOut 0.45s ease-in forwards;
}
.stage-gift-sticker {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  background: linear-gradient(135deg, var(--gift-c1, #f59e0b), var(--gift-c2, #7c3aed));
  box-shadow: 0 0 18px var(--gift-c1, #fbbf24);
  animation: giftStickerPop 1.1s ease-in-out infinite;
}
.stage-gift-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stage-gift-from { font-size: 11.5px; color: #e2e8f0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-gift-amount { font-size: 17px; font-weight: 900; color: #fde047; line-height: 1.1; text-shadow: 0 0 12px rgba(250, 204, 21, 0.55); }
.stage-gift-label { font-size: 10.5px; color: #c4b5fd; font-weight: 700; }
.stage-gift-note { font-size: 10.5px; color: #f8fafc; font-style: italic; opacity: 0.92; }

@keyframes giftSlideIn {
  from { opacity: 0; transform: translateX(-36px) scale(0.88); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes giftSlideOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(-36px) scale(0.9); }
}
@keyframes giftStickerPop {
  0%, 100% { transform: scale(1) rotate(-3deg); }
  50%      { transform: scale(1.13) rotate(4deg); }
}

/* GIFT CARDS INSIDE CHAT & GIFT MODAL PICKERS */
.chat-msg.gift-msg {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.16), rgba(124, 58, 237, 0.2));
  border: 1px solid rgba(251, 191, 36, 0.52);
  padding: 9px 10px;
}
.chat-gift-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-gift-badge {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: linear-gradient(135deg, var(--gift-c1, #f59e0b), var(--gift-c2, #7c3aed));
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.35);
  animation: giftStickerPop 1.8s ease-in-out infinite;
}
.chat-gift-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.chat-gift-title { font-size: 12px; color: #f8fafc; line-height: 1.3; }
.chat-gift-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(250, 204, 21, 0.2);
  border: 1px solid rgba(250, 204, 21, 0.55);
  color: #fde047;
  font-size: 11px;
  font-weight: 900;
  padding: 1px 7px;
  border-radius: 999px;
  width: fit-content;
}
.gift-preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.gift-preset-btn {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text);
  transition: all 0.14s;
}
.gift-preset-btn:hover { border-color: #fbbf24; transform: translateY(-1px); }
.gift-preset-btn.selected {
  border-color: #fbbf24;
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.24), rgba(124, 58, 237, 0.24));
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.28);
}
.gift-sticker-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.gift-sticker-btn {
  background: var(--bg-main);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 6px 2px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 9px;
  transition: all 0.12s;
}
.gift-sticker-btn span:first-child { font-size: 20px; line-height: 1.1; }
.gift-sticker-btn:hover { border-color: #a855f7; color: #fff; }
.gift-sticker-btn.selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.18);
  color: #fff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}
.gift-confirm-card {
  background: linear-gradient(145deg, rgba(16, 20, 42, 0.96), rgba(36, 20, 68, 0.92));
  border: 1.5px solid rgba(251, 191, 36, 0.55);
  border-radius: 14px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gift-recip-list {
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 3px;
}
.gift-recip-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 9px;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  text-align: left;
}
.gift-recip-item:hover { border-color: #a855f7; }
.gift-recip-item.selected { border-color: #4ade80; background: rgba(34, 197, 94, 0.15); }
@media (max-width: 520px) {
  .gift-preset-grid { grid-template-columns: repeat(2, 1fr); }
  .gift-sticker-grid { grid-template-columns: repeat(4, 1fr); }
  .stage-chat-overlay { width: 225px; max-height: 165px; bottom: 8px; left: 8px; }
  .stage-gift-stack { left: 8px; max-width: calc(100% - 16px); }
  .stage-gift-sticker { width: 42px; height: 42px; font-size: 24px; }
  .stage-gift-amount { font-size: 14.5px; }
}

.hud-drag-handle {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  cursor: grab;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.4px;
  padding: 2px 4px;
}
.hud-drag-handle:active { cursor: grabbing; color: #e9d5ff; }

.hud-mini-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hud-opacity-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
}

.hud-opacity-slider {
  width: 56px;
  height: 4px;
  accent-color: #a855f7;
  cursor: pointer;
}

.hud-icon-btn {
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #cbd5e1;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  cursor: pointer;
  transition: all 0.12s;
}
.hud-icon-btn:hover { border-color: #a855f7; color: #fff; }
.hud-icon-btn.active {
  background: rgba(124, 58, 237, 0.35);
  border-color: #a855f7;
  color: #f3e8ff;
}

.hud-zoom-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 7px;
  padding: 1px 3px;
}
.hud-zoom-btn {
  border: 0;
  background: transparent;
  padding: 2px 6px;
  font-size: 12.5px;
  font-weight: 900;
  line-height: 1;
  color: #e2e8f0;
}
.hud-zoom-btn:hover { background: rgba(124, 58, 237, 0.45); color: #fff; }
.hud-zoom-val {
  font-size: 9.5px;
  font-weight: 800;
  color: #e2e8f0;
  min-width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* BELOW-SCREEN PANEL CONTROL DECK */
.hud-deck {
  background: linear-gradient(135deg, rgba(12, 16, 32, 0.96), rgba(22, 16, 44, 0.92));
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 14px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: 0 6px 24px rgba(6, 182, 212, 0.08);
}
.hud-deck.hidden { display: none; }
.hud-deck-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 165px;
}
.hud-deck-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
}
.hud-deck-svg { width: 204px; height: 128px; }

.hud-body-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-player-info { display: flex; flex-direction: column; gap: 3px; min-width: 108px; }
.hud-player-name { font-size: 13px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.hud-timer { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; color: #fff; line-height: 1.1; }
.hud-sub { font-size: 11px; color: var(--text-muted); }

.hud-controller-svg { width: 176px; height: 112px; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.65)); }
.hud-controller-svg.hidden { display: none; }
.hud-controller-svg .pad-btn {
  fill: #1b213a;
  stroke: #475569;
  stroke-width: 1.4;
  transition: all 0.05s ease-out;
}
.hud-controller-svg .pad-btn.btn-a { stroke: #22c55e; }
.hud-controller-svg .pad-btn.btn-b { stroke: #ef4444; }
.hud-controller-svg .pad-btn.btn-x { stroke: #38bdf8; }
.hud-controller-svg .pad-btn.btn-y { stroke: #facc15; }

.hud-controller-svg .pad-btn.active {
  fill: #38bdf8;
  stroke: #ffffff;
  filter: drop-shadow(0 0 8px #38bdf8);
}
.hud-controller-svg .pad-btn.btn-a.active { fill: #22c55e; filter: drop-shadow(0 0 8px #22c55e); }
.hud-controller-svg .pad-btn.btn-b.active { fill: #ef4444; filter: drop-shadow(0 0 8px #ef4444); }
.hud-controller-svg .pad-btn.btn-x.active { fill: #38bdf8; filter: drop-shadow(0 0 8px #38bdf8); }
.hud-controller-svg .pad-btn.btn-y.active { fill: #facc15; filter: drop-shadow(0 0 8px #facc15); }

.hud-controller-svg .stick-dot { fill: #cbd5e1; stroke: #38bdf8; stroke-width: 1.5; transition: transform 0.03s linear; }
.hud-controller-svg .stick-dot.active { fill: #38bdf8; filter: drop-shadow(0 0 8px #38bdf8); }

.your-turn-banner {
  position: absolute;
  top: 14px;
  left: 14px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.94), rgba(6, 182, 212, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
  z-index: 7;
  box-shadow: 0 8px 25px var(--purple-glow);
}

.practice-banner {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(245, 158, 11, 0.94);
  color: #0f172a;
  border-radius: 10px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 800;
  z-index: 7;
  display: none;
}

/* FOOTER & METRICS DECK */
.stage-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 12px;
  gap: 10px;
  flex-wrap: wrap;
}
.footer-left, .footer-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge-pill { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; font-size: 12px; color: var(--text-muted); }
.badge-pill strong { color: var(--text); }

.metrics-deck { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.metrics-deck.hidden { display: none; }
.metric-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.metric-card-label { font-size: 10.5px; color: var(--text-muted); display: flex; justify-content: space-between; align-items: center; gap: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.metric-card-value { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-card-sub { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* MULTI-TOUCH VIRTUAL GAMEPAD */
.touch-pad {
  display: none;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  flex-direction: column;
  gap: 12px;
  user-select: none;
  touch-action: none;
}
.touch-pad.visible { display: flex; }
.touch-shoulders { display: flex; justify-content: space-between; gap: 8px; }
.touch-shoulders-group { display: flex; gap: 6px; }
.touch-main-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stick-zone {
  width: 114px; height: 114px; border-radius: 50%;
  background: radial-gradient(circle, #1e2340 0%, #0d1020 75%);
  border: 2px solid #384068; position: relative;
  display: flex; align-items: center; justify-content: center; touch-action: none;
}
.stick-label { position: absolute; bottom: 6px; font-size: 10px; color: var(--text-muted); font-weight: 700; pointer-events: none; }
.stick-nub { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, #06b6d4, #9333ea); border: 2px solid #e9d5ff; box-shadow: 0 4px 14px rgba(124, 58, 237, 0.55); pointer-events: none; }
.dpad-grid, .abxy-grid { display: grid; grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(3, 42px); gap: 4px; }
.pad-key { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); border-radius: 10px; font-weight: 800; font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; touch-action: none; min-height: 38px; padding: 6px 12px; }
.pad-key:active, .pad-key.pressed { background: var(--purple); border-color: #e9d5ff; transform: scale(0.95); }

/* RIGHT SIDEBAR */
.sidebar {
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}

.user-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-profile-chip { display: flex; align-items: center; gap: 9px; min-width: 0; }

.avatar-circle {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff; flex-shrink: 0;
  overflow: hidden; background-size: cover; background-position: center;
  border: 2px solid rgba(255, 255, 255, 0.14);
}
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; display: block; }

.user-quick-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 2px 0 0;
  font-size: 12px;
}

.tabs-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
  background: rgba(9, 11, 20, 0.45);
}

.tab-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
  padding: 11px 4px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab-btn.active { color: #fff; border-bottom-color: var(--purple-bright); background: rgba(124, 58, 237, 0.12); }

.tab-body { flex: 1; overflow-y: auto; padding: 13px; display: none; flex-direction: column; gap: 11px; }
.tab-body.active { display: flex; }

/* Pre-first-paint active tab rules driven by <html data-active-tab="..."> (zero flash of Fila on reload) */
html[data-active-tab] .tab-body { display: none; }
html[data-active-tab="queue"] #tab-queue,
html[data-active-tab="chat"] #tab-chat,
html[data-active-tab="friends"] #tab-friends,
html[data-active-tab="controls"] #tab-controls { display: flex; }

html[data-active-tab] .tab-btn {
  color: var(--text-muted);
  border-bottom-color: transparent;
  background: transparent;
}
html[data-active-tab="queue"] .tab-btn[data-tab="queue"],
html[data-active-tab="chat"] .tab-btn[data-tab="chat"],
html[data-active-tab="friends"] .tab-btn[data-tab="friends"],
html[data-active-tab="controls"] .tab-btn[data-tab="controls"] {
  color: #fff;
  border-bottom-color: var(--purple-bright);
  background: rgba(124, 58, 237, 0.12);
}

/* BUTTONS */
.btn {
  border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 700; font-size: 13px;
  cursor: pointer; transition: transform 0.08s, filter 0.15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--purple), var(--purple-bright)); color: #fff; box-shadow: 0 6px 20px var(--purple-glow); }
.btn-cta-gold { background: linear-gradient(135deg, #f59e0b, #ea580c); color: #0b0d17; font-weight: 800; box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35); }
.btn-green { background: linear-gradient(135deg, #16a34a, #22c55e); color: #052e16; font-weight: 800; }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-toggle-active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.92), rgba(6, 182, 212, 0.85)) !important;
  color: #ffffff !important;
  border: 1px solid rgba(233, 213, 255, 0.65) !important;
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-danger { background: rgba(239, 68, 68, 0.18); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.45); }
.btn-sm { padding: 6px 10px; font-size: 11.5px; border-radius: 8px; }

/* QUEUE & VIP BIDDING */
.tariff-box {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 2px 2px;
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.48;
}
.tariff-box strong { color: #e9d5ff; }

.vip-bid-card {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), var(--bg-card));
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 12px;
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.preset-chip {
  background: var(--bg-main);
  border: 1px solid var(--border);
  color: #fbbf24;
  border-radius: 8px;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s, color 0.14s, box-shadow 0.14s, transform 0.1s;
}
.preset-chip:hover { border-color: #f59e0b; background: rgba(245, 158, 11, 0.14); }
.preset-chip.active {
  border-color: #fbbf24;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.34), rgba(124, 58, 237, 0.38));
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.65), 0 4px 14px rgba(245, 158, 11, 0.28);
}

.queue-subtabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.q-subtab {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 9px; padding: 7px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
}
.q-subtab.active { border-color: var(--purple-bright); color: #fff; background: rgba(124, 58, 237, 0.18); }
.q-subtab.vip.active { border-color: var(--amber); color: #fde68a; background: rgba(245, 158, 11, 0.15); }

.queue-section-title { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.7px; }
.queue-list { display: flex; flex-direction: column; gap: 7px; }
.queue-item { display: flex; align-items: center; justify-content: space-between; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; gap: 8px; }
.queue-item.vip { border-color: rgba(245, 158, 11, 0.48); background: linear-gradient(90deg, rgba(245, 158, 11, 0.1), var(--bg-card)); }
.queue-item.playing-now { border-color: rgba(34, 197, 94, 0.65); background: linear-gradient(90deg, rgba(34, 197, 94, 0.15), var(--bg-card)); }
.queue-item.ready-now { border-color: rgba(250, 204, 21, 0.72); background: linear-gradient(90deg, rgba(245, 158, 11, 0.18), var(--bg-card)); }
.queue-item.is-me { border-color: #a855f7; box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.35); }
.q-status-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.q-status-pill.playing { background: transparent; color: #4ade80; border: 0; padding: 0; }
.q-status-pill.ready { background: rgba(245, 158, 11, 0.22); color: #fde047; border: 1px solid rgba(245, 158, 11, 0.55); }
.queue-item-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.q-pos { width: 22px; font-size: 12px; font-weight: 800; color: var(--text-muted); text-align: center; }
.q-meta { display: flex; flex-direction: column; min-width: 0; }
.q-name { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-lvl  { font-size: 10.5px; color: var(--text-muted); }
.q-time { font-size: 12px; font-weight: 800; color: #fbbf24; text-align: right; white-space: nowrap; }

/* GAMEPAD PANEL */
.gp-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 9px; }
.gp-badge { display: inline-block; font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: #272d4d; color: var(--text-muted); }
.gp-badge.connected { background: rgba(34, 197, 94, 0.18); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.45); }
.gp-badge.playstation { background: rgba(37, 99, 235, 0.22); color: #93c5fd; border-color: rgba(59, 130, 246, 0.5); }
.gp-legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 11px; color: var(--text-muted); }
.gp-legend-grid strong { color: #e9d5ff; }
.remap-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.remap-btn { background: var(--bg-main); border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: 6px 4px; font-size: 11px; font-weight: 700; cursor: pointer; }
.remap-btn.capturing { border-color: var(--amber); color: #fbbf24; animation: pulse 0.9s infinite; }

/* CHAT & FRIENDS DM */
.chat-lock-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; font-size: 11.5px;
}
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding-right: 4px; min-height: 180px; }
.chat-msg { font-size: 12.5px; line-height: 1.4; background: var(--bg-card); padding: 8px 10px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.04); word-break: break-word; }
.chat-msg.system { background: rgba(124, 58, 237, 0.14); border-color: rgba(124, 58, 237, 0.35); color: #e9d5ff; font-size: 11.5px; }
.chat-author { font-weight: 700; margin-right: 6px; }
.chat-form { display: flex; gap: 7px; padding-top: 8px; border-top: 1px solid var(--border); }

.friend-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.dm-drawer {
  background: #0b0f1e; border: 1px solid var(--purple-bright); border-radius: 12px;
  padding: 10px; display: none; flex-direction: column; gap: 8px;
}
.dm-drawer.open { display: flex; }
.dm-msgs { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }

/* INPUTS & MODALS */
.input-field { width: 100%; background: var(--bg-main); border: 1px solid var(--border); border-radius: 9px; color: var(--text); padding: 9px 12px; font-size: 13px; outline: none; }
.input-field:focus { border-color: var(--purple-bright); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5, 7, 15, 0.86);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 14px;
  will-change: auto;
}
.modal-backdrop.open { display: flex; }

/* Full-screen solid non-flickering redirect state while launching DAVIpay / Wompi */
.payment-redirect-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  background: #060913;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.payment-redirect-card {
  width: min(440px, 94vw);
  background: var(--bg-panel);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 16px;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72);
}
.payment-redirect-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(56, 189, 248, 0.25);
  border-top-color: #38bdf8;
  animation: paySpin 0.85s linear infinite;
}
@keyframes paySpin {
  to { transform: rotate(360deg); }
}
body.payment-active .live-dot,
body.payment-active .ready-check-banner {
  animation: none !important;
}

/* Defensive sizing & solid backdrop if ePayco OnePage container ever mounts */
#epayco-onepage-v2-container dialog {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background-color: rgba(4, 6, 14, 0.88) !important;
}
#epayco-onepage-v2-container dialog > div {
  width: min(760px, 94vw) !important;
  max-width: min(760px, 94vw) !important;
  height: min(820px, 92vh) !important;
  max-height: 92vh !important;
}
.modal-card {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px;
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
  padding: 20px; display: flex; flex-direction: column; gap: 14px;
}
.modal-card.wide { max-width: 680px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.alert-err { background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.4); color: #fca5a5; padding: 9px 12px; border-radius: 8px; font-size: 12px; display: none; }
.alert-err.show { display: block; }

.tx-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.tx-table th, .tx-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.tx-table th { color: var(--text-muted); font-size: 11px; text-transform: uppercase; }
.tx-plus { color: #4ade80; font-weight: 800; }
.tx-minus { color: #f87171; font-weight: 800; }

.keymap-list { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.keymap-row { display: flex; justify-content: space-between; background: var(--bg-card); padding: 6px 10px; border-radius: 8px; }
.kbd { background: var(--bg-main); border: 1px solid var(--border); padding: 2px 7px; border-radius: 5px; font-family: monospace; color: #c084fc; }

/* EMOJI PICKER POPOVER */
.emoji-popover {
  position: fixed;
  width: 310px;
  max-width: calc(100vw - 20px);
  background: var(--bg-panel);
  border: 1px solid var(--purple-bright);
  border-radius: 13px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.72);
  padding: 8px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.emoji-cats {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 8px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: #8b5cf6 #0b0f1f;
}

.emoji-cat-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.emoji-cat-btn.active {
  background: rgba(124, 58, 237, 0.3);
  border-color: var(--purple-bright);
  color: #fff;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: #8b5cf6 #0b0f1f;
}

/* THEMED VERTICAL & HORIZONTAL SCROLLBARS (EMOJI PICKERS, AVATARS, CHAT, STAGE CHAT, MODALS) */
.emoji-cats::-webkit-scrollbar,
.emoji-grid::-webkit-scrollbar,
.avatar-gallery-grid::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.stage-chat-list::-webkit-scrollbar,
.dm-msgs::-webkit-scrollbar,
.tab-body::-webkit-scrollbar,
.modal-card::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.emoji-cats::-webkit-scrollbar-track,
.emoji-grid::-webkit-scrollbar-track,
.avatar-gallery-grid::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.stage-chat-list::-webkit-scrollbar-track,
.dm-msgs::-webkit-scrollbar-track,
.tab-body::-webkit-scrollbar-track,
.modal-card::-webkit-scrollbar-track {
  background: #0a0e1d;
  border-radius: 999px;
  border: 1px solid rgba(39, 47, 82, 0.7);
}

.emoji-cats::-webkit-scrollbar-thumb,
.emoji-grid::-webkit-scrollbar-thumb,
.avatar-gallery-grid::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.stage-chat-list::-webkit-scrollbar-thumb,
.dm-msgs::-webkit-scrollbar-thumb,
.tab-body::-webkit-scrollbar-thumb,
.modal-card::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.6);
}

.emoji-cats::-webkit-scrollbar-thumb:hover,
.emoji-grid::-webkit-scrollbar-thumb:hover,
.avatar-gallery-grid::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover,
.stage-chat-list::-webkit-scrollbar-thumb:hover,
.dm-msgs::-webkit-scrollbar-thumb:hover,
.tab-body::-webkit-scrollbar-thumb:hover,
.modal-card::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #a855f7, #22d3ee);
}

.emoji-cats::-webkit-scrollbar-corner,
.emoji-grid::-webkit-scrollbar-corner,
.stage-chat-list::-webkit-scrollbar-corner {
  background: transparent;
}

.avatar-gallery-grid,
.chat-messages,
.stage-chat-list,
.dm-msgs,
.tab-body,
.modal-card {
  scrollbar-width: thin;
  scrollbar-color: #7c3aed #0a0e1d;
}

.emoji-item {
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-size: 19px;
  padding: 4px 0;
  cursor: pointer;
  transition: transform 0.08s, background 0.1s;
}
.emoji-item:hover {
  background: var(--bg-hover);
  transform: scale(1.18);
}

/* 60 AVATAR PICKER GALLERY */
.avatar-gallery-wrap {
  display: none;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px;
}
.avatar-gallery-wrap.open { display: flex; }

.avatar-gallery-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
  max-height: 225px;
  overflow-y: auto;
  padding-right: 4px;
}

.avatar-pick-btn {
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 9.5px;
  transition: all 0.12s;
}
.avatar-pick-btn:hover { border-color: rgba(168, 85, 247, 0.6); color: #fff; }
.avatar-pick-btn.selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.16);
  color: #fff;
}

/* AUTH EMAIL VALIDATION, PASSWORD SHOW/HIDE & LEGAL MODALS */
.auth-inline-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.auth-inline-row .input-field { flex: 1; min-width: 0; }
.input-field.verified-input {
  border-color: #22c55e !important;
  background: rgba(34, 197, 94, 0.1);
}
.verify-hint-text {
  text-align: center;
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.45;
  padding: 2px 4px;
}
.verify-code-box {
  background: rgba(23, 28, 51, 0.85);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.verify-code-input {
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 800;
  font-size: 14px;
}
.verified-badge-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #4ade80;
  font-size: 13px;
  font-weight: 800;
  padding: 2px 0;
}
.pass-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pass-wrap .input-field { padding-right: 78px; }
.pass-toggle-btn {
  position: absolute;
  right: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: #cbd5e1;
  border-radius: 7px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.pass-toggle-btn:hover { border-color: var(--purple-bright); color: #fff; }
.legal-check-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 11.8px;
  color: #cbd5e1;
  line-height: 1.45;
  cursor: pointer;
}
.legal-check-row input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: #7c3aed;
  flex-shrink: 0;
  cursor: pointer;
}
.legal-link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: #a855f7;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: inherit;
  vertical-align: baseline;
}
.legal-link-btn:hover { color: #38bdf8; }
.legal-doc {
  font-size: 12.5px;
  line-height: 1.62;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.legal-doc .legal-ver {
  font-size: 11px;
  font-weight: 800;
  color: #38bdf8;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.legal-doc h2 {
  font-size: 16px;
  color: #fff;
  line-height: 1.3;
  margin-bottom: 4px;
}
.legal-doc h4 {
  font-size: 13px;
  color: #c084fc;
  margin-top: 6px;
}
.legal-doc ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.legal-modal-scroll {
  max-height: 60vh;
  overflow-y: auto;
  padding: 14px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 11px;
  scrollbar-width: thin;
  scrollbar-color: #7c3aed #0a0e1d;
}
.legal-modal-scroll::-webkit-scrollbar { width: 7px; }
.legal-modal-scroll::-webkit-scrollbar-track { background: #0a0e1d; border-radius: 999px; }
.legal-modal-scroll::-webkit-scrollbar-thumb { background: linear-gradient(135deg, #7c3aed, #06b6d4); border-radius: 999px; }

@media (max-width: 1320px) {
  .metrics-deck { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; border-left: 0; border-top: 1px solid var(--border); }
  .metrics-deck { grid-template-columns: repeat(3, 1fr); }
  .billing-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Allow Standby Arcade Menu to expand cleanly with zero vertical clipping on mobile portrait */
  .video-stage.stage-standby-mode:not(:fullscreen) {
    aspect-ratio: auto;
    height: auto;
    min-height: 0;
  }
  .video-stage.stage-standby-mode:not(:fullscreen) .static-standby-screen {
    position: relative;
    inset: auto;
    justify-content: flex-start;
    padding: 14px 12px;
    overflow: visible;
  }
  .video-stage.stage-arcade-mode:not(:fullscreen) {
    aspect-ratio: 16 / 10;
    min-height: 235px;
  }
  .arcade-hub-content { max-width: 100%; }
  .car-lb-card {
    display: flex;
    max-width: 100%;
    padding: 8px 10px;
  }
  .arcade-selector-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .arcade-game-chip { padding: 8px 4px; min-height: 64px; }
  .arcade-chip-icon { font-size: 18px; }
  .arcade-chip-name { font-size: 10.5px; }
  .arcade-chip-pb { font-size: 9px; }

  /* Compact uniform 3x2 action toolbar on mobile */
  .stage-footer {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 8px;
  }
  .footer-left, .footer-right { display: contents; }
  .stage-footer .btn {
    width: 100%;
    padding: 8px 5px;
    font-size: 11px;
    min-height: 36px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Symmetrical ergonomic dual-thumb virtual Xbox controller */
  .touch-pad { padding: 10px; gap: 10px; }
  .touch-shoulders .pad-key { padding: 5px 10px; font-size: 11.5px; min-height: 34px; }
  .touch-main-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-items: center;
    align-items: center;
    gap: 10px 8px;
  }
  #stickZoneL { order: 1; }
  .abxy-grid  { order: 2; }
  .dpad-grid  { order: 3; }
  #stickZoneR { order: 4; }
  .stick-zone { width: 96px; height: 96px; }
  .stick-nub { width: 38px; height: 38px; }
  .dpad-grid, .abxy-grid {
    grid-template-columns: repeat(3, 38px);
    grid-template-rows: repeat(3, 38px);
    gap: 4px;
  }
  .dpad-grid .pad-key, .abxy-grid .pad-key { padding: 0; font-size: 12px; min-height: 38px; }
}

@media (max-width: 640px) {
  .stage-col { padding: 8px 8px 14px; gap: 8px; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand-group { gap: 6px; width: 100%; }
  .console-title { font-size: 13.5px; }
  .live-pill { font-size: 10px; padding: 4px 8px; }
  .method-chip { font-size: 10px; padding: 2px 7px; }
  .stats-strip { width: 100%; justify-content: space-between; gap: 8px; padding-top: 4px; border-top: 1px solid rgba(148, 163, 184, 0.12); }
  .stat-item { align-items: flex-start; }
  .stat-label { font-size: 9px; }
  .stat-value { font-size: 13px; }
  .stat-value.timer { font-size: 14px; }

  .hud-overlay { top: 6px; right: 6px; }
  .hud-surface { padding: 5px 8px; border-radius: 10px; }
  .hud-body-row { gap: 8px; }
  .hud-player-info { min-width: 78px; }
  .hud-player-name { font-size: 11px; }
  .hud-timer { font-size: 14px; }
  .hud-sub { font-size: 9.5px; }
  .hud-controller-svg { width: 88px; height: 56px; }
  .hud-deck { padding: 10px 12px; gap: 10px; }
  .hud-deck-svg { width: 150px; height: 96px; }

  .telemetry-hud {
    bottom: 6px;
    right: 6px;
    left: 6px;
    max-width: none;
  }
  .telemetry-surface { padding: 5px 8px; border-radius: 9px; }
  .tm-body-row { gap: 8px; justify-content: space-between; }
  .tm-label { font-size: 8px; }
  .tm-val { font-size: 10.5px; }
  .tm-qual { font-size: 10px; padding: 2px 6px; }

  .metrics-deck { grid-template-columns: repeat(2, 1fr); gap: 7px; }
  .metric-card { padding: 9px 10px; }
  .metric-card-value { font-size: 15px; }

  .standby-badge { font-size: 10px; padding: 4px 9px; }
  .standby-title { font-size: 19px; }
  .standby-desc { font-size: 11.5px; line-height: 1.42; }
  .car-countdown-num { font-size: 68px; }
  .car-over-card { padding: 14px 16px; gap: 8px; }
  .arcade-exit-btn { top: 8px; right: 8px; padding: 5px 9px !important; font-size: 11px !important; }

  /* Mobile-friendly modals, forms & prevent iOS Safari input auto-zoom */
  .modal-backdrop { padding: 8px; }
  .modal-card { padding: 14px; max-height: 92dvh; border-radius: 14px; gap: 12px; }
  .modal-tabs { flex-wrap: wrap; }
  .modal-tabs .btn { flex: 1 1 auto; font-size: 11px; padding: 7px 8px; }
  .input-field, select.input-field { font-size: 16px; padding: 9px 10px; }
  .tab-btn { font-size: 11.5px; padding: 12px 4px; }
  .chat-messages { max-height: 360px; }
  #toastBanner { width: calc(100vw - 24px); max-width: 420px; text-align: center; font-size: 12px; bottom: 14px; }
}

@media (max-width: 520px) {
  .form-grid-2 { grid-template-columns: 1fr; }
  .avatar-gallery-grid { grid-template-columns: repeat(4, 1fr); }
  .preset-row { gap: 5px; }
  .preset-chip { padding: 8px 4px; font-size: 11.5px; }
}

/* Mobile Landscape Optimization: keep full 16:9 game/stream inside viewport with zero top/bottom clipping */
@media (max-height: 540px) and (orientation: landscape) {
  .stage-col { padding: 4px 10px 12px; gap: 6px; }
  .topbar { padding: 5px 10px; gap: 6px; }
  .method-chip { display: none; }
  .video-stage:not(.stage-standby-mode):not(:fullscreen) {
    max-height: calc(100dvh - 64px);
    width: auto;
    max-width: 100%;
    margin: 0 auto;
  }
  .video-stage.stage-standby-mode:not(:fullscreen) {
    aspect-ratio: auto;
    height: auto;
  }
  .video-stage.stage-standby-mode:not(:fullscreen) .static-standby-screen {
    position: relative;
    inset: auto;
    padding: 12px 14px;
  }
  .hud-overlay { top: 6px; right: 6px; }
  .hud-surface { padding: 4px 8px; }
  .hud-controller-svg { width: 92px; height: 58px; }
  .hud-timer { font-size: 15px; }
  .telemetry-hud { bottom: 6px; right: 6px; }
  .telemetry-surface { padding: 4px 8px; }
  .tm-val { font-size: 10.5px; }
  .arcade-exit-btn { top: 8px; right: 8px; padding: 4px 9px !important; font-size: 11px !important; }
  .car-over-card { padding: 12px 16px; gap: 6px; }
}
