/* ==========================================
   CargoX HARBOR RUN — HUD + menus
   Fullscreen WebGL canvas with a DOM HUD on top.
   ========================================== */
:root {
    --navy: #07111d; --navy2: #0b1a33; --panel: rgba(8, 20, 42, .82); --panel2: rgba(12, 28, 58, .9);
    --green: #5ce12c; --green2: #48c81e; --green-dim: rgba(92, 225, 44, .35);
    --blue: #2f6bff; --blue2: #4a9eff; --cyan: #43d6ff;
    --red: #ff3b3b; --orange: #ff9f40; --yellow: #ffd24a;
    --text: #e6eeff; --muted: #8fa3c9;
    --brd: rgba(84, 132, 255, .45);
    --font: 'Outfit', system-ui, sans-serif; --font2: 'Inter', system-ui, sans-serif;
    --sa-t: env(safe-area-inset-top, 0px); --sa-b: env(safe-area-inset-bottom, 0px);
    --sa-l: env(safe-area-inset-left, 0px); --sa-r: env(safe-area-inset-right, 0px);
    --gap: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    background: #0a2c5c; color: var(--text); font-family: var(--font2);
    overflow: hidden; overscroll-behavior: none;
    -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
    touch-action: none;
}
button { font: inherit; color: inherit; }
.hidden { display: none !important; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }

/* ---------- glass surfaces ---------- */
.glass {
    background: linear-gradient(180deg, rgba(12, 28, 58, .86), rgba(6, 16, 36, .86));
    border: 1.5px solid var(--brd); border-radius: 14px;
    box-shadow: 0 8px 26px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06);
    backdrop-filter: blur(8px) saturate(1.2); -webkit-backdrop-filter: blur(8px) saturate(1.2);
}
svg { width: 22px; height: 22px; flex: 0 0 auto; }

/* ---------- logo ---------- */
.logo { text-align: center; font-family: var(--font); line-height: 1; }
.logo .lg-word { font-weight: 900; letter-spacing: -.5px; }
.logo .lg-cargo { color: #fff; }
.logo .lg-x { color: var(--green); text-shadow: 0 0 18px rgba(92, 225, 44, .55); }
.logo .lg-sub { color: var(--blue2); font-weight: 800; letter-spacing: .42em; margin-right: -.42em; }
.logo-hud { position: fixed; top: calc(10px + var(--sa-t)); left: 50%; transform: translateX(-50%); z-index: 20; pointer-events: none;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .45)); }
.logo-hud .lg-word { font-size: 40px; }
.logo-hud .lg-sub { font-size: 12px; margin-top: 3px; }
.logo-big .lg-word { font-size: 76px; }
.logo-big .lg-sub { font-size: 20px; margin-top: 6px; }

/* ---------- HUD layout ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }
#hud #feed, #hud #alert, #hud #dock-hint, #hud #vignette, #hud .logo-hud { pointer-events: none; }

#mission { position: fixed; top: calc(var(--gap) + var(--sa-t)); left: calc(var(--gap) + var(--sa-l)); display: flex; gap: 14px; align-items: center;
    padding: 12px 18px 12px 14px; border-color: rgba(92, 225, 44, .7); min-width: 280px; max-width: 360px; }
.mission-icon { width: 58px; height: 58px; border-radius: 10px; display: grid; place-items: center; color: #06210a;
    background: linear-gradient(180deg, #78ec3e, #3fb214); box-shadow: 0 0 18px rgba(92, 225, 44, .45); }
.mission-icon svg { width: 42px; height: 42px; }
.m-title { font-family: var(--font); font-weight: 900; font-size: 20px; letter-spacing: .02em; }
.m-route { font-weight: 700; font-size: 15px; margin-top: 3px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-route .ab { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 11px; font-weight: 900;
    background: var(--green); color: #06210a; margin-right: 4px; vertical-align: 1px; }
.m-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.m-meta { display: none; }   /* the compact touch card's "28 · 1.2 km" */
#msg-col { display: contents; }   /* desktop: every message keeps its own fixed spot */
.m-dock { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, .1); margin-top: 8px; overflow: hidden; opacity: 0; transition: opacity .2s; }
.m-dock.on { opacity: 1; }
#m-dock-fill { height: 100%; width: 0; background: linear-gradient(90deg, #3fb214, #9dff5e); box-shadow: 0 0 10px rgba(92, 225, 44, .7); }

.icon-btn { position: fixed; top: calc(var(--gap) + var(--sa-t)); left: calc(var(--gap) + var(--sa-l) + 376px); width: 46px; height: 46px; display: grid; place-items: center;
    cursor: pointer; color: var(--cyan); }
.icon-btn:hover { border-color: var(--cyan); }

