/* Gr3yF0x Express. Desert dusk: the game is the hero, the page is the ground it runs on. */
:root {
  --plum: #2b1e4a;
  --night: #160f2b;
  --coral: #ff6b4a;
  --amber: #ffc24b;
  --wire: #3fe0d0;
  --paper: #fff4e0;
  --paper-dim: rgba(255, 244, 224, 0.72);
  --rule: rgba(255, 244, 224, 0.16);
  --ui: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --slab: "Alfa Slab One", "Rockwell", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--paper);
  background: var(--night);
  font-family: var(--ui);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

p { margin: 0 0 1rem; }
:focus-visible { outline: 3px solid var(--wire); outline-offset: 3px; border-radius: 4px; }

/* ---- The stage ---- */
.stage {
  position: relative;
  height: min(86vh, 720px);
  min-height: 520px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--plum) 0%, #7a3a6b 42%, var(--coral) 70%, var(--amber) 84%, var(--night) 84%);
  user-select: none;
  -webkit-user-select: none;
}
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline-offset: -4px;
}

.bar {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1.1rem clamp(1rem, 4vw, 3rem) 0;
  pointer-events: none;
}
.bar p { margin: 0; }
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; }
.hud { display: flex; gap: 1.75rem; font-weight: 600; font-size: 0.98rem; font-variant-numeric: tabular-nums; }
.hud span:empty { display: none; }

.card {
  position: absolute;
  right: clamp(1rem, 6vw, 5.5rem);
  top: clamp(4.25rem, 13vh, 7rem);
  width: min(32rem, calc(100% - 2rem));
  text-shadow: 0 1px 14px rgba(22, 15, 43, 0.55);
}
.card[hidden], .card [hidden] { display: none; }
.card h1 {
  font-family: var(--slab);
  font-weight: 400;
  font-size: clamp(3.4rem, 11.5vw, 7.25rem);
  line-height: 0.92;
  letter-spacing: 0.005em;
  margin: 0 0 0.3em;
  overflow-wrap: anywhere;
}
.card h1.long { font-size: clamp(2.3rem, 8vw, 4.75rem); }
.card-line { font-size: clamp(1.1rem, 2.4vw, 1.35rem); font-weight: 500; line-height: 1.4; max-width: 28rem; }
.card-result { font-size: clamp(1.1rem, 2.4vw, 1.3rem); font-weight: 600; line-height: 1.4; max-width: 30rem; }
.card-how { font-size: 0.98rem; color: var(--paper); max-width: 27rem; margin-top: 0.9rem; }
.card-extra { margin: 0; min-height: 1.6rem; }

.carry { margin-top: 1.4rem; text-shadow: none; }
.carry label { display: block; font-weight: 700; font-size: 0.95rem; margin-bottom: 0.4rem; text-shadow: 0 1px 14px rgba(22, 15, 43, 0.55); }
.carry-row { display: flex; gap: 0.6rem; }
.carry input {
  flex: 1 1 auto;
  min-width: 0;
  font: 500 1.05rem var(--ui);
  color: var(--paper);
  background: rgba(22, 15, 43, 0.62);
  border: 1.5px solid rgba(255, 244, 224, 0.4);
  border-radius: 12px;
  padding: 0.8rem 0.95rem;
}
.carry input:focus { border-color: var(--wire); outline: none; box-shadow: 0 0 0 3px rgba(63, 224, 208, 0.3); }

.button {
  flex: 0 0 auto;
  font: 800 1.08rem var(--ui);
  color: var(--night);
  background: var(--amber);
  border: 0;
  border-radius: 12px;
  padding: 0.8rem 1.35rem;
  cursor: pointer;
  box-shadow: 0 5px 0 #b97c12;
  transition: transform 70ms ease, box-shadow 70ms ease;
}
.button:hover { background: #ffd070; }
.button:active { transform: translateY(4px); box-shadow: 0 1px 0 #b97c12; }

.link {
  font: 700 1rem var(--ui);
  color: var(--paper);
  background: none;
  border: 0;
  padding: 0.2rem 0;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
  text-shadow: 0 1px 14px rgba(22, 15, 43, 0.55);
}
.link[hidden] { display: none; }

.toast {
  position: absolute;
  top: clamp(4.5rem, 14vh, 7rem);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 2rem);
  margin: 0;
  padding: 0.55rem 1rem;
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.3;
  text-align: center;
  color: var(--night);
  background: var(--paper);
  border-radius: 12px;
  box-shadow: 0 6px 0 rgba(22, 15, 43, 0.35);
  opacity: 0;
  transition: opacity 160ms ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.bad { background: var(--coral); }

.ink {
  position: absolute;
  inset: auto 0 0 0;
  margin: 0;
  padding: 0 1rem 0.85rem;
  text-align: center;
  font-weight: 700;
  font-size: clamp(0.95rem, 2.6vw, 1.25rem);
  letter-spacing: 0.14em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  pointer-events: none;
}
.ink .gone { color: var(--coral); }

/* ---- The page under the stage ---- */
.band { border-top: 1px solid var(--rule); padding: clamp(3rem, 8vw, 5.5rem) 0; }
.trail-band { border-top: 0; padding-top: clamp(1.5rem, 4vw, 2.5rem); }
.wrap { max-width: 68rem; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 3rem); }
.narrow > * { max-width: 40rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 6vw, 5rem); }

