.ba-atlas {
  --ba-ink: #244b40;
  --ba-paper: #fff9e8;
  --ba-edge: #96885f;
  --ba-left: calc(14px + env(safe-area-inset-left, 0px));
  --ba-right: calc(14px + env(safe-area-inset-right, 0px));
  --ba-top: calc(72px + env(safe-area-inset-top, 0px));
  --ba-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  position: absolute;
  inset: 0;
  overflow: hidden;
  overflow: clip;
  isolation: isolate;
  color: var(--ba-ink);
  background-color: #e4e8dc;
  background-image: linear-gradient(to right, #788e841a 1px, transparent 1px), linear-gradient(to bottom, #788e841a 1px, transparent 1px);
  background-size: 36px 36px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  color-scheme: light;
}
.ba-atlas *, .ba-atlas *::before, .ba-atlas *::after { box-sizing: border-box; }
.ba-sheet { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.ba-panning .ba-sheet, .ba-atlas.ba-panning button { cursor: grabbing; }
.ba-atlas :focus-visible, .ba-atlas [data-just-posted]:focus { outline:2px solid var(--ba-ink); outline-offset:2px }
.ba-atlas .ba-sheet:focus-visible { outline-offset: -4px; }
.ba-atlas button { margin: 0; cursor: pointer; color: var(--ba-ink); touch-action: none; }
.ba-compass {
  position: absolute;
  top: var(--ba-top);
  right: calc(var(--ba-right) + 5px);
  z-index: 3;
  display: grid;
  place-items: center;
  width: 48px; height: 48px; padding: 0;
  appearance: none;
  border: 3px double #907748; border-radius: 50%;
  background: var(--ba-paper);
  box-shadow: 0 1px 3px #193c3250;
}
.ba-compass:active { background: #ebdfbd; }
@media (hover:hover) { .ba-compass:hover { border-color: var(--ba-ink); } }
.ba-ruler {
  position: absolute;
  bottom: max(var(--ba-bottom), var(--ba-dock-clearance, 0px));
  left: var(--ba-left);
  display: grid;
  grid-template-columns: 83px max-content;
  align-items: center;
  column-gap: 0;
  z-index: 3;
  padding: 4px 6px;
  color: #314e43;
  text-shadow: 0 0 3px #fffff2, 1px 1px #fff9e8;
  font: 650 11px/1.2 system-ui, sans-serif;
  pointer-events: none;
}
.ba-scale { display: grid; justify-items: center; gap: 2px; }
.ba-credits {
  display:grid; place-items:center; width:44px; height:44px; pointer-events:auto; color:inherit; text-decoration:none;
}
.ba-credits svg { width:15px; height:15px; filter:drop-shadow(0 0 1px #fff9e8) }
.ba-fallback { grid-column: 1 / -1; }
.ba-scale-bar { display: block; height: 5px; border: 1px solid #3e5349; background: linear-gradient(90deg,#3e5349 50%,#fbf7e4 50%); }
.ba-annotations { position: absolute; inset: 0; pointer-events: none; }
.ba-atlas .ba-engine-hit {
  position: absolute; display: grid; place-items: center; z-index: 4;
  height: 44px; width: 44px; padding: 0; border: 0; border-radius: 50%;
  appearance: none; background: transparent; pointer-events: auto;
}
.ba-engine-model {
  position: absolute; width: 128px; height: 128px; left: var(--ba-marker-x); top: var(--ba-marker-y);
  transform: translate(-50%,-50%); pointer-events: none;
}
.ba-engine-seal {
  width: 36px; height: 36px; padding: 2px;
  color: #203d34; background: #edda9f;
  border: 3px double #706039; border-radius: 50%;
  box-shadow: 0 1px 2px #203e3755;
}
.ba-engine-hit::before {
  /* Only the badge and the carriage footprint are train-ticket targets. */
  content: ''; position: absolute; left: var(--ba-hit-x); top: var(--ba-hit-y);
  width: var(--ba-hit-width); height: var(--ba-hit-height); transform: translate(-50%,-50%);
}
.ba-engine-hit:active .ba-engine-seal { background: #d7bb77; transform: scale(.94); }
.ba-mark {
  position: absolute;
  pointer-events: none;
  color: #29473e;
  font: italic 14px/1.2 Georgia, 'Times New Roman', serif;
  text-shadow: -1px -1px 0 #f8f6e6, -1px 1px 0 #f8f6e6, 1px -1px 0 #f8f6e6, 1px 1px 0 #f8f6e6, 0 0 4px #fffbea;
}
.ba-mark::before {
  content: '';
  position: absolute;
  left: var(--ba-marker-x, 0px);
  top: var(--ba-marker-y, 0px);
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid #344f48;
  background: #fff9dc;
  box-shadow: 0 0 0 1px #fdfae3;
  pointer-events: none;
}
.ba-label { position: relative; display: block; white-space: nowrap; }
.ba-atlas .ba-stamp {
  z-index: 2;
  width: max-content;
  appearance: none;
  padding: 0;
  border: 0;
  border-radius: 1px;
  background: transparent;
  color: #213e35;
  pointer-events: auto;
  text-align: left;
  text-shadow: none;
  font: 600 clamp(14px, 1.3vw, 18px)/1.12 Georgia, 'Times New Roman', serif;
}
.ba-stamp .ba-label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 3px 8px 3px 3px;
  border: 1px solid var(--ba-edge);
  background: var(--ba-paper);
  box-shadow: inset 0 0 0 2px #fff9eb, inset 0 0 0 3px #c6b994, 1px 2px 3px #1f382e38;
}
.ba-collection .ba-count { color:var(--ba-ink); font-weight:700 }
.ba-stamp::before {
  z-index: 1;
  width:12px;
  height:12px;
  border-color:var(--ba-ink);
  background:radial-gradient(circle,var(--ba-ink) 2px,#fff9dc 2.5px);
}
.ba-stamp::after, .ba-selected::after, .ba-engine-hit::after {
  content: '';
  position: absolute;
  z-index: -1;
  left: var(--ba-marker-x);
  top: var(--ba-marker-y);
  width: var(--ba-leader);
  height: 1px;
  background: #695c43;
  transform-origin: 0 50%;
  transform: rotate(var(--ba-bearing));
  mask-image: var(--ba-line-mask, none);
  pointer-events: none;
}
.ba-stamp::after {
  height:3px; margin-top:-1.5px; border-radius:2px;
  background:var(--ba-ink); box-shadow:0 0 0 1px #fff9dc;
}
.ba-mark.ba-under-train::before { visibility: hidden; }
.ba-mark.ba-selected, .ba-atlas .ba-stamp:focus-visible { z-index: 3; }
.ba-mark.ba-selected::before {
  width: 14px; height: 14px; border: 3px solid var(--ba-ink);
  background: #efd99e; box-shadow: 0 0 0 2px var(--ba-paper), 0 0 0 3px #917748;
}
.ba-selected:not(.ba-stamp) .ba-label {
  padding: 4px 9px; border: 3px double #dcc591;
  background: var(--ba-ink); color: var(--ba-paper);
  text-shadow: none; font: 600 15px/1.2 Georgia, serif;
}
.ba-stamp.ba-selected .ba-label {
  outline: 2px solid var(--ba-ink); outline-offset: 1px;
  background: var(--ba-paper); border-inline-start: 4px solid #9b7a3e;
}
.ba-selected:not(.ba-stamp)::after { height: 2px; background: var(--ba-ink); }
.ba-selected:focus-visible { outline-offset: 4px; }
.ba-vignette { display: grid; justify-items: stretch; flex: none; text-align: center; }
.ba-altitude { padding-top: 1px; font: 11px/1 Georgia, serif; color: #475747; font-variant-numeric: tabular-nums; }
.ba-illustration {
  display: block;
  flex: none;
  width: clamp(37px, 4.4vw, 56px);
  height: clamp(30px, 3vw, 39px);
  object-fit: cover;
  border: 2px dotted #faf3dc;
  outline: 1px solid #b6a781;
  outline-offset: -1px;
  background: #c0cdbb;
}
.ba-lettering { display: grid; gap: 2px; padding-block: 3px; }
.ba-name { max-width: min(48vw, 230px); overflow: hidden; text-overflow: ellipsis; font: inherit; }
.ba-count { color:#43594e; font:italic 13px/1.15 Georgia,serif; font-variant-numeric:lining-nums }
@media (hover: hover) {
  .ba-stamp:hover .ba-name { text-decoration: underline; text-underline-offset: 3px; }
  .ba-engine-hit:hover .ba-engine-seal { background: #fae7b3; border-color: var(--ba-ink); box-shadow: 0 0 0 1px var(--ba-ink); }
}
.ba-stamp:active .ba-label { background: #f1e6c9; }
.ba-rail-base,.ba-rail-future,.ba-rail-elapsed { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ba-rail-base { stroke: #fffae5; stroke-width: 6; }
.ba-rail-future { stroke: #465a52; stroke-width: 2.8; stroke-dasharray: 4 4; }
.ba-rail-elapsed { stroke: #a73d29; stroke-width: 4; }
@media (max-width:719px), (max-height:480px) {
  /* The hit area is larger than the light paper slip under the lettering. */
  .ba-stamp .ba-label { padding:0 6px; border:0; border-radius:0; background:transparent; box-shadow:none }
  .ba-stamp .ba-label::before { content:""; position:absolute; inset:4px 0; background:#faf7e9; box-shadow:0 1px 2px #243e3426; z-index:-1 }
  .ba-stamp .ba-vignette { display:none }
  .ba-lettering { gap:1px; padding:0 }
  .ba-stamp:active .ba-label::before { background:#e5e7d9 }
  .ba-mark:not(.ba-stamp) { font-size:13px }
}
@media (max-height: 480px) {
  .ba-atlas { --ba-top: calc(63px + env(safe-area-inset-top, 0px)); --ba-bottom: calc(67px + env(safe-area-inset-bottom, 0px)); }
}
@media (forced-colors: active) {
  .ba-stamp .ba-label { box-shadow: none; background: Canvas; color: CanvasText; border: 1px solid ButtonText; }
  .ba-mark::before { border-color: CanvasText; }
  .ba-mark.ba-selected .ba-label { outline: 3px double Highlight; }
  .ba-engine-seal { border-color: ButtonText; }
}
