:root {
  color-scheme: light;
  --ink: #26180c;
  --muted: #715f4f;
  --green: #0dd206;
  --green-dark: #087f04;
  --green-pale: #efffee;
  --brown: #7b3d02;
  --brown-dark: #4d2601;
  --brown-pale: #f7eee5;
  --blue: var(--green);
  --blue-bright: var(--green-dark);
  --blue-pale: var(--green-pale);
  --paper: #ffffff;
  --panel: #ffffff;
  --line: #ddcbb9;
  --gold: var(--brown);
  --danger: #a6291e;
  --typewriter: "American Typewriter", "Courier Prime", "Courier New", Courier, monospace;
  --shadow: 0 16px 44px rgba(16, 42, 56, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 280px;
  background: var(--paper);
}

body {
  margin: 0;
  min-width: 280px;
  min-height: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.quiz-app {
  width: 100%;
  padding: clamp(10px, 2.2vw, 22px) clamp(8px, 2vw, 16px);
}

.quiz-shell {
  width: min(100%, 740px);
  margin: 0 auto;
}

.quiz-header {
  width: min(100%, 720px);
  margin: 0 auto clamp(12px, 2vw, 20px);
  text-align: center;
}

.eyebrow,
.question-kicker,
.detail-label,
.reveal-label,
.year-readout-label {
  margin: 0;
  color: var(--blue-bright);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  line-height: 1.3;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 5px 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.15rem, 6.5vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.92;
}

.quiz-intro {
  max-width: 590px;
  margin: 9px auto 0;
  color: var(--muted);
  font-size: clamp(0.88rem, 1.8vw, 1rem);
  line-height: 1.4;
}

.status-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 120px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: #f7fafb;
  text-align: center;
}

.status-card.is-error {
  color: var(--danger);
}

.status-spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid rgba(13, 210, 6, 0.16);
  border-top-color: var(--blue-bright);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.status-card.is-error .status-spinner {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.question-meta {
  display: grid;
  grid-template-columns: max-content minmax(80px, 1fr);
  align-items: center;
  gap: 16px;
  margin: 0 2px 8px;
}

.question-progress {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.progress-track {
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1e9ec;
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2388ad, var(--blue-bright));
  transition: width 350ms ease;
}

.question-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: clamp(15px, 2vw, 22px);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.photo-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: auto;
  min-height: 470px;
  margin: 0;
  padding: clamp(10px, 2.5vw, 20px);
  overflow: hidden;
  background: var(--brown-pale);
  transition: min-height 220ms ease, padding 220ms ease;
}

.photo-frame:not(.is-loading) {
  min-height: 0;
}

.question-image {
  display: block;
  width: min(100%, 360px);
  max-width: 100%;
  height: auto;
  aspect-ratio: 500 / 647;
  object-fit: contain;
  animation: image-in 450ms ease both;
}

.quiz-content.has-reveal .photo-frame {
  display: none;
}

@keyframes image-in {
  from { opacity: 0; transform: scale(1.015); }
  to { opacity: 1; transform: scale(1); }
}

.photo-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(78, 200, 231, 0.08), transparent 45%),
    var(--brown-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.photo-placeholder-mark {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  place-items: center;
  border: 1px solid rgba(140, 231, 246, 0.35);
  border-radius: 50%;
  color: var(--blue-bright);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  letter-spacing: 0.05em;
}

.question-body {
  padding: clamp(15px, 3vw, 28px);
}

.question-body h2 {
  max-width: 720px;
  margin: 0 0 2px;
  color: var(--green-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.25rem, 3.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.1;
  text-align: center;
}

.answer-panel {
  display: grid;
  gap: 10px;
}

.year-readout {
  display: grid;
  justify-items: center;
  gap: 0;
  padding: 2px 20px 5px;
  border: 0;
  border-radius: 16px;
  background: transparent;
}

#year-output {
  color: var(--ink);
  font-family: var(--typewriter);
  font-size: clamp(2.5rem, 8vw, 3.8rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.065em;
  line-height: 1;
}

.year-readout.is-ticking #year-output {
  animation: typewriter-tick 115ms ease-out;
}

.year-readout.is-decade #year-output {
  animation: typewriter-decade 160ms ease-out;
}