h2 {
  font-weight: 800;
  font-size: clamp(1.9rem, 4.6vw, 2.9rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 0 0 1rem;
}
.lede { color: var(--paper-dim); max-width: 38rem; }

#map { display: block; width: 100%; height: auto; overflow: visible; margin: 1.5rem 0 0.5rem; }
.peaks polyline { stroke: rgba(255, 244, 224, 0.4); stroke-width: 2.5; stroke-linejoin: round; }
.trail { fill: none; stroke: rgba(255, 244, 224, 0.5); stroke-width: 2.5; stroke-dasharray: 2 9; stroke-linecap: round; }
.ridden { fill: none; stroke: var(--amber); stroke-width: 4; stroke-linecap: round; }
.stop { fill: var(--night); stroke: var(--paper); stroke-width: 2.5; }
.stop.done { fill: var(--amber); stroke: var(--amber); }
.rider { fill: var(--coral); stroke: var(--paper); stroke-width: 2.5; }
.place { font-family: var(--ui); font-weight: 700; font-size: 24px; fill: var(--paper); }

.log { margin: 1.5rem 0 0; padding: 0 0 0 2.4rem; max-width: 46rem; }
.log:empty { display: none; }
.log li { padding: 0.5rem 0; border-bottom: 1px solid var(--rule); }
.log li::marker { color: var(--paper-dim); font-variant-numeric: tabular-nums; }
.log .hop-head { display: block; font-weight: 700; }
.log .hop-note { display: block; color: var(--paper-dim); }
.log .hop-note.late { color: var(--coral); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; vertical-align: top; padding: 0.75rem 0.75rem 0.75rem 0; border-bottom: 1px solid var(--rule); }
thead th { font-weight: 600; font-size: 0.95rem; color: var(--paper-dim); }
tbody th { font-weight: 700; }
.wire, tr.wire td, tr.wire th { color: var(--wire); }

.versus { margin: 0 0 1.25rem; }
.versus > div { display: grid; grid-template-columns: 7rem 1fr 1fr; gap: 0.2rem 1rem; padding: 0.75rem 0; border-bottom: 1px solid var(--rule); }
.versus dt { font-weight: 600; color: var(--paper-dim); }
.versus dd { margin: 0; font-weight: 600; }
.aside { color: var(--paper-dim); }

.status { background: var(--plum); border-top: 0; }
.status-big {
  font-family: var(--slab);
  font-size: clamp(2.8rem, 11vw, 6.5rem);
  line-height: 0.95;
  color: var(--coral);
  margin: 0 0 0.3em;
}
.status-count { font-weight: 800; font-size: clamp(1.2rem, 3vw, 1.6rem); font-variant-numeric: tabular-nums; }
.status ul { margin: 0; padding-left: 1.2rem; color: var(--paper-dim); }

footer { border-top: 1px solid var(--rule); padding: 2.25rem 0 3.5rem; color: var(--paper-dim); font-size: 0.96rem; }
footer p { margin: 0 0 0.5rem; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.92em; color: var(--wire); }

@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; }
  .hud { gap: 1rem; font-size: 0.9rem; }
  .brand { font-size: 1.02rem; }
}
@media (max-width: 560px) {
  .stage { height: min(88vh, 680px); min-height: 540px; }
  .carry-row { flex-direction: column; }
  .hud span + span { display: none; }
  .versus > div { grid-template-columns: 1fr 1fr; }
  .versus dt { grid-column: 1 / -1; }
  .place { font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .button, .toast { transition: none; }
}
