@font-face {
  font-family: "Year Display";
  src: url('assets/barlow-condensed-800-latin.woff2') format('woff2');
  font-weight: 800;
  font-display: swap;
}

@font-face {
  font-family: "Year Sans";
  src: url('assets/dm-sans-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --page: #ebe6de;
  --paper: #fffcf5;
  --ink: #251f29;
  --muted: #635866;
  --line: #c5b9c4;
  --accent: #673888;
  --tint: #f0e6f5;
  --button: #512b68;
  --button-ink: #fff9ff;
  --gold: #85500b;
  --focus: #8642a7;
  --err: #94273a;
  --cover: #35243f;
  --cover-line: #64516c;
  --cover-ink: #fff8ef;
  --cover-accent: #f6cb80;
  --plate: #ac87ba;
  --plate-line: #d9c2df;
  --display: "Year Display", "Arial Narrow", sans-serif;
  --dial: url("data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%20240%20240%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20fill%3D%22none%22%20stroke%3D%22black%22%3E%3Ccircle%20cx%3D%22120%22%20cy%3D%22120%22%20r%3D%22111%22%20stroke-width%3D%222%22%2F%3E%3Ccircle%20cx%3D%22120%22%20cy%3D%22120%22%20r%3D%22102%22%2F%3E%3Ccircle%20cx%3D%22120%22%20cy%3D%22120%22%20r%3D%2284%22%2F%3E%3Ccircle%20cx%3D%22120%22%20cy%3D%22120%22%20r%3D%2277%22%20stroke-dasharray%3D%221%207.06%22%20stroke-width%3D%223%22%2F%3E%3Cpath%20d%3D%22M120%209v18m0%20186v18M9%20120h18m186%200h18m-34-77-12%2012M55%20185l-12%2012M43%2043l12%2012m130%20130%2012%2012%22%20stroke-width%3D%223%22%2F%3E%3Cpath%20d%3D%22m65%20151%2055-31%2019-65%22%20stroke-width%3D%223%22%2F%3E%3Ccircle%20cx%3D%22120%22%20cy%3D%22120%22%20r%3D%225%22%2F%3E%3C%2Fsvg%3E");
  --divisions: url("data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2040%209%22%20width%3D%2240%22%20height%3D%229%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M.5%200v9m8-9v4m8-4v4m8-4v4m8-4v4%22%20stroke%3D%22black%22%20fill%3D%22none%22%2F%3E%3C%2Fsvg%3E");
  color-scheme: light;
}

html[data-theme="dark"], body[data-theme="dark"] {
  --page: #19171c;
  --paper: #28232b;
  --ink: #fbf3e9;
  --muted: #c9bdcc;
  --line: #645869;
  --accent: #dfb4ef;
  --tint: #3b3042;
  --button: #d9b1e9;
  --button-ink: #271a30;
  --gold: #f5ca83;
  --focus: #efcaff;
  --err: #ffacb6;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font: 1rem/1.5 "Year Sans", system-ui, sans-serif;
}
button, input { font: inherit; }
button, summary { cursor: pointer; }
button, input, a { touch-action: manipulation; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1:focus-visible, h2:focus-visible, h3:focus-visible { outline-offset: 1px; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 {
  font-family: var(--display);
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -.012em;
  text-wrap: balance;
}
h2 { font-size: clamp(2rem, 5vw, 3.5rem); }
h3 { font-size: clamp(1.65rem, 4vw, 2.4rem); }

.shell {
  width: min(100%, 58rem);
  margin: auto;
  padding: 0 clamp(.75rem, 4vw, 2.25rem) 2rem;
}
.mast {
  isolation: isolate;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .62rem 0;
  color: #fff7ed;
}
.mast::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 calc(50% - 50vw);
  background: #26212a;
  border-bottom: 3px solid #ad88ba;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  color: #fff7ed;
  text-decoration: none;
}
.brand img { display: block; }
.related-playtests {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--line);
}
.related-playtests span { color: var(--muted); font-weight: 650; }
.related-playtests a { display: inline-flex; align-items: center; min-height: 44px; }
.brand .brand-star { width: 2.52rem; height: 2.52rem; }
.brand img:not(.brand-star) { width: clamp(6.5rem, 18vw, 8rem); height: auto; filter: invert(1); }
.brand-mode {
  padding-left: .6rem;
  margin-left: .1rem;
  border-left: 1px solid #897391;
  color: var(--cover-accent);
  font: 800 1.26rem/1 var(--display);
  letter-spacing: .025em;
  text-transform: uppercase;
}
body[data-screen="setup"] .brand-mode { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  white-space: nowrap;
}
#theme {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .35rem .7rem;
  border: 1px solid #76697a;
  border-radius: 2px;
  color: #fff7ed;
  background: #332d35;
  font-size: .86rem;
  font-weight: 650;
}
.mast :focus-visible { outline-color: #f3d2fc; }
.paper { margin-top: clamp(.8rem, 2.5vw, 1.55rem); }
.intro {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  min-height: clamp(12.25rem, 24vw, 15rem);
  border: 2px solid #312338;
  border-bottom-width: 5px;
  background: var(--cover);
  color: var(--cover-ink);
}
.intro::before,
.portrait::before {
  content: "";
  position: absolute;
  pointer-events: none;
  aspect-ratio: 1;
  mask: var(--dial) center / contain no-repeat;
}
.intro::before {
  z-index: -1;
  left: 29%;
  top: 50%;
  width: 47%;
  transform: translateY(-50%) rotate(-20deg);
  background: var(--cover-line);
}
.copy {
  align-self: center;
  min-width: 0;
  padding: clamp(1.25rem, 4vw, 2.3rem);
  padding-right: .25rem;
}
h1 {
  text-transform: uppercase;
  color: var(--cover-ink);
  font-size: clamp(3.6rem, 8.3vw, 6.15rem);
  line-height: .85;
  letter-spacing: -.025em;
}
h1 em { font-style: normal; color: var(--cover-accent); }
.lede {
  max-width: 36ch;
  margin-top: 1.05rem;
  color: var(--cover-ink);
  font-weight: 550;
  line-height: 1.4;
  text-wrap: pretty;
}
.portrait {
  position: relative;
  isolation: isolate;
  align-self: stretch;
  overflow: hidden;
  min-width: 0;
  margin: 0;
  background: var(--plate);
  clip-path: polygon(14% 0, 100% 0, 100% 100%, 0 100%);
}
.portrait::before {
  width: 125%;
  left: -7%;
  top: 44%;
  transform: translateY(-50%) rotate(20deg);
  background: var(--plate-line);
}
.portrait::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 9px;
  background: #37273e;
  mask: var(--divisions) left bottom / 40px 9px repeat-x;
  pointer-events: none;
}
.portrait img {
  display: block;
  position: absolute;
  top: 3%;
  left: 12%;
  width: 86%;
  height: auto;
  pointer-events: none;
}