@keyframes typewriter-tick {
  0% { opacity: 0.55; transform: translateY(-2px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes typewriter-decade {
  0% { opacity: 0.45; transform: translateY(-3px) scale(1.025); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.year-scrubber {
  --tick-width: clamp(38px, 7vw, 50px);
  position: relative;
  width: 100%;
  height: 76px;
  overflow: hidden;
  border-block: 1px solid var(--line);
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}

.year-scrubber.is-dragging {
  cursor: grabbing;
}

.year-scrubber.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.year-scrubber:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

.fixed-playhead {
  position: absolute;
  z-index: 3;
  top: 0;
  bottom: 9px;
  left: 50%;
  width: 2px;
  background: var(--blue-bright);
  transform: translateX(-1px);
  pointer-events: none;
}

.fixed-playhead::before {
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: 0;
  border-top: 9px solid var(--blue-bright);
  border-right: 7px solid transparent;
  border-left: 7px solid transparent;
  content: "";
  transform: translateX(-50%);
}

.timeline-ticks {
  position: absolute;
  top: 17px;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(15, var(--tick-width));
  width: max-content;
  transform: translateX(-50%);
}

.timeline-ticks.shift-left {
  animation: ruler-left 120ms ease-out;
}

.timeline-ticks.shift-right {
  animation: ruler-right 120ms ease-out;
}

@keyframes ruler-left {
  from { transform: translateX(calc(-50% + 5px)); }
  to { transform: translateX(-50%); }
}

@keyframes ruler-right {
  from { transform: translateX(calc(-50% - 5px)); }
  to { transform: translateX(-50%); }
}

.timeline-tick {
  position: relative;
  display: grid;
  justify-items: center;
  height: 50px;
  color: #74818a;
  font-family: var(--typewriter);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.timeline-tick::before {
  width: 1px;
  height: 15px;
  margin-top: 15px;
  background: #93a4ac;
  content: "";
}

.timeline-tick::after {
  position: absolute;
  top: 22px;
  right: 0;
  left: 0;
  height: 1px;
  background: #aebcc2;
  content: "";
}

.timeline-tick.is-five::before {
  height: 23px;
  margin-top: 7px;
  background: #52636c;
}

.timeline-tick.is-decade {
  color: var(--ink);
  font-weight: 700;
}

.timeline-tick.is-current::before {
  width: 3px;
  height: 27px;
  margin-top: 1px;
  background: var(--blue-bright);
}

.timeline-label {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  background: var(--paper);
  line-height: 1;
}

.scrubber-help {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
  text-align: center;
}

.year-control {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.step-button {
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue-bright);
  background: var(--paper);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.step-button:first-child {
  justify-self: start;
}

.step-button:last-child {
  justify-self: end;
}

.step-button:hover:not(:disabled) {
  border-color: var(--blue-bright);
  background: var(--blue-pale);
  transform: translateY(-1px);
}

.step-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.range-limits {
  display: flex;
  gap: 5px;
  color: var(--muted);
  font-family: var(--typewriter);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  padding: 11px 20px;
  border: 1px solid var(--green-dark);
  border-radius: 999px;
  color: #ffffff;
  background: var(--green-dark);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.primary-button:hover:not(:disabled) {
  background: #066403;
  box-shadow: 0 9px 25px rgba(8, 127, 4, 0.2);
  transform: translateY(-1px);
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.primary-button:focus-visible,
.step-button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

.reveal {
  display: grid;
  gap: 11px;
  padding-top: 4px;
  animation: reveal-in 320ms ease both;
}

.reveal-summary {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: start;
  gap: clamp(15px, 3vw, 25px);
}

.reveal-summary.has-no-thumbnail {
  grid-template-columns: 1fr;
}

.reveal-thumbnail {
  display: block;
  grid-row: 1 / span 2;
  width: auto;
  max-width: 140px;
  height: 180px;
  aspect-ratio: 500 / 647;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 8px 22px rgba(77, 38, 1, 0.14);
}

.reveal-result-copy {
  min-width: 0;
}

@keyframes reveal-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.correct-year {
  margin: 2px 0 0;
  color: var(--ink);
  font-family: var(--typewriter);
  font-size: clamp(3.4rem, 14vw, 6rem);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.065em;
  line-height: 0.9;
}

.answer-comparison {
  margin: 2px 0 0;
  color: var(--gold);
  font-size: clamp(1.3rem, 4.5vw, 2.15rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.15;
  text-transform: uppercase;
}

.answer-explanation {
  grid-column: 2;
  margin: 9px 0 0;
  color: #3f3328;
  font-size: 0.96rem;
  line-height: 1.48;
}

.answer-comparison.is-bullseye {
  color: var(--green-dark);
  animation: bullseye-pop 480ms cubic-bezier(0.18, 0.85, 0.32, 1.3) both;
}

.answer-comparison.is-near {
  color: var(--brown);
}

@keyframes bullseye-pop {
  0% { opacity: 0; transform: scale(0.72) rotate(-2deg); }
  70% { opacity: 1; transform: scale(1.06) rotate(1deg); }
  100% { transform: scale(1) rotate(0); }
}

.result-timeline {
  --guess-position: 50%;
  --actual-position: 50%;
  position: relative;
  height: 86px;
  margin: 0 8px 3px;
}

.result-line {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 2px;
  background: var(--line);
}

.result-marker {
  position: absolute;
  left: 50%;
  display: grid;
  justify-items: center;
  color: var(--muted);
  font-family: var(--typewriter);
  font-variant-numeric: tabular-nums;
  transform: translateX(-50%);
}

.result-marker::after {
  width: 2px;
  height: 28px;
  background: currentColor;
  content: "";
}

.guess-marker {
  top: 0;
  left: var(--guess-position);
}

.actual-marker {
  bottom: 0;
  left: var(--actual-position);
  color: var(--blue-bright);
}

.actual-marker.is-animating {
  animation: reveal-actual 520ms cubic-bezier(0.2, 0.75, 0.25, 1) both;
}

.actual-marker::after {
  order: -1;
}

@keyframes reveal-actual {
  from { left: var(--guess-position); opacity: 0.35; }
  to { left: var(--actual-position); opacity: 1; }
}

.result-timeline.is-exact .guess-marker {
  display: none;
}

.marker-year {
  font-size: 0.9rem;
  font-weight: 700;
}

.marker-label {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.community-card,
.final-community {
  padding: clamp(13px, 2.5vw, 19px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbf7f2;
}

.community-card,
.final-community {
  border-color: rgba(8, 127, 4, 0.28);
  background: #ecffea;
}

.community-results p,
.final-community p {
  margin: 9px 0 0;
  color: #34444d;
  font-size: 0.96rem;
  line-height: 1.48;
}

.community-results {
  display: grid;
  gap: 5px;
}

.community-results p + p {
  margin-top: 0;
}

.final-result {
  padding: clamp(20px, 4vw, 36px);
  border: 1px solid var(--line);
  border-radius: clamp(18px, 3vw, 28px);
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
  animation: reveal-in 350ms ease both;
}

.final-result h2 {
  margin: 7px 0 16px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 5.5vw, 3rem);
  font-weight: 400;
  letter-spacing: -0.04em;
  line-height: 1;
}

.final-score {
  margin: 0;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 9vw, 4.8rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.055em;
  line-height: 0.95;
  text-transform: uppercase;
}

.final-summary {
  max-width: 560px;
  margin: 12px auto 18px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.final-community {
  max-width: 600px;
  margin: 0 auto 24px;
  text-align: left;
}

.share-card {
  display: grid;
  gap: 16px;
  max-width: 610px;
  margin: 18px auto 16px;
  padding: clamp(18px, 4vw, 30px);
  overflow: hidden;
  border: 1px solid #c9b196;
  border-radius: 24px;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(13, 210, 6, 0.15), transparent 35%),
    linear-gradient(155deg, #ffffff 0%, var(--brown-pale) 100%);
  box-shadow: 0 18px 50px rgba(16, 42, 56, 0.11);
  text-align: left;
}

.share-brand,
.share-title,
.share-journey,
.share-trail-label {
  margin: 0;
}

.share-brand {
  color: var(--brown);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.share-title {
  margin-top: -11px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 7vw, 3.55rem);
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.share-subtitle {
  margin: -9px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.share-journey {
  max-width: 480px;
  font-family: var(--typewriter);
  font-size: clamp(1.15rem, 3.8vw, 1.65rem);
  line-height: 1.35;
}

.share-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.share-stats > div {
  display: grid;
  gap: 5px;
  align-content: start;
  padding: 15px 10px;
  border: 1px solid rgba(123, 61, 2, 0.18);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.72);
  text-align: center;
}

.share-stats strong {
  color: var(--brown);
  font-family: var(--typewriter);
  font-size: clamp(1rem, 3.5vw, 1.35rem);
  font-variant-numeric: tabular-nums;
}

.share-stats span,
.share-trail-label {
  color: var(--muted);
  font-size: 0.61rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.share-answer-trail {
  display: grid;
  grid-template-columns: repeat(15, minmax(22px, 1fr));
  gap: 4px;
  margin-top: 10px;
}

.share-answer-marker {
  display: grid;
  min-width: 0;
  min-height: 50px;
  place-content: center;
  border-radius: 8px;
  color: #6c7880;
  background: rgba(98, 113, 123, 0.1);
  text-align: center;
}

.share-answer-marker.is-near {
  color: var(--brown);
  background: rgba(123, 61, 2, 0.12);
}

.share-answer-marker.is-bullseye {
  color: var(--green-dark);
  background: rgba(13, 210, 6, 0.13);
}

.share-answer-marker strong {
  overflow: hidden;
  font-family: var(--typewriter);
  font-size: clamp(0.6rem, 1.8vw, 0.8rem);
  font-variant-numeric: tabular-nums;
  text-overflow: clip;
  white-space: nowrap;
}

.share-answer-marker small {
  margin-top: 3px;
  font-size: 0.52rem;
  font-weight: 800;
  opacity: 0.68;
}

.final-actions {
  display: grid;
  grid-template-columns: minmax(0, 360px);
  justify-content: center;
  gap: 12px;
  max-width: 610px;
  margin: 0 auto;
}

.secondary-button {
  width: 100%;
  min-height: 48px;
  padding: 11px 20px;
  border: 1px solid var(--brown);
  border-radius: 999px;
  color: var(--brown);
  background: var(--paper);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  cursor: pointer;
}

.secondary-button:hover {
  background: var(--brown-pale);
}

.secondary-button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

.share-status {
  min-height: 1.4em;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.share-copy-field {
  position: fixed;
  left: -9999px;
}

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

@media (max-width: 520px) {
  .quiz-app {
    padding: 8px 8px 16px;
  }

  .quiz-header {
    padding: 0 8px;
  }

  .photo-frame {
    height: auto;
    min-height: 365px;
    padding: 6px;
  }

  .photo-frame:not(.is-loading) {
    min-height: 0;
  }

  .question-image {
    width: min(100%, 270px);
  }

  .question-body {
    padding: 9px 10px 12px;
  }

  .question-body h2 {
    margin-bottom: 0;
    font-size: 1.15rem;
  }

  .answer-panel {
    gap: 6px;
  }

  .reveal-summary {
    grid-template-columns: minmax(0, 1fr) 140px;
    gap: 12px;
  }

  .reveal-thumbnail {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    max-width: 140px;
    height: 180px;
  }

  .reveal-result-copy {
    grid-column: 1;
    grid-row: 1;
  }

  .correct-year {
    font-size: clamp(3rem, 15vw, 4.6rem);
  }

  .answer-comparison {
    font-size: clamp(1.08rem, 4.5vw, 1.45rem);
  }

  .answer-explanation {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 0.88rem;
    line-height: 1.4;
  }

  .year-readout {
    padding: 0 12px 2px;
  }

  #year-output {
    font-size: 2.35rem;
  }

  .year-scrubber {
    height: 66px;
  }

  .timeline-ticks {
    top: 12px;
  }

  .fixed-playhead {
    bottom: 6px;
  }

  .scrubber-help {
    display: none;
  }

  .question-meta {
    margin-inline: 6px;
  }

  .year-control {
    gap: 6px;
  }

  .step-button {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 0.65rem;
  }

  #submit-answer {
    position: sticky;
    z-index: 5;
    bottom: calc(8px + env(safe-area-inset-bottom));
    min-height: 46px;
    box-shadow: 0 8px 24px rgba(8, 127, 4, 0.24);
  }

  .year-scrubber {
    --tick-width: 39px;
  }

  .marker-label {
    font-size: 0.56rem;
  }

  .share-card {
    gap: 14px;
    padding: 18px 13px;
  }

  .share-stats {
    gap: 6px;
  }

  .share-stats > div {
    padding-inline: 5px;
  }

  .share-answer-trail {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .final-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
