/* BOATCITY — HUD styles. Colors come from CONFIG.ui (set as CSS vars by main.js). */
:root {
  --ink: #fff6dc; --muted: #a9c6e8; --panel: #0c2344; --panel2: #123563;
  --edge: #06142a; --line: #2f6aa8; --accent: #ffd23f; --accent2: #ff8a3d;
  --good: #7ee081; --danger: #ff5d5d;
  --pix: 'Press Start 2P', ui-monospace, monospace;
  --body: 'Pixelify Sans', ui-rounded, system-ui, sans-serif;
  --gap: 16px;
  --dock-h: 150px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2a7dc6; color: var(--ink); font-family: var(--body); -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior: none; touch-action: none; }
#world { position: fixed; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; cursor: grab; touch-action: none; display: block; }
#world.dragging { cursor: grabbing; }
#world.pointing { cursor: pointer; }
button, a { font: inherit; color: inherit; }
button { cursor: pointer; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
#hud > * { pointer-events: auto; }
#labels { pointer-events: none !important; position: absolute; inset: 0; }

/* ---------- pixel panel ---------- */
.panel {
  background: var(--panel);
  border: 3px solid var(--edge);
  box-shadow: inset 0 0 0 2px var(--line), inset 0 -5px 0 0 rgba(0,0,0,.22), 4px 4px 0 0 rgba(4, 14, 32, .5);
  border-radius: 0;
}

.pbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 12px;
  background: var(--panel2); color: var(--ink);
  border: 3px solid var(--edge); border-radius: 0;
  box-shadow: inset 0 0 0 2px var(--line), inset 0 -4px 0 0 rgba(0,0,0,.28), 3px 3px 0 0 rgba(4,14,32,.5);
  font-family: var(--pix); font-size: 10px; letter-spacing: .5px; text-decoration: none;
  transition: transform .08s steps(2), background .12s, box-shadow .08s;
  user-select: none;
}
.pbtn:hover { background: #1a4680; transform: translateY(-1px); }
.pbtn:active { transform: translate(2px, 2px); box-shadow: inset 0 0 0 2px var(--line), inset 0 3px 0 0 rgba(0,0,0,.28), 1px 1px 0 0 rgba(4,14,32,.5); }
.pbtn:focus-visible, .buy:focus-visible, .mission:focus-visible, .missions-head:focus-visible, .mlabel:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pbtn.sq { width: 40px; padding: 0; }
.pbtn svg { width: 18px; height: 18px; display: block; }

.chip {
  font-family: var(--pix); font-size: 7px; line-height: 1; padding: 4px 5px 3px;
  background: var(--accent); color: #2a1a00; border: 2px solid var(--edge);
}

/* ---------- brand ---------- */
.brand { position: absolute; left: var(--gap); top: calc(var(--gap) + var(--safe-t)); padding: 12px 14px 11px; max-width: 300px; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 32px; height: 26px; flex: none; animation: bob 2.4s steps(4) infinite; }
.brand h1 { margin: 0; font-family: var(--pix); font-size: 20px; line-height: 1; letter-spacing: 1px; color: var(--accent); text-shadow: 3px 3px 0 var(--edge), 0 3px 0 #c9781b; }
.brand-tag { margin: 8px 0 0; font-size: 16px; line-height: 1.2; color: var(--ink); }
.brand-status { margin: 6px 0 0; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; min-height: 18px; }
.brand-status span { transition: opacity .25s; }
.brand-status span.out { opacity: 0; }
.blip { width: 8px; height: 8px; background: var(--good); box-shadow: 0 0 0 2px var(--edge); animation: blink 1.6s steps(2) infinite; flex: none; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- top right ---------- */
.topright { position: absolute; right: var(--gap); top: calc(var(--gap) + var(--safe-t)); display: flex; gap: 8px; }
#sound .snd-on { display: none; }
#sound[aria-pressed="true"] .snd-on { display: inline; }
#sound[aria-pressed="true"] .snd-off { display: none; }
#sound[aria-pressed="true"] { color: var(--accent); }

/* ---------- missions ---------- */
.missions { position: absolute; left: var(--gap); top: calc(var(--gap) + var(--safe-t) + 132px); width: 300px; max-height: calc(100vh - 190px - var(--safe-t)); display: flex; flex-direction: column; }
.missions-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; background: none; border: 0; text-align: left; }
.mh-title { font-family: var(--pix); font-size: 12px; color: var(--ink); letter-spacing: 1px; }
.mh-caret { margin-left: auto; width: 10px; height: 10px; background:
  linear-gradient(var(--ink),var(--ink)) 0 0/10px 2px no-repeat,
  linear-gradient(var(--ink),var(--ink)) 2px 2px/6px 2px no-repeat,
  linear-gradient(var(--ink),var(--ink)) 4px 4px/2px 2px no-repeat; transition: transform .15s steps(2); }
.missions-head[aria-expanded="false"] .mh-caret { transform: rotate(180deg); }
.missions-body { padding: 0 12px 12px; overflow-y: auto; scrollbar-width: thin; }
.missions-head[aria-expanded="false"] + .missions-body { display: none; }
.missions-sub { margin: -2px 2px 10px; font-size: 14px; color: var(--muted); }
.missions-sub b { color: var(--accent); font-weight: 600; }
#mission-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mission {
  width: 100%; display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 10px;
  padding: 8px 9px; text-align: left; background: var(--panel2); border: 2px solid var(--edge);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); transition: transform .1s steps(2), background .12s;
}
.mission:hover { background: #1a4680; transform: translateX(3px); }
.mission:active { transform: translate(4px, 1px); }
.mission .ico { width: 30px; height: 30px; display: grid; place-items: center; background: var(--edge); box-shadow: inset 0 0 0 2px var(--c); }
.mission .ico svg { width: 18px; height: 18px; }
.mission .t { font-family: var(--pix); font-size: 9px; line-height: 1.35; color: var(--ink); display: block; }
.mission .d { font-size: 14px; line-height: 1.2; color: var(--muted); display: block; margin-top: 3px; }
.mission .s { display: inline-block; vertical-align: 1px; margin-left: 4px; font-family: var(--pix); font-size: 6px; line-height: 1; color: var(--c); border: 2px solid var(--c); padding: 3px 4px 2px; white-space: nowrap; }
.missions-foot { display: flex; align-items: center; gap: 10px; margin: 10px 2px 0; font-family: var(--pix); font-size: 8px; color: var(--muted); }
.loadbar { width: 64px; height: 10px; border: 2px solid var(--edge); background: var(--panel2); position: relative; overflow: hidden; flex: none; }
.loadbar i { position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: repeating-linear-gradient(90deg, var(--accent) 0 4px, transparent 4px 6px); animation: load 1.6s steps(12) infinite; }
@keyframes load { to { left: 100%; } }

/* ---------- token dock ---------- */
.dock { position: absolute; right: var(--gap); bottom: calc(var(--gap) + var(--safe-b)); width: 360px; padding: 12px; display: grid; gap: 10px; }
.ca-label { font-family: var(--pix); font-size: 9px; color: var(--accent); letter-spacing: .5px; }
.ca-row { display: flex; gap: 8px; align-items: stretch; }
#ca { flex: 1; min-width: 0; display: flex; align-items: center; padding: 6px 10px; min-height: 38px; background: var(--edge); border: 2px solid var(--line); font-family: var(--body); font-size: 15px; line-height: 1.3; color: var(--ink); white-space: normal; word-break: break-all; overflow-wrap: anywhere; user-select: all; }
#ca.placeholder { color: var(--muted); }
.copy { min-width: 78px; }
.copy.ok { background: #1f6b3a; color: #eaffe9; }

.buy {
  position: relative; display: grid; place-items: center; gap: 5px; padding: 13px 12px 11px; text-decoration: none; text-align: center;
  background: var(--accent); color: #2a1a00; border: 3px solid var(--edge);
  box-shadow: inset 0 -6px 0 0 #d99a12, inset 0 0 0 2px #fff0a8, 4px 4px 0 0 rgba(4,14,32,.55);
  transition: transform .08s steps(2), filter .12s; overflow: hidden; user-select: none;
}
.buy-main { font-family: var(--pix); font-size: 14px; letter-spacing: .5px; position: relative; }
.buy-sub { font-size: 14px; font-weight: 600; position: relative; opacity: .8; }
.buy:hover { transform: translateY(-2px); filter: brightness(1.06); }
.buy:active { transform: translate(3px, 3px); box-shadow: inset 0 4px 0 0 #d99a12, inset 0 0 0 2px #fff0a8, 1px 1px 0 0 rgba(4,14,32,.55); }
.buy.soon { cursor: not-allowed; filter: saturate(.75); }
.buy.soon:hover, .buy.soon:active { transform: none; filter: saturate(.75); box-shadow: inset 0 -6px 0 0 #d99a12, inset 0 0 0 2px #fff0a8, 4px 4px 0 0 rgba(4,14,32,.55); }
.copy:disabled { cursor: not-allowed; opacity: .6; transform: none; }
.buy.soon::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(-45deg, rgba(255,138,61,.35) 0 10px, transparent 10px 20px); background-size: 28px 28px; animation: stripes 1.2s linear infinite; }
@keyframes stripes { to { background-position: 28px 0; } }

/* ---------- map controls / hint / readout ---------- */
.mapctrl { position: absolute; right: var(--gap); bottom: calc(var(--gap) + var(--safe-b) + var(--dock-h) + 12px); display: flex; gap: 8px; }
.hint { position: absolute; left: 50%; bottom: calc(var(--gap) + var(--safe-b)); transform: translateX(-50%); padding: 8px 12px; background: rgba(6,20,42,.82); border: 2px solid var(--edge); font-size: 15px; color: var(--ink); white-space: nowrap; pointer-events: none !important; transition: opacity .6s; }
.hint.dim { opacity: .45; }
.hint-mob { display: none; }
.readout { position: absolute; left: var(--gap); bottom: calc(var(--gap) + var(--safe-b)); font-family: var(--pix); font-size: 8px; line-height: 1.7; color: var(--ink); text-shadow: 2px 2px 0 var(--edge); pointer-events: none !important; }

/* ---------- world labels (mission markers + edge arrows) ---------- */
.mlabel {
  position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; align-items: center; gap: 6px;
  padding: 5px 7px 4px; background: var(--edge); border: 2px solid var(--c); color: var(--ink);
  font-family: var(--pix); font-size: 7px; white-space: nowrap; will-change: transform; cursor: pointer;
}
.mlabel svg { width: 12px; height: 12px; flex: none; }
.mlabel .arr { display: none; width: 0; height: 0; border: 5px solid transparent; border-left: 7px solid var(--c); border-right: 0; }
.mlabel.edge .arr { display: block; }
.mlabel.edge .nm { color: var(--muted); }
.mlabel:not(.edge) .nm { display: none; }
.mlabel:not(.edge)::after { content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -4px; border: 4px solid transparent; border-top: 4px solid var(--c); border-bottom: 0; }

/* ---------- popup ---------- */
.popup { position: absolute; left: 0; top: 0; width: 290px; padding: 12px 12px 12px; will-change: transform; animation: pop .16s steps(3); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.popup .p-head { display: flex; align-items: center; gap: 8px; padding-right: 26px; }
.popup .p-ico { width: 26px; height: 26px; flex: none; display: grid; place-items: center; background: var(--edge); box-shadow: inset 0 0 0 2px var(--c, var(--accent)); }
.popup .p-ico svg { width: 16px; height: 16px; }
.popup h2 { margin: 0; font-family: var(--pix); font-size: 10px; line-height: 1.4; color: var(--ink); }
.popup .p-kind { margin-top: 8px; display: inline-block; font-family: var(--pix); font-size: 7px; padding: 3px 5px 2px; color: var(--c, var(--accent)); border: 2px solid var(--c, var(--accent)); }
.popup p { margin: 8px 0 0; font-size: 15px; line-height: 1.25; color: var(--ink); }
.popup p.m { color: var(--muted); font-size: 14px; }
.popup .p-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.popup .p-actions .pbtn { min-height: 34px; font-size: 8px; }
.popup .pbtn.wait { opacity: .8; cursor: default; position: relative; overflow: hidden; }
.popup .pbtn.wait::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 30%; background: var(--accent); animation: load 1.4s steps(10) infinite; }
.popup .p-x { position: absolute; right: 6px; top: 6px; width: 26px; height: 26px; min-height: 0; padding: 0; font-size: 10px; }

/* ---------- toast ---------- */
#toast { position: absolute; left: 50%; top: calc(var(--gap) + var(--safe-t)); transform: translate(-50%, -140%); padding: 10px 14px; background: var(--accent); color: #2a1a00; border: 3px solid var(--edge); box-shadow: 4px 4px 0 rgba(4,14,32,.5); font-family: var(--pix); font-size: 9px; line-height: 1.5; max-width: min(440px, calc(100vw - 32px)); text-align: center; transition: transform .25s steps(5); pointer-events: none !important; }
#toast.show { transform: translate(-50%, 0); }

/* ---------- loader ---------- */
#loader { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: #1b5c9f; transition: opacity .5s steps(5), visibility .5s; }
#loader.done { opacity: 0; visibility: hidden; }
.loader-card { display: grid; gap: 14px; justify-items: center; }
.loader-title { font-family: var(--pix); font-size: 22px; color: var(--accent); text-shadow: 3px 3px 0 var(--edge); }
.loader-bar { width: 220px; height: 18px; border: 3px solid var(--edge); background: var(--panel); box-shadow: inset 0 0 0 2px var(--line); padding: 3px; }
.loader-bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--accent) 0 8px, #f0b81f 8px 10px); transition: width .12s steps(3); }
.loader-text { font-size: 16px; color: var(--ink); }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; font-family: var(--pix); font-size: 12px; background: #1b5c9f; color: #fff6dc; z-index: 20; }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  :root { --gap: 10px; }
  .brand { padding: 9px 10px 8px; max-width: calc(100vw - 160px); }
  .brand h1 { font-size: 14px; }
  .brand-icon { width: 24px; height: 20px; }
  .brand-tag { font-size: 14px; margin-top: 6px; }
  .brand-status { font-size: 13px; }
  .topright { gap: 6px; }
  .pbtn.sq { width: 38px; }

  .dock { left: var(--gap); right: var(--gap); width: auto; padding: 10px; gap: 8px; }
  .ca-label { font-size: 8px; }
  #ca { font-size: 14px; min-height: 36px; }
  .buy { padding: 11px 10px 9px; gap: 4px; }
  .buy-main { font-size: 12px; }
  .buy-sub { font-size: 13px; }

  .missions { top: auto; bottom: calc(var(--gap) + var(--safe-b) + var(--dock-h) + 10px); width: auto; max-width: calc(100vw - 2 * var(--gap) - 100px); max-height: 52vh; }
  .missions.open { max-width: none; right: var(--gap); }
  .missions-head { padding: 10px 11px; min-height: 40px; }
  .mh-title { font-size: 10px; }
  .missions-body { padding: 0 10px 10px; }

  .mapctrl { bottom: calc(var(--gap) + var(--safe-b) + var(--dock-h) + 10px); gap: 6px; }
  .mapctrl .pbtn { min-height: 40px; }
  .missions.open ~ .mapctrl { visibility: hidden; }

  .hint { bottom: auto; top: calc(var(--gap) + var(--safe-t) + 104px); font-size: 13px; padding: 6px 9px; }
  .hint-desk { display: none; } .hint-mob { display: inline; }
  .readout { display: none; }
  .popup { width: min(300px, calc(100vw - 20px)); }
  .mlabel { font-size: 6px; padding: 4px 5px 3px; }
  .mlabel.edge .tt { display: none; }
  .dock > * { min-width: 0; }
}
@media (max-width: 360px) { .brand h1 { font-size: 11px; } .brand { max-width: calc(100vw - 132px); } .brand-tag { font-size: 13px; } .topright .pbtn.sq { width: 32px; min-height: 32px; } .topright { gap: 5px; } }
@media (max-width: 720px) and (max-height: 640px) { .brand-status { display: none; } .hint { top: calc(var(--gap) + var(--safe-t) + 84px); } }
@media (hover: none) { .hint-desk { display: none; } .hint-mob { display: inline; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}
