:root {
  --olive: #3d4a2c;
  --olive-2: #56643f;
  --paper: #f3ecd8;
  --paper-2: #e8dfc4;
  --ink: #1f1d17;
  --muted: #6b6553;
  --red: #b3261e;
  --amber: #c98a12;
  --green: #2e7d32;
  --blue: #2b5fa8;
  --line: #cfc4a3;
  --close: #4f7a3a;
  --middle: #2b6ca8;
  --far: #8a4fa8;
  --deep: #b3261e;
  --radius: 14px;
  --hud-h: 58px;
  --tabs-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); }
body { font-size: 17px; line-height: 1.4; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
.stencil { font-family: "Courier New", Courier, monospace; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }

/* HUD */
#hud {
  position: fixed; inset: 0 0 auto 0; z-index: 1000;
  height: calc(var(--hud-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0;
  display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 6px;
  background: var(--olive); color: var(--paper);
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.hud-cell { display: flex; flex-direction: column; justify-content: center; align-items: center; background: none; border: 0; padding: 0; min-width: 0; }
.hud-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.hud-val { font-family: "Courier New", Courier, monospace; font-weight: 700; font-size: 22px; white-space: nowrap; }
#hud-fuel.warn { background: var(--amber); border-radius: 10px; color: #1b1300; }
#hud-fuel.danger { background: var(--red); border-radius: 10px; color: #fff; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .7; } }
#sync { font-size: 15px; }

/* Layout */
#app { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
body.in-game #app { top: calc(var(--hud-h) + env(safe-area-inset-top)); bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
.page { padding: 16px 16px 32px; max-width: 640px; margin: 0 auto; }
#tabs {
  position: fixed; inset: auto 0 0 0; z-index: 1000;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--paper-2); border-top: 1px solid var(--line);
}
#tabs button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 13px; font-weight: 600; color: var(--muted); }
#tabs button span { font-size: 22px; }
#tabs button.on { color: var(--olive); background: var(--paper); box-shadow: inset 0 3px 0 var(--olive); }

/* Map */
#map { position: absolute; inset: 0; background: #e9e4cf; }
.map-btns { position: absolute; right: 12px; bottom: 16px; z-index: 600; display: flex; flex-direction: column; gap: 10px; }
.map-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--paper); box-shadow: 0 2px 8px rgba(0,0,0,.3); font-size: 22px; }
.gps-chip { position: absolute; left: 12px; bottom: 16px; z-index: 600; background: rgba(243,236,216,.95); border-radius: 999px; padding: 6px 12px; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.25); max-width: calc(100% - 90px); }
.pin { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); }
.pin.done { background: #9a9480 !important; }
.pin.base { background: var(--olive); width: 40px; height: 40px; font-size: 18px; }
.leaflet-container { font: inherit; }
.leaflet-tooltip.lbl { background: rgba(243,236,216,.92); border: 0; box-shadow: none; font-size: 11px; font-weight: 700; padding: 1px 5px; color: var(--ink); }
.leaflet-tooltip.lbl::before { display: none; }

/* Cards & lists */
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
.card { background: #fffaf0; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; }
.chip.close { background: var(--close); } .chip.middle { background: var(--middle); } .chip.far { background: var(--far); } .chip.deep { background: var(--deep); }
.target { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: #fffaf0; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; min-height: 64px; }
.target.done { opacity: .6; }
.target .name { font-weight: 700; }
.ticks { font-size: 18px; letter-spacing: 2px; white-space: nowrap; }
.dist { font-family: "Courier New", Courier, monospace; font-weight: 700; white-space: nowrap; }

/* Buttons */
.btn { display: block; width: 100%; min-height: 56px; border-radius: 12px; border: 0; padding: 12px 16px; font-size: 18px; font-weight: 700; background: var(--olive); color: var(--paper); margin: 10px 0; }
.btn.secondary { background: var(--paper-2); color: var(--ink); border: 1px solid var(--line); }
.btn.red { background: var(--red); color: #fff; }
.btn:disabled { opacity: .45; }
.opt { display: block; width: 100%; min-height: 54px; text-align: left; border-radius: 12px; border: 2px solid var(--line); background: #fffaf0; padding: 12px 14px; margin: 8px 0; font-size: 17px; font-weight: 600; }
.opt.sel { border-color: var(--olive); background: #eef0e2; }
input[type=text], input[type=number], input[type=tel] { width: 100%; font-size: 20px; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: #fffaf0; }

/* Sheet (target detail) */
#sheet { position: fixed; inset: 0; z-index: 1500; background: var(--paper); overflow-y: auto; padding-top: env(safe-area-inset-top); }
.sheet-top { position: sticky; top: 0; background: var(--olive); color: var(--paper); display: flex; align-items: center; gap: 8px; padding: 10px 12px; z-index: 2; }
.sheet-top button { background: none; border: 0; color: var(--paper); font-size: 17px; font-weight: 700; padding: 8px; min-height: 44px; }
.step { border-left: 4px solid var(--line); padding-left: 12px; margin: 18px 0; }
.step.ok { border-color: var(--green); }
.result { font-size: 20px; font-weight: 800; }
.result.hit { color: var(--green); } .result.miss { color: var(--red); }
.thumb { width: 100%; border-radius: 10px; display: block; margin-top: 8px; }

#toast { position: fixed; left: 50%; top: calc(var(--hud-h) + env(safe-area-inset-top) + 10px); transform: translateX(-50%) translateY(-20px); opacity: 0; transition: .25s; z-index: 2000; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-weight: 700; max-width: 90vw; text-align: center; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hero { background: var(--olive); color: var(--paper); padding: calc(28px + env(safe-area-inset-top)) 20px 24px; text-align: center; }
.hero .badge { font-size: 54px; }
.big-clock { font-family: "Courier New", Courier, monospace; font-size: 48px; font-weight: 800; text-align: center; }
ol.rules { padding-left: 22px; } ol.rules li { margin: 6px 0; }
.warnbox { background: #fdecea; border: 1px solid #f2b8b5; border-radius: 12px; padding: 12px 14px; }

.beacon { position: fixed; inset: 0; z-index: 3000; background: rgba(20,24,12,.85); display: grid; place-items: center; padding: 20px; animation: flash .6s 3; }
.beacon-box { background: var(--paper); border-radius: 18px; padding: 22px; max-width: 420px; text-align: center; box-shadow: 0 0 0 6px var(--amber); }
@keyframes flash { 50% { background: rgba(201,138,18,.7); } }

.legend { position: absolute; left: 12px; top: 12px; z-index: 600; background: rgba(243,236,216,.96); border-radius: 12px; padding: 6px 12px; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.25); max-width: calc(100% - 24px); }
.legend summary { font-weight: 700; cursor: pointer; min-height: 28px; line-height: 28px; }
.legend .lg { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin: 0 3px 0 6px; vertical-align: -1px; }
.legend .ln { display: inline-block; width: 26px; margin-right: 6px; vertical-align: middle; }

/* Netlify injects a "Powered by Netlify" badge that covers the tab bar on phones */
#nl-badge-frame { display: none !important; }

.lb { display: grid; grid-template-columns: 30px 84px 1fr auto; gap: 8px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.lb.me { background: #eef0e2; border-radius: 10px; }
.lb .rk { font-family: "Courier New", monospace; font-weight: 800; font-size: 22px; text-align: center; }
.lb .pt { font-family: "Courier New", monospace; font-weight: 800; font-size: 26px; }
.lb .pl { background: #eef3e3; border-radius: 6px; }

/* the hidden attribute must win over display:grid on #hud/#tabs */
[hidden] { display: none !important; }

/* question countdown */
.qclock { position: relative; height: 26px; border-radius: 13px; background: #e4dcc0; overflow: hidden; margin: 6px 0 10px; }
.qbar { position: absolute; inset: 0 auto 0 0; background: #4f7a3a; transition: width .5s linear; }
.qclock span { position: relative; display: block; text-align: center; line-height: 26px; font-weight: 700; font-size: 14px; color: #1d2414; }
/* compass arrow on the "me" dot */
.me-arrow { width: 34px; height: 34px; transition: transform .2s linear; }
