:root {
  --bg: rgb(22, 24, 34);
  --text: #f3f5f7;
  --muted: rgba(243, 245, 247, 0.68);
  --line: rgba(243, 245, 247, 0.22);
  --accent: #8fdcff;
  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.16));
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
}

body.settling { transition: background-color 1.6s linear; }

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.brand { font-weight: 600; color: var(--text); }

.progress { font-variant-numeric: tabular-nums; }

.status { margin: 40vh 0 0; text-align: center; color: var(--muted); }

.panel { display: flex; flex: 1; flex-direction: column; }

.prompt {
  margin: 28px 0 0;
  font-family: var(--serif);
  font-size: clamp(1.375rem, 5.6vw, 1.75rem);
  font-weight: 500;
  line-height: 1.25;
  text-wrap: balance;
}

.guessing, .reveal, .result { display: flex; flex: 1; flex-direction: column; }

.readout { margin: auto 0; padding: 24px 0; text-align: center; }

.readout-date {
  display: block;
  font-size: clamp(1.75rem, 8vw, 2.5rem);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.readout-era {
  display: block;
  margin-top: 6px;
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.sliders { display: grid; gap: 14px; margin-bottom: 20px; }

.slider-row {
  display: grid;
  grid-template-columns: 32px 28px minmax(0, 1fr) 28px;
  align-items: center;
  column-gap: 6px;
}

.slider-row label { font-size: 0.8125rem; color: var(--muted); }

.stepper {
  width: 28px;
  height: 36px;
  padding: 0 0 3px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.375rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.stepper:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }

.track { position: relative; }

.ticks {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  pointer-events: none;
}

.tick {
  position: absolute;
  width: 1px;
  height: 7px;
  margin: -3.5px 0 0 -0.5px;
  background: var(--line);
}

.scale {
  grid-column: 3;
  position: relative;
  height: 14px;
  font-size: 0.6875rem;
  line-height: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.scale-label {
  position: absolute;
  top: 0;
  white-space: nowrap;
  transform: translateX(-50%);
}

.scale-label.at-start { left: 0; transform: none; }

.scale-label.at-end { right: 0; transform: none; }

input[type="range"] {
  width: 100%;
  height: 36px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line);
}

input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--line);
}

/* A wide transparent thumb keeps the slim marker easy to grab. Its width is also THUMB_WIDTH in app.js. */
input[type="range"]::-webkit-slider-thumb {
  width: 28px;
  height: 36px;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 50% 8px, var(--text) 4.5px, transparent 5px),
    linear-gradient(var(--text), var(--text)) center 8px / 2.5px 22px no-repeat;
  margin-top: -17px;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 36px;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 50% 8px, var(--text) 4.5px, transparent 5px),
    linear-gradient(var(--text), var(--text)) center 8px / 2.5px 22px no-repeat;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.action {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: var(--text);
  color: #161b22;
  font: 600 1rem var(--sans);
  cursor: pointer;
  touch-action: manipulation;
}

.action:hover { background: #fff; }

.action:disabled { opacity: 0.55; cursor: default; }

.stage {
  display: block;
  width: 100%;
  height: 210px;
  margin-top: 16px;
  cursor: pointer;
}

.result { padding-top: 8px; }

.result-score {
  margin: 0;
  font-size: 2.75rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.result-max { font-size: 1rem; color: var(--muted); }

.result-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0 0;
}

.result-dates dt { font-size: 0.75rem; color: var(--muted); }

.result-dates dd { margin: 2px 0 0; font-size: 0.9375rem; }

.fact { margin: 14px 0 0; font-size: 0.9375rem; line-height: 1.45; color: var(--muted); }

.source {
  align-self: flex-start;
  margin: 6px 0 20px;
  padding: 4px 0;
  font-size: 0.8125rem;
  color: var(--accent);
}

.result .action { margin-top: auto; }

.end-label { margin: 28px 0 0; font-size: 0.8125rem; letter-spacing: 0.06em; color: var(--muted); }

.end-total {
  margin: 2px 0 0;
  font-size: 3.25rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.score-list { display: grid; gap: 10px; margin: 8px 0 20px; padding: 0; list-style: none; }

.score-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 16px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.score-prompt { font-size: 0.9375rem; line-height: 1.3; }

.score-value { font-variant-numeric: tabular-nums; font-weight: 600; }

.score-answer { grid-column: 1 / -1; font-size: 0.8125rem; color: var(--muted); }

.share-status { min-height: 1.25rem; margin: 8px 0 0; text-align: center; font-size: 0.8125rem; color: var(--muted); }

.end-note { margin: 4px 0 16px; text-align: center; font-size: 0.8125rem; color: var(--muted); }

.ad-slot { width: 100%; min-height: 100px; }

@media (prefers-reduced-motion: reduce) {
  body.settling { transition: none; }
}

#end-canvas { height: 150px; }
