:root {
  --ink: #171717;
  --muted: #6f6a62;
  --paper: #f3f1eb;
  --line: #e4dfd6;
  --lime: #c6f04a;
  --red: #ff4d4d;
  --white: #fff;
  --shadow: 0 1px 0 rgba(23, 23, 23, 0.04), 0 18px 50px rgba(48, 36, 12, 0.06);
  --radius: 16px;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100dvh;
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

button:focus-visible,
label:focus-within {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.noscript {
  max-width: 40rem;
  margin: 4rem auto;
  padding: 0 1.5rem;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Intro and results */

.sheet {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.card {
  width: min(640px, 100%);
  background: var(--white);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 42px 40px 36px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 48px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 650;
}

.lead {
  margin: 16px 0 0;
  font-size: 17px;
  line-height: 1.5;
  color: #3c3832;
}

.wave {
  display: block;
  width: 100%;
  height: 72px;
  margin: 22px 0 4px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.btn {
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 16px;
  font-weight: 600;
  border: 2.5px solid var(--ink);
  background: var(--white);
}

.btn:hover { background: #f6f4ef; }

.btn-primary {
  background: var(--ink);
  color: var(--white);
}

.btn-primary:hover { background: #000; }

.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding-inline: 12px;
}

.btn-quiet:hover { color: var(--ink); background: transparent; }

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

kbd {
  font-family: inherit;
  font-weight: 650;
  border: 1.5px solid #d9d3c8;
  border-bottom-width: 2.5px;
  border-radius: 7px;
  padding: 1px 6px;
  background: #fff;
  color: var(--ink);
}

.resume {
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f7f6f1;
  color: #3c3832;
  font-size: 14px;
}

.score-wrap { text-align: center; }

.score-num {
  margin: 8px 0 0;
  font-size: 104px;
  line-height: 0.86;
  letter-spacing: -0.06em;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.score-of {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.stats {
  margin: 28px 0 0;
  display: grid;
  gap: 10px;
}

.stat {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  font-size: 18px;
}

.stat b {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #3c3832;
  font-size: 14px;
}

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--ink);
  margin-right: 6px;
  vertical-align: -2px;
}

.swatch.ok { background: var(--lime); }
.swatch.bad { background: var(--red); }

/* Exam */

.scorer {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 6px 6px 8px;
  gap: 6px;
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 28px;
  padding: 0 6px;
}

.brand {
  border: 0;
  background: transparent;
  padding: 0;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand:hover { color: #000; }

.top-mid {
  margin: 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 15px;
}

.top-side {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 12px;
}

.meter {
  height: 3px;
  background: #e3ded4;
  border-radius: 99px;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--ink);
  border-radius: inherit;
}

.frame {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.frame img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 150px);
  margin: 0 auto;
  object-fit: contain;
  background: var(--white);
  cursor: zoom-in;
}

.img-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
}

.zoom-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 1;
  border: 1.5px solid var(--ink);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 650;
}

.zoom-btn:hover { background: var(--white); }

.dock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--paper);
  padding: 6px 4px 2px;
}

.jumps {
  width: 100%;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scroll-padding-inline: 24px;
}

.jumps::-webkit-scrollbar { height: 8px; }
.jumps::-webkit-scrollbar-thumb { background: #d7d1c6; border-radius: 99px; }

.jump {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1.5px solid var(--ink);
  background: var(--white);
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  padding: 0;
}

.jump.is-filled { background: var(--ink); color: var(--white); }
.jump.is-right { background: var(--lime); color: var(--ink); }
.jump.is-miss { background: var(--red); color: var(--ink); }
.jump.is-current { outline: 3px solid var(--ink); outline-offset: 1px; }

.choices {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nav, .stage {
  height: 50px;
  border-radius: 14px;
}

.nav {
  width: 48px;
  border: 0;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
}

.nav:hover:not(:disabled) { background: rgba(23, 23, 23, 0.06); }

.nav:disabled {
  opacity: 0.28;
  cursor: default;
}

.stage {
  min-width: 68px;
  padding: 0 14px;
  border: 2.5px solid var(--ink);
  background: var(--white);
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.stage:hover:not(.is-on):not(.is-correct):not(.is-wrong) { background: #f6f4ef; }

.stage.is-on,
.stage.is-correct { background: var(--lime); }

.stage.is-wrong { background: var(--red); }

.scorer[data-mode="review"] .stage { cursor: default; }

.finish { min-width: 240px; }

.subrow {
  min-height: 0;
  width: min(920px, 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.verdict {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.verdict .ok { color: #3d6b00; }
.verdict .bad { color: #b42318; }

.only-wrong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #3c3832;
  cursor: pointer;
}

/* Zoom */

.zoom {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(16, 13, 10, 0.9);
  display: none;
  flex-direction: column;
}

.zoom.open { display: flex; }

.zoom-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  color: white;
}

.zoom-bar button {
  border: 1.5px solid white;
  background: transparent;
  color: white;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 650;
}

.zoom-bar button:hover { background: white; color: var(--ink); }

.zoom-scroll {
  flex: 1;
  overflow: auto;
  padding: 0 16px 24px;
}

.zoom-scroll img {
  display: block;
  margin: 0 auto;
  background: white;
  max-width: none;
  height: auto;
}

/* Dialog */

dialog {
  border: 0;
  border-radius: 22px;
  padding: 28px;
  width: min(440px, calc(100% - 32px));
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(20, 16, 10, 0.48); }

dialog h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.03em;
}

dialog p { margin: 10px 0 0; line-height: 1.45; }

dialog .actions { margin-top: 22px; }

@media (max-width: 720px) {
  .card { padding: 28px 20px 22px; }
  .scorer { padding: 10px 10px 12px; }
  .hint { display: none; }
  .top { gap: 8px; }
  .brand,
  .top-mid,
  .top-side,
  .btn-quiet { white-space: nowrap; }
  .brand { font-size: 13px; }
  .top-mid { font-size: 14px; }
  .top-side { gap: 6px; }
  .btn-quiet { padding-inline: 4px; font-size: 13px; }
  .choices { flex-wrap: nowrap; gap: 6px; width: 100%; }
  .stage {
    min-width: 0;
    flex: 1 1 0;
    max-width: 68px;
    height: 48px;
    padding: 0;
    font-size: 16px;
  }
  .nav { width: 36px; height: 48px; flex: 0 0 auto; }
  .score-num { font-size: 80px; }
  .subrow { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
