@import url('https://fonts.googleapis.com/css2?family=Geologica:wght@700;800&family=Onest:wght@400;500;600;700&family=JetBrains+Mono:wght@400;700&display=swap');

/* ══════════════════════════════════════════════════════════════
   LIGHT THEME (default) — warm cream
   ══════════════════════════════════════════════════════════════ */
:root {
  --bg:            #faf8f8;
  --surface:       #ffffff;
  --surface2:      #f3eeee;
  --border:        #e6dcdc;
  --border2:       #d4c8c8;
  --accent:        #ff2d6b;
  --accent-bg:     #fff0f4;
  --accent-border: #ffb3cb;
  --label:         #c2004a;
  --text:          #1a1010;
  --muted:         #6b5858;
  --dim:           #a89090;
  --green:         #0d8f6c;
  --red:           #cc2a2a;
  --opt-a:         #5436e0;
  --opt-b:         #d45a1a;
  --opt-c:         #0a8c74;
  --opt-d:         #b82020;
  --r:             8px;
  --r-lg:          16px;
  --r-pill:        100px;
  --shadow:        0 1px 4px rgba(0,0,0,.06), 0 2px 12px rgba(0,0,0,.04);
  --shadow-lg:     0 4px 24px rgba(0,0,0,.10);
}

/* ══════════════════════════════════════════════════════════════
   DARK THEME — warm charcoal
   ══════════════════════════════════════════════════════════════ */
html[data-theme="dark"] {
  --bg:            #13100f;
  --surface:       #1c1816;
  --surface2:      #252019;
  --border:        #2e2825;
  --border2:       #3d3530;
  --accent:        #ff2d6b;
  --accent-bg:     #2a1420;
  --accent-border: #6e1030;
  --label:         #ff6090;
  --text:          #f0ebe6;
  --muted:         #a09080;
  --dim:           #5e5248;
  --green:         #1ec99e;
  --red:           #f05050;
  --opt-a:         #6C47FF;
  --opt-b:         #e06820;
  --opt-c:         #0fb898;
  --opt-d:         #e84040;
  --shadow:        0 2px 12px rgba(0,0,0,.5);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Onest', system-ui, sans-serif;
  min-height: 100vh;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }
.mono { font-family: 'JetBrains Mono', monospace; }

/* ── Nav ── */
.nav {
  height: 60px;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 4px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 100;
  box-shadow: var(--shadow);
}
.nav-logo {
  font-family: 'Geologica', sans-serif;
  font-size: 18px; font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text); margin-right: 20px;
}
.nav-logo span { color: var(--accent); }
.nav-link {
  padding: 6px 12px; border-radius: var(--r);
  font-size: 14px; font-weight: 500;
  color: var(--muted); transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-icon { display: inline-flex; align-items: center; margin-right: 5px; opacity: .7; vertical-align: middle; }
.nav-link.active { color: var(--text); }
.nav-spacer { flex: 1; }
.nav-user { display: flex; align-items: center; gap: 10px; }
.nav-avatar-btn {
  width: 34px; height: 34px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer; transition: border-color .15s;
}
.nav-avatar-btn:hover { border-color: var(--accent); }
.nav-name { font-size: 14px; font-weight: 500; color: var(--muted); }

/* ── Nav dropdown ── */
.nav-dropdown { position: relative; }
.nav-dropdown-btn {
  padding: 6px 10px; border-radius: var(--r);
  font-size: 14px; font-weight: 500;
  color: var(--muted); cursor: pointer; background: none; border: none;
  display: flex; align-items: center; gap: 4px;
  transition: color .15s, background .15s; font-family: inherit;
}
.nav-dropdown-btn:hover { color: var(--text); background: var(--surface2); }
.nav-dropdown-btn svg { transition: transform .2s; }
.nav-dropdown.open .nav-dropdown-btn { color: var(--text); background: var(--surface2); }
.nav-dropdown.open .nav-dropdown-btn svg { transform: rotate(180deg); }
.nav-dropdown-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r-lg); padding: 6px;
  min-width: 180px; box-shadow: 0 8px 24px rgba(0,0,0,.15);
  z-index: 200;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block; padding: 8px 12px; border-radius: var(--r);
  font-size: 14px; color: var(--muted);
  transition: color .15s, background .15s;
}
.nav-dropdown-menu a:hover { color: var(--text); background: var(--surface2); }
.nav-dropdown-menu a.active { color: var(--accent); }

/* ── Footer ── */
.site-footer {
  margin-top: 80px; border-top: 1px solid var(--border);
  background: var(--surface); padding: 48px 28px 32px;
}
.footer-inner {
  max-width: 980px; margin: 0 auto;
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px;
}
.footer-brand .nav-logo { font-size: 20px; display: inline-block; margin-bottom: 10px; }
.footer-brand p { font-size: 13px; color: var(--muted); line-height: 1.6; max-width: 220px; }
.footer-col h4 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--label); margin-bottom: 12px; }
.footer-col a { display: block; font-size: 13px; color: var(--muted); padding: 3px 0; transition: color .15s; }
.footer-col a:hover { color: var(--text); }
.footer-bottom {
  max-width: 980px; margin: 32px auto 0;
  border-top: 1px solid var(--border); padding-top: 20px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted); flex-wrap: wrap; gap: 8px;
}
.footer-bottom a { color: var(--muted); }
.footer-bottom a:hover { color: var(--text); }
@media (max-width: 680px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

#theme-toggle {
  width: 34px; height: 34px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer;
  transition: border-color .15s, color .15s;
  margin-right: 6px; flex-shrink: 0;
}
#theme-toggle:hover { border-color: var(--border2); color: var(--text); }

