/* ═══════════════════════════════════════════════════════════════
   ROBLOX 2026 — COMPLETE DARK THEME
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg:         #1a1a1a;
  --bg2:        #252525;
  --bg3:        #2e2e2e;
  --border:     rgba(255,255,255,0.08);
  --accent:     #0066ff;
  --accent-h:   #0052cc;
  --red:        #e53e3e;
  --text:       #f0f0f0;
  --text-dim:   #888;
  --radius:     8px;
  --topbar-h:   52px;
  --font:       -apple-system,'Segoe UI',Roboto,sans-serif;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* ── HOME SCREEN ─────────────────────────────────────────────── */
#home-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  overflow-y: auto;
  display: flex; flex-direction: column;
}

/* Topbar */
#home-topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: #111;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px; gap: 0;
  flex-shrink: 0;
}
.tb-left  { display: flex; align-items: center; gap: 4px; flex: 1; }
.tb-center { flex: 0 0 260px; }
.tb-right { display: flex; align-items: center; gap: 4px; justify-content: flex-end; flex: 1; }

.roblox-logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.2em; font-weight: 800; letter-spacing: -0.5px;
  margin-right: 12px; color: #fff;
  cursor: pointer; user-select: none;
}
.tb-nav {
  padding: 6px 12px; border-radius: 6px;
  color: var(--text-dim); text-decoration: none;
  font-weight: 500; font-size: 0.9em;
  transition: color .15s, background .15s;
}
.tb-nav:hover { color: #fff; background: rgba(255,255,255,0.06); }
.tb-nav.active { color: #fff; }

.tb-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; padding: 6px 14px;
}
.tb-search input {
  background: none; border: none; outline: none;
  color: var(--text); width: 180px; font-size: 0.9em;
}

.tb-robux {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,200,0,.15); border: 1px solid rgba(0,200,0,.3);
  color: #4ade80; border-radius: 20px;
  padding: 5px 12px; cursor: pointer; font-weight: 600;
  font-size: 0.85em;
}
.tb-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: none; border: none;
  color: var(--text-dim); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.tb-icon:hover { background: var(--bg3); color: #fff; }
.tb-avatar-btn {
  background: none; border: none; cursor: pointer; margin-left: 4px;
}
.tb-avatar-circle {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1em;
  border: 2px solid rgba(255,255,255,.15);
}

/* Hero */
#home-hero {
  position: relative; min-height: 380px;
  display: flex; align-items: center;
  overflow: hidden; padding: 40px 48px;
  gap: 48px;
}
#hero-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #0d1b4b 0%, #091128 60%, #1a0530 100%);
}
#hero-content { position: relative; z-index: 1; flex: 1; max-width: 560px; }
#hero-preview  { position: relative; z-index: 1; flex: 0 0 220px; }

#hero-badge {
  display: inline-block;
  background: rgba(255,200,0,.15); border: 1px solid rgba(255,200,0,.3);
  color: #fbbf24; border-radius: 20px; padding: 3px 12px;
  font-size: 0.75em; font-weight: 700; letter-spacing: 1px;
  margin-bottom: 14px;
}
#hero-title {
  font-size: 2.4em; font-weight: 800; line-height: 1.1;
  margin-bottom: 10px;
}
#hero-desc { color: #aaa; font-size: 0.95em; margin-bottom: 14px; }
#hero-meta  { display: flex; gap: 18px; color: #888; font-size: 0.85em; margin-bottom: 22px; }
#hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

#preview-canvas {
  width: 220px; height: 280px;
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
}

