:root {
  --navy: #072f69;
  --navy-dark: #041f47;
  --blue: #1889e8;
  --sky: #e8f5ff;
  --yellow: #ffc928;
  --yellow-soft: #fff5c9;
  --green: #16895a;
  --green-soft: #e5f8ed;
  --red: #d93838;
  --red-soft: #fff0ed;
  --purple: #7047c8;
  --purple-soft: #f1ebff;
  --ink: #14213d;
  --muted: #5d6b82;
  --paper: #fffdf8;
  --line: #dce6f2;
  --shadow: 0 18px 50px rgba(7, 47, 105, .12);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 10%, rgba(255, 201, 40, .18), transparent 24rem),
    radial-gradient(circle at 95% 20%, rgba(24, 137, 232, .12), transparent 28rem),
    #f7f9fc;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, .option:focus-visible {
  outline: 3px solid rgba(24, 137, 232, .35);
  outline-offset: 3px;
}

.top-notice {
  display: flex;
  justify-content: center;
  gap: .55rem;
  padding: .72rem 1rem;
  color: white;
  background: var(--navy-dark);
  font-size: .9rem;
  font-weight: 700;
  text-align: center;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  padding: 2.2rem 1rem 1.7rem;
  color: white;
  background: linear-gradient(135deg, var(--navy-dark), var(--navy) 72%, #0a4d95);
  border-bottom: 7px solid var(--yellow);
}

.hero h1 { margin: .15rem 0; font-size: clamp(1.75rem, 4vw, 2.7rem); line-height: 1.05; }
.hero p { margin: 0; color: #dcecff; }
.brand-mark { font-size: 3rem; filter: drop-shadow(0 6px 12px rgba(0,0,0,.2)); }
.eyebrow { margin: 0; color: var(--yellow) !important; font-size: .78rem; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }

.shell { width: min(1180px, calc(100% - 2rem)); margin: 2rem auto 3rem; }
.welcome-card, .dashboard, .question-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow);
}

.welcome-card { max-width: 820px; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem); text-align: center; }
.welcome-card h2 { margin: .7rem 0; color: var(--navy); font-size: clamp(1.7rem, 4vw, 2.4rem); }
.welcome-card > p { max-width: 650px; margin: 0 auto 1.8rem; color: var(--muted); line-height: 1.65; }
.level-label { display: inline-block; padding: .45rem .8rem; border-radius: 999px; color: var(--navy); background: var(--yellow); font-weight: 900; font-size: .8rem; text-transform: uppercase; }