#start, #round, #results {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  padding: clamp(1rem, 3.5vw, 2rem);
}
#start { margin-top: clamp(.75rem, 2vw, 1.15rem); }
.parts { min-width: 0; padding: 0; margin: 0 0 1.2rem; border: 0; }
.parts legend {
  padding: 0;
  font: 800 clamp(1.45rem, 3.3vw, 2rem)/1.12 var(--display);
}
.note, .hint, .scoring { color: var(--muted); font-size: .9rem; }
.parts .note { margin: .32rem 0 .85rem; }
.choices { display: flex; flex-wrap: wrap; gap: .45rem; }
.choices label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  min-height: 44px;
  padding: .35rem .72rem;
  border: 1px solid var(--line);
  cursor: pointer;
}
.choices label:has(input:checked) {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--tint);
}
.choices label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.choices input { flex: none; width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent); }
.choices input:focus-visible { outline: 0; }
.choices span { font-size: .94rem; font-weight: 700; }
.scoring { margin-top: .6rem; }
.scoring summary { width: fit-content; min-height: 44px; padding: .6rem 0; color: var(--accent); }
.scoring p { max-width: 55ch; }
button.primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .65rem;
  min-height: 46px;
  padding: .62rem 1.08rem;
  border: 1px solid var(--button);
  border-radius: 2px;
  background: var(--button);
  color: var(--button-ink);
  font-weight: 750;
  line-height: 1.25;
}
button.primary:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
button.primary:active:not(:disabled) { translate: 0 1px; }
.round-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .3rem .8rem;
  padding-bottom: .65rem;
  border-bottom: 1px solid var(--line);
  color: var(--accent);
  font-size: .79rem;
  font-weight: 800;
  letter-spacing: .055em;
  text-transform: uppercase;
}
#round-no { color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-numbers { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .8rem; }
#run-score { color: var(--ink); font-variant-numeric: tabular-nums; }
.round-progress {
  display: flex;
  list-style: none;
  gap: 3px;
  margin: -2px 0 0;
  padding: 0;
}
.round-progress li { flex: 1; height: 4px; background: var(--line); }
.round-progress li[data-state="done"] { background: var(--accent); }
.round-progress li[data-state="current"] { background: var(--gold); }
.event-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(6rem, 24%, 11.25rem);
  align-items: center;
  gap: clamp(.8rem, 3.2vw, 2rem);
  margin: 1rem 0 1.15rem;
}
.event-block > div { min-width: 0; }
.event-block h2 { font-size: clamp(1.9rem, 4.7vw, 3.18rem); line-height: 1.03; }
.event-block .portrait { min-height: 7.3rem; border-bottom: 3px solid #775b83; }
.event-block .portrait img { top: 1%; }
#guess-form { padding-top: .7rem; border-top: 1px solid var(--line); }
#guess-form > label { display: block; margin-bottom: .4rem; font-weight: 750; }
.year-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: stretch; }
.year-row #year {
  min-width: 0;
  width: 8ch;
  max-width: 100%;
  height: 3.15rem;
  padding: .18rem .55rem;
  border: 2px solid var(--accent);
  border-radius: 1px;
  background: var(--tint);
  color: var(--ink);
  font: 800 2rem/1 var(--display);
  letter-spacing: .055em;
  font-variant-numeric: tabular-nums;
}
.year-row #year::placeholder { color: var(--muted); opacity: .88; }
.year-row #year[aria-invalid="true"] { border-color: var(--err); }
#validation, #setup-error { color: var(--err); font-weight: 650; margin-top: .4rem; }
#validation:empty, #setup-error:empty { display: none; }
#reveal {
  border-top: 2px solid var(--accent);
  padding-top: .95rem;
}
#actual {
  width: fit-content;
  max-width: 100%;
  font-size: clamp(2.2rem, 5vw, 3.25rem);
  font-variant-numeric: tabular-nums;
}
#actual:focus-visible {
  outline: 0;
  text-decoration: underline;
  text-decoration-color: var(--focus);
  text-decoration-thickness: 2px;
  text-underline-offset: .09em;
}
#reveal > p:first-of-type { margin-top: .45rem; }
#points { color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }
.ruler {
  position: relative;
  height: 2.05rem;
  margin: .85rem .4rem .08rem;
}
.ruler::before, .ruler::after {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
}
.ruler::before { height: 2px; background: var(--muted); }
.ruler::after {
  height: 7px;
  background: var(--line);
  mask: var(--divisions) left top / 40px 9px repeat-x;
}
.tick { position: absolute; top: calc(50% - 4px); height: 11px; border-left: 1px solid var(--muted); }
.gap-line { position: absolute; z-index: 1; top: calc(50% - 1px); height: 4px; background: var(--gold); }
.marker {
  position: absolute;
  z-index: 1;
  top: calc(50% + 1px);
  display: block;
  height: .85rem;
  width: .85rem;
  transform: translate(-50%, -50%);
}
.marker.guessed { background: var(--paper); border: 2px solid var(--gold); border-radius: 50%; }
.marker.correct { background: var(--accent); transform: translate(-50%, -50%) rotate(45deg); }
.year-key {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .25rem .85rem;
  color: var(--muted);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}
