:root {
  color-scheme: light;
  --paper: #f7e5c7;
  --ink: #221811;
  --muted: #67503d;
  --red: #b83521;
  --gold: #eeb54b;
  --rule: #94795a;
  --display: Impact, "Arial Narrow", "Avenir Next Condensed", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  font: 16px/1.5 system-ui, sans-serif;
  background: radial-gradient(ellipse at 32% 0%, #fff0d5, transparent 72%), var(--paper);
}
main { width: min(100% - 64px, 1410px); margin: 0 auto; padding: 24px 0 42px; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding-bottom: 14px; border-bottom: 2px solid; }
h1, h2, p { margin: 0; }
h1 { font: 900 clamp(3.1rem, 7.1vw, 7.4rem)/.88 var(--display); letter-spacing: -.025em; }
h1 span { color: var(--red); }
.event { border-left: 1px solid var(--rule); padding-left: 24px; text-align: right; }
.event strong { display: block; font: 900 clamp(1.1rem, 3.1vw, 3rem)/1 var(--display); text-transform: uppercase; }
.event small, .week small, .stage-info, .range, .weather span, .weather small, .ledger, .readouts, .log button {
  font-family: var(--mono);
  font-size: .75rem;
}
.event small { display: block; margin-top: 6px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.event small span { color: var(--red); }
.towns { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 7px 0 0; }
.towns a, .next-town { color: var(--muted); font: 750 .75rem/1.5 var(--mono); text-underline-offset: 3px; }
.towns a[aria-current], .next-town { color: var(--red); }
.tour-picker { font: 750 .75rem/1.5 var(--mono); }
.tour-picker summary { cursor: pointer; }
.tour-picker[open] { flex-basis: 100%; }
.tour-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr));
  gap: 5px 16px;
  margin-top: 6px;
  padding: 9px 12px;
  border: 1px solid var(--rule);
}
.next-town { display: inline-block; margin-top: 10px; }
.week { margin: 12px 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.week li { position: relative; padding: 8px 4px 7px; }
.week li::before { content: ""; position: absolute; top: 15px; left: 0; width: 100%; height: 1px; background: var(--rule); }
.week li:first-child::before { left: 50%; width: 50%; }
.week li:last-child::before { width: 50%; }
.week b { display: block; position: relative; font: 900 1.2rem/1.1 var(--display); text-transform: uppercase; }
.week b::before { content: ""; display: block; width: 11px; height: 11px; margin: 0 auto 5px; border: 2px solid var(--ink); border-radius: 50%; background: var(--paper); }
.week li[aria-current] { background: var(--gold); }
.week li[aria-current] b::before { background: var(--red); }
.week li.complete b::before { background: var(--ink); }
.week small { color: var(--muted); }
.stage { position: relative; isolation: isolate; aspect-ratio: 2.95; border: 7px solid var(--ink); overflow: hidden; background: #8ca8a0; }
.backdrop, #course { position: absolute; inset: 0; width: 100%; height: 100%; }
.backdrop { z-index: -2; background: url(assets/fairground.jpg) center / 100% 100% no-repeat; }
.dive-stage .backdrop { background-image: url(assets/moonlight-pier.jpg); }
.cannon-stage .backdrop, .tour-circus .backdrop { background-image: url(assets/red-mesa-circus.jpg); }
.tour-pier .backdrop { background-image: url(assets/moonlight-pier.jpg); }
.cannon-stage .backdrop, .tour-stage .backdrop, .career-course .backdrop {
  transform-origin: top left;
  transform: translate3d(var(--cannon-backdrop-x, 0px), var(--cannon-backdrop-y, 0px), 0)
    scale(var(--cannon-backdrop-zoom, 1));
}
.night .backdrop { filter: brightness(.57) saturate(.85) hue-rotate(12deg); }
.night::after {
  position: absolute; inset: 0; z-index: -1; content: "";
  background: radial-gradient(ellipse at 50% 89%, #ffdf9c7d, transparent 51%), linear-gradient(#1424409e, transparent 74%);
}
#course { z-index: 0; }
.stage-info { position: absolute; z-index: 1; inset: 12px 12px auto; display: flex; justify-content: space-between; gap: 4px; pointer-events: none; text-transform: uppercase; font-weight: 700; letter-spacing: .035em; }
.stage-info span { padding: 5px 8px; background: var(--ink); color: #ffebc8; }
.stage-info span:last-child { color: var(--ink); background: #f8e6c7; }
#stage-status[data-verdict="pass"] { color: #fff0d5; background: #245644; }
#stage-status[data-verdict="fail"] { color: #fff0d5; background: #9a3223; }
.controls { display: grid; grid-template-columns: 1fr 1fr 1fr .67fr .9fr; align-items: stretch; border: 2px solid; margin-top: 14px; padding: 10px; }
.parameter, .weather { min-width: 0; padding: 4px 14px; border-right: 1px solid var(--rule); }
.parameter label, .weather strong { font: 900 clamp(.95rem, 1.6vw, 1.35rem)/1.1 var(--display); text-transform: uppercase; }
.parameter label { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.parameter output { white-space: nowrap; color: var(--red); }
input[type=range] { display: block; width: 100%; margin: 10px 0 3px; accent-color: var(--red); cursor: pointer; }
input[type=number] { width: 100%; margin: 5px 0 2px; padding: 2px 6px; border: 1px solid var(--rule); border-radius: 2px; background: #fff0d5; color: var(--ink); font: 700 1rem/1.2 var(--mono); }
input[type=number]:invalid:not(:placeholder-shown):focus { border-color: var(--red); }
input:disabled { cursor: default; opacity: .48; }
.range { display: flex; justify-content: space-between; color: var(--muted); }
.weather strong, .weather span, .weather small { display: block; }
.weather span { font-weight: 800; margin-top: 5px; }
.weather small { color: var(--muted); }
button { cursor: pointer; font: inherit; color: inherit; }
.go { margin-left: 10px; background: var(--red); color: #fff1d6; border: 0; border-radius: 4px; min-height: 66px; padding: 8px; font: 900 clamp(1.2rem, 2.85vw, 2.55rem)/1 var(--display); font-style: italic; text-transform: uppercase; }
.go:hover:not(:disabled) { background: #932719; }
.go:disabled { background: #765b4b; cursor: default; }
:focus-visible { outline: 3px solid #205f70; outline-offset: 3px; }
.ledger { display: flex; flex-wrap: wrap; gap: 6px 20px; padding: 9px 0; border-bottom: 1px solid var(--rule); color: var(--muted); }
.ledger strong { color: var(--ink); }
#purchase { margin-left: auto; }
.notes { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 16px; }
.notes h2 { font: 900 1.45rem/1.2 var(--display); text-transform: uppercase; margin-bottom: 4px; }
.notes p { color: var(--muted); font-size: .9rem; }
.log { border-left: 1px solid var(--rule); padding-left: 18px; }
.log ol { list-style: none; margin: 0; padding: 0; }
.log li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 5px 0; border-bottom: 1px solid #b69b766b; font-size: .8rem; }
.log li strong { display: block; }
.log button { border: 1px solid var(--ink); padding: 4px 7px; background: transparent; white-space: nowrap; }
.log button:hover:not(:disabled) { background: var(--gold); }
.readouts { display: flex; flex-wrap: wrap; column-gap: 18px; row-gap: 4px; margin: 9px 0 0; }
.readouts div { display: flex; gap: 6px; }
.readouts dt { color: var(--muted); }
.readouts dd { margin: 0; font-weight: 750; }
[hidden] { display: none !important; }
@media (min-width: 921px) and (max-height: 800px) {
  main { padding-top: 16px; }
  .stage { height: clamp(265px, calc(100svh - 360px), 410px); aspect-ratio: auto; }
  h1 { font-size: clamp(3.1rem, 6.5vw, 6rem); }
}
@media (max-width: 920px) {
  main { width: calc(100% - 36px); }
  .controls { grid-template-columns: 1fr 1fr 1fr .8fr; }
  .weather { border-right: 0; }
  .go { grid-column: 1 / -1; margin: 8px 0 0; min-height: 48px; }
}
@media (max-width: 550px) {
  main { width: calc(100% - 24px); padding-top: 16px; }
  .masthead { gap: 8px; }
  h1 { font-size: clamp(2rem, 10vw, 3.2rem); }
  .event { padding-left: 8px; }
  .event small { font-size: .57rem; letter-spacing: 0; }
  .week small { font-size: .59rem; }
  .stage { aspect-ratio: 2.15; border-width: 4px; }
  .stage-info { inset: 6px 6px auto; font-size: .55rem; }
  .stage-info span { padding: 3px 4px; }
  .controls { grid-template-columns: 1fr 1fr; padding: 6px; }
  .parameter, .weather { padding: 6px 9px; }
  .parameter:nth-child(2) { border-right: 0; }
  .notes { grid-template-columns: 1fr; gap: 16px; }
  .log { border-left: 0; border-top: 1px solid var(--rule); padding: 12px 0 0; }
  #purchase { margin-left: 0; }
}
