@font-face {
  font-family: Inter;
  src: url("assets/replay-fonts/Inter.woff") format("woff");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: Marcellus;
  src: url("assets/replay-fonts/Marcellus-400.woff") format("woff");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --base: #252524;
  --panel: #31312f;
  --edge: #5d5750;
  --paper: #fff6e6;
  --muted: #d4cabe;
  --red: #a8313d;
  --pop: #ffc479;
  font-family: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--base); color: var(--paper); line-height: 1.45; }
h1, h2, h3, p, figure, dl, dd { margin: 0; }
a { color: inherit; text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .65; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--pop); outline-offset: 3px; }

main { max-width: 1240px; margin: auto; padding: 0 20px 36px; }
.lead { display: flex; align-items: center; justify-content: flex-start; gap: clamp(12px, 2.5vw, 30px); padding: clamp(14px, 2.4vw, 28px) 0 clamp(16px, 2.2vw, 26px); }
.overline { font-size: 11px; font-weight: 800; letter-spacing: .11em; color: #f6a3aa; }
.lead h1 { font: clamp(34px, 5.4vw, 68px)/1.05 Marcellus, Georgia, serif; letter-spacing: -.043em; margin: 4px 0; }
.archive-status { margin-bottom: 10px; color: var(--muted); }

.journey-review { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(245px, 1fr); align-items: start; gap: 14px; }
.map-panel, .story-panel { min-width: 0; border: 1px solid var(--edge); border-top: 3px solid var(--red); background: var(--panel); }
.section-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; background: #20201f; }
.section-bar h2 { font-size: 17px; letter-spacing: -.025em; }
.section-bar p { font-size: 12px; color: var(--muted); margin-top: 2px; }
#replay-clock { font-size: 14px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }

.map-stage { position: relative; overflow: hidden; isolation: isolate; width: 100%; aspect-ratio: 1000 / 650; background: #252725; border-top: 1px solid var(--edge); }
.map-stage canvas { display: block; width: 100%; height: 100%; }
.cast { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.replay-time { display: grid; justify-items: end; gap: 2px; flex: none; line-height: 1.2; }
.replay-light { --light-accent: #aec3e3; display: inline-flex; align-items: center; gap: 5px; color: var(--light-accent); font-size: 11px; }
.replay-light::before { content: ''; width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; }
.replay-light[data-phase="dawn"], .replay-light[data-phase="sunrise"] { --light-accent: #ffbd98; }
.replay-light[data-phase="daylight"] { --light-accent: #f7e4a1; }
.replay-light[data-phase="dusk"] { --light-accent: #ffb3a4; }
.replay-light[data-phase="sunrise"]::before, .replay-light[data-phase="daylight"]::before { background: currentColor; }
.actor { position: absolute; display: grid; justify-items: center; gap: 2px; transform-origin: bottom center; }
.actor.emily, .actor.partner { width: 21%; z-index: 3; }
.actor.emily { z-index: 4; }
.actor.vehicle { width: 23%; }
.actor.roadside { width: 15%; z-index: 2; }
.actor.roadside b, .actor.vehicle b { border-bottom-color: #458c85; }
.map-stage[data-meetup] .actor.emily, .map-stage[data-meetup] .actor.partner { width: 17%; }
.map-stage[data-meetup] .actor.vehicle { width: var(--meetup-car-width, 36%); }
.map-stage[data-meetup] .actor.vehicle b:empty { display: none; }
.sprite {
  width: 100%;
  background-repeat: no-repeat;
  filter: brightness(var(--scene-brightness, 1)) saturate(var(--scene-saturation, 1))
    sepia(var(--scene-warmth, 0)) drop-shadow(2px 5px 4px var(--scene-shadow, #0b0b0adc));
}
.map-stage[data-light="daylight"] { --scene-shadow: #3e4d4368; }
.map-stage[data-light="sunrise"], .map-stage[data-light="dusk"] { --scene-shadow: #54382c85; }
.actor b { font-size: clamp(9px, 1.15vw, 13px); white-space: nowrap; background: var(--paper); color: #2d2523; border-radius: 3px; border-bottom: 2px solid #ae3943; line-height: 1.2; padding: 2px 5px; }
.map-key { position: absolute; right: 8px; bottom: 6px; z-index: 3; font-size: 10px; background: #242524ec; padding: 3px 5px; border: 1px solid #56534e; border-radius: 3px; color: #eadbcb; }
.milestone-chip {
  position: absolute;
  z-index: 5;
  top: 13%;
  left: 3%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px 5px 5px;
  background: var(--paper);
  color: #2f2623;
  border-bottom: 3px solid var(--red);
  border-radius: 6px;
  box-shadow: 0 4px 14px #0007;
  pointer-events: none;
}
.milestone-chip img { height: clamp(26px, 4vw, 52px); width: clamp(26px, 4vw, 52px); object-fit: contain; }
.milestone-chip b { display: block; color: #962b35; font-size: clamp(12px, 2vw, 22px); font-weight: 880; line-height: 1; }
.milestone-chip small { font-size: clamp(9px, 1vw, 11px); font-weight: 700; }
.milestone-chip.gold { border-bottom-color: #aa6f21; background: #f9e6b6; }
.milestone-chip.gold b { color: #61501f; }
.meetup-cue { border-bottom-color: #42877b; }
.meetup-cue b { color: #2d625b; }
.map-pace {
  position: absolute;
  inset-block-start: calc(100% + 2px);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 4px;
  color: #294d42;
  background: #e5f1d6;
  border: 1px solid #789b80;
  border-bottom: 2px solid #579177;
  border-radius: 8px;
  box-shadow: 0 2px 0 #273c3980, inset 0 1px #fff8;
  pointer-events: none;
}
.pace-clock {
  display: grid;
  place-items: center;
  border-radius: 50%;
  width: clamp(13px, 1.6vw, 22px);
  aspect-ratio: 1;
  font-size: clamp(11px, 1.4vw, 17px);
  line-height: 1;
  background: linear-gradient(145deg, #f7ffe8, #b9d4b4);
  box-shadow: inset 0 1px #fff9, 0 2px 0 #5b907251;
}
.map-pace strong { display: block; font-size: clamp(10px, 1.6vw, 16px); line-height: 1.05; font-variant-numeric: tabular-nums; white-space: nowrap; }
.map-pace small { font-size: clamp(8px, 1vw, 11px); }


.story-panel { background: var(--paper); color: #292521; }
.story-panel .section-bar { color: var(--paper); }
.story-panel .section-bar a { color: #f7ccb1; font-size: 12px; white-space: nowrap; }
.story-content { padding: 14px; }
.memory-title { font-size: 13px; margin: 9px 0 6px; }
.memory-empty { font-size: 13px; color: #5a4a3f; margin-bottom: 9px; }
.memory-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.memory-grid figure { min-width: 0; }
.memory-grid a, #journey-poster a { display: block; background: #252422; }
.memory-grid img, #journey-poster img { display: block; width: 100%; object-fit: contain; }
.memory-grid img { height: clamp(140px, 15vw, 210px); }
#journey-poster img { max-height: 360px; }
figcaption { padding: 5px 0; font-size: 12px; }
#journey-poster:not(:empty) { border-top: 1px solid #c8b69a; padding-top: 8px; margin-top: 8px; }
.missing-image { display: block; padding: 12px; color: var(--paper); }

.race-photos, .source-notes { margin-top: 25px; border-top: 1px solid var(--edge); padding-top: 15px; }
.race-photos > p, .source-notes p { color: var(--muted); margin-top: 8px; max-width: 80ch; font-size: 14px; }
.race-photos summary, .source-notes summary { font-size: 15px; font-weight: 730; min-height: 34px; }
.race-photos .memory-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr)); margin-top: 10px; }
.source-notes a { display: block; width: fit-content; margin: 8px 0; color: #ffcfaa; }
footer { padding: 0 16px 24px; text-align: center; font-size: 13px; color: var(--muted); }

dialog { width: min(720px, calc(100% - 26px)); padding: 14px; background: #212120; border: 1px solid #63594e; color: var(--paper); }
dialog::backdrop { background: #000c; }
dialog img { display: block; max-height: 76vh; max-width: 100%; object-fit: contain; margin: auto; }
dialog form { position: absolute; right: 8px; top: 8px; }
dialog button { border: 1px solid #cfc2aa; background: #211e1b; font-size: 25px; width: 44px; height: 44px; border-radius: 50%; }
#memory-caption { font-size: 13px; color: var(--muted); text-align: center; margin-top: 7px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

body[data-replay-style="clay"] {
  --base: #2e241f;
  --panel: #443329;
  --edge: #826353;
  --paper: #ffefdb;
  --muted: #ecceb6;
  --red: #bb654c;
  --pop: #ffd396;
  background: radial-gradient(ellipse at 52% 0%, #4c3528, var(--base) 67%);
}
[data-replay-style="clay"] .section-bar { background: #372920; }
[data-replay-style="clay"] .map-panel,
[data-replay-style="clay"] .story-panel { border-radius: 14px; overflow: hidden; box-shadow: 0 7px 0 #1e181438; }
[data-replay-style="clay"] .milestone-chip { border-radius: 12px; box-shadow: 0 4px 0 #52382788, 0 6px 15px #2e241f65; }
[data-replay-style="clay"] .actor b { border-radius: 7px; box-shadow: 0 2px 0 #3f2d2380; }
[data-replay-style="clay"] .actor.emily,
[data-replay-style="clay"] .actor.partner { width: 19%; }
[data-replay-style="clay"] .map-stage[data-meetup] .actor.emily,
[data-replay-style="clay"] .map-stage[data-meetup] .actor.partner { width: 16%; }


.lead-crow {
  display: block;
  width: clamp(82px, 12vw, 155px);
  height: clamp(82px, 12vw, 155px);
  object-fit: contain;
  flex: none;
  filter: drop-shadow(0 5px 4px #1e181455);
}
.lead-title { min-width: 0; }
.replay-heading { min-height: 58px; flex-wrap: wrap; }
.replay-heading > div:first-child { flex: 1 1 140px; min-width: 0; }
.replay-heading button {
  min-height: 44px;
  border: 1px solid #e7a58b;
  border-radius: 9px;
  background: #963e29;
  color: var(--paper);
  font-weight: 750;
  padding: 8px 18px;
  box-shadow: inset 0 2px #fff2d711, 0 3px 0 #22191388;
}
.replay-actions { padding: 8px 12px; }
.replay-actions .map-source { margin: 0; font-size: 11px; color: var(--muted); }
.story-panel { min-height: 180px; }

@media (max-width: 760px) {
  main { padding-inline: 12px; }
  .journey-review { grid-template-columns: 1fr; }
  .lead-crow { width: 86px; height: 86px; }
  .lead h1 { font-size: clamp(31px, 7vw, 48px); }
  .replay-heading { min-height: 52px; }
  .memory-grid img { height: 180px; }
}
@media (max-width: 450px) {
  .section-bar { padding: 7px 8px; }
  .section-bar h2 { font-size: 15px; }
  #replay-clock { font-size: 12px; }
  .map-key { bottom: 4px; right: 4px; font-size: 8px; }
  .lead-crow { width: 70px; height: 70px; }
  .lead { gap: 9px; }
  .lead h1 { font-size: clamp(27px, 7vw, 34px); }
  .overline { font-size: 10px; letter-spacing: .07em; }
  .replay-actions { padding: 8px 10px; }
  .replay-heading button { order: 3; flex: 0 0 auto; font-size: 12px; padding-inline: 12px; }
  .memory-grid img { height: 145px; }
}
