@font-face { font-family: Pixelify; src: url("./pixelify.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: Inter; src: url("./inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
:root {
  color-scheme: dark;
  --panel: #111c23;
  --panel-raised: #1b2d35;
  --ink: #08131a;
  --line: #abbab8;
  --text: #fbf7eb;
  --mute: #b9cac8;
  --green: #65f5a4;
  --amber: #f7ca68;
  --cyan: #71edf0;
  --font: Pixelify, ui-monospace, monospace;
  font: 18px/1.15 var(--font);
  background: var(--panel);
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { display: grid; grid-template-rows: auto minmax(0,1fr); margin: 0; height: 100vh; height: 100dvh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { font-weight: 600; }
.frame {
  color: var(--text); background: var(--panel); border: 2px solid var(--line); border-radius: 6px;
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--ink), 3px 4px 0 rgba(8,19,26,.6);
}
button.frame:not(:disabled):hover { background: var(--panel-raised); }
.top {
  display: flex; align-items: center; gap: 22px; z-index: 2; min-height: 62px; border-bottom: 2px solid var(--line);
  padding: max(6px,env(safe-area-inset-top)) max(13px,env(safe-area-inset-right)) 7px max(22px,env(safe-area-inset-left));
  box-shadow: 0 3px 0 var(--ink);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand > .glyph { color: var(--green); width: 40px; height: 40px; }
h1 { font-size: clamp(25px, 3.1vw, 43px); letter-spacing: .018em; line-height: 1; }
.connection { min-width: 0; padding-left: 20px; border-left: 2px solid var(--line); color: var(--mute); display: flex; align-items: center; gap: 9px; }
.connection span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.connection i { flex: 0 0 8px; height: 8px; box-shadow: 0 0 0 2px var(--ink); background: #85918d; }
.connection[data-mode="live"] i { background: var(--green); }
.connection[data-mode="retrying"] i { background: var(--amber); }
.connect { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 43px; padding: 6px 13px; }
.top .connect { margin-left: auto; font-size: clamp(16px, 2vw, 25px); border-color: var(--text); white-space: nowrap; }
.connect .glyph, .hud-head > .glyph { color: var(--green); }
.stage { min-height: 0; position: relative; overflow: hidden; border: 3px solid var(--ink); border-top: 0; }
#map { position: absolute; inset: 0; background: #204b44; font: 14px/1.3 Inter, system-ui, sans-serif; z-index: 0; }
.leaflet-tile { image-rendering: pixelated; }
.map-tools { display: grid; gap: 8px; position: absolute; top: 18px; right: max(14px,env(safe-area-inset-right)); }
.square { display: grid; place-items: center; width: 57px; height: 57px; }
.square .glyph { width: 30px; height: 30px; }
.square[aria-pressed="true"] { color: var(--green); border-color: var(--green); }
.hud {
  position: absolute; left: max(10px,env(safe-area-inset-left)); bottom: max(11px,env(safe-area-inset-bottom));
  width: min(370px, calc(100% - 22px)); padding: 13px 14px 15px;
}
.hud-head { display: flex; align-items: center; gap: 12px; min-height: 36px; padding-bottom: 10px; border-bottom: 2px solid var(--line); }
.hud-head h2 { font-size: 26px; }
.hud-head > .glyph { width: 31px; height: 31px; }
.plain { background: transparent; border: 0; margin-left: auto; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; }
.stats { display: grid; gap: 10px; margin: 13px 3px 16px; font-size: 22px; }
.stats div, .stats dt { display: flex; align-items: center; gap: 11px; }
.stats div { justify-content: space-between; }
.stats dt .glyph { width: 24px; height: 24px; }
.stats dd { font-variant-numeric: tabular-nums; }
.primary {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 45px;
  padding: 6px; color: #10242a; background: var(--green); border-color: #adffd1; font-size: 24px; font-weight: 700;
  box-shadow: 0 0 0 2px var(--ink), inset 0 -3px 0 #348d5d;
}
button.primary:not(:disabled):hover { background: #a5ffcb; }
.primary.recording { background: var(--amber); border-color: #ffe1a2; box-shadow: 0 0 0 2px var(--ink), inset 0 -3px 0 #ab7836; }
button.primary.recording:hover { background: #ffe1a2; }
.survey-state, .terrain-state { color: var(--mute); font: 13px/1.4 Inter, system-ui, sans-serif; }
.survey-state { margin: 0 3px 11px; }
.terrain-state { position: absolute; top: 13px; left: 13px; max-width: calc(100% - 100px); padding: 6px 9px; background: var(--panel); border: 1px solid var(--line); }
dialog { width: min(440px,calc(100% - 28px)); max-height: calc(100% - 28px); padding: 15px 17px 18px; }
dialog::backdrop { background: #070e13af; }
.transport { display: grid; gap: 11px; padding: 15px 0 0; }
.transport p, .transport input, #node-state { color: var(--mute); font: 14px/1.45 Inter, system-ui, sans-serif; }
.transport label { display: grid; gap: 5px; }
.transport input { min-height: 43px; min-width: 0; padding: 6px 9px; color: var(--text); background: var(--ink); border: 1px solid var(--line); border-radius: 3px; }
#ios-help a { text-decoration: none; }
#node-state { margin-top: 14px; }
#node-state[data-error] { color: #ffbfa8; }
#disconnect { margin-top: 15px; }
.leaflet-container .leaflet-control-attribution, .leaflet-container .leaflet-control-scale-line {
  background: var(--panel); color: var(--text); border-color: var(--line); text-shadow: none; font: 12px/1.1 var(--font);
}
.leaflet-container .leaflet-control-attribution { margin: 0 9px max(9px,env(safe-area-inset-bottom)) 0; padding: 5px 8px; border: 1px solid #79918e; }
.leaflet-container .leaflet-control-attribution a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.leaflet-bottom.leaflet-right { display: flex; align-items: end; max-width: 100%; }
.leaflet-container .leaflet-control-scale { margin: 0 6px max(9px,env(safe-area-inset-bottom)) 0; }
.leaflet-container .leaflet-control-scale-line { padding: 5px 5px 4px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { color: var(--text); background: var(--panel); border-radius: 3px; border: 1px solid var(--line); }
.leaflet-container a.leaflet-popup-close-button { color: var(--mute); }
.leaflet-popup-content b { font: 20px var(--font); }
.glyph {
  display: inline-block; flex: none; width: 22px; height: 22px; background: currentColor;
  -webkit-mask: var(--glyph) center / contain no-repeat;
  mask: var(--glyph) center / contain no-repeat;
}
.glyph.radio { --glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='black' d='M2 2h2v2H3v2H2v4h1v2h1v2H2v-2H1v-2H0V6h1V4h1zm14 0h2v2h1v2h1v4h-1v2h-1v2h-2v-2h1v-2h1V6h-1V4h-1zM5 5h2v2H6v3h1v2H5v-2H4V7h1zm8 0h2v2h1v3h-1v2h-2v-2h1V7h-1zM9 6h2v1h1v3h-1v2h1v3h1v2h2v2H5v-2h2v-2h1v-3h1v-2H8V7h1zm2 10H9v1h2z'/%3E%3C/svg%3E"); }
.glyph.gps { --glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='black' stroke-width='2' d='m6 7 3-3 5 5-3 3zM2 13l3-3 3 3-3 3zM12 3l3-3 3 3-3 3zM15 11a4 4 0 0 1-4 4m7-3a7 7 0 0 1-6 6'/%3E%3C/svg%3E"); }
.glyph.layers { --glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2' d='m2 8 10-5 10 5-10 5zm0 4 10 5 10-5M2 16l10 5 10-5'/%3E%3C/svg%3E"); }
.glyph.trail { --glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2' d='M17 12s-4-4-4-6a4 4 0 0 1 8 0c0 2-4 6-4 6ZM6 22s-4-4-4-6a4 4 0 0 1 8 0c0 2-4 6-4 6Zm5-1h7v-5m-8-9H6v3'/%3E%3C/svg%3E"); }
.glyph.plus, .glyph.minus { --glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2 10h8V2h4v8h8v4h-8v8h-4v-8H2z'/%3E%3C/svg%3E"); }
.glyph.minus { --glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2 10h20v4H2z'/%3E%3C/svg%3E"); }
.glyph.target { --glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2.4' d='M12 2v4m0 12v4M2 12h4m12 0h4M5 9l4-4h6l4 4v6l-4 4H9l-4-4z'/%3E%3Cpath d='M10 10h4v4h-4z'/%3E%3C/svg%3E"); }
.glyph.play { --glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3 1h3v2h3v2h3v2h3v2h3v2h-3v2h-3v2H9v2H6v2H3z'/%3E%3C/svg%3E"); }
.glyph.stop { --glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3 3h14v14H3z'/%3E%3C/svg%3E"); }
.glyph.download { --glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2' d='M12 2v13m-5-5 5 5 5-5M4 15v6h16v-6'/%3E%3C/svg%3E"); }
.glyph.close { --glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2' d='m5 5 14 14m0-14L5 19'/%3E%3C/svg%3E"); }
.player-icon span { position: absolute; inset: 5px; box-shadow: 0 0 0 4px var(--ink), inset 0 0 0 4px var(--ink); border: 4px solid var(--green); transform: rotate(45deg); background: var(--green); }
.relay-icon { border-radius: 4px; background: var(--ink); color: var(--cyan); box-shadow: 0 0 0 2px #10232a; display: grid; place-items: center; }
.relay-icon[data-type="2"] { color: var(--amber); }
.relay-icon .glyph { width: 26px; height: 26px; }
.leaflet-interactive.survey-track { stroke-linecap: butt; }
@media (max-width: 660px) {
  .top { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 55px; gap: 5px 8px; padding-left: max(10px,env(safe-area-inset-left)); }
  .brand { gap: 5px; }
  .brand h1 { font-size: clamp(20px, 5.85vw, 27px); }
  .brand > .glyph { width: 22px; height: 22px; }
  .connection { grid-column: 1 / -1; grid-row: 2; padding: 0 0 0 4px; border: 0; font-size: 14px; }
  .top .connect { gap: 5px; min-height: 40px; margin: 0; padding: 5px 7px; font-size: 15px; }
  .top .connect .glyph { width: 17px; height: 17px; }
  .map-tools { top: 12px; right: 9px; gap: 6px; }
  .square { width: 44px; height: 44px; }
  .square .glyph { width: 24px; height: 24px; }
  .hud { bottom: calc(env(safe-area-inset-bottom) + 53px); padding: 8px 11px 11px; }
  .hud-head h2 { font-size: 24px; }
  .stats { font-size: 19px; gap: 5px; margin: 8px 2px 10px; }
  .primary { font-size: 22px; }
}
@media (max-width: 360px) {
  .brand > .glyph { display: none; }
  .brand h1 { font-size: 18px; }
  .top .connect .glyph { display: none; }
}
@media (min-width: 661px) and (max-height: 460px) {
  .stage .hud { padding-top: 6px; padding-bottom: 8px; }
  .hud-head { padding-bottom: 3px; }
  .stats { margin-block: 6px; }
}
#journal-entries { display: grid; gap: 8px; padding: 0; list-style: none; }
#journal-entries li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 6px; }
#journal-entries small { color: var(--mute); }
#journal-state { color: #ffbfa8; }
/* Living map: water shimmer, drifting cloud shadows, pulsing markers. */
.terrain-tile canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.terrain-tile .glint { animation: shimmer 1.8s steps(1, end) infinite; }
.terrain-tile .glint-1 { animation-delay: -.9s; }
@keyframes shimmer { 0% { opacity: 1; } 50% { opacity: 0; } }
.leaflet-clouds-pane { z-index: 250; pointer-events: none; }
.clouds { position: absolute; overflow: hidden; pointer-events: none; }
.clouds i {
  position: absolute; inset: -512px; opacity: .17; background-position: var(--cx, 0) var(--cy, 0); background-size: 512px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 128 128' shape-rendering='crispEdges'%3E%3Cpath fill='%23061016' d='M14 20h14v-4h10v4h8v4h6v8H8v-6h6zM74 78h10v-4h14v4h6v4h8v6h4v6H66v-8h8zM94 22h10v4h6v6H88v-6h6zM24 98h8v-4h10v4h4v6H18v-4h6z'/%3E%3C/svg%3E");
  animation: drift 150s linear infinite;
}
@keyframes drift { to { transform: translate3d(512px, 0, 0); } }
.player-icon::before, .player-icon::after {
  content: ""; position: absolute; inset: 4px; border: 3px solid var(--green); transform: rotate(45deg); opacity: 0;
  animation: sonar 2.4s steps(8, end) infinite;
}
.player-icon::after { animation-delay: -1.2s; }
@keyframes sonar { 0% { opacity: .9; scale: .7; } 100% { opacity: 0; scale: 2.6; } }
.player-icon span { animation: bob 1.2s steps(2, jump-none) infinite alternate; }
@keyframes bob { to { translate: 0 -2px; } }
.relay-icon::after { content: ""; position: absolute; inset: -3px; border: 3px solid currentColor; border-radius: 6px; opacity: 0; pointer-events: none; }
.relay-icon.ping::after { animation: ping 1.1s steps(6, end); }
.relay-icon.ping .glyph { animation: heard .5s steps(3, end); }
@keyframes ping { 0% { opacity: 1; scale: 1; } 100% { opacity: 0; scale: 2.4; } }
@keyframes heard { 50% { scale: 1.25; } }
@media (prefers-reduced-motion: reduce) {
  .terrain-tile .glint-1, .player-icon::before, .player-icon::after { display: none; }
  .terrain-tile .glint, .clouds i, .player-icon span, .relay-icon.ping::after, .relay-icon.ping .glyph { animation: none; }
}
