:root {
    color-scheme: light;
    font: 100%/1.4 Inter, "Segoe UI", system-ui, sans-serif;
    color: #193b32;
    background: #fbfaf4;
    -webkit-text-size-adjust: 100%;
    --paper: #fbfaf4;
    --green: #153e35;
    --line: #cdd1c2;
    --muted: #50645a;
    --gutter: clamp(.8rem, 3vw, 2.2rem);
}
* { box-sizing: border-box; }
body, h1, fieldset, legend { margin: 0; }
main {
    height: 100vh;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto auto minmax(9rem, 1fr) auto;
}
header, .choices, footer {
    padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding-block: calc(.65rem + env(safe-area-inset-top)) .65rem;
    border-bottom: 1px solid var(--line);
}
h1 {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    font: 600 clamp(1.45rem, 3.1vw, 2.2rem)/1.1 Baskervville, "Iowan Old Style", Georgia, serif;
    letter-spacing: -.035em;
}
.station-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 2.15rem;
    height: 2.15rem;
    border-radius: .45rem;
    background: var(--green);
}
.station-mark i { width: 3px; height: .42rem; border-radius: 3px; background: #f8f3d5; }
.station-mark i:nth-child(even) { height: .84rem; }
.station-mark i:nth-child(3) { height: 1.28rem; background: #f5804a; }
a { color: inherit; text-underline-offset: .18em; }
.back { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; font-weight: 650; font-size: .88rem; white-space: nowrap; }
.back span { font-size: 1.15rem; }
.choices { display: flex; align-items: end; gap: 1.1rem; padding-block: .55rem .72rem; border-bottom: 1px solid var(--line); }
#location-form { display: flex; flex-wrap: wrap; gap: .45rem; align-items: end; }
#location-form label { display: grid; gap: .22rem; flex: 1 1 6.5rem; min-width: 0; }
#location-form input { width: 100%; min-width: 0; }
#location-form button { white-space: nowrap; cursor: pointer; }
#location-form input, #location-form button { min-height: 44px; padding: .3rem .6rem; border: 1px solid #a9b7a7; border-radius: .45rem; background: var(--paper); color: inherit; font: inherit; }
#location-form button[type="submit"] { color: var(--paper); background: var(--green); }
#location-status:empty { display: none; }
#location-status { font-size: .86rem; }
#location-form label, legend { font-size: .76rem; font-weight: 700; color: var(--muted); }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0 0 .22rem; }
button, .styles { font: inherit; color: inherit; }
.styles { display: flex; min-height: 44px; padding: 2px; border: 1px solid var(--line); border-radius: .5rem; background: #ebede3; }
.styles label { position: relative; display: flex; flex: 1; }
.styles input, .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.styles span { display: grid; place-items: center; min-width: 4.5rem; height: 100%; padding: .2rem .9rem; border-radius: .32rem; cursor: pointer; font-size: .9rem; font-weight: 650; }
.styles input:checked + span { background: var(--green); color: #fffdf1; }
:focus-visible, .styles input:focus-visible + span { outline: 3px solid #ad4a1a; outline-offset: 2px; }
.stage { position: relative; min-height: 0; background: #e4e7d8; isolation: isolate; }
main:has(canvas[hidden]) { height: auto; grid-template-rows: auto auto auto; }
.stage:has(canvas[hidden]) { display: none; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
canvas:active { cursor: grabbing; }
canvas:focus-visible { outline-offset: -3px; }
.map-tools, .map-scale { position: absolute; border: 1px solid #a5b09e; border-radius: .5rem; background: var(--paper); box-shadow: 0 2px 8px #183a2e26; }
.map-tools { display: grid; right: max(var(--gutter), env(safe-area-inset-right)); top: .7rem; overflow: hidden; }
.map-tools button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; font-weight: 580; font-size: 1.45rem; line-height: 1; cursor: pointer; }
.map-tools button + button { border-top: 1px solid var(--line); }
.map-tools button:focus-visible { outline-offset: -3px; }
.map-tools button:disabled { color: #869287; cursor: default; }
.map-tools button:hover:enabled { background: #e8ecdf; }
#center i { display: grid; place-items: center; width: 1.15rem; height: 1.15rem; border: 1.8px dashed currentColor; border-radius: 50%; }
#center i::after { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; }
.map-scale { left: max(var(--gutter), env(safe-area-inset-left)); bottom: .65rem; padding: .19rem .55rem .38rem; pointer-events: none; text-align: center; font-size: .72rem; font-weight: 680; }
#scale-line { display: block; height: 5px; border: solid currentColor; border-width: 0 1.5px 1.5px; }
footer, .readout, .credits { display: flex; align-items: center; flex-wrap: wrap; column-gap: .8rem; row-gap: .22rem; }
footer { justify-content: space-between; padding-block: .55rem max(.55rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: .77rem; color: var(--muted); }
#position { font-variant-numeric: tabular-nums; font-weight: 650; }
#status[data-state="error"] { color: #964021; }
#retry { min-height: 32px; border: 1px solid var(--line); border-radius: .35rem; background: var(--paper); cursor: pointer; }
.credits { column-gap: .6rem; }
[hidden] { display: none !important; }
@media (max-width: 580px) {
    .choices { flex-wrap: wrap; column-gap: .7rem; row-gap: .45rem; }
    #location-form { width: 100%; }
    fieldset { display: flex; align-items: center; }
    fieldset legend { float: left; margin-right: .65rem; padding: 0; }
    .styles span { min-width: 4.3rem; }
    .credits { font-size: .72rem; }
}
@media (max-height: 450px) and (min-width: 580px) {
    header, .choices { padding-block: .2rem; }
    header { padding-top: max(.2rem, env(safe-area-inset-top)); }
    .map-tools { grid-auto-flow: column; }
    .map-tools button + button { border-top: 0; border-left: 1px solid var(--line); }
}
