:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #1f2a44;
  --muted: #6b7896;
  --brand: #3b5bdb;
  --brand-dark: #2f49b0;
  --accent: #f59f00;
  --correct: #2f9e44;
  --correct-bg: #ebfbee;
  --border: #e3e8f2;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(31, 42, 68, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.wrap { max-width: 860px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--brand), #5c7cfa);
  color: #fff;
  padding: 28px 0;
  box-shadow: var(--shadow);
}
.site-header h1 { margin: 6px 0; font-size: 1.7rem; }
.site-header .tagline { margin: 0; opacity: 0.9; }
.back { color: #dbe4ff; text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.back:hover { text-decoration: underline; }

main.wrap { padding-top: 28px; padding-bottom: 60px; }
h2 { font-size: 1.3rem; }

/* About / olympiad-info section */
.about { margin-bottom: 36px; }
.about-lede { color: var(--muted); max-width: 640px; margin: 0 0 18px; }
.olympiad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.olympiad-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.olympiad-card.is-soon { opacity: 0.75; background: #f7f9fc; box-shadow: none; }
.olympiad-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.olympiad-card h3 { margin: 0 0 6px; font-size: 1rem; }
.olympiad-card p { margin: 0; color: var(--muted); font-size: 0.88rem; }

/* Grade cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.grade-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 16px; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease;
}
.grade-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(31,42,68,.14); }
.grade-num {
  font-size: 2.4rem; font-weight: 800; color: var(--brand);
  background: #edf2ff; width: 68px; height: 68px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
}
.grade-label { font-weight: 600; color: var(--muted); }

/* Active (available) grade — make it clearly stand out */
a.grade-card { border: 2px solid var(--brand); }
a.grade-card .grade-num { background: var(--brand); color: #fff; }
a.grade-card .grade-label { color: var(--brand-dark); }
.grade-ready {
  margin-top: 10px; font-size: 0.68rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--correct); background: var(--correct-bg);
  padding: 3px 10px; border-radius: 999px;
}

/* "Coming soon" grades (not yet available) — clearly muted */
.grade-card.is-soon {
  opacity: 0.65; cursor: not-allowed; background: #f7f9fc;
  border: 1px dashed #cfd6e4; box-shadow: none;
}
.grade-card.is-soon:hover { transform: none; box-shadow: none; }
.grade-card.is-soon .grade-num { background: #eef1f6; color: #aab3c6; }
.grade-card.is-soon .grade-label { color: #aab3c6; }
.soon-badge {
  margin-top: 10px; font-size: 0.68rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: #93a0b8; background: #eef1f6;
  padding: 3px 10px; border-radius: 999px;
}

/* Paper list */
.paper-list { display: grid; gap: 14px; }
.paper-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.paper-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(31,42,68,.14); }
.paper-card h3 { margin: 8px 0 6px; }
.paper-meta { color: var(--muted); font-size: 0.9rem; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.paper-badges { display: flex; gap: 8px; }
.paper-actions { display: flex; gap: 10px; margin-top: 14px; }
.paper-actions .btn { text-decoration: none; display: inline-block; }
.paper-actions .btn:first-child { background: var(--brand); color: #fff; }
.paper-actions .btn:first-child:hover { background: var(--brand-dark); }

.badge {
  display: inline-block; background: #edf2ff; color: var(--brand-dark);
  font-size: 0.72rem; font-weight: 700; letter-spacing: .03em;
  padding: 3px 9px; border-radius: 999px; text-transform: uppercase;
}
.badge-year { background: #fff3bf; color: #9c6a00; }

.paper-card.is-soon {
  opacity: 0.65; cursor: not-allowed; background: #f7f9fc;
  border: 1px dashed #cfd6e4; box-shadow: none;
}
.paper-card.is-soon:hover { transform: none; box-shadow: none; }
.paper-card.is-soon .badge, .paper-card.is-soon .badge-year { background: #eef1f6; color: #aab3c6; }

.empty { color: var(--muted); padding: 30px 0; }

/* Instructions */
.instructions {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 22px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.instructions h2 { margin-top: 6px; font-size: 1.05rem; }
.instructions ul { margin: 0; padding-left: 20px; color: var(--muted); }

/* Toolbar */
.toolbar { margin: 6px 0 20px; }
.btn {
  background: var(--brand); color: #fff; border: none; border-radius: 10px;
  padding: 10px 16px; font-weight: 600; cursor: pointer; font-size: 0.92rem;
}
.btn:hover { background: var(--brand-dark); }
.btn-small { padding: 6px 12px; font-size: 0.82rem; background: #edf2ff; color: var(--brand-dark); }
.btn-small:hover { background: #dbe4ff; }

/* Sections & questions */
.section-head { border-bottom: 2px solid var(--border); margin: 26px 0 16px; }
.section-head h2 { margin-bottom: 2px; }
.section-desc { margin: 0 0 10px; color: var(--muted); font-size: 0.9rem; }

.question {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.question.revealed { border-color: #b2c2ff; }
.q-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.q-num {
  background: var(--brand); color: #fff; font-weight: 800; border-radius: 8px;
  min-width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px;
}
.q-tags { display: flex; gap: 6px; }
.tag {
  font-size: 0.7rem; color: var(--muted); background: #f1f4fa; border-radius: 6px;
  padding: 2px 8px; text-transform: capitalize;
}
.tag-diff { background: #fff3bf; color: #9c6a00; }

.q-text { white-space: pre-wrap; font-size: 1.02rem; margin: 6px 0 12px; }
.q-image { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; display: block; margin: 10px 0; }
.q-note { font-size: 0.82rem; color: var(--muted); font-style: italic; margin: 4px 0 10px; }

.options { margin: 10px 0; padding: 0; display: grid; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; background: #fbfcfe; cursor: pointer;
  transition: border-color .1s ease, background .1s ease;
}
.option:hover { border-color: #b2c2ff; }
.opt-radio { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--brand); cursor: pointer; }
.opt-label {
  font-weight: 700; color: var(--brand-dark); background: #edf2ff; border-radius: 6px;
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.opt-image { max-height: 110px; width: auto; }
/* Currently selected choice */
.option:has(.opt-radio:checked) { border-color: var(--brand); background: #edf2ff; }

/* Numeric answer input */
.int-answer { margin: 10px 0; }
.int-input {
  font-size: 1.05rem; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 10px; width: 220px; max-width: 100%; background: #fbfcfe;
}
.int-input:focus { outline: none; border-color: var(--brand); background: #fff; }
.int-input:disabled { background: #f1f4fa; color: var(--ink); }

/* Correct / wrong highlights after grading or in study mode */
.option.correct-opt { border-color: var(--correct); background: var(--correct-bg); }
.option.correct-opt .opt-label { background: var(--correct); color: #fff; }
.option.chosen-wrong { border-color: #e03131; background: #fff0f0; }
.option.chosen-wrong .opt-label { background: #e03131; color: #fff; }

.question.correct { border-color: var(--correct); }
.question.wrong { border-color: #ffc9c9; }
.question.correct .int-input { border-color: var(--correct); background: var(--correct-bg); }
.question.wrong .int-input { border-color: #e03131; background: #fff0f0; }

/* Per-question result badge */
.q-result { font-size: 0.72rem; font-weight: 800; border-radius: 6px; padding: 2px 8px; }
.q-result.is-ok { background: var(--correct); color: #fff; }
.q-result.is-bad { background: #e03131; color: #fff; }
.q-result.is-skip { background: #ced4da; color: #212529; }

/* Toolbar / mode hint */
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.mode-hint { color: var(--muted); font-size: 0.85rem; margin-left: 10px; }
.exam-timer {
  font-weight: 700; font-size: 0.9rem; color: var(--brand-dark);
  background: #edf2ff; padding: 6px 12px; border-radius: 999px;
}
.exam-timer.time-low { color: #fff; background: #e03131; }

/* Sticky action bar */
.action-bar {
  position: sticky; bottom: 0; display: flex; gap: 12px; justify-content: center;
  padding: 14px; margin: 20px -20px 0; background: rgba(244,247,251,.92);
  backdrop-filter: blur(4px); border-top: 1px solid var(--border);
}
.btn-secondary { background: #edf2ff; color: var(--brand-dark); }
.btn-secondary:hover { background: #dbe4ff; }

/* Results panel */
.results {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 24px; box-shadow: var(--shadow); margin-top: 20px;
}
.results h2 { margin-top: 4px; }
.score-row { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; }
.score-big { font-size: 2.6rem; font-weight: 800; color: var(--brand); }
.score-max { font-size: 1.2rem; color: var(--muted); font-weight: 600; margin-left: 6px; }
.score-breakdown { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.score-breakdown li { color: var(--ink); }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; }
.dot-correct { background: var(--correct); }
.dot-wrong { background: #e03131; }
.dot-skip { background: #ced4da; }
.results-note { color: var(--muted); font-size: 0.9rem; margin-bottom: 0; }

.q-answer { margin-top: 12px; }
.answer-box {
  margin-top: 10px; padding: 12px 16px; background: var(--correct-bg);
  border: 1px solid #c3e6cb; border-radius: 10px;
}
.answer-line { margin: 0 0 6px; }
.answer-line strong { color: var(--correct); }
.solution { margin: 0; color: #2b3a2e; white-space: pre-wrap; font-size: 0.94rem; }

/* Report a problem */
.report-wrap { margin-top: 12px; }
.report-link {
  font-size: 0.78rem; color: var(--muted); text-decoration: underline; cursor: pointer;
}
.report-link:hover { color: var(--brand-dark); }
.report-box {
  margin-top: 10px; padding: 14px 16px; background: #f7f9fc;
  border: 1px solid var(--border); border-radius: 10px;
}
.report-field { display: block; margin-bottom: 10px; font-size: 0.85rem; color: var(--ink); }
.report-field span { display: block; margin-bottom: 4px; color: var(--muted); font-weight: 600; }
.report-field select, .report-field textarea, .report-field input {
  width: 100%; font-size: 0.9rem; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; font-family: inherit;
}
.report-field select:focus, .report-field textarea:focus, .report-field input:focus {
  outline: none; border-color: var(--brand);
}
.report-field textarea { resize: vertical; }
.report-actions { display: flex; align-items: center; gap: 12px; }
.report-error { color: #e03131; font-size: 0.8rem; }
.report-thanks { margin: 0; color: var(--correct); font-size: 0.88rem; font-weight: 600; }

/* Footer */
.site-footer { color: var(--muted); text-align: center; padding: 24px 0; font-size: 0.85rem; }

@media (max-width: 560px) {
  .site-header h1 { font-size: 1.35rem; }
  .question { padding: 16px; }
}