/* Games grid */
#home-games { padding: 32px 48px 48px; }
.section-title { font-size: 1.15em; font-weight: 700; margin-bottom: 16px; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.game-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  transition: transform .15s, border-color .15s;
  cursor: pointer; position: relative;
}
.game-card:hover { transform: translateY(-3px); border-color: rgba(255,255,255,.2); }
.game-card.active-card { border-color: var(--accent); }
.game-thumb {
  height: 120px; display: flex; align-items: center;
  justify-content: center; font-size: 3rem;
}
.game-info { padding: 10px 12px; }
.game-name { font-weight: 600; margin-bottom: 2px; }
.game-meta { font-size: 0.8em; color: var(--text-dim); }
.btn-play-small {
  position: absolute; bottom: 10px; right: 10px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 6px;
  padding: 5px 12px; font-weight: 600; cursor: pointer;
  font-size: 0.8em; transition: background .15s;
}
.btn-play-small:hover { background: var(--accent-h); }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius);
  padding: 10px 22px; font-weight: 700; cursor: pointer;
  font-size: 0.95em; display: inline-flex; align-items: center;
  gap: 6px; transition: background .15s;
}
.btn-primary:hover  { background: var(--accent-h); }
.btn-secondary {
  background: rgba(255,255,255,.08); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 22px; font-weight: 600; cursor: pointer;
  font-size: 0.95em; transition: background .15s;
}
.btn-secondary:hover { background: rgba(255,255,255,.13); }
.btn-danger {
  background: rgba(220,50,50,.85); color: #fff;
  border: none; border-radius: var(--radius);
  padding: 10px 22px; font-weight: 700; cursor: pointer;
  transition: background .15s;
}
.btn-danger:hover { background: #b91c1c; }

/* ── MODALS ─────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(4px);
}
.modal-box {
  position: relative; z-index: 1;
  background: #1e1e1e; border: 1px solid var(--border);
  border-radius: 14px; padding: 24px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,.8);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 1.2em; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 1.2em; cursor: pointer; width: 32px; height: 32px;
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; transition: background .15s;
}
.modal-close:hover { background: var(--bg3); color: #fff; }
.modal-input {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  color: var(--text); font-size: 1em; outline: none;
  transition: border-color .15s;
}
.modal-input:focus { border-color: var(--accent); }

.verify-error {
  color: #f87171; font-size: 0.85em; margin-top: 8px;
  padding: 8px 12px; background: rgba(248,113,113,.1);
  border-radius: 6px;
}
.verify-error.hidden { display: none; }

/* Avatar Editor */
#avatar-editor-inner {
  display: flex; gap: 20px;
}
#ae-preview-wrap {
  flex: 0 0 220px;
  position: relative;
}
#ae-canvas {
  width: 220px; height: 300px;
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  display: block;
}
#ae-spin-hint {
  text-align: center; font-size: 0.75em; color: var(--text-dim);
  margin-top: 6px;
}
#ae-controls { flex: 1; }
.ae-section { margin-bottom: 16px; }
.ae-section-title {
  font-size: 0.75em; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-dim); margin-bottom: 8px; font-weight: 700;
}
.ae-color-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ae-color-grid label {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px;
  font-size: 0.85em;
}
.ae-color-grid input[type="color"] {
  width: 32px; height: 24px; border: none; border-radius: 4px;
  cursor: pointer; padding: 0;
}
#hat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.hat-opt {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px; text-align: center;
  cursor: pointer; font-size: 0.82em; transition: border-color .15s;
}
.hat-opt:hover    { border-color: rgba(255,255,255,.3); }
.hat-opt.selected { border-color: var(--accent); background: rgba(0,100,255,.15); }
.btn-char-type {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 6px;
  padding: 6px 16px; cursor: pointer; font-weight: 600;
}
.btn-char-type.active { border-color: var(--accent); color: var(--accent); }

/* ── GAME SCREEN ─────────────────────────────────────────────── */
#game-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
#game-screen.hidden { display: none; }

/* In-game topbar */
#game-topbar {
  height: var(--topbar-h);
  background: rgba(17,17,17,.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  display: flex; align-items: center;
  padding: 0 12px; gap: 8px;
  flex-shrink: 0; z-index: 50;
}
.gtb-left  { display: flex; align-items: center; gap: 8px; flex: 1; }
.gtb-center { flex: 0 0 auto; }
.gtb-right { display: flex; align-items: center; gap: 6px; justify-content: flex-end; flex: 1; }