.key-actual { color: var(--accent); }
.key-guess { color: var(--gold); }
#why { margin: .9rem 0 .25rem; max-width: 63ch; }
.sources { display: flex; flex-wrap: wrap; gap: .15rem 1rem; margin: .1rem 0 .8rem; font-size: .9rem; }
.sources a { display: inline-flex; align-items: center; min-height: 44px; }
.reveal-actions { display: flex; align-items: start; flex-wrap: wrap; gap: .3rem 1.25rem; margin-top: 1rem; }
.source-notes { min-width: 0; }
.source-notes summary { display: list-item; width: fit-content; padding: .64rem 0; min-height: 44px; color: var(--accent); font-size: .9rem; font-weight: 650; }
.source-notes .sources { display: grid; gap: 0; margin: 0; }
.source-notes .sources a { width: fit-content; }
#results::after {
  content: "";
  position: absolute;
  top: clamp(1rem, 3.5vw, 2rem);
  right: clamp(1rem, 3.5vw, 2rem);
  width: clamp(2.9rem, 8vw, 5.3rem);
  aspect-ratio: 1;
  background: var(--line);
  mask: var(--dial) center / contain no-repeat;
  pointer-events: none;
}
#results-title, #score-total { padding-right: clamp(3.5rem, 10vw, 6.4rem); }
#score-total { margin: .5rem 0 1rem; color: var(--accent); }
#history { list-style: none; margin: 1rem 0 1.2rem; padding: 0; }
#history li {
  position: relative;
  margin-left: .35rem;
  border-left: 2px solid var(--line);
  padding: .25rem 0 .95rem 1.2rem;
}
#history li::before {
  content: "";
  position: absolute;
  top: .64rem;
  left: -.32rem;
  width: .55rem;
  height: .55rem;
  transform: rotate(45deg);
  background: var(--accent);
}
#history li:last-child { border-left-color: transparent; padding-bottom: .1rem; }
#history small { color: var(--muted); }
#history strong { font-weight: 800; color: var(--accent); }