/* ── Layout ── */
.page      { max-width: 980px;  margin: 0 auto; padding: 40px 28px; }
.page-sm   { max-width: 520px;  margin: 0 auto; padding: 40px 28px; }
.page-wide { max-width: 1140px; margin: 0 auto; padding: 40px 28px; }

/* ── Section header ── */
.sec-label {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--label);
  font-weight: 700; margin-bottom: 8px;
}
.sec-title {
  font-family: 'Geologica', sans-serif;
  font-size: 30px; font-weight: 800;
  color: var(--text); line-height: 1.15; margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.sec-sub  { font-size: 15px; color: var(--muted); line-height: 1.7; }
.sec-header { margin-bottom: 28px; }
.sec-header-row {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px; margin-bottom: 28px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px; border-radius: var(--r); border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  letter-spacing: 0.01em; white-space: nowrap; line-height: 1;
}
.btn:hover:not(:disabled)  { opacity: .85; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn-primary {
  background: var(--accent); color: #fff; font-weight: 700;
  border: 1.5px solid transparent;
}
.btn-primary:hover:not(:disabled) {
  opacity: 1; filter: brightness(1.08);
  box-shadow: 0 4px 18px rgba(255,45,107,.4);
}
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border2); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-ghost     { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border2); background: var(--surface2); }

.btn-lg  { padding: 13px 28px; font-size: 15px; border-radius: var(--r); font-weight: 700; }
.btn-sm  { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }

/* ── Form ── */
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-label {
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.form-input, .form-select, .form-textarea {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r); padding: 11px 14px;
  color: var(--text); font-size: 14px;
  transition: border-color .15s, box-shadow .15s; width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245,195,0,.18);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--dim); }
.form-select  { cursor: pointer; appearance: none; }
.form-textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.form-hint { font-size: 12px; color: var(--muted); }

