:host {
  display: block;
  container-type: inline-size;
  color-scheme: light;
  --pine: #102922;
  --forest: #194238;
  --cream: #fcf6e8;
  --paper: #fffaf0;
  --gold: #dbb77c;
  --wine: #8b3340;
  --ink: #21372d;
  --muted: #58655b;
  --line: #dcd2bd;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Trebuchet MS', Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

.quiz-shell {
  min-width: 0;
  margin: 0;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: clamp(22px, 5cqw, 48px) clamp(24px, 4cqw, 64px);
  background: radial-gradient(ellipse at 50% 0%, #24473a, var(--pine) 72%);
  color: var(--ink);
  font: 1rem/1.5 var(--sans);
}

.book {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
  width: min(1112px, 100%);
  overflow: hidden;
  border: 1px solid #b79d6b;
  border-radius: 16px;
  box-shadow: 0 24px 64px #06171080;
  background: var(--cream);
}

.cover {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 660px;
  padding: clamp(35px, 5.2cqw, 68px) clamp(30px, 4.2cqw, 53px) 36px;
  color: var(--cream);
  background: #12322a;
}

.cover::before,
.cover::after {
  position: absolute;
  content: '';
  pointer-events: none;
}

.cover::before {
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, #102a23eb 0%, #102a2390 29%, #102a2320 57%, #102a2310 72%, #102a23dd 100%),
    url('victorian-london.webp') center 62% / cover no-repeat,
    radial-gradient(ellipse at 40% 72%, #49614b, #102a23 72%);
}

.cover::after {
  inset: 16px;
  z-index: -1;
  border: 1px solid #dbb77c7d;
  border-radius: 6px;
}

.cover-kicker,
.cover-credit,
.progress-label,
.results-kicker {
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  font-size: .73rem;
}

.cover-kicker { color: #f0cd8f; }
.cover-kicker span { margin-right: .35em; font-size: 1.3em; }
.cover h1 {
  margin: 15px 0 19px;
  font: 400 clamp(2.6rem, 5cqw, 4.65rem)/.99 var(--serif);
  letter-spacing: -.055em;
}
.cover h1 em {
  display: block;
  color: #e9c78d;
  font-size: .73em;
  font-weight: 400;
  margin-top: .13em;
  letter-spacing: -.04em;
}
.cover-rule { display: flex; align-items: center; gap: 9px; color: var(--gold); font-size: .72rem; }
.cover-rule::before,
.cover-rule::after { content: ''; width: 24px; height: 1px; background: currentColor; }
.cover-copy p { max-width: 28ch; margin: 16px 0 0; color: #fff2d9; }
.cover-credit { margin: 0; color: #ffde9e; letter-spacing: .11em; }
.cover-credit span { padding-inline: .35em; }

.pages {
  min-width: 0;
  padding: clamp(34px, 5cqw, 68px) clamp(30px, 4.8cqw, 64px);
  background: radial-gradient(ellipse at top right, #f6ebd5, transparent 60%), var(--cream);
}

.progress-label {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 12px;
  color: var(--forest);
}
#answered { color: var(--muted); letter-spacing: .07em; }
progress {
  display: block;
  width: 100%;
  height: 6px;
  margin: 12px 0 29px;
  overflow: hidden;
  appearance: none;
  border: 0;
  border-radius: 10px;
  background: #e6dbc4;
}
progress::-webkit-progress-bar { background: #e6dbc4; }
progress::-webkit-progress-value { background: #966326; border-radius: 10px; }
progress::-moz-progress-bar { background: #966326; border-radius: 10px; }

h2 {
  margin: 0;
  color: var(--ink);
  font: 400 clamp(1.85rem, 3.25cqw, 2.75rem)/1.12 var(--serif);
  letter-spacing: -.038em;
}
[tabindex="-1"] { scroll-margin-block-start: 16px; }
h2:focus,
h3:focus { outline: none; }

.instructions { margin: 10px 0 23px; color: var(--muted); }
#choices { display: grid; gap: 10px; }

.choice {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffbf3;
  cursor: pointer;
  line-height: 1.35;
}
.choice:hover { border-color: #927d54; }
.choice:has(input:checked) { border-color: #39634c; background: #e8f0e4; box-shadow: inset 0 0 0 1px #39634c; }
.choice:has(input:focus-visible),
.button:focus-visible { outline: 3px solid #996323; outline-offset: 3px; }
.choice input,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.choice-letter {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid #e9ddc4;
  border-radius: 5px;
  background: #f3ead7;
  color: var(--forest);
  font: 700 1rem var(--serif);
}
.choice:has(input:checked) .choice-letter { background: var(--forest); color: white; border-color: var(--forest); }
.choice-text { overflow-wrap: anywhere; }
.choice-mark { width: 17px; height: 17px; border: 1px solid #877d66; border-radius: 50%; }
.choice:has(input:checked) .choice-mark { border: 5px solid var(--forest); background: white; }

.actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 25px;
}
.actions { padding-top: 19px; border-top: 1px solid var(--line); }
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  font: 700 .94rem/1.2 var(--sans);
  text-align: center;
  cursor: pointer;
}
.button.primary { background: var(--wine); color: #fffaf0; }
.button.primary:hover:enabled { background: #6e2532; }
.button.secondary { background: transparent; color: var(--forest); border-color: #9eac98; }
.button.secondary:hover:enabled { background: #e9efdf; }
.button:disabled { cursor: default; }
.button.primary:disabled { background: #eddcdf; color: #61464c; }
.button.secondary:disabled { border-color: #ded5c2; color: #6b6d5e; }

.results-kicker { margin-bottom: 16px; color: var(--wine); }
.score-panel {
  margin-top: 25px;
  padding: 18px 22px;
  border: 1px solid #ddc7a0;
  border-radius: 9px;
  background: #f3e8d0;
}
.score { margin: 0 0 8px; color: var(--wine); font: 400 3.8rem/1 var(--serif); }
.score-total { color: var(--muted); font-size: .5em; }
#message { margin: 0; }
#review { margin-top: 32px; }
#review-heading { margin: 0; font: 400 1.8rem/1.2 var(--serif); }
#review-list { margin: 15px 0 25px; padding-left: 25px; }
#review-list li { padding: 14px 0 14px 4px; border-top: 1px solid var(--line); }
#review-list li::marker { color: var(--forest); font-weight: 700; }
#review-list h4 { margin: 0 0 6px; font: 700 1.08rem/1.3 var(--serif); }
#review-list p { margin: 4px 0; font-size: .94rem; }
.correct { color: #23613e; font-weight: 700; }
.incorrect { color: #8b3340; font-weight: 700; }
.explanation { color: var(--muted); }

@container (max-width: 900px) {
  .cover { min-height: 610px; }
}

@container (max-width: 700px) {
  .quiz-shell { padding: 14px; }
  .book { grid-template-columns: minmax(0, 1fr); border-radius: 12px; }
  .cover { min-height: 0; padding: 24px 24px 26px; }
  .cover::before {
    background:
      linear-gradient(90deg, #102a23f5 4%, #102a23d0 42%, #102a2333 100%),
      url('victorian-london.webp') center 60% / cover no-repeat,
      #12322a;
  }
  .cover::after { inset: 9px; }
  .cover h1 { font-size: clamp(2rem, 8cqw, 3rem); line-height: 1; margin: 8px 0; }
  .cover h1 br { display: none; }
  .cover h1 em { display: inline; font-size: .82em; }
  .cover-rule, .cover-credit { display: none; }
  .cover-copy p { max-width: 34ch; margin-top: 10px; font-size: .92rem; }
  .pages { padding: 24px clamp(17px, 4cqw, 27px) 26px; }
  progress { margin: 10px 0 20px; }
  .instructions { margin: 8px 0 15px; }
  #choices { gap: 8px; }
  .choice { gap: 10px; min-height: 52px; padding: 8px 10px; }
  .actions { margin-top: 16px; padding-top: 14px; }
}

@container (max-width: 360px) {
  .button { font-size: .86rem; padding-inline: 10px; }
}

@container (min-width: 701px) {
  .book:has(#review:not([hidden])) { background: linear-gradient(90deg, #12322a 41%, var(--cream) 41%); }
  .book:has(#review:not([hidden])) .cover { align-self: start; }
}
