:root {
  --sea: #0f4c5c;
  --deep: #0b2f3a;
  --panel: #0c3541;
  --land: #f1e7cf;
  --border: #b9a983;
  --line: rgba(255, 255, 255, .16);
  --text: #f6f3ea;
  --mist: #a8c3c9;
  --gold: #f2c14e;
  --coral: #ff6b4a;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  display: flex; flex-direction: column;
  background: var(--deep); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

header {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) 14px 8px; background: var(--deep); z-index: 3;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.rose { width: 36px; height: 36px; flex: none; }
h1 { margin: 0; font-size: 19px; letter-spacing: .2em; text-transform: uppercase; }
.brand p { margin: 0; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--mist); }
.hud { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--mist); font-size: 14px; }
.hud b { font-size: 22px; color: var(--gold); }
.round {
  width: 38px; height: 38px; flex: none; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(11, 47, 58, .85); color: var(--text); font-size: 17px; line-height: 1; cursor: pointer;
}
@media (max-width: 380px) { .brand p { display: none; } h1 { font-size: 16px; letter-spacing: .12em; } }
@media (max-width: 330px) { .hud span { display: none; } .rose { width: 28px; height: 28px; } h1 { font-size: 14px; letter-spacing: .06em; } }

/* ---- the map ---- */
#stage { position: relative; flex: 1; min-height: 0; background: var(--deep); }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
#map.dragging { cursor: grabbing; }
#map.locked { cursor: grab; }
#sea { fill: var(--deep); }
#frame { stroke: var(--gold); stroke-width: 2; vector-effect: non-scaling-stroke; opacity: .55; }
#land path { fill: var(--land); stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
#other path { fill: #2f5c68; stroke: #24505c; stroke-width: 1; vector-effect: non-scaling-stroke; }
#water { fill: var(--sea); }
.trail { stroke: #c0392b; stroke-width: 2.5; stroke-dasharray: 7 6; stroke-linecap: round; vector-effect: non-scaling-stroke; fill: none; }
.pin path { fill: var(--coral); stroke: #fff; stroke-width: 1.6; }
.pin circle { fill: #fff; }
.pin.drop { animation: drop .28s cubic-bezier(.3, 1.5, .5, 1); }
.pin.old path { fill: #9aa7ab; }
@keyframes drop { from { opacity: 0; translate: 0 -18px; } }
.truth .ring { fill: none; stroke: var(--gold); stroke-width: 3; }
.truth .dot { fill: var(--gold); stroke: var(--deep); stroke-width: 2; }
.truth .pulse { fill: none; stroke: var(--gold); stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: ripple 1.6s ease-out infinite; }
@keyframes ripple { from { transform: scale(.4); opacity: 1; } to { transform: scale(2.6); opacity: 0; } }
.tag text { font: 700 12px system-ui, sans-serif; fill: var(--deep); text-anchor: middle; }
.tag rect { fill: var(--gold); }
.zoom { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 2; }

/* ---- the panel ---- */
#panel {
  flex: none; z-index: 3; max-height: 52vh; overflow-y: auto;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
@media (min-width: 860px) {
  /* wide screens: the panel is a column on the left, the map gets the rest */
  body { display: grid; grid-template: "head head" auto "panel stage" minmax(0, 1fr) / 390px minmax(0, 1fr); }
  header { grid-area: head; }
  #stage { grid-area: stage; }
  #panel { grid-area: panel; max-height: none; padding: 26px 24px; border-top: 0; border-right: 1px solid var(--line); }
}
#panel > * { animation: rise .35s cubic-bezier(.2, .7, .2, 1) both; }
#panel > :nth-child(2) { animation-delay: .04s; }
#panel > :nth-child(3) { animation-delay: .08s; }
#panel > :nth-child(n+4) { animation-delay: .12s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
h2 { margin: 0 0 8px; font-size: 24px; line-height: 1.2; text-wrap: balance; }
h2 small { display: inline-block; margin-left: 6px; padding: 2px 9px; border-radius: 99px; background: rgba(255, 255, 255, .1); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mist); vertical-align: middle; }
p { margin: 0 0 10px; }
.muted { color: var(--mist); font-size: 14px; }
.btn {
  display: block; width: 100%; margin-top: 10px; padding: 14px 18px; border: 0; border-radius: 12px;
  background: var(--gold); color: #1b1404; font: inherit; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
  transition: transform .12s, filter .12s, opacity .2s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; filter: none; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn:focus-visible, .round:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.link { background: none; border: 0; padding: 0; color: var(--mist); font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; }
.big { margin: 2px 0; font-size: 42px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.big small { font-size: 18px; font-weight: 600; color: var(--mist); }
.gain { font-size: 15px; }
.gain b { color: var(--gold); font-size: 20px; }
.row5 { margin: 8px 0; font-size: 26px; letter-spacing: 4px; }
.row5 span { display: inline-block; animation: pop .45s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes pop { from { transform: scale(0) rotate(-25deg); opacity: 0; } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 0; }
.stats div { padding: 9px 6px; border-radius: 12px; background: rgba(255, 255, 255, .07); text-align: center; }
.stats b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--mist); }
.log { list-style: none; margin: 12px 0 0; padding: 0; }
.log li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); align-items: baseline; }
.log .a { font-weight: 600; }
.log .q { font-size: 13px; color: var(--mist); }
.log .p { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

dialog { width: min(520px, calc(100vw - 32px)); max-height: 86vh; overflow-y: auto; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: #0c3541; color: var(--text); }
dialog::backdrop { background: rgba(3, 16, 20, .72); }
dialog h2 { font-size: 17px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin-top: 6px; }
dialog ul { padding-left: 20px; margin: 0 0 16px; }
dialog li { margin-bottom: 8px; }
dialog p { color: var(--mist); font-size: 14px; }
dialog .more { margin: 14px 0 0; text-align: center; }
#feedback label { display: block; margin: 12px 0 6px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--mist); }
#feedback select, #feedback textarea { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: #124552; color: var(--text); font: inherit; resize: vertical; }
#feedback .fine { margin: 10px 0 0; font-size: 13px; }
.status { min-height: 20px; margin: 8px 0 0; font-size: 14px; color: #ffb3a1; }
.status.ok { color: #9be3a8; }
.petal { position: fixed; z-index: 9; width: 9px; height: 9px; border-radius: 2px; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  #panel > *, .row5 span, .pin.drop, .truth .pulse { animation: none; }
}