@media (max-width: 560px) {
  .mast { padding: .45rem 0; }
  .brand .brand-star { width: 2.25rem; height: 2.25rem; }
  .brand-mode { font-size: 1rem; padding-left: .42rem; margin-left: 0; }
  .intro { grid-template-columns: minmax(0, 1.58fr) minmax(0, 1fr); min-height: 11.75rem; }
  .copy { padding: 1.05rem .2rem 1.05rem .9rem; }
  h1 { font-size: clamp(2.8rem, 11.6vw, 4.1rem); }
  .lede { font-size: .92rem; line-height: 1.36; margin-top: .65rem; }
  .intro .portrait img { width: 120%; left: -4%; top: 4%; }
  .event-block { grid-template-columns: minmax(0, 1fr) clamp(4.65rem, 21vw, 6.4rem); gap: .8rem; }
  .event-block .portrait { min-height: 5.65rem; }
  .event-block h2 { font-size: clamp(1.6rem, 6.1vw, 2.05rem); }
  .choices { gap: .35rem; }
  .choices label { padding: .3rem .51rem; }
  .round-meta { font-size: .72rem; }
  .year-key { font-size: .82rem; }
}

@media (max-width: 360px) {
  .mast { gap: .4rem; }
  .brand .brand-star { width: 1.95rem; height: 1.95rem; }
  .brand img:not(.brand-star) { width: 5.75rem; }
  .brand-mode { font-size: .94rem; }
  #theme { padding-inline: .5rem; white-space: nowrap; font-size: .8rem; }
}

:root[data-text-size="large"] { font-size: 112.5%; }
.intro:has(.portrait[hidden]), .event-block:has(.portrait[hidden]) { grid-template-columns: 1fr; }

@media (prefers-reduced-motion: no-preference) {
  .event-block.entering { animation: page-in 160ms ease-out; }
  #setup:not([hidden]) .intro,
  #results:not([hidden]) {
    animation: page-in 170ms ease-out;
  }
  #guess-form:not([hidden]), #reveal:not([hidden]) {
    animation: page-in 160ms ease-out;
  }
  #round[data-phase="reveal"] .gap-line { animation: mark-distance 220ms ease-out; }
  @keyframes mark-distance {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
  }
  @keyframes page-in {
    from { opacity: .82; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
  }
}


/* The setup reads like a printed chronology. Keep dates for the reveal. */
html[data-quiz] { --panel:var(--paper); --bg:var(--page); }
html[data-quiz] .shell .intro h1 { font:800 clamp(3.5rem,8vw,6.2rem)/.86 var(--display); margin:0; }
html[data-quiz] .shell .intro { margin:0; }
html[data-quiz] .paper { margin-top:0; }
#setup .intro::after {
  content:""; position:absolute; inset:auto 0 0; height:8px;
  background:var(--cover-accent); mask:var(--divisions) left bottom / 40px 9px repeat-x;
  pointer-events:none;
}
.choices { display:grid; grid-template-columns:repeat(auto-fit,minmax(124px,1fr)); gap:.5rem; }
.choices label { align-items:flex-start; padding:.7rem .55rem; border-bottom-width:3px; }
.choices input { margin-top:.25rem; }
.choices label span { display:block; line-height:1.25; }
.choices small { display:block; margin-top:.23rem; font-weight:500; color:var(--muted); font-size:.79rem; }
#start::after, #round::before {
  content:""; position:absolute; inset:0 auto 0 0; width:5px; pointer-events:none;
  background:var(--accent); mask:var(--divisions) left top / 32px 8px repeat-y;
}
#history li::before {border-radius:50%;outline:2px solid var(--paper)}
@media(min-width:1050px) {
  html[data-quiz] body::before, html[data-quiz] body::after {
    content:""; position:fixed; z-index:-1; width:min(32vw,500px); aspect-ratio:1;
    mask:var(--dial) center / contain no-repeat; background:var(--line); pointer-events:none;
  }
  html[data-quiz] body::before {top:10rem;left:-19vw;transform:rotate(-17deg)}
  html[data-quiz] body::after {bottom:-10rem;right:-15vw;transform:rotate(48deg)}
}
@media(max-width:560px) {
  html[data-quiz] .shell .intro h1 {font-size:clamp(2.65rem,11.4vw,4rem)}
  .choices { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .choices label { padding:.45rem .55rem; }
}
html[data-decoration=reduced] body::before, html[data-decoration=reduced] body::after {display:none}
