:root {
  --orange: #f58220;
  --orange-dark: #d96808;
  --navy: #263149;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f6f7f9;
  --white: #ffffff;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 18px;
  --shadow: 0 14px 35px rgba(31, 41, 55, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
.container { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.hidden { display: none !important; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.screen { animation: fade .2s ease-in; }

.topbar { background: var(--white); border-bottom: 4px solid var(--orange); position: sticky; top: 0; z-index: 50; }
.topbar__inner { min-height: 78px; display: flex; align-items: center; gap: 18px; }
.logo-link { display: inline-flex; align-items: center; text-decoration: none; }
.logo { height: 54px; width: auto; display: block; }
.topbar__text { display: flex; flex-direction: column; line-height: 1.2; }
.topbar__text strong { font-size: 1.1rem; color: var(--navy); }
.topbar__text span { color: var(--muted); font-size: .94rem; }

.app { padding: 28px 0 36px; min-height: calc(100vh - 140px); }
.hero { display: grid; place-items: center; min-height: 68vh; }
.hero__content { padding: clamp(28px, 5vw, 56px); text-align: center; max-width: 790px; }
.eyebrow { color: var(--orange); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; margin: 0 0 10px; }
h1, h2 { color: var(--navy); margin: 0; }
h1 { font-size: clamp(2rem, 6vw, 4rem); line-height: 1; }
.subtitle { color: var(--muted); font-size: 1.15rem; line-height: 1.55; margin: 18px auto 24px; max-width: 650px; }
.hero__meta { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }
.hero__meta span { border: 1px solid var(--line); color: var(--navy); padding: 9px 13px; border-radius: 999px; font-size: .9rem; background: #fbfbfc; }

.btn { border: 0; border-radius: 12px; padding: 14px 20px; font-weight: 700; cursor: pointer; font-size: 1rem; transition: transform .15s ease, opacity .15s ease, background .15s ease, border-color .15s ease; min-height: 48px; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn--large { padding: 17px 28px; font-size: 1.05rem; }
.btn--primary { background: var(--orange); color: var(--white); }
.btn--primary:hover { background: var(--orange-dark); }
.btn--ghost { background: var(--white); color: var(--navy); border: 1px solid var(--line); }

.quiz-header { padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; position: sticky; top: 82px; z-index: 35; }
.quiz-header__progress { min-width: 0; flex: 1; }
.progress-text { font-weight: 800; color: var(--navy); }
.progress-bar { width: 100%; max-width: 620px; height: 9px; background: #edf0f4; border-radius: 999px; margin-top: 9px; overflow: hidden; }
#progressBar { height: 100%; width: 0%; background: var(--orange); border-radius: 999px; transition: width .2s ease; }
.timer { color: var(--muted); white-space: nowrap; padding: 10px 12px; background: #f9fafb; border: 1px solid var(--line); border-radius: 999px; }
.timer strong { color: var(--navy); }

.quiz-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; align-items: start; }
.question-nav { padding: 16px; position: sticky; top: 178px; }
.question-nav strong { display: block; color: var(--navy); margin-bottom: 12px; }
.question-nav small { display: block; color: var(--muted); line-height: 1.4; margin-top: 14px; }
.question-nav__grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.question-dot { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--navy); font-weight: 800; cursor: pointer; }
.question-dot:hover { border-color: var(--orange); }
.question-dot.current { background: var(--orange); color: #fff; border-color: var(--orange); }
.question-dot.answered:not(.current) { background: #fff1e5; border-color: #ffd1ad; color: var(--orange-dark); }

.question-card { padding: clamp(22px, 4vw, 38px); }
.question-card__top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.subject-tag, .answered-status { display: inline-flex; align-items: center; border-radius: 999px; padding: 7px 10px; font-size: .78rem; font-weight: 800; }
.subject-tag { color: var(--orange-dark); background: #fff1e5; }
.answered-status { color: var(--muted); background: #f3f4f6; }
.answered-status.is-answered { color: var(--green); background: #ecfdf5; }
.question-card h2 { font-size: clamp(1.28rem, 2.4vw, 1.85rem); line-height: 1.38; margin-bottom: 22px; }
.options { display: grid; gap: 12px; }
.option { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 17px 16px; cursor: pointer; background: #fff; line-height: 1.45; text-align: left; color: var(--text); display: flex; gap: 12px; align-items: flex-start; }
.option:hover { border-color: var(--orange); background: #fff8f1; }
.option.selected { border-color: var(--orange); background: #fff1e5; box-shadow: inset 4px 0 0 var(--orange); }
.option__key { flex: 0 0 auto; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); color: var(--navy); font-weight: 800; background: #fff; }
.option.selected .option__key { border-color: var(--orange); color: #fff; background: var(--orange); }
.option__text { flex: 1; }
.actions { display: flex; justify-content: space-between; margin-top: 18px; gap: 12px; }
.mobile-actions { display: none; }

.result-card { padding: clamp(24px, 5vw, 44px); text-align: center; margin-bottom: 22px; }
.result-card h2 { font-size: clamp(2.4rem, 8vw, 4.5rem); margin: 8px 0; }
.result-card p { color: var(--muted); }
.result-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.training-section { padding: clamp(22px, 4vw, 34px); }
.training-title { margin-bottom: 18px; }
.training-title h2 { font-size: clamp(1.4rem, 3vw, 2rem); margin-bottom: 8px; }
.training-title p { color: var(--muted); margin: 0; }
.training-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.training-card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; text-decoration: none; color: var(--text); display: flex; flex-direction: column; min-height: 100%; transition: transform .15s ease, border-color .15s ease; }
.training-card:hover { transform: translateY(-2px); border-color: var(--orange); }
.training-card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: #eee; }
.training-card__body { padding: 12px; }
.training-card h3 { color: var(--navy); font-size: .95rem; margin: 0 0 8px; line-height: 1.25; }
.training-card span { color: var(--orange); font-size: .88rem; font-weight: 700; }

.review-top { padding: 20px; display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 16px; }
.review-list { display: grid; gap: 14px; }
.review-item { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.review-item h3 { margin: 0 0 12px; color: var(--navy); line-height: 1.35; }
.review-item p { margin: 8px 0; line-height: 1.45; }
.badge { display: inline-block; color: var(--orange); font-weight: 700; }
.correct { border-left: 5px solid var(--green); }
.wrong { border-left: 5px solid var(--red); }

.footer { padding: 22px 0; background: #101827; color: rgba(255,255,255,.78); text-align: left; font-size: .92rem; }
.footer__inner { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; }
.footer__brand { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.footer__brand a { display: inline-flex; align-items: center; }
.footer__logo { height: 34px; width: auto; display: block; }
.footer__links { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.footer__link { display: inline-flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; }
.footer__link svg { width: 24px; height: 24px; fill: var(--orange); }
.footer__link:hover span { text-decoration: underline; }

@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 980px) {
  .quiz-layout { grid-template-columns: 1fr; }
  .question-nav { position: static; order: 2; }
  .question-nav small { display: none; }
  .question-nav__grid { grid-template-columns: repeat(10, 1fr); }
  .training-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .container { width: min(100% - 22px, 1120px); }
  .topbar__inner { min-height: 66px; gap: 12px; }
  .logo { height: 40px; }
  .topbar__text strong { font-size: .98rem; }
  .topbar__text span { font-size: .82rem; }
  .app { padding: 18px 0 96px; }
  .hero { min-height: calc(100vh - 170px); }
  .hero__content { padding: 26px 18px; }
  .hero__meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .hero__meta span { font-size: .82rem; padding: 8px 9px; }
  .quiz-header { top: 70px; padding: 12px; align-items: stretch; flex-direction: column; gap: 10px; margin-bottom: 12px; border-radius: 14px; }
  .timer { align-self: flex-start; padding: 8px 10px; }
  .question-nav { padding: 12px; border-radius: 14px; }
  .question-nav__grid { grid-template-columns: repeat(10, 1fr); gap: 6px; }
  .question-dot { width: 100%; min-width: 26px; height: 30px; border-radius: 8px; font-size: .82rem; }
  .question-card { padding: 18px 14px; border-radius: 14px; }
  .question-card h2 { font-size: 1.18rem; margin-bottom: 16px; }
  .option { padding: 15px 12px; border-radius: 12px; font-size: .98rem; min-height: 54px; }
  .option__key { width: 26px; height: 26px; }
  .desktop-actions { display: none; }
  .mobile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding: 10px 12px max(10px, env(safe-area-inset-bottom)); z-index: 60; box-shadow: 0 -10px 30px rgba(31,41,55,.08); }
  .mobile-actions .btn { width: 100%; }
  .result-actions, .review-top { flex-direction: column; align-items: stretch; }
  .result-actions .btn, .review-top .btn { width: 100%; }
  .training-grid { grid-template-columns: 1fr; }
  .footer__inner, .footer__brand, .footer__links { flex-direction: column; align-items: flex-start; }
  .footer__link { padding: 6px 0; }
}