#gtb-home-btn {
  width: 36px; height: 36px; border-radius: 8px;
  background: none; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; transition: background .15s;
}
#gtb-home-btn:hover { background: rgba(220,50,50,.2); border-color: #e53e3e; }

#gtb-game-name { font-weight: 700; font-size: 0.95em; }
#gtb-players-badge {
  display: flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 10px;
  font-size: 0.8em; color: var(--text-dim);
}
.gtb-btn {
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 10px;
  cursor: pointer; font-size: 0.85em; color: var(--text);
  transition: background .15s; white-space: nowrap;
}
.gtb-btn:hover { background: rgba(255,255,255,.12); }
.gtb-btn.active { background: rgba(0,100,255,.3); border-color: var(--accent); }

#gtb-health-pill {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.4); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 10px;
}
#gtb-hpbar {
  width: 80px; height: 8px;
  background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden;
}
#gtb-hpfill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  border-radius: 4px; transition: width .3s, background .3s;
}
#gtb-hptext { font-size: 0.8em; font-weight: 700; min-width: 26px; }

/* Canvas */
#game-canvas {
  display: block;
  width: 100%;
  height: calc(100vh - var(--topbar-h));
  cursor: crosshair;
  flex: 1 1 0;
  min-height: 0;
}

/* HUD */
#hud {
  position: absolute; inset: var(--topbar-h) 0 0 0;
  pointer-events: none; font-family: var(--font);
  color: var(--text);
}

/* Leaderboard */
#leaderboard {
  position: absolute; top: 10px; right: 10px;
  width: 180px;
  background: rgba(0,0,0,.55);
  border: 1px solid var(--border);
  backdrop-filter: blur(4px);
  border-radius: 10px; padding: 10px;
  pointer-events: none;
  max-height: 300px; overflow: hidden;
}
.lb-title { font-size: 0.7em; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 6px; font-weight: 700; }
.lb-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.05);
  font-size: 0.82em;
}
.lb-row:last-child { border: none; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-hp { color: #4ade80; font-weight: 600; }

/* Chat */
#chat-display {
  position: absolute; bottom: 58px; left: 10px;
  width: 300px; max-height: 200px;
  background: rgba(0,0,0,.5);
  border: 1px solid var(--border);
  backdrop-filter: blur(3px);
  border-radius: 10px; padding: 8px 10px;
  overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
  pointer-events: auto; font-size: 0.83em;
}
.chat-msg { color: #e0e0e0; word-break: break-word; }
.chat-sender { font-weight: 700; color: #93c5fd; margin-right: 4px; }
.chat-system { color: #a3e635; font-style: italic; }

/* Bottom bar */
#bottom-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 6px 10px;
  display: flex; align-items: center; gap: 10px;
  pointer-events: auto;
}
#chat-input-wrap {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.6); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px; flex: 1;
  max-width: 300px;
}
.chat-icon { font-size: 1em; }
#chat-input {
  background: none; border: none; outline: none;
  color: var(--text); font-size: 0.9em; flex: 1;
}
#chat-input::placeholder { color: var(--text-dim); }

/* Hotbar */
#hotbar {
  display: flex; gap: 4px;
}
.hb-slot {
  width: 56px; height: 56px; border-radius: 8px;
  background: rgba(0,0,0,.65);
  border: 2px solid rgba(255,255,255,.12);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer; transition: border-color .15s, background .15s;
  pointer-events: auto; user-select: none;
}
.hb-slot:hover { border-color: rgba(255,255,255,.3); }
.hb-slot.active {
  border-color: #fff;
  background: rgba(0,100,255,.3);
}
.hb-num { font-size: 0.62em; color: var(--text-dim); font-weight: 700; }
.hb-icon { font-size: 1.5em; }