#top-right { position: fixed; top: calc(var(--gap) + var(--sa-t)); right: calc(var(--gap) + var(--sa-r)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 12; }
.pill { display: flex; align-items: center; gap: 10px; padding: 10px 18px; cursor: pointer; font-family: var(--font); font-weight: 800; font-size: 17px; letter-spacing: .02em; }
.pill svg { color: var(--blue2); width: 26px; height: 26px; }
#online-label b { color: var(--green); }
.docs-pill { cursor: default; padding: 7px 14px; font-size: 15px; gap: 8px; }
.docs-pill b { font-family: var(--font); font-size: 17px; color: #fff; transition: color .3s; }
.docs-pill small { font-family: var(--font2); font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.docs-pill .live-dot { width: 7px; height: 7px; border-radius: 50%; background: #5a6a88; }
.docs-pill .live-dot.on { background: #10b981; animation: livepulse 1.4s ease-in-out infinite; }
.docs-pill.tick b { color: var(--green); }
.docs-pill.tick { box-shadow: 0 0 18px rgba(92, 225, 44, .45); }
@keyframes livepulse { 50% { opacity: .35; } }
.menu-docs { margin-top: 4px; font-size: 13px; color: var(--muted); min-height: 16px; }
.menu-docs b { color: #fff; }
.ping { font-size: 11px; color: var(--muted); padding-right: 6px; min-height: 13px; }
#side-panel { width: 270px; max-height: 50vh; overflow: auto; padding: 10px; }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tab { flex: 1; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1); border-radius: 8px; padding: 6px; font-size: 12px; font-weight: 800; letter-spacing: .08em; cursor: pointer; color: var(--muted); }
.tab.active { color: #fff; border-color: var(--green); }
.plist { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.plist li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, .04); font-size: 13px; }
.plist li.me { background: rgba(92, 225, 44, .14); border: 1px solid rgba(92, 225, 44, .4); }
.plist li .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist li .n i { color: var(--muted); font-style: normal; margin-right: 6px; }
.plist li b { color: var(--green); font-family: var(--font); }
.plist li .bdg { margin-right: 4px; }
.plist li .bdg.b1 { color: var(--cyan); }
.plist li .bdg.b2 { color: var(--yellow); }
.plist .empty { color: var(--muted); justify-content: center; }

#feed { position: fixed; top: calc(118px + var(--sa-t)); right: calc(var(--gap) + var(--sa-r)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 360px; z-index: 11; }
.feed-item { background: rgba(6, 16, 36, .78); border: 1px solid rgba(255, 255, 255, .1); border-radius: 10px; padding: 7px 12px; font-size: 13px;
    animation: feedIn .3s ease-out; transition: opacity .6s, transform .6s; }
.feed-item.bad { border-color: rgba(255, 59, 59, .55); }
.feed-item.good { border-color: rgba(92, 225, 44, .55); }
.feed-item.out { opacity: 0; transform: translateX(20px); }
@keyframes feedIn { from { opacity: 0; transform: translateX(30px); } }

#alert { position: fixed; top: calc(92px + var(--sa-t)); left: 50%; transform: translateX(-50%); z-index: 15; padding: 10px 22px; border-radius: 12px;
    background: linear-gradient(180deg, rgba(120, 10, 10, .92), rgba(70, 6, 10, .92)); border: 1.5px solid var(--red); font-family: var(--font); font-weight: 800;
    font-size: 17px; letter-spacing: .02em; box-shadow: 0 0 30px rgba(255, 59, 59, .45); animation: pulse 1s ease-in-out infinite; white-space: nowrap; }
@keyframes pulse { 50% { box-shadow: 0 0 10px rgba(255, 59, 59, .2); } }

#dock-hint { position: fixed; top: 58%; left: 50%; transform: translateX(-50%); z-index: 14; font-family: var(--font); font-weight: 800; font-size: 20px;
    padding: 8px 18px; border-radius: 12px; background: rgba(6, 16, 36, .75); border: 1.5px solid var(--green); color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .6); }
#dock-hint.warn { border-color: var(--yellow); color: var(--yellow); }

/* captain card (bottom-left) */
#captain { position: fixed; left: calc(var(--gap) + var(--sa-l)); bottom: calc(var(--gap) + var(--sa-b)); display: flex; gap: 14px; align-items: center; padding: 12px 16px 12px 12px; min-width: 330px; }
.avatar { width: 96px; height: 100px; border-radius: 12px; flex: 0 0 auto;
    /* Frame 1 of the 4-frame sheet is x 0–238 (956 px wide); trim the start of the speed trail so the whole mascot fits. */
    background: url('img/mascot-sheet.png') -11px 12px / 429px auto no-repeat, linear-gradient(180deg, #2a8cf0, #1352b8);
    border: 2px solid rgba(255, 255, 255, .25); }
.cap-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.cap-name { font-family: var(--font); font-weight: 800; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cap-name .you { color: var(--green); }
.cap-row { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 600; }
.cap-row svg { color: var(--blue2); }
.cap-delivered { margin-left: auto; color: var(--green); font-family: var(--font); font-weight: 800; }
.cap-hull { display: flex; align-items: center; gap: 10px; }
.seg-bar { display: flex; gap: 3px; flex: 1; }
.seg-bar i { flex: 1; height: 12px; border-radius: 3px; background: rgba(255, 255, 255, .12); }
.seg-bar i.on { background: linear-gradient(180deg, #86f24c, #3fb214); box-shadow: 0 0 6px rgba(92, 225, 44, .5); }
.seg-bar.mid i.on { background: linear-gradient(180deg, #ffe066, #e0a800); box-shadow: 0 0 6px rgba(255, 210, 74, .5); }
.seg-bar.low i.on { background: linear-gradient(180deg, #ff7a7a, #d62020); box-shadow: 0 0 6px rgba(255, 59, 59, .6); }
.cap-hull .shield { color: var(--muted); width: 24px; height: 24px; }

.cap-money { gap: 12px; font-family: var(--font); font-weight: 800; }
.cap-money .credits { color: var(--yellow); }
.cap-money .points { color: #fff; }
.cap-money .mult { margin-left: auto; font-size: 12px; padding: 1px 7px; border-radius: 8px; background: rgba(224, 184, 74, .18); border: 1px solid rgba(224, 184, 74, .6); color: #ffe39a; }
.badge-ico { margin-right: 4px; }
.badge-ico.b1 { color: var(--cyan); }
.badge-ico.b2 { color: #ffd24a; text-shadow: 0 0 10px rgba(255, 210, 74, .6); }

.shop-btn { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--gap) + var(--sa-b) + 150px); display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; cursor: pointer; border-color: rgba(255, 210, 74, .7); font-family: var(--font); font-weight: 900; font-size: 17px; letter-spacing: .04em; color: #ffe39a;
    box-shadow: 0 0 22px rgba(255, 210, 74, .35); animation: pulse-gold 1.6s ease-in-out infinite; }
.shop-btn svg { color: var(--yellow); width: 24px; height: 24px; }
.shop-btn kbd { font-family: var(--font2); font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .3); color: var(--muted); }
@keyframes pulse-gold { 50% { box-shadow: 0 0 8px rgba(255, 210, 74, .15); } }
.shop-panel { max-width: 720px; }
.shop-wallet { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; font-family: var(--font); font-weight: 800; font-size: 20px; }
.shop-wallet #shop-credits { color: var(--yellow); }
.shop-wallet #shop-account { font-size: 13px; color: var(--muted); font-family: var(--font2); font-weight: 600; }
.shop-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 8px; text-align: left; }
.shop-item { background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .12); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.shop-item h3 { font-family: var(--font); font-size: 16px; display: flex; justify-content: space-between; gap: 6px; }
.shop-item h3 small { color: var(--muted); font-size: 12px; font-weight: 700; }
.shop-item p { font-size: 12.5px; color: var(--muted); line-height: 1.4; flex: 1; }
.shop-item .btn { padding: 9px 10px; font-size: 14px; }
.shop-item .btn.buy { background: linear-gradient(180deg, #ffe066, #e0a800); color: #3a2800; }
.shop-item.maxed { opacity: .6; }
.board-tabs { max-width: 360px; margin: 0 auto 10px; }
.board-note { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.board .bdg { margin-right: 5px; }
.board .bdg.b1 { color: var(--cyan); }
.board .bdg.b2 { color: var(--yellow); }
.account-box { margin: -8px 0 18px; font-size: 13.5px; line-height: 1.5; color: var(--muted); padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); }
.account-box a { color: var(--green); font-weight: 700; }
.account-box b { color: #fff; }
.account-box .op { color: #ffe39a; }
.over-career { font-size: 13px; color: var(--muted); margin: -4px 0 12px; }

#hot-banner { position: fixed; top: calc(62px + var(--sa-t)); left: 50%; transform: translateX(-50%); z-index: 15; padding: 7px 18px; border-radius: 12px; pointer-events: none;
    background: linear-gradient(180deg, rgba(120, 60, 0, .9), rgba(80, 36, 0, .9)); border: 1.5px solid #ffb13b; font-family: var(--font); font-weight: 800; font-size: 15px;
    color: #ffe2a8; box-shadow: 0 0 24px rgba(255, 160, 40, .45); white-space: nowrap; }
#hot-banner b { color: #fff; }
#alert { top: calc(104px + var(--sa-t)); }
#social { position: fixed; right: calc(var(--gap) + var(--sa-r)); bottom: calc(var(--gap) + var(--sa-b) + 252px); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 12; }
.soc-btn { width: 46px; height: 46px; border-radius: 50%; font-size: 21px; cursor: pointer; display: grid; place-items: center; }
.soc-btn:hover { border-color: var(--cyan); }
.emote-menu { display: flex; flex-direction: column; gap: 4px; padding: 6px; position: absolute; right: 54px; bottom: 0; }
.emote-menu button { background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1); border-radius: 8px; padding: 7px 12px; text-align: left; cursor: pointer; font-size: 14px; white-space: nowrap; }
.emote-menu button:hover { border-color: var(--green); }
.tag .bubble { position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%) scale(.6); opacity: 0; transition: opacity .2s, transform .2s;
    background: #fff; color: #0b1a33; font-family: var(--font); font-weight: 800; font-size: 14px; padding: 5px 11px; border-radius: 12px; white-space: nowrap; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); }
.tag .bubble::after { content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #fff; }
.tag .bubble.show { opacity: 1; transform: translateX(-50%) scale(1); }
.m-title.hot { color: #ffb13b; text-shadow: 0 0 12px rgba(255, 160, 40, .6); }

/* weapon bar (above the controls bar) */
#weapon-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--gap) + var(--sa-b) + 88px); display: flex; gap: 6px; padding: 6px; z-index: 11; }
.wslot { position: relative; display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 10px; cursor: pointer; min-width: 96px;
    background: rgba(255, 255, 255, .05); border: 1.5px solid rgba(255, 255, 255, .12); font-family: var(--font); font-weight: 800; font-size: 13px; letter-spacing: .03em; }
.wslot .wico { font-style: normal; font-size: 17px; }
.wslot .wammo { margin-left: auto; font-size: 13px; color: var(--yellow); }
.wslot.active { border-color: var(--red); box-shadow: 0 0 14px rgba(255, 80, 60, .45); background: rgba(255, 70, 40, .14); }
.wslot.locked { opacity: .38; }
.wslot.locked::after { content: '🔒'; position: absolute; top: -6px; right: -4px; font-size: 11px; }
.wslot.empty .wammo { color: var(--red); }
.wheat { position: absolute; left: 8px; right: 8px; bottom: 3px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .1); overflow: hidden; }
#heat-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ffd24a, #ff3b3b); }
.wslot.hot #heat-fill { background: #ff3b3b; animation: pulse 0.4s infinite; }
body.playing #scene { cursor: crosshair; }
#aimstick, .weapon-touch { display: none; }

.map-overlay { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; pointer-events: none; background: rgba(4, 12, 26, .35); }
.map-panel { pointer-events: auto; padding: 10px; }
.map-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 0 4px 8px; font-family: var(--font); }
.map-head b { font-size: 18px; letter-spacing: .1em; }
.map-head span { font-size: 12px; color: var(--muted); }
#bigmap { display: block; width: min(86vh, 92vw, 860px); height: min(86vh, 92vw, 860px); border-radius: 10px; cursor: pointer; }
#minimap { cursor: pointer; }

/* bottom-centre controls */
#controls-bar { position: fixed; bottom: calc(var(--gap) + var(--sa-b)); left: 50%; transform: translateX(-50%); display: flex; gap: 12px; align-items: stretch; padding: 10px; }
#controls-bar > * { border-radius: 11px; }
.speed { display: flex; align-items: center; gap: 8px; padding: 0 16px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .12); min-width: 170px; }
.speed svg { width: 34px; height: 34px; color: #fff; }
.speed b { font-family: var(--font); font-size: 30px; font-weight: 800; min-width: 44px; text-align: right; }
.speed span { font-size: 16px; font-weight: 700; color: var(--muted); }
.throttle { width: 8px; height: 38px; border-radius: 4px; background: rgba(255, 255, 255, .1); margin-left: 6px; position: relative; overflow: hidden; }
#throttle-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--cyan); }
#throttle-fill.rev { background: var(--orange); }
.boost-btn { position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px; padding: 12px 28px; cursor: pointer; border: 0;
    background: #1b3a1a; color: #062a06; font-family: var(--font); font-size: 24px; font-weight: 900; letter-spacing: .02em; min-width: 210px; justify-content: center; }
.boost-btn svg, .boost-btn span { position: relative; z-index: 1; }
.boost-btn svg { width: 30px; height: 30px; }
#boost-fill, #boost-fill-touch { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(180deg, #8cf552, #45c11a); transition: filter .15s; }
.boost-btn.active #boost-fill { filter: brightness(1.25) saturate(1.3); }
.boost-btn.active { box-shadow: 0 0 26px rgba(92, 225, 44, .8); }
.boost-btn.empty { color: rgba(255, 255, 255, .5); }
.flare-btn { position: relative; display: flex; align-items: center; gap: 8px; padding: 0 18px; cursor: pointer; background: rgba(255, 70, 40, .12); border: 1px solid rgba(255, 110, 70, .55);
    font-family: var(--font); font-size: 19px; font-weight: 800; letter-spacing: .03em; color: #ffd9cf; }
.flare-btn svg { width: 28px; height: 28px; color: #ff5a36; }
.flare-btn b, .flare-touch b { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 11px; background: #ff5a36; color: #fff; font-size: 13px; }
.flare-btn:hover { border-color: #ff8a66; box-shadow: 0 0 16px rgba(255, 90, 54, .4); }
.flare-btn.empty, .flare-touch.empty { opacity: .45; }
.flare-btn.empty b, .flare-touch.empty b { background: rgba(255, 255, 255, .2); }
.route-btn { display: flex; align-items: center; gap: 10px; padding: 0 22px; cursor: pointer; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .15);
    font-family: var(--font); font-size: 19px; font-weight: 800; letter-spacing: .03em; }
.route-btn svg { width: 30px; height: 30px; color: var(--muted); }
.route-btn.active { border-color: var(--green); }
.route-btn.active svg { color: var(--green); }

#minimap-wrap { position: fixed; right: calc(var(--gap) + var(--sa-r)); bottom: calc(var(--gap) + var(--sa-b)); padding: 8px; }
#minimap { display: block; width: 220px; height: 220px; border-radius: 9px; }
.mm-n { position: absolute; top: 12px; right: 16px; font-family: var(--font); font-weight: 900; font-size: 14px; color: #fff; text-shadow: 0 1px 3px #000; }
.mm-n::before { content: '▲'; display: block; font-size: 16px; line-height: 1; text-align: center; }
.mm-scale { position: absolute; right: 16px; bottom: 12px; font-size: 11px; font-weight: 700; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-shadow: 0 1px 3px #000; }
.mm-scale i { display: block; width: 36px; height: 5px; border: 2px solid #fff; border-top: 0; }

#rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 520px) {
    body.touch #rotate-hint { display: block; position: fixed; left: 50%; bottom: calc(352px + var(--sa-b)); transform: translateX(-50%); z-index: 12; pointer-events: none;
        padding: 5px 12px; border-radius: 10px; background: rgba(6, 16, 36, .7); font-size: 12px; color: var(--muted); white-space: nowrap; animation: hint-fade 8s forwards; }
}
@keyframes hint-fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
#vignette { position: fixed; inset: 0; z-index: 9; opacity: 0; transition: opacity .5s;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 30, 30, .55) 100%); }
#vignette.on { opacity: 1; transition: opacity .05s; }

/* touch controls */
#joystick, .boost-touch, .flare-touch { display: none; }
body.touch #joystick { display: block; position: fixed; left: calc(28px + var(--sa-l)); bottom: calc(30px + var(--sa-b)); width: 136px; height: 136px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, .08), rgba(255, 255, 255, .03)); border: 2px solid rgba(255, 255, 255, .22); touch-action: none; z-index: 13; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #8cf552, #2f8d10); box-shadow: 0 4px 12px rgba(0, 0, 0, .4); }
body.touch .boost-touch { display: grid; place-items: center; position: fixed; right: calc(28px + var(--sa-r)); bottom: calc(36px + var(--sa-b)); width: 104px; height: 104px;
    border-radius: 50%; border: 2px solid rgba(255, 255, 255, .3); background: #1b3a1a; overflow: hidden; color: #062a06; z-index: 13; touch-action: none; }
body.touch .flare-touch { display: grid; place-items: center; position: fixed; right: calc(40px + var(--sa-r)); bottom: calc(152px + var(--sa-b)); width: 74px; height: 74px;
    border-radius: 50%; border: 2px solid rgba(255, 110, 70, .6); background: rgba(80, 16, 8, .7); color: #ff5a36; z-index: 13; touch-action: none; }
.flare-touch svg { width: 32px; height: 32px; }
.flare-touch b { position: absolute; top: -4px; right: -4px; }
.boost-touch svg { position: relative; z-index: 1; width: 44px; height: 44px; }
.boost-touch.active { box-shadow: 0 0 26px rgba(92, 225, 44, .8); }
#boost-fill-touch { inset: auto 0 0 0; width: 100%; height: 100%; }

/* ---------- world labels ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; will-change: transform; }
.tag .tb { background: rgba(6, 16, 36, .82); border: 1.5px solid rgba(255, 255, 255, .22); border-radius: 7px; padding: 3px 9px 4px; font-family: var(--font); font-weight: 700; font-size: 14px;
    text-align: center; }
.tag .hb { display: flex; gap: 2px; margin-top: 3px; }
.tag .hb i { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .15); }
.tag .hb i.on { background: var(--green); }
.tag.me .tb { border-color: var(--green); }
.tag.me .tb b { color: var(--green); }
.tag .tb .b1 { color: var(--cyan); }
.tag .tb .b2 { color: var(--yellow); }
.tag.op .tb { border-color: rgba(255, 210, 74, .75); }
.tag.bot .tb { color: #c9d6f0; border-style: dashed; }
.tag.bot.hostile .tb { border-color: var(--orange); color: #ffd9b0; }
.plist li.bot { opacity: .8; }
.tag.pirate .tb { border-color: var(--red); color: #ffd6d6; }
.tag.pirate .tb b { color: var(--red); }
.tag.pirate .hb i.on { background: var(--red); }
.tag.guard .tb { border-color: var(--cyan); color: #d6f6ff; }
.tag.guard .tb b { color: var(--cyan); }
.tag.port .tb { font-family: var(--font); font-weight: 900; font-size: 17px; letter-spacing: .04em; padding: 5px 14px; border: 2px solid rgba(84, 132, 255, .6); background: rgba(8, 20, 42, .85); }
.tag.port.target .tb { border-color: var(--green); box-shadow: 0 0 16px rgba(92, 225, 44, .5); }
.tag.port .ab { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #06210a; font-size: 13px; margin-left: 8px; vertical-align: 1px; }
.tag.far { opacity: .55; transform-origin: 50% 100%; }

/* ---------- overlays / menus ---------- */
.lang-selector { position: fixed; top: calc(12px + var(--sa-t)); right: calc(14px + var(--sa-r)); z-index: 40; display: flex; gap: 6px; }
.lang-btn { background: rgba(20, 32, 70, .6); border: 1px solid rgba(255, 255, 255, .15); color: var(--muted); border-radius: 9px; padding: 5px 10px; font-size: 12px; font-weight: 800; cursor: pointer; font-family: var(--font); }
.lang-btn.active, .lang-btn:hover { color: #fff; border-color: var(--cyan); box-shadow: 0 0 12px rgba(67, 214, 255, .35); }
.overlay { position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; padding: 20px;
    background: radial-gradient(ellipse at center, rgba(4, 12, 26, .35), rgba(4, 12, 26, .75)); }
.overlay.active { display: flex; }
.overlay.translucent { background: rgba(4, 12, 26, .45); }
#screen-menu { background: radial-gradient(ellipse at 50% 40%, rgba(4, 12, 26, .1), rgba(4, 12, 26, .6)); }
.panel { background: linear-gradient(180deg, rgba(10, 24, 50, .9), rgba(6, 14, 32, .92)); border: 1.5px solid var(--brd); border-radius: 20px; padding: 30px 34px;
    max-width: 480px; width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); max-height: calc(100vh - 40px); overflow: auto; }
.panel.wide { max-width: 980px; }
.panel.small { max-width: 340px; padding: 24px; }
.menu-panel { background: linear-gradient(180deg, rgba(10, 24, 50, .72), rgba(6, 14, 32, .8)); }
.panel h2 { font-family: var(--font); font-weight: 900; font-size: 28px; margin-bottom: 10px; }
.panel .lead { color: var(--muted); font-size: 15px; line-height: 1.5; margin-bottom: 18px; }
.tagline { color: var(--muted); margin: 14px 0 22px; font-size: 15px; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; }
.menu-buttons .row { display: flex; gap: 10px; }
.menu-buttons .row > * { flex: 1; }
.btn { display: block; border-radius: 13px; padding: 14px 18px; font-family: var(--font); font-weight: 800; font-size: 16px; letter-spacing: .04em; cursor: pointer;
    text-decoration: none; text-align: center; border: 1.5px solid transparent; transition: transform .1s, box-shadow .15s, border-color .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(180deg, #7cf046, #3fb214); color: #062a06; font-size: 20px; font-weight: 900; }
.btn.primary.glow { box-shadow: 0 0 26px rgba(92, 225, 44, .45); position: relative; overflow: hidden; }
.btn.primary.glow::after { content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
    transform: skewX(-20deg); animation: sheen 3.2s ease-in-out infinite; }
@keyframes sheen { 0%, 60% { left: -60%; } 100% { left: 130%; } }
.btn.secondary { background: rgba(30, 60, 130, .35); border-color: rgba(84, 132, 255, .5); color: #fff; }
.btn.secondary:hover { border-color: var(--cyan); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: #fff; }
.btn.danger { background: rgba(160, 20, 20, .35); border-color: rgba(255, 59, 59, .6); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.lang-row { justify-content: center; }
.lang-row .lang-btn { flex: 0 0 auto; padding: 8px 18px; font-size: 14px; }
.menu-online { margin-top: 16px; font-size: 13px; color: var(--green); min-height: 16px; }
.credits { margin-top: 10px; font-size: 12px; color: var(--muted); opacity: .7; }

#nick-input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--brd); background: rgba(0, 0, 0, .35); color: #fff;
    font-family: var(--font); font-size: 22px; font-weight: 700; text-align: center; outline: none; user-select: text; -webkit-user-select: text; }
#nick-input:focus { border-color: var(--green); box-shadow: 0 0 16px rgba(92, 225, 44, .3); }
.form-msg { min-height: 22px; margin: 8px 0 10px; font-size: 14px; color: var(--yellow); }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 12px; margin-bottom: 16px; }
.step { background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .1); border-radius: 14px; padding: 16px 12px; text-align: center; }
.step .badge { width: 36px; height: 36px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: #062a06; font-family: var(--font); font-weight: 900; }
.step.danger .badge { background: var(--red); color: #fff; }
.step h3 { font-family: var(--font); font-size: 16px; margin-bottom: 6px; }
.step p { font-size: 13px; color: var(--muted); line-height: 1.45; }
.keys { font-size: 13px; color: var(--cyan); margin-bottom: 18px; }

.board { width: 100%; border-collapse: collapse; margin-bottom: 18px; font-size: 14px; }
.board th { font-size: 11px; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; padding: 6px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, .1); }
.board td { padding: 8px 6px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.board td:nth-child(n+3), .board th:nth-child(n+3) { text-align: right; }
.board td:nth-child(3) { color: var(--green); font-family: var(--font); font-weight: 800; }
.board tr.me td { background: rgba(92, 225, 44, .12); }
.board .empty td { text-align: center; color: var(--muted); }
.board.compact { font-size: 13px; }
.board.compact td { padding: 5px 6px; }

.over-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 8px 0 14px; }
.over-stats div { background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 12px 6px; }
.over-stats label { display: block; font-size: 11px; color: var(--muted); letter-spacing: .06em; margin-bottom: 4px; }
.over-stats b { font-family: var(--font); font-size: 24px; color: var(--green); }
.title-bad { color: var(--red); text-shadow: 0 0 16px rgba(255, 59, 59, .45); }

.spinner { width: 38px; height: 38px; margin: 0 auto 14px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .15); border-top-color: var(--green); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#boot-error { position: fixed; inset: auto 20px 20px 20px; z-index: 60; background: rgba(120, 10, 10, .92); border: 1px solid var(--red); border-radius: 12px; padding: 12px 16px; font-size: 14px; }

/* ---------- responsive ---------- */
/* Mid-size screens: FLARE / ROUTE shrink to icons so the bar clears the captain card. */
@media (max-width: 1440px) {
    .route-btn span, .flare-btn span { display: none; }
    .route-btn, .flare-btn { padding: 0 14px; }
}
/* Laptop widths: the bottom row can't fit the captain card next to the controls
   bar, so the card moves up under the mission card. */
@media (max-width: 1280px) {
    #captain { top: calc(var(--gap) + var(--sa-t) + 126px); bottom: auto; }
}
@media (max-width: 1180px) {
    .speed { min-width: 140px; }
    .logo-hud .lg-word { font-size: 30px; }
    .logo-hud .lg-sub { font-size: 10px; }
    .boost-btn { min-width: 150px; font-size: 20px; padding: 10px 16px; }
    .route-btn { font-size: 16px; padding: 0 14px; }
    .flare-btn { font-size: 16px; padding: 0 12px; }
    #captain { min-width: 280px; }
}
@media (max-width: 900px), (max-height: 560px) {
    :root { --gap: 10px; }
    .logo-hud { display: none; }
    #mission { min-width: 0; max-width: 270px; padding: 8px 12px 8px 8px; gap: 10px; }
    .mission-icon { width: 40px; height: 40px; }
    .mission-icon svg { width: 28px; height: 28px; }
    .m-title { font-size: 15px; }
    .m-route { font-size: 13px; }
    .m-sub { font-size: 12px; }
    .icon-btn { left: auto; right: calc(var(--gap) + var(--sa-r)); top: calc(var(--gap) + var(--sa-t)); width: 40px; height: 40px; }
    #top-right { right: calc(var(--gap) + var(--sa-r) + 50px); }
    .pill { padding: 7px 12px; font-size: 14px; }
    .docs-pill small { display: none; }
    .pill svg { width: 20px; height: 20px; }
    #feed { top: calc(64px + var(--sa-t)); max-width: 260px; }
    .feed-item { font-size: 12px; padding: 5px 9px; }
    /* Small screens: captain card sits under the mission card so the bottom row
       only holds the controls bar and the minimap. */
    #captain { min-width: 0; padding: 8px 10px 8px 8px; gap: 10px; top: calc(var(--gap) + var(--sa-t) + 88px); bottom: auto; }
    .avatar { width: 56px; height: 58px; background-size: 250px auto; background-position: -6px 7px; }
    .cap-name { font-size: 14px; }
    .cap-row { font-size: 12px; gap: 6px; }
    .cap-row svg { width: 16px; height: 16px; }
    .seg-bar i { height: 8px; }
    #minimap { width: 120px; height: 120px; }
    #minimap-wrap { padding: 5px; }
    .mm-n { top: 7px; right: 10px; font-size: 11px; }
    .mm-scale { display: none; }
    #controls-bar { padding: 6px; gap: 8px; }
    .speed { min-width: 0; padding: 0 10px; }
    .speed svg { width: 24px; height: 24px; }
    .speed b { font-size: 22px; min-width: 30px; }
    .speed span { font-size: 12px; }
    .boost-btn { min-width: 0; font-size: 16px; padding: 8px 14px; }
    .boost-btn svg { width: 22px; height: 22px; }
    .route-btn { font-size: 14px; padding: 0 10px; }
    .flare-btn { font-size: 14px; padding: 0 10px; gap: 6px; }
    .flare-btn svg { width: 20px; height: 20px; }
    .flare-btn span { display: none; }
    .route-btn svg { width: 22px; height: 22px; }
    #alert { font-size: 13px; top: calc(70px + var(--sa-t)); white-space: normal; text-align: center; width: min(92vw, 440px); }
    #dock-hint { font-size: 16px; }
    .tag .tb { font-size: 12px; padding: 2px 7px 3px; }
    .tag.guard .tb { border-color: var(--cyan); color: #d6f6ff; }
.tag.guard .tb b { color: var(--cyan); }
.tag.port .tb { font-size: 13px; padding: 3px 10px; }
    .logo-big .lg-word { font-size: 52px; }
    .logo-big .lg-sub { font-size: 15px; }
    .panel { padding: 20px 18px; }
    .steps { grid-template-columns: repeat(2, 1fr); }
    .over-stats { grid-template-columns: repeat(3, 1fr); }
    #social { bottom: calc(var(--gap) + var(--sa-b) + 146px); }
    .soc-btn { width: 38px; height: 38px; font-size: 17px; }
    #hot-banner { display: none; }
    .shop-btn { bottom: calc(var(--gap) + var(--sa-b) + 64px); font-size: 14px; padding: 7px 14px; }
    .cap-money { font-size: 12px; }
}
/* phones: captain card moves under the mission card, joystick + boost take the bottom corners */
body.touch #controls-bar .boost-btn, body.touch #controls-bar .flare-btn { display: none; }
body.touch #captain { top: calc(var(--gap) + var(--sa-t) + 88px); bottom: auto; }
body.touch #controls-bar { bottom: calc(14px + var(--sa-b)); }
body.touch .shop-btn { bottom: calc(80px + var(--sa-b)); }
body.touch #minimap-wrap { bottom: auto; top: calc(var(--gap) + var(--sa-t) + 56px); }
body.touch #feed { top: auto; bottom: calc(150px + var(--sa-b)); }
body.touch #social { bottom: auto; top: calc(var(--gap) + var(--sa-t) + 190px); }
body.touch #top-right #side-panel { max-height: 40vh; }
@media (max-width: 520px) {
    .ol-pre, .ol-word { display: none; }
    .pill { gap: 6px; padding: 7px 10px; }
    #mission { max-width: calc(100vw - 150px); }
    .docs-pill { display: none; }
    /* Portrait phone: the controls bar sits above the joystick/boost row. */
    body.touch #controls-bar { bottom: calc(238px + var(--sa-b)); }
    /* Shop becomes a round gold icon under the horn/message buttons. */
    body.touch .shop-btn { left: auto; right: calc(var(--gap) + var(--sa-r)); transform: none; bottom: auto; top: calc(var(--gap) + var(--sa-t) + 352px);
        width: 46px; height: 46px; padding: 0; border-radius: 50%; justify-content: center; }
    body.touch .shop-btn span, body.touch .shop-btn kbd { display: none; }
    body.touch #social { top: calc(var(--gap) + var(--sa-t) + 250px); }
    .steps { grid-template-columns: 1fr; }
    .over-stats b { font-size: 22px; }
    body.touch #minimap-wrap { display: none; }
}

/* Phone in landscape: little height, so the captain card hides (hull + cargo stay on
   the ship tag and the mission card) and the right column is re-packed. */
@media (max-height: 500px) {
    body.touch #captain { display: none; }
    body.touch #minimap-wrap { top: calc(var(--gap) + var(--sa-t) + 50px); }
    body.touch #minimap { width: 110px; height: 110px; }
    body.touch #social { top: calc(var(--gap) + var(--sa-t) + 50px); right: calc(var(--gap) + var(--sa-r) + 130px); bottom: auto; flex-direction: row; }
    body.touch #social .emote-menu { right: 0; top: 50px; bottom: auto; }
    body.touch .flare-touch { right: calc(146px + var(--sa-r)); bottom: calc(40px + var(--sa-b)); width: 64px; height: 64px; }
    body.touch #joystick { width: 120px; height: 120px; bottom: calc(18px + var(--sa-b)); }
    body.touch .boost-touch { width: 96px; height: 96px; bottom: calc(24px + var(--sa-b)); }
    body.touch #feed { bottom: auto; top: calc(var(--gap) + var(--sa-t) + 50px); right: calc(var(--gap) + var(--sa-r) + 250px); max-width: 220px; }
}

/* Twin-stick touch: left = steer/throttle, right = aim (push = fire). */
body.touch #aimstick { display: block; position: fixed; right: calc(28px + var(--sa-r)); bottom: calc(30px + var(--sa-b)); width: 136px; height: 136px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 70, 40, .10), rgba(255, 255, 255, .03)); border: 2px solid rgba(255, 110, 70, .45); touch-action: none; z-index: 13; }
#aim-knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #ff8a66, #c2281a); box-shadow: 0 4px 12px rgba(0, 0, 0, .4); }
#aim-knob::after { content: '⌖'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 26px; }
body.touch .boost-touch { right: calc(176px + var(--sa-r)); bottom: calc(30px + var(--sa-b)); width: 84px; height: 84px; }
body.touch .boost-touch svg { width: 36px; height: 36px; }
body.touch .flare-touch { right: calc(176px + var(--sa-r)); bottom: calc(128px + var(--sa-b)); width: 60px; height: 60px; }
body.touch .weapon-touch { display: grid; place-items: center; position: fixed; right: calc(48px + var(--sa-r)); bottom: calc(180px + var(--sa-b)); width: 56px; height: 56px;
    border-radius: 50%; border: 2px solid rgba(255, 110, 70, .6); background: rgba(40, 10, 8, .7); font-size: 24px; z-index: 13; touch-action: none; }
body.touch #weapon-bar { gap: 3px; padding: 4px; bottom: calc(80px + var(--sa-b)); }
body.touch .wslot { min-width: 0; padding: 5px 8px; }
body.touch .wslot .wname { display: none; }
@media (max-width: 520px) {
    body.touch #weapon-bar { bottom: calc(292px + var(--sa-b)); }
    body.touch .boost-touch { right: calc(24px + var(--sa-r)); bottom: calc(176px + var(--sa-b)); }
    body.touch .flare-touch { right: calc(118px + var(--sa-r)); bottom: calc(190px + var(--sa-b)); }
    body.touch .weapon-touch { right: calc(176px + var(--sa-r)); bottom: calc(40px + var(--sa-b)); }
    body.touch #rotate-hint { bottom: calc(400px + var(--sa-b)); }
}
@media (max-height: 500px) {
    body.touch #aimstick { width: 120px; height: 120px; bottom: calc(18px + var(--sa-b)); }
    body.touch .boost-touch { right: calc(158px + var(--sa-r)); bottom: calc(20px + var(--sa-b)); width: 76px; height: 76px; }
    body.touch .flare-touch { right: calc(158px + var(--sa-r)); bottom: calc(104px + var(--sa-b)); width: 56px; height: 56px; }
    body.touch .weapon-touch { right: calc(244px + var(--sa-r)); bottom: calc(28px + var(--sa-b)); width: 52px; height: 52px; font-size: 22px; }
    body.touch .weapon-touch b { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--yellow); color: #3a2800;
        font-size: 11px; display: grid; place-items: center; }
    body.touch #controls-bar { left: 40%; }
    body.touch #weapon-bar { display: none; }   /* the weapon button shows the current weapon + ammo */
    body.touch .shop-btn { bottom: calc(76px + var(--sa-b)); left: 40%; }
}
@media (max-width: 1180px) {
    .wslot { min-width: 0; padding: 5px 9px; }
    .wslot .wname { display: none; }
    #weapon-bar { bottom: calc(var(--gap) + var(--sa-b) + 70px); }
}

/* Portrait phone: keep only what you need while sailing — the rest is on the ship tag,
   the mission card, the weapon button and the pause menu. Landscape is recommended. */
@media (orientation: portrait) and (max-width: 520px) {
    body.touch #captain, body.touch #weapon-bar, body.touch #docs-pill, body.touch #ping { display: none !important; }
    body.touch #controls-bar { top: calc(var(--gap) + var(--sa-t) + 62px); bottom: auto; left: auto; right: calc(var(--gap) + var(--sa-r)); transform: none; padding: 4px; gap: 4px; }
    body.touch #controls-bar .speed { padding: 0 8px; }
    body.touch #controls-bar .speed svg, body.touch #controls-bar .throttle { display: none; }
    body.touch #controls-bar .route-btn { padding: 0 8px; }
    body.touch #social { top: calc(var(--gap) + var(--sa-t) + 124px); }
    body.touch .shop-btn { top: calc(var(--gap) + var(--sa-t) + 226px); }
    body.touch #feed { top: calc(var(--gap) + var(--sa-t) + 140px); bottom: auto; right: calc(var(--gap) + var(--sa-r) + 58px); max-width: 64vw; }
    body.touch #rotate-hint { display: block; position: fixed; left: 50%; top: calc(var(--gap) + var(--sa-t) + 104px); bottom: auto; transform: translateX(-50%);
        animation: none; z-index: 12; pointer-events: none; padding: 6px 12px; border-radius: 10px; background: rgba(6, 16, 36, .82);
        border: 1px solid rgba(67, 214, 255, .5); font-size: 12px; color: var(--cyan); white-space: nowrap; }
    body.touch .weapon-touch { right: calc(176px + var(--sa-r)); bottom: calc(40px + var(--sa-b)); }
    body.touch .weapon-touch b { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--yellow); color: #3a2800;
        font-size: 11px; display: grid; place-items: center; }
    #dock-hint { top: 44%; }
}
.nick-tip { display: none; margin: -6px 0 14px; font-size: 13px; color: var(--cyan); }
@media (orientation: portrait) and (max-width: 520px) { body.touch .nick-tip { display: block; } }

/* ---------- aiming feedback ---------- */
/* Hit marker: four ticks around the hit point, for hits the server confirmed. */
#hitmark { position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: 8; pointer-events: none; opacity: 0; }
#hitmark i { position: absolute; left: -1.5px; top: -9px; width: 3px; height: 7px; border-radius: 2px; background: #fff; box-shadow: 0 0 6px rgba(255, 220, 120, .9); }
#hitmark i:nth-child(1) { transform: rotate(45deg) translateY(-7px); }
#hitmark i:nth-child(2) { transform: rotate(135deg) translateY(-7px); }
#hitmark i:nth-child(3) { transform: rotate(225deg) translateY(-7px); }
#hitmark i:nth-child(4) { transform: rotate(315deg) translateY(-7px); }
#hitmark.on { animation: hitmark .28s ease-out; }
#hitmark.strong i { background: #ffd23a; height: 10px; box-shadow: 0 0 10px rgba(255, 150, 40, .95); }
#hitmark.strong.on { animation: hitmark .45s ease-out; }
@keyframes hitmark { 0% { opacity: 1; scale: .6; } 35% { opacity: 1; scale: 1.15; } 100% { opacity: 0; scale: 1.3; } }

#weapon-toast { position: fixed; left: 50%; bottom: calc(var(--gap) + var(--sa-b) + 150px); transform: translateX(-50%); z-index: 12; pointer-events: none; opacity: 0;
    padding: 6px 14px; border-radius: 10px; background: rgba(6, 16, 36, .82); border: 1px solid rgba(255, 110, 70, .55); font-family: var(--font); font-weight: 800;
    font-size: 15px; letter-spacing: .04em; white-space: nowrap; }
#weapon-toast.on { animation: wtoast 1.3s ease-out forwards; }
@keyframes wtoast { 0% { opacity: 0; translate: 0 6px; } 12%, 70% { opacity: 1; translate: 0 0; } 100% { opacity: 0; } }

/* Pressed feedback for buttons that act on press. */
.pressed { filter: brightness(1.45); scale: .92; transition: scale .06s, filter .06s; }
.wslot, .flare-btn, .soc-btn, .route-btn, .shop-btn, .flare-touch, .weapon-touch, .boost-touch { transition: scale .12s, filter .12s; }

/* ---------- touch action cluster (phones / tablets) ----------
   The right thumb rests on the aim stick; boost, flare and weapon sit on an arc
   around it, big enough to hit blind. The ::before ring widens the hit area. */
body.touch .flare-touch, body.touch .weapon-touch { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
body.touch .flare-touch::before, body.touch .weapon-touch::before { content: ''; position: absolute; inset: -12px; border-radius: 50%; }
body.touch .boost-touch { -webkit-tap-highlight-color: transparent; }
body.touch .weapon-touch { width: 64px; height: 64px; font-size: 27px; }
body.touch .flare-touch { width: 66px; height: 66px; }
body.touch .weapon-touch b, body.touch .flare-touch b { pointer-events: none; }
body.touch #weapon-toast { bottom: calc(var(--sa-b) + 84px); }
@media (orientation: portrait) and (max-width: 520px) { body.touch #weapon-toast { bottom: calc(var(--sa-b) + 272px); } }

/* ---------- Battle Royale ---------- */
.soc-btn.off { opacity: .42; filter: grayscale(.6); }
.br-bar { position: fixed; top: calc(62px + var(--sa-t)); left: 50%; transform: translateX(-50%); z-index: 15; pointer-events: none; display: flex; align-items: center; gap: 14px;
    padding: 7px 16px; border-radius: 12px; white-space: nowrap; font-family: var(--font); font-weight: 800; font-size: 15px; color: #ffe0e5;
    background: linear-gradient(180deg, rgba(90, 8, 24, .9), rgba(52, 4, 14, .9)); border: 1.5px solid rgba(255, 59, 92, .8); box-shadow: 0 0 22px rgba(255, 40, 80, .35); }
.br-bar b { color: #fff; }
.br-bar.count { font-size: 16px; animation: pulse 1s ease-in-out infinite; }
.br-bar .bp { display: inline-flex; align-items: baseline; gap: 5px; }
.br-bar .bp i { font-style: normal; }
.br-bar .bp small { font-family: var(--font2); font-size: 12px; font-weight: 600; color: #ffb3c0; }
.br-bar .bz.shrink b { color: #ff8a9c; }
.br-center { position: fixed; top: 34%; left: 50%; transform: translate(-50%, -50%); z-index: 16; pointer-events: none; text-align: center; white-space: nowrap;
    font-family: var(--font); font-weight: 900; font-size: 42px; letter-spacing: .02em; color: #fff; text-shadow: 0 3px 14px rgba(0, 0, 0, .6); }
.br-center.grace { color: #ffe39a; font-size: 34px; }
.br-center.free { color: #ff5a6e; animation: brpop .5s ease-out; }
.br-center.out { color: #ff3b5c; animation: pulse-text .5s ease-in-out infinite alternate; }
.br-center.elim { color: #ffd6dc; font-size: 36px; animation: brpop .5s ease-out; }
@keyframes brpop { 0% { scale: .6; opacity: 0; } 60% { scale: 1.12; opacity: 1; } 100% { scale: 1; } }
@keyframes pulse-text { to { opacity: .55; scale: 1.06; } }
#vignette.zone { opacity: 1; animation: zonevig 1s ease-in-out infinite;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 20, 50, .6) 100%); }
@keyframes zonevig { 50% { opacity: .35; } }
.spec-bar { position: fixed; left: 50%; bottom: calc(var(--gap) + var(--sa-b) + 10px); transform: translateX(-50%); z-index: 14; display: flex; align-items: center; gap: 12px;
    padding: 8px 10px; border-color: rgba(255, 255, 255, .35); }
.spec-btn { width: 48px; height: 48px; border-radius: 12px; border: 1.5px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .06); cursor: pointer;
    font-size: 20px; display: grid; place-items: center; touch-action: none; transition: scale .12s, filter .12s; }
.spec-btn:hover { border-color: var(--cyan); }
.spec-body { text-align: center; min-width: 200px; max-width: 60vw; }
.spec-name { font-family: var(--font); font-weight: 800; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spec-name b { color: #fff; }
.spec-name .spec-k { font-size: 14px; color: #ffb3c0; margin-left: 4px; }
.spec-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Out of the round / waiting for it: no ship controls, only the camera and the menus. */
body.br-spec #controls-bar, body.br-spec #weapon-bar, body.br-spec #captain, body.br-spec #social, body.br-spec .shop-btn, body.br-spec #dock-hint,
body.br-spec #joystick, body.br-spec #aimstick, body.br-spec .boost-touch, body.br-spec .flare-touch, body.br-spec .weapon-touch, body.br-spec #weapon-toast { display: none !important; }
body.br-spec #scene { cursor: default; }
/* During a round: no flares, no hot-cargo banner; the mission card turns red. */
body.br-live .flare-btn, body.br-live .flare-touch { opacity: .3; filter: grayscale(1); }
body.br-on #hot-banner { display: none; }
body.br-live #mission { border-color: rgba(255, 59, 92, .75); }
body.br-live .mission-icon { background: linear-gradient(180deg, #ff6b7f, #c21a34); box-shadow: 0 0 18px rgba(255, 40, 80, .45); color: #2a0008; }
.tag.enemy .tb { border-color: rgba(255, 59, 92, .9); color: #ffe0e5; }
.tag.enemy .hb i.on { background: #ff5a6e; }
.tag.watched .tb { border-color: #fff; box-shadow: 0 0 12px rgba(255, 255, 255, .45); }
.plist li .brk { margin-left: auto; color: var(--muted); font-size: 12px; }
.br-start { border-color: rgba(255, 59, 92, .6); background: rgba(120, 12, 32, .35); }
.br-start:not(:disabled):hover { border-color: #ff5a6e; }
.br-note { font-size: 12.5px; color: var(--muted); margin-top: -4px; }
.br-confirm-note { font-size: 13px; color: var(--muted); line-height: 1.45; margin: -8px 0 18px; }
.btn.primary.br-go { background: linear-gradient(180deg, #ff6b7f, #c21a34); color: #fff; box-shadow: 0 0 26px rgba(255, 40, 80, .45); }
.br-results { max-width: 620px; }
.br-res-kicker { font-family: var(--font); font-weight: 800; font-size: 12px; letter-spacing: .24em; color: #ff8a9c; margin-bottom: 6px; }
.br-results h2.br-won { color: var(--yellow); text-shadow: 0 0 18px rgba(255, 210, 74, .55); }
.br-res-scroll { max-height: 44vh; overflow: auto; margin-bottom: 8px; }
.br-table { margin-bottom: 0; }
.br-table td:nth-child(3) { color: #ff8a9c; }
.br-table td:nth-child(4) { color: var(--green); font-family: var(--font); font-weight: 800; }
.br-table td:nth-child(5) { color: var(--yellow); }
.br-table tr.win td { background: rgba(255, 210, 74, .08); }
.br-table tr.me td { background: rgba(92, 225, 44, .16); }
.br-results .board-note { margin-top: 8px; }
.board-tabs { max-width: 480px; }

@media (max-width: 900px), (max-height: 560px) {
    .br-bar { top: calc(var(--gap) + var(--sa-t)); font-size: 13px; padding: 5px 12px; gap: 10px; }
    .br-bar.count { font-size: 13px; }
    .br-bar .bp small { display: none; }   /* icons + numbers only */
    .br-bar .bb-by { display: none; }
    .br-center { font-size: 28px; top: 30%; }
    .br-center.grace, .br-center.elim { font-size: 24px; }
    .spec-btn { width: 42px; height: 42px; font-size: 18px; }
    .spec-name { font-size: 15px; }
    .spec-body { min-width: 150px; }
}
/* Low screens (phone landscape): a compact results panel so CLOSE stays on screen. */
@media (max-height: 560px) {
    #screen-br-results, #screen-br { padding: 8px; }
    .br-results { padding: 12px 16px; max-height: calc(100vh - 16px); }
    .br-results h2 { font-size: 20px; margin-bottom: 2px; }
    .br-results .lead { font-size: 12.5px; margin-bottom: 6px; }
    .br-res-kicker { margin-bottom: 2px; font-size: 11px; }
    .br-res-scroll { max-height: 34vh; }
    .board.br-table td { padding: 3px 6px; }
    .br-results .board-note { margin: 4px 0 6px; font-size: 11.5px; }
    .br-results .btn, #screen-br .btn { padding: 8px 14px; font-size: 15px; }
}
/* Narrow phones: the five result columns must fit without a sideways scroll. */
@media (max-width: 520px) {
    .br-results { padding: 16px 10px; }
    .board.br-table { font-size: 12px; }
    .board.br-table th { font-size: 9.5px; letter-spacing: .03em; padding: 5px 3px; }
    .board.br-table td { padding: 5px 3px; }
    .spec-body { min-width: 0; }
}
@media (orientation: portrait) and (max-width: 520px) {
    body.touch .shop-btn { top: calc(var(--gap) + var(--sa-t) + 272px); }
    body.br-on.touch #rotate-hint { display: none; }
    body.br-live.touch .m-sub { display: none; }   /* keep the mission card short above the BR pill */
    body.touch .br-bar { top: calc(var(--gap) + var(--sa-t) + 104px); }
    .br-center { white-space: normal; width: 92vw; }
}

/* ---------- touch declutter ----------
   Phones and tablets: the middle of the screen stays free for the sea. Transient messages
   stack in one compact column on the left under a one-line mission card; only the
   out-of-zone warning stays central. The sticks and action buttons keep their places. */
body.touch #mission { padding: 4px 10px 4px 4px; gap: 7px; min-width: 0; max-width: min(400px, 46vw); border-radius: 11px; }
body.touch .mission-icon { width: 26px; height: 26px; border-radius: 7px; box-shadow: none; }
body.touch .mission-icon svg { width: 18px; height: 18px; }
body.touch .mission-body { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; min-width: 0; }
body.touch .m-title, body.touch .m-sub { display: none; }
body.touch .m-route { margin: 0; font-size: 13px; min-width: 0; flex: 0 1 auto; }
body.touch .m-route .ab { width: 16px; height: 16px; font-size: 10px; margin-right: 3px; }
body.touch .m-route .ab:not(.on) { background: transparent; color: var(--green); box-shadow: inset 0 0 0 1.5px var(--green); }
body.touch .m-meta { display: block; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
body.touch .m-meta::before { content: '· '; }
body.touch .m-meta:empty { display: none; }
body.touch .m-dock { position: absolute; left: 6px; right: 6px; bottom: 2px; height: 3px; margin: 0; }
body.touch #mission.hot { border-color: rgba(255, 166, 43, .85); }
body.touch #mission.hot .m-meta { color: #ffb13b; }
body.touch.br-live .m-title { display: block; font-size: 13px; }   /* Battle Royale: the card only names the mode */
body.touch.br-live .m-route, body.touch.br-live .m-meta { display: none; }
body.touch #captain { top: calc(var(--gap) + var(--sa-t) + 50px); }

#hud #msg-col { pointer-events: none; }
body.touch #msg-col { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; position: fixed; z-index: 15; overflow: hidden;
    left: calc(var(--gap) + var(--sa-l)); top: calc(var(--gap) + var(--sa-t) + 46px); max-width: min(330px, 44vw);
    max-height: calc(100vh - var(--gap) - var(--sa-t) - 46px - 160px - var(--sa-b)); }
body.touch #msg-col > * { position: static; inset: auto; transform: none; margin: 0; width: auto; max-width: 100%; text-align: left; white-space: normal;
    font-size: 12px; line-height: 1.3; padding: 4px 10px; border-radius: 9px; box-shadow: none; }
body.touch #msg-col > #feed { padding: 0; border-radius: 0; gap: 4px; align-items: flex-start; }
body.touch #feed .feed-item { font-size: 11.5px; padding: 3px 8px; animation-name: feedInL; }
body.touch #feed .feed-item.out { transform: translateX(-16px); }
@keyframes feedInL { from { opacity: 0; transform: translateX(-24px); } }
body.touch #msg-col > #alert { font-size: 12.5px; animation: none; box-shadow: 0 0 14px rgba(255, 59, 59, .45); }
body.touch #msg-col > #dock-hint { font-size: 13px; padding: 3px 10px; }
body.touch #msg-col > .br-bar { gap: 8px; font-size: 12px; padding: 4px 10px; }
body.touch #msg-col > .br-bar .bp small, body.touch #msg-col > .br-bar .bb-by { display: none; }
body.touch #msg-col > .br-center { font-size: 13px; letter-spacing: .02em; background: rgba(6, 16, 36, .8); border: 1px solid rgba(255, 255, 255, .15); text-shadow: none; animation: none; }
body.touch #msg-col > .br-center.grace { border-color: rgba(255, 210, 74, .6); }
body.touch #msg-col > .br-center.free, body.touch #msg-col > .br-center.elim { border-color: rgba(255, 59, 92, .7); }
/* The one call-out that stays central: short, the red vignette does most of the work. */
body.touch #msg-col > .br-center.out { position: fixed; left: 50%; top: 27%; transform: translate(-50%, -50%); white-space: nowrap; width: auto;
    font-size: 22px; padding: 4px 14px; background: rgba(60, 0, 12, .55); border: 1px solid rgba(255, 59, 92, .7); animation: pulse-text .5s ease-in-out infinite alternate; }
body.touch #msg-col > #weapon-toast { font-size: 12px; padding: 3px 10px; }
body.touch #msg-col > #weapon-toast:not(.on) { display: none; }
body.touch #msg-col > #hot-banner { font-size: 12px; }

/* Port shop: a round icon with the side buttons, not a bar in front of the ship. */
body.touch .shop-btn { left: auto; right: calc(var(--gap) + var(--sa-r)); bottom: auto; top: calc(var(--gap) + var(--sa-t) + 350px); transform: none;
    width: 46px; height: 46px; padding: 0; border-radius: 50%; justify-content: center; }
body.touch .shop-btn span, body.touch .shop-btn kbd { display: none; }

/* Tags: smaller, ours always on top (overlaps are nudged apart in hud.js). */
.tag.me { z-index: 3; }
body.touch .tag .tb { font-size: 11px; padding: 2px 6px; }
body.touch .tag .hb i { height: 3px; }
body.touch .tag.port .tb { font-size: 12px; padding: 2px 8px; }
body.touch .tag.port .ab { width: 18px; height: 18px; font-size: 11px; margin-left: 5px; }

/* Tablets (captain card shown under the mission card): the messages go below it. */
@media (min-height: 501px) and (min-width: 521px) {
    body.touch #msg-col { top: calc(var(--gap) + var(--sa-t) + 190px); max-height: calc(100vh - var(--gap) - var(--sa-t) - 190px - 180px - var(--sa-b)); }
}
/* Phone landscape: shop icon under the horn / message row; docs pill and ping would sit on the minimap. */
@media (max-height: 500px) {
    body.touch .shop-btn { top: calc(var(--gap) + var(--sa-t) + 96px); right: calc(var(--gap) + var(--sa-r) + 130px); }
    body.touch #docs-pill, body.touch #ping { display: none !important; }
}
/* Phone portrait: the right-hand column (speed, horn, shop) starts at 62 px — the message column stays left of it. */
@media (orientation: portrait) and (max-width: 520px) {
    body.touch #mission { max-width: calc(100vw - 150px); }
    body.touch #msg-col { max-width: calc(100vw - 150px); max-height: calc(100vh - var(--gap) - var(--sa-t) - 46px - 290px - var(--sa-b)); }
    body.touch .shop-btn { top: calc(var(--gap) + var(--sa-t) + 272px); right: calc(var(--gap) + var(--sa-r)); }
    body.touch #msg-col > #rotate-hint { display: block; color: var(--cyan); background: rgba(6, 16, 36, .82); border: 1px solid rgba(67, 214, 255, .5);
        overflow: hidden; animation: hint-gone 12s forwards; }
    body.br-on.touch #msg-col > #rotate-hint { display: none; }
}
@keyframes hint-gone { 0%, 88% { opacity: 1; max-height: 60px; } 100% { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; border-width: 0; } }
