:root {
  --ink: #1a1a1a;
  --muted: #6d6d6a;
  --hair: #e6e6e2;
  --paper: #ffffff;
  --red: #e5382c;
  --blue: #1f74c4;
  --yellow: #f2b705;
  --green: #2f9e58;
  --water: #bfe0f3;
  --land: #ecece7;
  --font: "Gabarito", "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
}

h1, h2, h3, p { margin: 0; }

[hidden] { display: none !important; }

a { color: inherit; }

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: grid;
  gap: 28px;
}

/* masthead */

.masthead {
  display: flex;
  align-items: center;
  gap: 16px;
}

.portrait {
  width: 84px;
  height: 84px;
  flex: none;
  border-radius: 50%;
  border: 5px solid var(--ink);
  object-fit: cover;
  background: var(--paper);
}

.eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  font-size: clamp(30px, 8.5vw, 44px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 2px 0 6px;
}

.tagline { color: var(--muted); font-size: 15.5px; line-height: 1.35; max-width: 34em; }

/* map */

.system { display: grid; gap: 14px; min-width: 0; }

.map-wrap { margin: 0 -16px; }

#map {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--font);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.geo-water { fill: none; stroke: var(--water); stroke-width: 44; stroke-linejoin: round; stroke-linecap: round; opacity: 0.5; }
.geo-land { fill: var(--land); opacity: 0.6; }
.geo-border { stroke: #cfcfc9; stroke-width: 1.5; stroke-dasharray: 2 7; stroke-linecap: round; }
.geo-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  fill: #b4b4ad;
  text-transform: uppercase;
}
.geo-label.water { fill: #8fbfdc; }

.line { fill: none; stroke-width: 15; stroke-linejoin: round; stroke-linecap: round; }

.station-shape { fill: #fff; stroke: var(--ink); stroke-width: 4.5; stroke-linejoin: round; transition: transform 0.15s ease; transform-box: fill-box; transform-origin: center; }
.station-hit { fill: transparent; }
.station-name {
  font-size: 20px;
  font-weight: 700;
  fill: var(--ink);
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 6px;
  stroke-linejoin: round;
}
.station { cursor: pointer; outline: none; }
.station:hover .station-shape,
.station:focus-visible .station-shape { transform: scale(1.3); }
.station:focus-visible .station-name { text-decoration: underline; }

.train-body { stroke: #fff; stroke-width: 2.5; }
.train-hit { fill: transparent; }
.train .rider { fill: #fff; stroke: var(--ink); stroke-width: 3; display: none; }
.train.has-rider .rider { display: block; }

.rider-dot { fill: var(--ink); stroke: #fff; stroke-width: 2.5; }
.rider-pulse { fill: none; stroke: var(--ink); stroke-width: 3; opacity: 0; transform-box: fill-box; transform-origin: center; animation: pulse 1.4s ease-out infinite; }
.goal-ring { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-dasharray: 5 7; stroke-linecap: round; transform-box: fill-box; transform-origin: center; animation: spin 6s linear infinite; }
.arrive-burst { fill: none; stroke: var(--ink); stroke-width: 5; transform-box: fill-box; transform-origin: center; animation: burst 0.7s ease-out forwards; }

@keyframes pulse { 0% { transform: scale(0.6); opacity: 0.7; } 100% { transform: scale(2.1); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes burst { 0% { transform: scale(0.5); opacity: 1; } 100% { transform: scale(3.4); opacity: 0; } }

.playing .station { cursor: default; }
.playing .station:hover .station-shape { transform: none; }
.playing .train { cursor: pointer; }

/* game panel */

.hud {
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 14px 16px;
}

.hud h2 { font-size: 20px; font-weight: 800; line-height: 1.2; }
.hud p { font-size: 15px; line-height: 1.35; }

.hud-idle { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hud-idle p { color: var(--muted); margin-top: 2px; }

.hud-live { display: grid; gap: 10px; }
.hud-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.fare { font-weight: 600; font-size: 16px !important; }
.fare-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}
.meters { white-space: nowrap; font-variant-numeric: tabular-nums; }
.clock, .score { font-size: 24px; font-weight: 800; }
.clock.low { color: var(--red); }
.meter-unit { font-size: 12px; color: var(--muted); margin: 0 8px 0 2px; }
.meter-unit:last-child { margin-right: 0; }
.status { color: var(--muted); min-height: 2.7em; }
.status a { color: var(--ink); font-weight: 600; }

.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  min-height: 46px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 3px solid var(--ink);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.btn-primary { background: var(--ink); color: #fff; padding-inline: 26px; font-size: 17px; }
.btn-quiet { border-color: transparent; color: var(--muted); min-height: 32px; padding: 2px 0; justify-self: start; font-weight: 600; text-decoration: underline; }

.btn-ride {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border-color: var(--c, var(--ink));
  border-left-width: 14px;
}
.btn-ride small { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.btn-ride[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); border-left-color: var(--c); color: #fff; }
.btn-ride[aria-pressed="true"] small { color: #c9c9c4; }

/* bio and index */

.bio { display: grid; gap: 12px; outline: none; scroll-margin-top: 16px; }
.bio h2 { font-size: 30px; font-weight: 800; line-height: 1.1; }
.index h2 { font-size: 20px; font-weight: 800; line-height: 1.2; margin-bottom: 4px; }
.bio p:not(.eyebrow) { max-width: 36em; }
.bio .eyebrow { display: flex; align-items: center; gap: 8px; }

.chip { display: inline-block; width: 26px; height: 9px; border-radius: 5px; background: var(--c); flex: none; }
.chip-interchange { width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 3.5px solid var(--ink); }

.index { display: grid; gap: 14px; border-top: 3px solid var(--ink); padding-top: 22px; }
.index-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; }
.index h3 { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.index ul { list-style: none; margin: 0; padding: 0; }
.index li a { display: inline-block; padding: 5px 0; font-size: 18px; font-weight: 600; text-decoration: none; }
.index li a:hover, .index li a:focus-visible { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; }
.index-note { font-size: 14.5px; color: var(--muted); line-height: 1.35; }

.foot { color: var(--muted); font-size: 13.5px; }

/* wide screens: text rides on the left, the map stays put on the right */

@media (min-width: 1040px) {
  .page {
    max-width: 1240px;
    padding: 36px 32px 56px;
    grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
    column-gap: 56px;
    align-items: start;
  }
  .masthead, .bio, .index, .foot { grid-column: 1; }
  .masthead { flex-direction: column; align-items: flex-start; }
  .portrait { width: 112px; height: 112px; }
  .system {
    grid-column: 2;
    grid-row: 1 / span 4;
    position: sticky;
    top: 20px;
    justify-items: center;
  }
  .map-wrap { margin: 0; width: min(100%, calc((100vh - 170px) * 600 / 760)); min-width: 380px; }
  .hud { width: min(100%, 620px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rider-pulse, .goal-ring { animation: none; opacity: 0.6; }
}

.train.has-rider .train-body { stroke: var(--ink); stroke-width: 4; }
.actions { min-height: 100px; align-content: start; }