/* Build panel */
#build-panel {
  position: absolute; top: 10px; left: 10px;
  width: 210px; background: rgba(20,20,20,.9);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; pointer-events: auto;
  max-height: calc(100vh - 160px); overflow-y: auto;
}
#build-panel.hidden { display: none; }
.bp-title { font-weight: 700; font-size: 0.9em; margin-bottom: 10px; }
.bp-section-label { font-size: 0.7em; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); font-weight: 700; margin: 10px 0 6px; }
.bp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.bp-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 5px; padding: 5px 4px;
  font-size: 0.75em; cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.bp-btn:hover { border-color: rgba(255,255,255,.3); }
.bp-btn.active { border-color: var(--accent); background: rgba(0,100,255,.2); color: #93c5fd; }
.bp-size-label { display: block; font-size: 0.7em; color: var(--text-dim); margin-bottom: 2px; }
.bp-size-input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 5px; color: var(--text); padding: 4px 6px;
  font-size: 0.85em; outline: none;
}

/* Voice panel */
#voice-panel {
  position: absolute; top: 10px; right: 200px;
  width: 160px; background: rgba(20,20,20,.9);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; pointer-events: auto;
}
#voice-panel.hidden { display: none; }
.vc-title { font-weight: 700; font-size: 0.85em; margin-bottom: 8px; }
.vc-user {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0; font-size: 0.82em;
}
.vc-dot { width: 8px; height: 8px; border-radius: 50%; background: #555; flex-shrink: 0; }
.vc-dot.speaking { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.vc-dot.muted    { background: #f87171; }
.vc-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; font-size: 0.78em; flex: 1;
}

/* Mobile controls */
#mobile-controls {
  position: absolute; left: 0; right: 0; bottom: 64px;
  pointer-events: none;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 12px 0 8px;
}
#joystick-zone {
  width: 150px; height: 150px; border-radius: 50%;
  pointer-events: auto; touch-action: none;
  background: rgba(255,255,255,.02);
}
#mobile-right {
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: auto;
}
.m-btn {
  background: rgba(0,0,0,.6); border: 1px solid var(--border);
  color: #fff; border-radius: 8px; padding: 10px 14px;
  font-size: 0.85em; cursor: pointer; pointer-events: auto;
  font-weight: 600;
}
@media (hover:hover) and (pointer:fine) { #mobile-controls { display: none; } }

/* Death overlay */
#death-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.75); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto; z-index: 200;
}
#death-overlay.hidden { display: none; }
#death-box {
  background: #1a1a1a; border: 1px solid rgba(220,50,50,.4);
  border-radius: 14px; padding: 32px 40px; text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,.8);
}
#death-icon { font-size: 3rem; margin-bottom: 10px; }
#death-title { font-size: 1.8em; font-weight: 800; color: #f87171; margin-bottom: 4px; }
#death-reason { color: var(--text-dim); margin-bottom: 4px; }

/* Crosshair */
#crosshair {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255,255,255,.8); font-size: 1.6em;
  pointer-events: none; user-select: none;
  text-shadow: 0 0 3px rgba(0,0,0,.8);
  display: none;
}

/* Connection status */
#conn-status {
  position: absolute; top: 8px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.7); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 14px;
  font-size: 0.75em; color: var(--text-dim);
  pointer-events: none; white-space: nowrap;
  opacity: 0; transition: opacity .3s;
}
#conn-status.visible { opacity: 1; }
#conn-status.online  { border-color: rgba(74,222,128,.4); color: #4ade80; }
#conn-status.offline { border-color: rgba(248,113,113,.4); color: #f87171; }

/* Nametag above players (CSS2DObject) */
.player-nametag {
  background: rgba(0,0,0,.65);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 20px; padding: 3px 10px;
  color: #fff; font-size: 12px; font-weight: 600;
  font-family: var(--font); pointer-events: none;
  white-space: nowrap;
}
.player-nametag .vc-indicator { color: #4ade80; margin-left: 4px; font-size: 10px; }
