@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg: #f8fafc;
  --bg2: #ffffff;
  --bg3: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text2: #64748b;
  --accent: #0d9488;
  --accent2: #0f766e;
  --gold: #d97706;
  --green: #16a34a;
  --red: #dc2626;
  --pink: #db2777;
  --cyan: #0891b2;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.07);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

h1, h2, h3, .brand { font-family: 'Space Grotesk', sans-serif; }

/* NAV */
.nav {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  padding: 0 2rem;
  display: flex; align-items: center; gap: 1rem;
  height: 60px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.nav .brand { font-size: 1.2rem; font-weight: 800; color: var(--accent); text-decoration: none; letter-spacing: -0.5px; }
.nav .brand span, .auth-title span { color: var(--gold); }
.nav-links { display: flex; gap: 0.25rem; margin-left: auto; align-items: center; }
.nav-links a {
  color: var(--text2); text-decoration: none; padding: 0.4rem 0.85rem;
  border-radius: 8px; font-size: 0.9rem; font-weight: 500; transition: all 0.15s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--bg3); }
.nav-links a.btn-nav {
  background: var(--accent); color: #fff; margin-left: 0.5rem;
}
.nav-links a.btn-nav:hover { background: var(--accent2); }
.avatar-circle {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; font-family: 'Space Grotesk', sans-serif;
  flex-shrink: 0;
}

/* LAYOUT */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.5px; }
.page-header p { color: var(--text2); margin-top: 0.4rem; }

/* CARDS */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(13,148,136,0.12); }
.card-link { text-decoration: none; color: inherit; display: block; }
.card-link:hover .card { transform: translateY(-2px); }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* STAT CARDS */
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.stat-icon { font-size: 2rem; }
.stat-value { font-size: 1.75rem; font-weight: 800; font-family: 'Space Grotesk', sans-serif; }
.stat-label { font-size: 0.8rem; color: var(--text2); margin-top: 0.1rem; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1.25rem; border-radius: 8px;
  font-size: 0.9rem; font-weight: 600; font-family: 'DM Sans', sans-serif;
  cursor: pointer; border: none; text-decoration: none;
  transition: all 0.15s; line-height: 1;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(13,148,136,0.3); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: rgba(220,38,38,0.08); color: var(--red); border: 1px solid rgba(220,38,38,0.25); }
.btn-danger:hover { background: rgba(220,38,38,0.15); }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn-success { background: rgba(22,163,74,0.08); color: var(--green); border: 1px solid rgba(22,163,74,0.25); }
.btn-success:hover { background: rgba(22,163,74,0.15); }

/* FORMS */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text2); margin-bottom: 0.4rem; font-weight: 500; }
.form-control {
  width: 100%; padding: 0.65rem 0.9rem;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,148,136,0.1); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control option { background: var(--bg2); }

/* BADGES */
.badge {
  display: inline-block; padding: 0.2rem 0.6rem;
  border-radius: 20px; font-size: 0.75rem; font-weight: 600;
}
.badge-purple { background: rgba(13,148,136,0.12); color: var(--accent); }
.badge-gold { background: rgba(217,119,6,0.12); color: var(--gold); }
.badge-green { background: rgba(22,163,74,0.12); color: var(--green); }
.badge-red { background: rgba(220,38,38,0.12); color: var(--red); }
.badge-gray { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }

/* TROPHY */
.trophy-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  text-align: center; transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.trophy-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.trophy-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.trophy-name { font-weight: 700; font-size: 0.95rem; }
.trophy-desc { font-size: 0.8rem; color: var(--text2); margin-top: 0.25rem; }

/* TABLE */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text2); padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; vertical-align: middle; }
.table tr:hover td { background: var(--bg3); }
.table-wrap { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }

/* QUIZ TAKE */
.question-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem;
  display: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.question-card.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.option-label {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1rem; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; margin-bottom: 0.6rem;
  transition: all 0.15s; background: var(--bg2);
}
.option-label:hover { border-color: var(--accent); background: rgba(13,148,136,0.04); }
.option-label input[type=radio] { display: none; }
.option-label.selected { border-color: var(--accent); background: rgba(13,148,136,0.08); }
.option-key {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--bg3); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}
.progress-bar { height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; margin-bottom: 1.5rem; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; }

/* RESULT */
.result-circle {
  width: 140px; height: 140px; border-radius: 50%;
  border: 4px solid var(--accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  margin: 0 auto 2rem;
  font-family: 'Space Grotesk', sans-serif;
}
.result-pct { font-size: 2.5rem; font-weight: 800; }
.answer-row { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.answer-row:last-child { border-bottom: none; }

/* AUTH */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--bg); }
.auth-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); }
.auth-title { font-size: 1.75rem; font-weight: 800; margin-bottom: 0.25rem; }
.auth-sub { color: var(--text2); font-size: 0.9rem; margin-bottom: 2rem; }