/* toggle switch */
.toggle {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 10px 14px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--r); user-select: none;
}
.toggle input[type=checkbox] { display: none; }
.toggle-track {
  width: 38px; height: 22px; background: var(--dim);
  border-radius: 11px; position: relative; flex-shrink: 0; transition: background .2s;
}
.toggle input:checked + .toggle-track { background: #22c55e; }
.toggle-thumb {
  position: absolute; width: 16px; height: 16px; background: #fff;
  border-radius: 50%; top: 3px; left: 3px; transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked ~ .toggle-thumb { left: 19px; }
.toggle-label { font-size: 14px; font-weight: 500; color: var(--text); }
.toggle-sub   { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ── Alert ── */
.alert { padding: 13px 16px; border-radius: var(--r); font-size: 14px; font-weight: 500; line-height: 1.5; }
.alert-error   { background: #fdf0f0; border: 1px solid #f0a0a0; color: #a01a1a; }
.alert-success { background: #f0fdf7; border: 1px solid #80d8b8; color: #065f46; }
.alert-info    { background: #fdf8e0; border: 1px solid var(--accent-border); color: var(--label); }

html[data-theme="dark"] .alert-error   { background: #200808; border-color: #f0504033; color: #ffaaaa; }
html[data-theme="dark"] .alert-success { background: #071a14; border-color: #1ec99e33; color: #7de8d8; }
html[data-theme="dark"] .alert-info    { background: #2a1020; border-color: #ff2d6b33; color: #ff6090; }

/* ── Quiz grid ── */
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.quiz-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color .2s, box-shadow .2s; box-shadow: var(--shadow);
}
.quiz-card:hover { border-color: var(--border2); box-shadow: var(--shadow-lg); }
.quiz-card-header { display: flex; gap: 10px; align-items: flex-start; }
.quiz-card-title  {
  font-family: 'Geologica', sans-serif;
  font-size: 16px; font-weight: 700; color: var(--text); flex: 1; line-height: 1.25;
}
.quiz-card-meta   { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r-pill); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
.badge-accent { background: var(--accent-bg); border-color: var(--accent-border); color: var(--label); }
.quiz-card-actions { display: flex; gap: 8px; margin-top: auto; }

/* ── Avatar picker ── */
.avatar-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.avatar-opt {
  aspect-ratio: 1; background: var(--surface2); border: 2px solid var(--border);
  border-radius: var(--r); display: flex; align-items: center; justify-content: center;
  font-size: 24px; cursor: pointer; transition: border-color .15s, background .15s;
}
.avatar-opt:hover    { border-color: var(--border2); }
.avatar-opt.selected { border-color: var(--accent); background: var(--accent-bg); }

/* ── Player / Leaderboard rows ── */
.player-list { display: flex; flex-direction: column; gap: 8px; }
.player-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r);
}
.player-avatar-lg { font-size: 22px; width: 36px; text-align: center; flex-shrink: 0; }
.player-name      { font-size: 14px; font-weight: 600; flex: 1; }
.player-score     { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; color: var(--label); }
.player-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: var(--r-pill); background: var(--surface); color: var(--dim); }
.player-online  { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.player-offline { opacity: .35; }

.lb-list { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r);
}
.lb-row.r1 { background: var(--accent-bg); border-color: var(--accent-border); }
.lb-row.r2 { border-color: #aaaaaa28; }
.lb-row.r3 { border-color: #cd7f3228; }
.lb-rank { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; width: 22px; text-align: center; flex-shrink: 0; color: var(--muted); }
.lb-rank.gold   { color: var(--label); }
.lb-rank.silver { color: #888; }
.lb-rank.bronze { color: #c07828; }
.lb-av    { font-size: 20px; flex-shrink: 0; }
.lb-name  { font-size: 14px; font-weight: 600; flex: 1; }
.lb-delta { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--green); }
.lb-score { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; color: var(--label); }
.lb-streak { font-size: 12px; }

/* ── Room code ── */
.room-code {
  font-family: 'JetBrains Mono', monospace; font-size: 36px; font-weight: 700;
  background: var(--accent); color: #fff; padding: 14px 28px; border-radius: var(--r);
  letter-spacing: .25em; display: inline-block; cursor: pointer; user-select: all;
  border: 2px solid transparent;
}

/* ── Answer options ── */
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt-btn {
  padding: 18px 16px; border-radius: var(--r-lg); border: none;
  font-size: 15px; font-weight: 700; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 12px; min-height: 70px; color: #fff;
  transition: transform .1s, opacity .2s, filter .2s; position: relative;
}
.opt-btn:hover:not(:disabled)  { transform: scale(1.02); }
.opt-btn:active:not(:disabled) { transform: scale(.98); }
.opt-btn:disabled { cursor: default; }
.opt-btn .opt-letter {
  width: 30px; height: 30px; border-radius: var(--r); background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 900; flex-shrink: 0;
}
.opt-btn span { flex: 1; }
.opt-0 { background: var(--opt-a); }
.opt-1 { background: var(--opt-b); }
.opt-2 { background: var(--opt-c); }
.opt-3 { background: var(--opt-d); }
.opt-btn.correct { outline: 3px solid #39ff89; }
.opt-btn.wrong   { opacity: .3; filter: grayscale(.5); }
.opt-btn.selected::after { content: '✓'; position: absolute; right: 14px; font-size: 16px; font-weight: 900; }

/* ── Timer bar ── */
.timer-wrap { display: flex; align-items: center; gap: 12px; }
.timer-val  { font-family: 'JetBrains Mono', monospace; font-size: 22px; font-weight: 700; min-width: 40px; }
.timer-bar  { flex: 1; height: 5px; background: var(--border); border-radius: var(--r-pill); overflow: hidden; }
.timer-fill { height: 100%; background: var(--accent); border-radius: var(--r-pill); transition: width 1s linear, background .5s; }
.timer-fill.danger { background: var(--red); }

/* ── Question image ── */
.q-image { width: 100%; max-height: 240px; object-fit: cover; border-radius: var(--r); border: 1px solid var(--border); }

/* ── Team chips ── */
.team-list { display: flex; gap: 8px; flex-wrap: wrap; }
.team-chip { padding: 8px 16px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .15s, transform .1s; border: 2px solid transparent; }
.team-chip.selected { border-color: var(--text); }
.team-chip:hover    { opacity: .85; }

/* ── Divider / Tabs ── */
hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab { padding: 10px 18px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s; }
.tab:hover  { color: var(--text); }
.tab.active { color: var(--label); border-bottom-color: var(--accent); }

/* ── Misc utils ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.flex-row { display: flex; align-items: center; gap: 10px; }
.flex-col { display: flex; flex-direction: column; gap: 10px; }
.gap-sm { gap: 6px; }
.gap-lg { gap: 20px; }
.text-muted  { color: var(--muted); }
.text-accent { color: var(--label); }
.text-sm  { font-size: 13px; }
.text-xs  { font-size: 11px; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.fw-900  { font-weight: 900; }
.uppercase { text-transform: uppercase; letter-spacing: .08em; }

/* ── Animations ── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.fade-up { animation: fadeUp .28s ease; }
@keyframes pop { 0% { transform: scale(.82); opacity: 0; } 60% { transform: scale(1.07); } 100% { transform: scale(1); opacity: 1; } }
.pop { animation: pop .35s ease; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .options-grid { grid-template-columns: 1fr; }
  .avatar-grid  { grid-template-columns: repeat(6, 1fr); }
  .quiz-grid    { grid-template-columns: 1fr; }
  .form-row     { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .room-code    { font-size: 26px; }
  .nav-link     { display: none; }
  .page, .page-sm, .page-wide { padding: 24px 16px; }
}
