/* ── Reset & variables ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: only dark;
  --bg0: #080a14;
  --bg1: #0d1020;
  --bg2: #141729;
  --bg3: #1d2140;
  --border: rgba(108, 99, 255, 0.25);
  --p:   #6c63ff;
  --p2:  #8b85ff;
  --cyan: #00d4ff;
  --gold: #ffd700;
  --red:  #ff4757;
  --green: #2ed573;
  --orange: #ffa502;
  --text:  #f0f2ff;
  --text2: #a0a8c8;
  --text3: #5a6080;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 8px 40px rgba(0,0,0,0.5);
  --transition: 0.25s cubic-bezier(.4,0,.2,1);
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
html { height: 100%; font-size: 16px; }

body {
  min-height: 100%;
  background: var(--bg0);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg1); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--p); }

/* ── Typography ──────────────────────────────────────────────────────────── */
h1 { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; }
h2 { font-size: 1.75rem; font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 600; }
h4 { font-size: 1rem;    font-weight: 600; }
p  { color: var(--text2); }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden   { display: none !important; }
.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.text-center { text-align: center; }
.text-gold { color: var(--gold); }
.text-cyan { color: var(--cyan); }
.text-red  { color: var(--red); }
.text-green { color: var(--green); }
.text-muted { color: var(--text2); }
.text-sm   { font-size: 0.85rem; }
.text-xs   { font-size: 0.75rem; }
.text-lg   { font-size: 1.1rem; }
.text-xl   { font-size: 1.4rem; font-weight: 700; }
.fw-bold   { font-weight: 700; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.w-full { width: 100%; }

/* ── Glass card ──────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.card-sm {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem;
  font-size: 0.9rem; font-weight: 600; font-family: inherit;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--p);
  color: #fff;
  border-color: var(--p);
  box-shadow: 0 0 20px rgba(108,99,255,0.35);
}
.btn-primary:hover:not(:disabled) {
  background: var(--p2);
  border-color: var(--p2);
  box-shadow: 0 0 30px rgba(108,99,255,0.55);
}

.btn-cyan {
  background: var(--cyan);
  color: #000;
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(0,212,255,0.35);
}
.btn-cyan:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 0 30px rgba(0,212,255,0.55);
}

.btn-gold {
  background: var(--gold);
  color: #000;
  border-color: var(--gold);
  font-weight: 700;
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.1); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}
.btn-danger:hover:not(:disabled) { background: var(--red); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg3); color: var(--text); }

.btn-lg {
  padding: 0.9rem 2rem;
  font-size: 1.05rem;
  border-radius: 12px;
}

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
}

.btn-icon {
  width: 2.5rem; height: 2.5rem;
  padding: 0;
  border-radius: 50%;
}

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem; font-family: inherit;
  padding: 0.65rem 1rem;
  transition: var(--transition);
  outline: none;
}
.input::placeholder { color: var(--text3); }
.input:focus { border-color: var(--p); box-shadow: 0 0 0 3px rgba(108,99,255,0.2); }

.input-group { display: flex; flex-direction: column; gap: 0.4rem; }
.input-label { font-size: 0.82rem; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.08em; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a0a8c8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.4rem;
}

/* ── Badge ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
}
.badge-gold   { background: rgba(255,215,0,0.15);  color: var(--gold); border-color: rgba(255,215,0,0.3); }
.badge-cyan   { background: rgba(0,212,255,0.12);  color: var(--cyan); border-color: rgba(0,212,255,0.3); }
.badge-red    { background: rgba(255,71,87,0.12);  color: var(--red);  border-color: rgba(255,71,87,0.3); }
.badge-green  { background: rgba(46,213,115,0.12); color: var(--green); border-color: rgba(46,213,115,0.3); }
.badge-purple { background: rgba(108,99,255,0.15); color: var(--p2);   border-color: rgba(108,99,255,0.3); }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 720px) {
  .two-col { grid-template-columns: 1fr; }
  h1 { font-size: 1.9rem; }
}

/* ── Avatar ──────────────────────────────────────────────────────────────── */
.avatar {
  width: 2.75rem; height: 2.75rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  background: var(--bg3);
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.avatar-sm { width: 2rem; height: 2rem; font-size: 1rem; }
.avatar-lg { width: 4rem; height: 4rem; font-size: 2rem; }

/* ── Player card ─────────────────────────────────────────────────────────── */
.player-card {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--bg3);
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: var(--transition);
}
.player-card:hover { border-color: var(--p); }
.player-card.is-host { border-color: var(--gold); }
.player-card.is-ready .ready-dot { background: var(--green); }
.player-card .player-info { flex: 1; min-width: 0; }
.player-card .player-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-card .player-score { font-size: 0.8rem; color: var(--text2); }
.ready-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); transition: var(--transition); }

/* ── Timer ring ──────────────────────────────────────────────────────────── */
.timer-ring-wrap {
  position: relative;
  width: 80px; height: 80px;
  flex-shrink: 0;
}
.timer-ring { transform: rotate(-90deg); }
.timer-ring .track { fill: none; stroke: var(--bg3); stroke-width: 6; }
.timer-ring .fill {
  fill: none;
  stroke: var(--p);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 220;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.timer-ring.urgent .fill { stroke: var(--red); }
.timer-value {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 800;
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--bg3);
  border-radius: 100px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--p), var(--cyan));
  border-radius: 100px;
  transition: width var(--transition);
}

/* ── Streak flame ─────────────────────────────────────────────────────────── */
.streak-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  background: rgba(255,165,0,0.15);
  color: var(--orange);
  font-size: 0.8rem; font-weight: 700;
  border: 1px solid rgba(255,165,0,0.3);
}

/* ── Notification toast ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: 1rem; right: 1rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  padding: 0.75rem 1.2rem;
  border-radius: 10px;
  font-size: 0.9rem; font-weight: 500;
  background: var(--bg2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red);   }
.toast.info    { border-color: var(--cyan);   color: var(--cyan);  }

@keyframes toastIn  { from { opacity: 0; transform: translateX(2rem); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(2rem); } }

/* ── Stars background decoration ────────────────────────────────────────── */
.stars-bg {
  position: fixed; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.stars-bg::before, .stars-bg::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  opacity: 0.08;
  filter: blur(80px);
}
.stars-bg::before {
  width: 600px; height: 600px;
  background: var(--p);
  top: -200px; left: -100px;
}
.stars-bg::after {
  width: 500px; height: 500px;
  background: var(--cyan);
  bottom: -150px; right: -100px;
}

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse   { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes bounce  { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes glow {
  0%,100% { box-shadow: 0 0 20px rgba(108,99,255,0.3); }
  50%      { box-shadow: 0 0 40px rgba(108,99,255,0.7); }
}

.animate-fade  { animation: fadeIn  0.4s ease both; }
.animate-scale { animation: scaleIn 0.35s ease both; }
.animate-pulse { animation: pulse   1.5s infinite; }
.animate-bounce { animation: bounce 0.6s ease; }

/* ── Logo ────────────────────────────────────────────────────────────────── */
.logo-text {
  font-size: 2rem; font-weight: 900;
  background: linear-gradient(135deg, var(--p), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}
.logo-text span { color: var(--gold); -webkit-text-fill-color: var(--gold); }
