/* ═══════════════════════════════════════════════════════════════
   BeatCollab — Design System v2
   Dark flat theme · Lime accent · Clean typography
════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&display=swap');

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg:             #0e0c0a;
  --bg-card:        #1a1612;
  --bg-card-hover:  #231e18;
  --border:         #2e2720;
  --accent:         #F97316;
  --accent-dim:     #ea6a0a;
  --text-primary:   #ffffff;
  --text-secondary: #aaaaaa;
  --text-muted:     #666666;
  --red:            #ff4444;
  --green:          #00cc66;
  --gold:           #ffcc00;
  --radius:         6px;
  --radius-sm:      4px;
  --radius-lg:      10px;
  --transition:     all 0.18s ease;
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100vh;
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.6;
}

::selection { background: rgba(200,255,0,0.25); }

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* ─── Typography ────────────────────────────────────────────── */
h1 { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 900; line-height: 1.1; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 600; }

.gradient-text { color: var(--accent); }
.text-muted     { color: var(--text-muted); font-size: 0.875rem; }
.text-secondary { color: var(--text-secondary); }

/* ─── Background (inert) ────────────────────────────────────── */
.bg-canvas { display: none; }
.bg-orb    { display: none; }

/* ─── Layout ────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.page { position: relative; z-index: 1; min-height: 100vh; }

/* ─── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition);
}
.card:hover { border-color: #3a3a3a; }
.card-glow  { border-color: #3a3a3a; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius);
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn:active   { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
.btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}
.btn-outline:hover { background: rgba(200,255,0,0.08); }

.btn-danger  { background: var(--red);   color: #fff; border: 1px solid var(--red); }
.btn-success { background: var(--green); color: #000; border: 1px solid var(--green); }
.btn-ghost   { background: transparent; color: var(--text-secondary); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border); }

.btn-lg   { padding: 14px 36px; font-size: 1.05rem; }
.btn-sm   { padding: 7px 16px; font-size: 0.875rem; }
.btn-icon { padding: 10px; width: 40px; height: 40px; border-radius: var(--radius); }
.btn-full { width: 100%; }

/* ─── Inputs ────────────────────────────────────────────────── */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-label { font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); }
.input {
  background: #111;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  width: 100%;
}
.input::placeholder { color: var(--text-muted); }
.input:focus { border-color: var(--accent); background: #1a1200; }
.input-code {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ─── Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}
.tab {
  flex: 1; padding: 9px;
  border: none; background: transparent;
  font-family: 'Outfit', sans-serif; font-size: 0.95rem; font-weight: 600;
  color: var(--text-muted); cursor: pointer;
  border-radius: calc(var(--radius) - 2px);
  transition: var(--transition);
}
.tab.active { background: var(--accent); color: #fff; }

/* ─── Avatar ────────────────────────────────────────────────── */
.avatar {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700;
  background: #2a2a2a;
  color: var(--accent);
  flex-shrink: 0;
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.4rem; }
.avatar-sm { width: 32px; height: 32px; font-size: 0.85rem; }
.av-a,.av-b,.av-c,.av-d,.av-e,.av-f,.av-g,.av-h,.av-i,.av-j,.av-default { background: #2a2a2a; color: var(--accent); }

/* ─── Player List ───────────────────────────────────────────── */
.player-list { display: flex; flex-direction: column; gap: 6px; }
.player-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}
.player-item.submitted { border-color: var(--green); background: rgba(0,204,102,0.05); }
.player-info  { flex: 1; }
.player-name  { font-weight: 600; font-size: 0.95rem; }
.player-status{ font-size: 0.78rem; color: var(--text-muted); }
.player-badge { font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-sm); }
.badge-host    { background: rgba(255,204,0,0.12); color: var(--gold);  border: 1px solid rgba(255,204,0,0.25); }
.badge-ready   { background: rgba(0,204,102,0.12); color: var(--green); border: 1px solid rgba(0,204,102,0.25); }
.badge-waiting { background: #1e1e1e; color: var(--text-muted); border: 1px solid var(--border); }

/* ─── Beat Cards ────────────────────────────────────────────── */
.beat-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.beat-card {
  padding: 18px 12px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}
.beat-card:hover    { border-color: #444; background: var(--bg-card); }
.beat-card.selected { border-color: var(--accent); background: #1f1200; }
.beat-emoji { font-size: 1.6rem; display: block; margin-bottom: 6px; }
.beat-name  { font-weight: 700; font-size: 0.9rem; }
.beat-bpm   { font-size: 0.75rem; color: var(--text-muted); margin-top: 3px; }

/* ─── Room Code ─────────────────────────────────────────────── */
.room-code-box {
  padding: 14px 20px;
  background: #111;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.room-code-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 2px; }
.room-code-value { font-size: 2.2rem; font-weight: 900; letter-spacing: 0.2em; color: var(--accent); }
.room-code-copy  { cursor: pointer; font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; display: block; }
.room-code-copy:hover { color: var(--accent); }

/* ─── Timer Ring ────────────────────────────────────────────── */
.timer-wrap  { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.timer-svg   { transform: rotate(-90deg); }
.timer-track { fill: none; stroke: #2a2a2a; }
.timer-prog  { fill: none; stroke: var(--accent); stroke-linecap: butt; transition: stroke-dashoffset 1s linear; }
.timer-text  { position: absolute; text-align: center; pointer-events: none; }
.timer-num   { font-size: 2.8rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.timer-label { font-size: 0.75rem; color: var(--text-muted); letter-spacing: 1px; }
.timer-warn  { animation: timerPulse 0.5s ease-in-out infinite alternate; }
@keyframes timerPulse { from { color: var(--text-primary); } to { color: var(--red); } }

/* ─── Record Button ─────────────────────────────────────────── */
.record-btn-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.record-btn {
  width: 110px; height: 110px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.6rem;
  transition: var(--transition);
  position: relative; z-index: 1;
}
.record-btn:hover     { background: var(--accent-dim); transform: scale(1.04); }
.record-btn:active    { transform: scale(0.97); }
.record-btn.recording { background: var(--red); }
.record-btn.recording:hover { background: #e03333; }

.record-ring {
  position: absolute; inset: -14px;
  border-radius: 50%;
  border: 2px solid rgba(255,68,68,0.4);
  opacity: 0;
}
.recording .record-ring { animation: ringExpand 1.2s ease-out infinite; }
.record-ring:nth-child(2) { animation-delay: 0.4s !important; }
.record-ring:nth-child(3) { animation-delay: 0.8s !important; }
@keyframes ringExpand { 0%{transform:scale(0.85);opacity:0.6} 100%{transform:scale(1.7);opacity:0} }

/* ─── Canvas Visualizer ─────────────────────────────────────── */
.visualizer-wrap { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: #0a0a0a; }
#viz-canvas { display: block; }

/* ─── Step Dots ─────────────────────────────────────────────── */
.step-row { display: flex; gap: 5px; align-items: center; }
.step-dot {
  width: 9px; height: 9px; border-radius: 2px;
  background: #2a2a2a;
  transition: background 0.05s;
  flex-shrink: 0;
}
.step-dot.active { background: var(--accent); }
.step-dot.beat   { background: var(--red); }

/* ─── Submission Card ───────────────────────────────────────── */
.submission-card {
  padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}
.submission-card:hover { border-color: #3a3a3a; }
.submission-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.submission-rank {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: #2a2a2a;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 800; color: var(--text-muted);
  flex-shrink: 0;
}
.rank-1 { background: var(--gold); color: #000; }
.rank-2 { background: #888; color: #000; }
.rank-3 { background: #7a4a1a; color: #fff; }

/* ─── Audio Player ──────────────────────────────────────────── */
.audio-player {
  display: flex; align-items: center; gap: 10px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 10px 0;
}
.play-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--accent);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; color: #fff;
  transition: var(--transition); flex-shrink: 0;
}
.play-btn:hover { background: var(--accent-dim); }
.progress-bar-wrap { flex: 1; cursor: pointer; }
.progress-bar-bg   { height: 4px; background: #2a2a2a; border-radius: 2px; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; width: 0%; transition: width 0.1s; }
.audio-time { font-size: 0.78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ─── Vote Buttons ──────────────────────────────────────────── */
.vote-row { display: flex; gap: 8px; align-items: center; }
.vote-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem; font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.vote-btn:hover       { background: var(--bg-card-hover); border-color: #444; }
.vote-btn.up-active   { border-color: var(--accent); color: var(--accent); background: rgba(200,255,0,0.06); }
.vote-btn.down-active { border-color: var(--red); color: var(--red); background: rgba(255,68,68,0.06); }
.vote-btn:disabled    { opacity: 0.35; pointer-events: none; }
.vote-count { font-size: 0.85rem; }

/* ─── Leaderboard ───────────────────────────────────────────── */
.leaderboard { display: flex; flex-direction: column; gap: 6px; }
.lb-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}
.lb-item:first-child { border-color: var(--accent); background: rgba(200,255,0,0.04); }
.lb-pos   { width: 22px; font-weight: 800; color: var(--text-muted); flex-shrink: 0; }
.lb-name  { flex: 1; font-weight: 600; }
.lb-score { font-weight: 800; font-size: 1.05rem; color: var(--accent); }
.lb-pts   { font-size: 0.75rem; color: var(--text-muted); }

/* ─── Navbar ────────────────────────────────────────────────── */
.navbar {
  padding: 14px 24px;
  display: flex; align-items: center; gap: 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-logo {
  font-size: 1.2rem; font-weight: 900;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.nav-room {
  padding: 3px 12px;
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem; font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
}
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav-user    { font-size: 0.9rem; color: var(--text-secondary); font-weight: 500; }

/* ─── Auth Hero ─────────────────────────────────────────────── */
.auth-hero {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.auth-card { width: 100%; max-width: 420px; padding: 36px 32px; }
.logo-mark { font-size: 2.4rem; margin-bottom: 4px; display: block; }

/* ─── Alerts & Toast ────────────────────────────────────────── */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  animation: fadeInUp 0.25s ease;
}
.alert-error   { background: rgba(255,68,68,0.08);  border: 1px solid rgba(255,68,68,0.25);  color: #ff8888; }
.alert-success { background: rgba(0,204,102,0.08);  border: 1px solid rgba(0,204,102,0.25);  color: #66ffaa; }
.alert-info    { background: rgba(200,255,0,0.06);  border: 1px solid rgba(200,255,0,0.2);   color: var(--accent); }

.toast-area {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  background: #1a1a1a;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  max-width: 300px;
  animation: fadeInUp 0.25s ease;
  pointer-events: none;
}
@keyframes fadeInUp { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
.toast.removing { animation: fadeOut 0.25s ease forwards; }
@keyframes fadeOut { to{opacity:0;transform:translateY(6px)} }

/* ─── Misc ──────────────────────────────────────────────────── */
.dot        { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-green  { background: var(--green); }
.dot-purple { background: var(--accent); }
.dot-red    { background: var(--red); animation: blinkDot 1s ease-in-out infinite alternate; }
@keyframes blinkDot { from{opacity:1} to{opacity:0.3} }
.dot-muted  { background: var(--text-muted); }

.divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 0.85rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid #2a2a2a;
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Utility ───────────────────────────────────────────────── */
.section-gap     { margin-bottom: 24px; }
.flex            { display: flex; }
.flex-col        { display: flex; flex-direction: column; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.p-4  { padding: 16px; }
.text-center { text-align: center; }
.hidden { display: none !important; }

@media (max-width: 768px) {
  .beat-cards { grid-template-columns: 1fr; }
  .auth-card  { padding: 24px 18px; }
}

/* ─── Chat Panel (always visible right sidebar) ─────────────── */
#chat-panel {
  position: fixed;
  top: 57px;
  right: 0;
  width: 260px;
  height: calc(100vh - 57px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: #111;
  border-left: 1px solid var(--border);
}

body.has-chat .page,
body.has-chat .lobby-layout,
body.has-chat .game-layout,
body.has-chat .results-layout,
body.has-chat .results-header,
body.has-chat #final-song-wrap {
  margin-right: 260px;
}

#chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 0.88rem;
  flex-shrink: 0;
  color: var(--text-secondary);
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#chat-messages::-webkit-scrollbar { width: 3px; }
#chat-messages::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.chat-msg {
  display: flex; flex-direction: column; gap: 2px;
  max-width: 92%;
  align-self: flex-start;
}
.chat-msg-self { align-self: flex-end; text-align: right; }

.chat-author { font-size: 0.68rem; font-weight: 700; color: var(--accent); }
.chat-msg-self .chat-author { color: var(--text-secondary); }

.chat-text {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: 0.84rem;
  line-height: 1.4;
  word-break: break-word;
}
.chat-msg-self .chat-text {
  background: rgba(200,255,0,0.07);
  border-color: rgba(200,255,0,0.2);
}

.chat-time { font-size: 0.62rem; color: var(--text-muted); }

#chat-input-row {
  display: flex; gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.84rem;
  color: var(--text-primary);
  outline: none;
  min-width: 0;
}
#chat-input:focus { border-color: var(--accent); }

#chat-send {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  border: none; cursor: pointer;
  color: #fff; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition); flex-shrink: 0;
}
#chat-send:hover { background: var(--accent-dim); }

/* ─── Discord Button ────────────────────────────────────────── */
.discord-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #5865F2;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(88,101,242,0.4);
  transition: var(--transition);
  z-index: 300;
}
.discord-btn:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(88,101,242,0.6); }
.discord-btn svg { width: 22px; height: 22px; fill: #fff; }

body.has-chat .discord-btn { right: 280px; }