.name-form { max-width: 620px; margin: 0 auto 2rem; text-align: left; }
.name-form label { display: block; margin-bottom: .55rem; color: var(--navy); font-weight: 800; }
.input-row { display: flex; gap: .65rem; }
.input-row input { flex: 1; min-width: 0; padding: .9rem 1rem; border: 2px solid var(--line); border-radius: 12px; background: white; }
.input-row input:focus { border-color: var(--blue); }
.resume-hint { margin: .65rem 0 0; color: var(--green); font-size: .9rem; font-weight: 700; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.info-grid article { padding: 1rem; border-radius: 16px; background: var(--sky); }
.info-grid article:nth-child(2) { background: var(--green-soft); }
.info-grid article:nth-child(3) { background: var(--purple-soft); }
.info-grid strong, .info-grid span { display: block; }
.info-grid strong { color: var(--navy); font-size: 1.08rem; }
.info-grid span { margin-top: .25rem; color: var(--muted); font-size: .84rem; line-height: 1.35; }

.quiz-layout { display: grid; grid-template-columns: 315px minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.dashboard { position: sticky; top: 1rem; padding: 1.2rem; }
.student-block { display: flex; align-items: center; gap: .8rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.student-block small, .student-block strong { display: block; }
.student-block small { color: var(--muted); }
.student-block strong { color: var(--navy); font-size: 1.1rem; overflow-wrap: anywhere; }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--yellow-soft); font-size: 1.35rem; }
.dashboard h2 { margin: 1.15rem 0 .7rem; color: var(--navy); font-size: 1rem; }
.progress-track { height: 11px; overflow: hidden; border-radius: 999px; background: #e7edf5; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--yellow), #ff9d23); transition: width .25s ease; }
.progress-text { margin: .45rem 0 1rem; color: var(--muted); font-size: .84rem; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.stat-card { padding: .85rem; border-radius: 14px; text-align: center; background: var(--sky); }
.stat-card:nth-child(2) { background: var(--red-soft); }
.stat-card.wide { grid-column: 1 / -1; background: var(--yellow-soft); }
.stat-card span, .stat-card small { display: block; }
.stat-card span { color: var(--navy); font-size: 1.45rem; font-weight: 900; }
.stat-card small { color: var(--muted); }

.level-legend { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0; }
.chip { display: inline-flex; align-items: center; padding: .35rem .65rem; border-radius: 999px; font-size: .75rem; font-weight: 900; text-transform: uppercase; }
.chip.easy { color: #075e3d; background: var(--green-soft); }
.chip.medium { color: #725500; background: var(--yellow-soft); }
.chip.hard { color: #8b2525; background: var(--red-soft); }

.question-navigator { display: grid; grid-template-columns: repeat(5, 1fr); gap: .38rem; }
.question-navigator button { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 10px; color: var(--navy); background: #f5f8fc; font-size: .78rem; font-weight: 800; }
.question-navigator button.current { color: white; border-color: var(--navy); background: var(--navy); }
.question-navigator button.correct { color: white; border-color: var(--green); background: var(--green); }
.question-navigator button.wrong { color: white; border-color: var(--red); background: var(--red); }

.storage-note { margin-top: 1rem; padding: .9rem; border-left: 4px solid var(--blue); border-radius: 10px; background: var(--sky); }
.storage-note strong { color: var(--navy); }
.storage-note p { margin: .3rem 0 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.text-button { width: 100%; margin-top: .75rem; border: 0; color: var(--red); background: transparent; font-size: .82rem; font-weight: 800; }

.question-panel { min-height: 640px; padding: clamp(1.3rem, 4vw, 2.4rem); }
.question-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; color: var(--muted); font-size: .82rem; }
.question-meta #mapReference { margin-left: auto; }
.question-panel h2 { margin: 1.25rem 0; color: var(--navy); font-size: clamp(1.35rem, 3vw, 1.9rem); line-height: 1.3; }
.options-list { display: grid; gap: .75rem; }
.option { display: flex; align-items: center; gap: .8rem; width: 100%; padding: 1rem; border: 2px solid var(--line); border-radius: 15px; color: var(--ink); background: white; text-align: left; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.option:hover:not(:disabled) { transform: translateY(-2px); border-color: #9dccf5; background: #f8fcff; }
.option .letter { display: grid; flex: 0 0 34px; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--navy); background: var(--sky); font-weight: 900; }
.option.selected { border-color: var(--blue); background: var(--sky); }
.option.correct { border-color: var(--green); background: var(--green-soft); }
.option.wrong { border-color: var(--red); background: var(--red-soft); }
.option:disabled { cursor: default; opacity: 1; }

.feedback { margin-top: 1rem; padding: 1rem 1.1rem; border-radius: 14px; line-height: 1.55; }
.feedback.correct { color: #075e3d; border: 1px solid #99d6b4; background: var(--green-soft); }
.feedback.wrong { color: #862c2c; border: 1px solid #efb3ac; background: var(--red-soft); }
.feedback strong { display: block; margin-bottom: .2rem; }
.question-actions { display: flex; justify-content: space-between; gap: .7rem; margin-top: 1.4rem; }

.primary-button, .secondary-button, .danger-button { min-height: 46px; padding: .78rem 1.15rem; border-radius: 12px; font-weight: 900; }
.primary-button { border: 0; color: white; background: var(--navy); box-shadow: 0 8px 20px rgba(7,47,105,.18); }
.primary-button:hover:not(:disabled) { background: #0a468d; }
.primary-button:disabled { cursor: not-allowed; opacity: .45; }
.secondary-button { color: var(--navy); border: 2px solid var(--line); background: white; }
.danger-button { color: white; border: 0; background: var(--red); }

.summary { max-width: 680px; margin: 0 auto; text-align: center; }
.summary-icon { font-size: 3.4rem; }
.summary h2 { margin: .45rem 0; }
.summary > p { color: var(--muted); line-height: 1.55; }
.summary-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: 1.3rem 0; }
.summary-stats article { padding: 1rem; border-radius: 14px; background: var(--sky); }
.summary-stats strong, .summary-stats span { display: block; }
.summary-stats strong { color: var(--navy); font-size: 1.5rem; }
.summary-stats span { color: var(--muted); font-size: .78rem; }
.level-results { display: grid; gap: .65rem; margin-bottom: 1.2rem; text-align: left; }
.level-result { display: grid; grid-template-columns: 80px 1fr auto; align-items: center; gap: .7rem; padding: .8rem; border-radius: 12px; background: #f6f8fb; }
.mini-track { height: 8px; overflow: hidden; border-radius: 999px; background: #dfe7f1; }
.mini-track span { display: block; height: 100%; background: var(--blue); }

footer { padding: 1.6rem 1rem 2.5rem; color: var(--muted); text-align: center; font-size: .82rem; }
footer p { margin: .3rem 0; }
footer strong { color: var(--navy); }

dialog { width: min(430px, calc(100% - 2rem)); padding: 1.4rem; border: 0; border-radius: 18px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(4, 31, 71, .58); }
dialog h2 { margin-top: 0; color: var(--navy); }
dialog p { color: var(--muted); line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .65rem; margin-top: 1rem; }

[hidden] { display: none !important; }

@media (max-width: 860px) {
  .quiz-layout { grid-template-columns: 1fr; }
  .dashboard { position: static; }
  .question-navigator { grid-template-columns: repeat(10, 1fr); }
}

@media (max-width: 600px) {
  .shell { width: min(100% - 1rem, 1180px); margin-top: 1rem; }
  .hero { justify-content: flex-start; }
  .brand-mark { font-size: 2.2rem; }
  .input-row, .question-actions { flex-direction: column; }
  .input-row button, .question-actions button { width: 100%; }
  .info-grid { grid-template-columns: 1fr; }
  .question-navigator { grid-template-columns: repeat(5, 1fr); }
  .question-meta #mapReference { width: 100%; margin-left: 0; }
  .summary-stats { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
