/* SWARM — shared design tokens & base styles */
:root {
  --bg:      #0f0f1a;
  --surface: #1a1a2e;
  --border:  #2a2a3a;
  --accent:  #6c63ff;
  --accent2: #43d9b0;
  --text:    #e2e2f0;
  --muted:   #6b6b80;
  --error:   #ff6584;
  --opt0:    #6c63ff;
  --opt1:    #ff6584;
  --opt2:    #43d9b0;
  --opt3:    #ffd166;
  --opt4:    #ef7d57;
  --opt5:    #83c5be;
}

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

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

/* ── Layout ───────────────────────────────────────────────────────────────── */
.page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}

.page-fill {
  height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
}

.card-wide {
  max-width: 640px;
}

/* ── Typography ───────────────────────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem;   font-weight: 700; }

.label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ── Form controls ────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  padding: 13px 18px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-align: center;
  text-decoration: none;
  color: #fff;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary   { background: var(--accent); }
.btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-danger    { background: var(--error); }
.btn-success   { background: #22c55e; }

.btn-sm {
  width: auto;
  display: inline-block;
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: 8px;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 3px 9px;
  border-radius: 20px;
}
.badge-lobby    { background: rgba(107,107,128,0.2); color: var(--muted); }
.badge-active   { background: rgba(67,217,176,0.15); color: var(--accent2); }
.badge-complete { background: rgba(108,99,255,0.15); color: var(--accent); }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.gap-8  { display: flex; flex-direction: column; gap: 8px; }
.gap-12 { display: flex; flex-direction: column; gap: 12px; }
.gap-16 { display: flex; flex-direction: column; gap: 16px; }
.mt-8   { margin-top: 8px; }
.mt-12  { margin-top: 12px; }
.mt-16  { margin-top: 16px; }
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.text-accent { color: var(--accent); }
.text-accent2 { color: var(--accent2); }

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ── Error message ────────────────────────────────────────────────────────── */
.error-msg {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 8px;
}

/* ── Code display ─────────────────────────────────────────────────────────── */
.code-display {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--accent);
}

/* ── Timer bar ────────────────────────────────────────────────────────────── */
.timer-track {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.timer-bar {
  height: 100%;
  background: var(--accent2);
  border-radius: 2px;
  width: 100%;
  transition: width 0.1s linear;
}
.timer-bar.urgent { background: var(--error); }

/* ── Ranked options list ──────────────────────────────────────────────────── */
.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.rank-num {
  font-size: 1.1rem;
  font-weight: 800;
  min-width: 28px;
  color: var(--muted);
}
.rank-num.first { color: var(--accent2); }
.rank-bar-wrap {
  flex: 1;
}
.rank-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.rank-bar-fill {
  height: 100%;
  border-radius: 3px;
}

/* ── Stat grid ────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
}
.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Scrollable areas ─────────────────────────────────────────────────────── */
.scroll-area {
  overflow-y: auto;
  overflow-x: hidden;
}
.scroll-area::-webkit-scrollbar { width: 6px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }
.scroll-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