/* ALERT */
.alert { padding: 0.85rem 1rem; border-radius: 8px; font-size: 0.9rem; margin-bottom: 1.25rem; }
.alert-error { background: rgba(220,38,38,0.06); border: 1px solid rgba(220,38,38,0.2); color: var(--red); }
.alert-success { background: rgba(22,163,74,0.06); border: 1px solid rgba(22,163,74,0.2); color: var(--green); }

/* MISC */
.text-muted { color: var(--text2); }
.text-gold { color: var(--gold); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-accent { color: var(--accent); }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; } .items-center { align-items: center; }
.gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; }
.ml-auto { margin-left: auto; }
.font-bold { font-weight: 700; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* TOPIC CHIP */
.topic-chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.7rem; background: rgba(13,148,136,0.1); color: var(--accent); border-radius: 20px; font-size: 0.8rem; font-weight: 600; }

/* LEADERBOARD */
.rank-1 { color: var(--gold); }
.rank-2 { color: #94a3b8; }
.rank-3 { color: #b45309; }
.rank-badge { font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 1.1rem; width: 36px; text-align: center; }

/* NEW TROPHY ANIMATION */
.trophy-popup { animation: popIn 0.5s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes popIn { from { opacity:0; transform: scale(0.5) rotate(-10deg); } to { opacity:1; transform: scale(1) rotate(0); } }

.shimmer { background: linear-gradient(90deg, var(--bg2) 25%, var(--bg3) 50%, var(--bg2) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

@media (max-width: 768px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .nav { padding: 0 1rem; }
  .container { padding: 1.25rem 1rem; }
}

/* Item pick cards */
.item-pick-card {
  user-select: none;
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  display: block;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.item-pick-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(13,148,136,0.15);
}
.item-pick-card.selected {
  border-color: var(--accent);
  background: rgba(13,148,136,0.06);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.2), 0 8px 24px rgba(13,148,136,0.12);
  transform: translateY(-4px);
}
.item-pick-card.selected .item-emoji {
  filter: drop-shadow(0 0 10px rgba(13,148,136,0.5));
  transform: scale(1.15);
  display: inline-block;
  transition: all 0.2s;
}

/* Checkmark badge — hidden by default, shown when selected */
.item-check {
  display: none;
  position: absolute;
  top: 10px; right: 10px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  align-items: center;
  justify-content: center;
}
.item-pick-card.selected .item-check {
  display: flex;
}

/* ── Item font: IBM Plex Mono — full unicode coverage, clean and readable ── */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* Text-based item rows (pick screen) */
.item-pick-row {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.75rem 1.1rem;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-left: 3px solid #94a3b8;
  border-radius: 8px; cursor: pointer;
  transition: all 0.15s; position: relative;
  user-select: none;
}
.item-pick-row:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(13,148,136,0.03);
}
.item-pick-row.selected {
  border-color: var(--accent);
  border-left-color: var(--accent);
  border-left-width: 4px;
  background: rgba(13,148,136,0.06);
  box-shadow: 0 0 0 2px rgba(13,148,136,0.15);
}
.item-row-check {
  display: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 0.72rem; font-weight: 800;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.item-pick-row.selected .item-row-check { display: flex; }
.item-row-str {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.88rem;
  color: var(--text);
  letter-spacing: 0.01em;
}

/* Collection display rows */
.item-str-row {
  padding: 0.6rem 1.1rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid #94a3b8;
  border-radius: 8px;
  animation: fadeIn 0.3s ease both;
  transition: border-color 0.15s;
}
.item-str-row:hover {
  border-left-color: var(--accent);
}
.item-str-row code {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--text);
  letter-spacing: 0.01em;
  background: none;
}

/* ── Modals ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 2rem 1.75rem;
  width: 100%; max-width: 440px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.15);
  animation: popIn 0.2s cubic-bezier(0.34,1.4,0.64,1);
}

/* Inline code pill for item strings inside modals / alerts */
.item-inline {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  word-break: break-all;
}

/* ── Lecture item pick cards ─────────────────────────────── */
.lecture-item-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.1rem;
  background: var(--bg2);
  border: 2px solid var(--border);
  border-left: 4px solid #94a3b8;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  position: relative;
}
.lecture-item-card:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(13,148,136,0.03);
}
.lecture-item-card.selected {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(13,148,136,0.06);
  box-shadow: 0 0 0 2px rgba(13,148,136,0.15);
}
.lecture-check {
  display: none;
  position: absolute; top: 8px; right: 10px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 0.72rem; font-weight: 800;
  align-items: center; justify-content: center;
}
.lecture-item-card.selected .lecture-check { display: flex; }
