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

:root {
  --bg:       #0f1117;
  --bg2:      #1a1d27;
  --bg3:      #242736;
  --border:   #2e3348;
  --accent:   #6c63ff;
  --accent2:  #a78bfa;
  --green:    #22c55e;
  --red:      #ef4444;
  --yellow:   #f59e0b;
  --text:     #e2e8f0;
  --text2:    #94a3b8;
  --radius:   14px;
  --shadow:   0 4px 24px rgba(0,0,0,.4);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px; padding-bottom: 14px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.3rem; }
.logo-icon { font-size: 1.6rem; }
nav { display: flex; align-items: center; gap: 8px; }
.nav-link {
  padding: 7px 16px; border-radius: 8px; font-size: .9rem; font-weight: 500;
  transition: background .2s;
}
.nav-link:hover { background: var(--bg3); }
.btn-nav {
  background: var(--accent); color: #fff;
  padding: 8px 18px; border-radius: 10px; font-weight: 600;
}
.btn-nav:hover { background: #5a54e0; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  color: var(--text2);
  font-size: .85rem;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 22px; border-radius: 10px; font-size: .95rem; font-weight: 600;
  cursor: pointer; border: none; transition: all .2s;
}
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: #5a54e0; transform: translateY(-1px); }
.btn-secondary{ background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover{ background: var(--border); }
.btn-success  { background: var(--green); color: #fff; }
.btn-success:hover  { background: #16a34a; }
.btn-ghost    { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover    { background: var(--bg3); color: var(--text); }
.btn-lg       { padding: 14px 32px; font-size: 1.05rem; border-radius: 12px; }
.hidden       { display: none !important; }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main-content { flex: 1; }

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero {
  padding: 70px 0 50px;
  background: linear-gradient(135deg, var(--bg) 0%, #16112b 100%);
}
.hero .container {
  display: flex; align-items: center; justify-content: space-between;
  gap: 40px; flex-wrap: wrap;
}
.hero-content { flex: 1; min-width: 280px; }
.hero-title {
  font-size: 3rem; font-weight: 800; line-height: 1.15;
  margin-bottom: 18px;
}
.hero-title .accent {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-sub { color: var(--text2); font-size: 1.1rem; margin-bottom: 32px; max-width: 420px; }
.hero-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 28px;
  display: flex; flex-direction: column; align-items: center;
}
.stat-number { font-size: 2.2rem; font-weight: 800; color: var(--accent2); }
.stat-label  { font-size: .8rem; color: var(--text2); margin-top: 2px; }

/* ── Categories ───────────────────────────────────────────────────────────── */
.categories-section { padding: 50px 0; }
.section-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 24px; }
.section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 24px; }
.link-all { color: var(--accent2); font-size: .9rem; }
.link-all:hover { color: var(--accent); }

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.category-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: all .2s;
  text-align: center;
}
.category-card:hover {
  border-color: var(--accent); transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(108,99,255,.25);
}
.all-card { border-color: var(--accent); background: linear-gradient(135deg, #1a1d27, #1e1538); }
.cat-icon  { font-size: 2.4rem; }
.cat-name  { font-weight: 700; font-size: 1rem; }
.cat-desc  { font-size: .8rem; color: var(--text2); }

/* ── Preview Ranking ─────────────────────────────────────────────────────── */
.preview-ranking { padding: 0 0 60px; }
.mini-ranking { display: flex; flex-direction: column; gap: 10px; }
.mini-rank-row {
  display: grid;
  grid-template-columns: 40px 1fr 130px 60px 1fr;
  align-items: center; gap: 12px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 18px;
}
.rank-pos  { font-size: 1.2rem; text-align: center; }
.rank-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-cat  { font-size: .82rem; color: var(--text2); }
.rank-score{ font-weight: 700; color: var(--accent2); text-align: right; }
.rank-bar-wrap { background: var(--bg3); border-radius: 4px; height: 6px; overflow: hidden; }
.rank-bar  { background: var(--accent); height: 100%; border-radius: 4px; transition: width .4s; }

/* ── Quiz ─────────────────────────────────────────────────────────────────── */
.quiz-wrapper { padding: 40px 0 60px; }
.quiz-header { margin-bottom: 30px; }
.quiz-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.quiz-cat-badge {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 14px; font-size: .85rem; font-weight: 600;
}
.quiz-count { color: var(--text2); font-size: .9rem; font-weight: 500; }
.progress-bar-wrap { background: var(--bg3); border-radius: 8px; height: 8px; overflow: hidden; }
.progress-bar {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  height: 100%; border-radius: 8px; transition: width .4s ease;
}

.question-card {
  display: none; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 36px;
  box-shadow: var(--shadow);
}
.question-card.active { display: block; }
.q-number  { font-size: .8rem; color: var(--text2); font-weight: 600; text-transform: uppercase;
              letter-spacing: .05em; margin-bottom: 6px; }
.q-difficulty { margin-bottom: 14px; }
.diff { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; }
.diff.easy   { background: rgba(34,197,94,.15); color: #4ade80; }
.diff.medium { background: rgba(245,158,11,.15); color: #fbbf24; }
.diff.hard   { background: rgba(239,68,68,.15);  color: #f87171; }

.q-text { font-size: 1.25rem; font-weight: 600; line-height: 1.5; margin-bottom: 28px; }

.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.option-label {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg3); border: 2px solid var(--border);
  border-radius: 10px; padding: 14px 18px; cursor: pointer; transition: all .18s;
}
.option-label:hover {
  border-color: var(--accent); background: rgba(108,99,255,.08);
}
.option-label input { display: none; }
.option-label.selected {
  border-color: var(--accent); background: rgba(108,99,255,.18);
}
.option-letter {
  min-width: 32px; height: 32px; border-radius: 8px;
  background: var(--border); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem; flex-shrink: 0;
}
.option-label.selected .option-letter { background: var(--accent); color: #fff; }
.option-text { font-size: .95rem; line-height: 1.4; }

.quiz-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 24px; gap: 12px;
}
.q-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg3); border: 2px solid var(--border);
  transition: all .2s; cursor: default;
}
.dot.answered { background: var(--accent); border-color: var(--accent); }
.dot.active   { border-color: var(--accent2); transform: scale(1.3); }

/* ── Result ───────────────────────────────────────────────────────────────── */
.result-wrapper { padding: 50px 0; }
.result-hero {
  text-align: center; margin-bottom: 36px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 44px 32px;
}
.result-emoji { font-size: 4rem; margin-bottom: 12px; }
.result-title { font-size: 2.4rem; font-weight: 800; margin-bottom: 28px; }
.result-score-wrap { display: flex; align-items: center; justify-content: center; gap: 32px; flex-wrap: wrap; }
.result-score-circle {
  width: 110px; height: 110px; border-radius: 50%;
  border: 4px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  gap: 2px;
}
.score-big   { font-size: 2.8rem; font-weight: 800; color: var(--accent2); }
.score-total { font-size: 1.2rem; color: var(--text2); margin-top: 12px; }
.score-pct-wrap { display: flex; flex-direction: column; gap: 8px; min-width: 200px; }
.score-pct-bar { background: var(--bg3); border-radius: 8px; height: 12px; overflow: hidden; }
.score-pct-fill{ background: linear-gradient(90deg, var(--accent), var(--accent2)); height: 100%; border-radius: 8px; }
.score-pct-label{ font-size: 1rem; font-weight: 600; color: var(--text2); }

.save-score-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 32px; margin-bottom: 36px;
}
.save-score-card h3 { font-size: 1.1rem; margin-bottom: 16px; }
.save-form { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.name-input {
  flex: 1; min-width: 200px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 16px; color: var(--text); font-size: .95rem;
  outline: none;
}
.name-input:focus { border-color: var(--accent); }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.answers-review { margin-top: 10px; }
.answer-card {
  border-radius: var(--radius); padding: 22px 26px; margin-bottom: 14px;
  border-left: 4px solid transparent;
}
.answer-card.correct { background: rgba(34,197,94,.07); border-left-color: var(--green); }
.answer-card.wrong   { background: rgba(239,68,68,.07);  border-left-color: var(--red);   }
.answer-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.answer-num    { font-weight: 700; color: var(--text2); font-size: .85rem; }
.answer-status { font-size: .85rem; font-weight: 700; }
.correct .answer-status { color: var(--green); }
.wrong   .answer-status { color: var(--red);   }
.answer-question { font-weight: 600; margin-bottom: 14px; font-size: 1rem; }
.answer-options-mini { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.opt-mini {
  background: var(--bg3); border-radius: 8px; padding: 6px 12px;
  font-size: .85rem; border: 1px solid var(--border);
}
.opt-correct { background: rgba(34,197,94,.15); border-color: var(--green); color: #4ade80; }
.opt-wrong   { background: rgba(239,68,68,.15);  border-color: var(--red);   color: #f87171; }
.answer-note { font-size: .85rem; color: var(--text2); margin-top: 8px; }

/* ── Ranking ──────────────────────────────────────────────────────────────── */
.ranking-wrapper { padding: 50px 0; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 30px; }
.page-title  { font-size: 2rem; font-weight: 800; }

.stats-bar {
  display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 30px;
}
.stat-pill {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; min-width: 120px;
}
.sp-val { font-size: 1.6rem; font-weight: 800; color: var(--accent2); }
.sp-lbl { font-size: .8rem; color: var(--text2); }

.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.filter-label { color: var(--text2); font-size: .85rem; }
.filter-btn {
  padding: 6px 14px; border-radius: 20px; font-size: .82rem; font-weight: 600;
  background: var(--bg3); border: 1px solid var(--border); transition: all .15s;
}
.filter-btn:hover, .filter-btn.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

.ranking-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.ranking-table { width: 100%; border-collapse: collapse; }
.ranking-table th {
  background: var(--bg3); padding: 12px 16px; text-align: left;
  font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text2);
}
.ranking-table td { padding: 13px 16px; border-top: 1px solid var(--border); font-size: .9rem; }
.ranking-table tr:hover td { background: rgba(255,255,255,.02); }

.top-row.top-1 td { background: rgba(245,158,11,.06); }
.top-row.top-2 td { background: rgba(148,163,184,.04); }
.top-row.top-3 td { background: rgba(180,83,9,.04); }

.col-pos   { font-size: 1.2rem; text-align: center; width: 50px; }
.col-name  { font-weight: 600; }
.col-score { font-size: .9rem; }
.col-date  { color: var(--text2); font-size: .8rem; white-space: nowrap; }
.col-pct   { min-width: 130px; }

.table-bar-wrap {
  display: flex; align-items: center; gap: 8px;
  font-size: .8rem; color: var(--text2);
}
.table-bar-wrap > div { flex: 1; background: var(--bg3); border-radius: 4px; height: 6px; overflow: hidden; }
.table-bar { background: var(--accent); height: 100%; border-radius: 4px; }

.empty-state {
  text-align: center; padding: 70px 20px;
  color: var(--text2); display: flex; flex-direction: column; align-items: center; gap: 20px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .hero-title   { font-size: 2.2rem; }
  .options-grid { grid-template-columns: 1fr; }
  .question-card{ padding: 22px 18px; }
  .mini-rank-row{ grid-template-columns: 36px 1fr 50px; }
  .mini-rank-row .rank-cat, .mini-rank-row .rank-bar-wrap { display: none; }
  .quiz-nav     { flex-wrap: wrap; justify-content: center; }
  .q-dots       { order: -1; justify-content: center; width: 100%; }
}
