:root {
  --bg: #080c14; --card: #0f172a; --border: #1e293b; --text: #e2e8f0; --muted: #94a3b8;
  --cyan: #00f3ff; --magenta: #ff0055; --yellow: #ffdd00; --amber: #f59e0b; --green: #34d399;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* The page is exactly one window high: the game fills whatever is left after the top bar, the side column scrolls. */
body { background: var(--bg); color: var(--text); font-family: Inter, system-ui, sans-serif; display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.orbitron, h1, h2 { font-family: Orbitron, Inter, sans-serif; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.small { font-size: 11px; } .big { font-size: 22px; font-weight: 900; }
.muted { color: var(--muted); } .center { text-align: center; }
.cyan { color: var(--cyan); } .magenta { color: var(--magenta); } .yellow { color: var(--yellow); } .green { color: var(--green); } .amber { color: var(--amber); } .orange { color: #fb923c; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.glass { background: rgba(15, 23, 42, 0.88); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.08); }
.pill { font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 999px; letter-spacing: .08em; font-family: Inter, sans-serif; vertical-align: middle; }
.pill-red { background: #dc2626; color: #fff; animation: pulse 2s infinite; }
.pill-cyan { background: #083344; color: var(--cyan); border: 1px solid rgba(0,243,255,.4); font-family: Orbitron, sans-serif; }
.chip { background: #1e293b; border: 1px solid #334155; padding: 3px 8px; border-radius: 6px; color: #cbd5e1; }
kbd { background: #1e293b; border: 1px solid #334155; border-radius: 4px; padding: 1px 5px; color: #e2e8f0; font-size: 11px; }
@keyframes pulse { 50% { opacity: .55; } }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; position: sticky; top: 0; z-index: 20; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 16px; margin: 0; letter-spacing: .06em; }
.brand p { margin: 2px 0 0; }
.logo { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; color: #000; font-weight: 900; background: linear-gradient(135deg, var(--cyan), #4f46e5, var(--magenta)); }
.topbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stat-box { background: rgba(15,23,42,.9); border: 1px solid var(--border); border-radius: 10px; padding: 4px 10px; min-width: 70px; }
.label { font-size: 9px; font-weight: 800; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.value { font-size: 12px; font-weight: 700; }
.icon-btn { background: #1e293b; border: 1px solid #334155; color: #cbd5e1; border-radius: 10px; width: 36px; height: 36px; cursor: pointer; font-size: 15px; }
.icon-btn:hover { border-color: var(--cyan); }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: minmax(0, 1fr); gap: 14px; padding: 14px; width: 100%; }
.game-col { min-height: 0; min-width: 0; }
.game-frame { border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; height: 100%; }
.frame-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: rgba(15,23,42,.95); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
/* Chunk streaming / network status: only with DEBUG=true in the server's .env */
.frame-bar.debug-bar { display: none; }
body.debug:not(.mobile) .frame-bar.debug-bar { display: flex; }
.frame-bar.controls { border-top: 1px solid var(--border); border-bottom: 0; color: var(--muted); font-size: 12px; }
.viewport { position: relative; flex: 1; min-height: 240px; background: #000; overflow: hidden; }
/* Narrow windows: game on top at (almost) full window height, side panels below; the page scrolls. */
@media (max-width: 1000px) {
  body:not(.mobile) { height: auto; min-height: 100dvh; overflow: auto; }
  body:not(.mobile) .layout { grid-template-columns: 1fr; grid-template-rows: auto; }
  body:not(.mobile) .viewport { flex: none; height: calc(100dvh - 190px); min-height: 320px; }
}
#gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.scanline { position: absolute; inset: 0; pointer-events: none; opacity: .15; background: linear-gradient(to bottom, transparent 50%, rgba(0,0,0,.35) 50%); background-size: 100% 4px; }

.hud { position: absolute; pointer-events: none; }
.hud-tl { top: 12px; left: 12px; display: flex; flex-direction: column; gap: 8px; }
.hud-tr { top: 12px; right: 12px; width: 190px; background: rgba(15,23,42,.9); border: 1px solid rgba(0,243,255,.4); border-radius: 12px; padding: 8px; }
.hud-bl { bottom: 14px; left: 14px; text-align: center; }
.hud-tc { top: 12px; left: 50%; transform: translateX(-50%); }
.job-panel { width: min(380px, 44%); background: rgba(15,23,42,.9); border: 1px solid #334155; border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.job-panel.active { border-color: rgba(255,221,0,.6); box-shadow: 0 0 18px rgba(255,221,0,.15); }
.job-panel.idle .bar, .job-panel.idle #jobTimer { display: none; }
.job-head { display: flex; justify-content: space-between; font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.job-kind { font-family: Orbitron, sans-serif; color: var(--muted); }
.job-dest { font-size: 12px; font-weight: 700; color: var(--yellow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-panel.idle .job-dest { color: var(--muted); font-weight: 400; white-space: normal; }
.toast { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; text-align: center; font-family: Orbitron, sans-serif; font-weight: 900; font-size: 26px; text-shadow: 0 0 16px currentColor; animation: toast 2.4s ease-out forwards; white-space: nowrap; }
.toast .sub { display: block; font-family: Inter, sans-serif; font-size: 13px; font-weight: 600; color: #e2e8f0; text-shadow: none; margin-top: 4px; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); } 10% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -70%); } }
@media (max-width: 700px) { .job-panel { top: 150px; width: 70%; } }
.hud-br { bottom: 10px; right: 12px; color: #64748b; }
.speed { font-size: 34px; font-weight: 900; color: #fff; text-shadow: 0 0 12px rgba(0,243,255,.6); line-height: 1; }
.meter { width: 210px; background: rgba(15,23,42,.9); border: 1px solid #334155; border-radius: 12px; padding: 7px 9px; }
.meter-head { display: flex; justify-content: space-between; font-size: 10px; font-weight: 700; font-family: Orbitron, sans-serif; margin-bottom: 4px; }
.bar { height: 9px; background: #1e293b; border-radius: 999px; overflow: hidden; border: 1px solid #334155; }
.fill { height: 100%; width: 100%; transition: width .1s linear; }
.fill-green { background: #10b981; } .fill-red { background: #ef4444; } .fill-cyan { background: var(--cyan); } .fill-amber { background: var(--amber); }
.fill-grad { background: linear-gradient(90deg, var(--cyan), #6366f1, var(--magenta)); }

.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(8,12,20,.6); }
.btn { border: 1px solid; border-radius: 10px; padding: 8px 14px; font-weight: 700; cursor: pointer; font-family: Inter, sans-serif; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn-cyan { background: rgba(0,243,255,.15); color: var(--cyan); border-color: rgba(0,243,255,.5); }
.btn-cyan:hover { background: rgba(0,243,255,.28); }
.btn.wide { width: 100%; margin-top: 8px; }

.side-col { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.side-col > * { flex-shrink: 0; }
.panel { border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.panel.grow { flex: 1; min-height: 160px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.panel-head h2 { margin: 0; font-size: 13px; letter-spacing: .06em; }
.minimap { width: 100%; aspect-ratio: 16 / 10; background: #050810; border-radius: 10px; border: 1px solid #1e293b; display: block; }
.sector-list { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }
.sector { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 9px; border-radius: 10px; background: rgba(15,23,42,.9); border: 1px solid #334155; font-size: 12px; }
.sector .name { font-weight: 700; color: #fff; }
.sector .owner { font-size: 10px; color: var(--muted); }
.sector .prog { width: 70px; height: 6px; background: #1e293b; border-radius: 99px; overflow: hidden; }
.sector .prog > div { height: 100%; }
.badge { font-size: 9px; font-weight: 800; padding: 2px 6px; border-radius: 5px; letter-spacing: .05em; }
.log { flex: 1; overflow-y: auto; background: rgba(0,0,0,.6); border-radius: 10px; padding: 8px; font-size: 11px; display: flex; flex-direction: column; gap: 4px; border: 1px solid #1e293b; max-height: 320px; }
.log .kill { color: var(--magenta); } .log .capture { color: var(--cyan); } .log .turret { color: var(--green); } .log .join { color: var(--muted); } .log .sys { color: var(--yellow); } .log .job { color: #fbbf24; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 50; overflow-y: auto; padding: 12px 0; }
.modal-card { width: min(420px, 92vw); border-radius: 18px; padding: 22px; }
.modal-card h2 { margin: 0 0 12px; font-size: 18px; color: var(--cyan); }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { flex: 1; background: #1e293b; color: var(--muted); border: 1px solid #334155; border-radius: 8px; padding: 7px; cursor: pointer; font-weight: 700; }
.tab.active { color: var(--cyan); border-color: var(--cyan); }
form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
form input { width: 100%; margin-top: 4px; padding: 9px 10px; border-radius: 8px; border: 1px solid #334155; background: #0b1220; color: #fff; font-size: 14px; }
form input:focus { outline: none; border-color: var(--cyan); }
.synd-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 4px; }
.synd { border: 2px solid #334155; border-radius: 10px; padding: 10px; cursor: pointer; background: #0b1220; text-align: center; font-weight: 800; font-size: 12px; }
.synd.selected { box-shadow: 0 0 0 2px currentColor inset; }
/* language choice (login + profile) */
.lang-choices { display: flex; gap: 6px; margin: 6px 0 8px; }
.lang-choices button { flex: 1; background: #0b1220; color: var(--muted); border: 1px solid #334155; border-radius: 8px; padding: 7px; cursor: pointer; font-weight: 700; }
.lang-choices button.active { color: var(--cyan); border-color: var(--cyan); }
/* profile */
.stat-btn { font: inherit; color: inherit; text-align: left; cursor: pointer; }
.stat-btn:hover { border-color: var(--cyan); }
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-bottom: 12px; }
.profile-stats .value { font-size: 14px; }
#profileModal .modal-card { display: flex; flex-direction: column; gap: 4px; }
#profileModal .panel-head h2 { margin: 0; }
.pm-dealer { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid #1e293b; font-size: 12px; }
.safe-zone { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); padding: 3px 10px; border-radius: 10px; border: 1px solid #3b82f6; background: rgba(15,23,42,.85); color: #93c5fd; font: 800 11px Orbitron, sans-serif; letter-spacing: .05em; pointer-events: none; z-index: 3; }
/* OSM attribution (ODbL): always visible on the map */
.osm-attrib { position: absolute; right: 8px; bottom: 4px; z-index: 3; font: 600 9px Inter, sans-serif; color: rgba(203,213,225,.7); background: rgba(8,12,20,.55); padding: 1px 5px; border-radius: 4px; text-decoration: none; }
.osm-attrib:hover { color: #fff; }
.hud-br { bottom: 22px; }
body.mobile .osm-attrib { right: auto; left: 50%; transform: translateX(-50%); bottom: calc(1px + env(safe-area-inset-bottom)); font-size: 8px; }
body.mobile .hud-bl { bottom: calc(14px + env(safe-area-inset-bottom)); }
.mv-attrib { font-size: 10px; color: var(--muted); margin-left: auto; }
.mv-results .credit { font-size: 10px; color: var(--muted); padding: 2px 6px; }
/* login / register */
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.4; }
.check input { width: auto; margin-top: 2px; }
.auth-links { display: flex; gap: 10px; font-size: 12px; margin-top: 4px; }
.auth-links .spacer { flex: 1; }
.auth-links a, .profile-about a, .check a { color: var(--cyan); }
/* profile */
.profile-email { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; margin-bottom: 4px; }
.profile-email .warn { color: #f59e0b; }
.profile-sec { border: 1px solid #1e293b; border-radius: 8px; padding: 5px 8px; font-size: 12px; }
.profile-sec summary { cursor: pointer; color: #cbd5e1; }
.profile-sec.danger summary { color: #ff0055; }
.profile-form { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 2px; }
.profile-form input { background: #0b1220; border: 1px solid #334155; color: #f1f5f9; border-radius: 8px; padding: 6px 8px; font: 13px Inter, sans-serif; }
.profile-about { border-top: 1px solid #1e293b; padding-top: 8px; margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
#profileModal .modal-card { max-height: 92vh; overflow-y: auto; }
.profile-actions { display: flex; gap: 8px; margin-top: 6px; }
.profile-actions a.btn { text-decoration: none; }
.error { color: #fb7185; min-height: 16px; }

.gang-body { display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.gang-head { display: flex; gap: 10px; align-items: center; }
.gang-name { font-weight: 800; color: #fff; font-size: 13px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 6px; border: 1px solid rgba(255,255,255,.3); }
.swatch.big { width: 26px; height: 26px; border-radius: 6px; margin: 0; }
.gang-members, .gang-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; }
.gang-members li, .gang-list li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; background: rgba(15,23,42,.8); border: 1px solid #1e293b; border-radius: 8px; padding: 4px 8px; }
.gang-members .dot { width: 8px; height: 8px; border-radius: 50%; background: #475569; }
.gang-members .dot.on { background: #34d399; }
.gang-boss { display: flex; flex-direction: column; gap: 4px; background: rgba(255,221,0,.06); border: 1px solid rgba(255,221,0,.25); border-radius: 8px; padding: 6px 8px; }
.mini-btn { margin-left: auto; background: #1e293b; color: #cbd5e1; border: 1px solid #334155; border-radius: 6px; font-size: 10px; padding: 2px 6px; cursor: pointer; }
.mini-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.gang-actions { display: flex; flex-direction: column; gap: 6px; }
.gang-form { display: flex; flex-direction: column; gap: 6px; }
.gang-form.row, .gang-form .row { flex-direction: row; align-items: center; gap: 6px; display: flex; }
.gang-form input:not([type]), .gang-form input[type=text] { flex: 1; min-width: 0; padding: 6px 8px; border-radius: 6px; border: 1px solid #334155; background: #0b1220; color: #fff; font-size: 12px; }
.gang-form input[type=color] { width: 36px; height: 30px; border: 1px solid #334155; border-radius: 6px; background: #0b1220; padding: 0; }

.svc-banner { position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%); pointer-events: none; padding: 5px 12px; border-radius: 10px; border: 1px solid; background: rgba(15,23,42,.9); font: 800 12px Orbitron, sans-serif; letter-spacing: .05em; white-space: nowrap; }
body.mobile .svc-banner { bottom: calc(44px + env(safe-area-inset-bottom)); font-size: 10px; }

/* ---------- Mobile / touch layout (body.mobile is set by touch.js) ---------- */
.mobile-only, .rotate-hint { display: none; }
body.mobile { overflow: hidden; position: fixed; inset: 0; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body.mobile .topbar, body.mobile .frame-bar, body.mobile .desktop-radar, body.mobile #hudFps, body.mobile .scanline { display: none; }
body.mobile .layout { position: fixed; inset: 0; display: block; padding: 0; max-width: none; }
body.mobile .game-col, body.mobile .game-frame { height: 100%; }
body.mobile .game-frame { border-radius: 0; border: 0; }
body.mobile .viewport { min-height: 0; height: 100%; touch-action: none; }

/* compact HUD */
body.mobile .hud-tl { top: calc(6px + env(safe-area-inset-top)); left: calc(6px + env(safe-area-inset-left)); gap: 4px; }
body.mobile .meter { width: 128px; padding: 3px 6px; border-radius: 8px; }
body.mobile .meter-head { font-size: 8px; margin-bottom: 2px; }
body.mobile .bar { height: 6px; }
body.mobile .m-stats { display: flex; justify-content: space-between; width: 128px; font-size: 12px; font-weight: 800; background: rgba(15,23,42,.9); border: 1px solid #334155; border-radius: 8px; padding: 3px 6px; }
/* The corner box itself lets touches through (its bounding box is taller than the radar); only its buttons/radar take them. */
body.mobile .m-corner { display: flex; position: absolute; top: calc(6px + env(safe-area-inset-top)); right: calc(6px + env(safe-area-inset-right)); gap: 6px; align-items: flex-start; z-index: 5; pointer-events: none; }
body.mobile .m-corner > * > * { pointer-events: auto; }
body.mobile .m-buttons { display: flex; flex-direction: column; gap: 6px; }
body.mobile .m-buttons .icon-btn { width: 40px; height: 40px; font-size: 18px; background: rgba(15,23,42,.9); }
body.mobile .m-minimap { width: 128px; }
body.mobile .m-minimap .minimap { border-radius: 8px; }
body.mobile .hud-tr { top: calc(92px + env(safe-area-inset-top)); right: calc(6px + env(safe-area-inset-right)); width: 128px; padding: 4px 6px; border-radius: 8px; }
body.mobile .hud-tr .label { font-size: 8px; }
body.mobile .hud-tr .small { font-size: 9px; }
body.mobile .job-panel { top: calc(6px + env(safe-area-inset-top)); width: min(300px, 40vw); padding: 4px 8px; gap: 2px; }
body.mobile .job-head { font-size: 9px; }
body.mobile .job-dest { font-size: 11px; }
body.mobile .job-panel.idle .job-dest { font-size: 10px; }
body.mobile .hud-bl { bottom: calc(6px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); }
body.mobile .speed { font-size: 22px; }
body.mobile .toast { font-size: 20px; top: 30%; }

/* touch controls */
/* Phones: brighter picture (no scanlines, lifted brightness/contrast). */
body.mobile .scanline { display: none; }
body.mobile #gameCanvas { filter: brightness(1.3) contrast(1.05); }
body.mobile .touch-ui { display: block; position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.stick-zone { position: absolute; left: 0; bottom: 0; width: 50%; height: 72%; pointer-events: auto; touch-action: none; }
.stick-base { position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%;
  left: calc(env(safe-area-inset-left) + 100px); top: calc(100% - 100px - env(safe-area-inset-bottom));
  border: 2px solid rgba(148,163,184,.5); background: rgba(15,23,42,.35); opacity: .45; transition: opacity .15s; }
.stick-base.active { opacity: 1; transition: none; }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(0,243,255,.55); border: 2px solid rgba(255,255,255,.7); }
.stick-hint { position: absolute; left: calc(env(safe-area-inset-left) + 52px); bottom: calc(env(safe-area-inset-bottom) + 10px); font: 700 9px Orbitron, sans-serif; color: rgba(148,163,184,.75); letter-spacing: .1em; }
.touch-actions { position: absolute; right: calc(10px + env(safe-area-inset-right)); bottom: calc(10px + env(safe-area-inset-bottom)); width: 256px; height: 160px; }
.act { position: absolute; pointer-events: auto; touch-action: none; border-radius: 50%; color: #fff; font: 900 11px Orbitron, sans-serif;
  border: 2px solid rgba(255,255,255,.35); background: rgba(30,41,59,.75); width: 54px; height: 54px; padding: 0; user-select: none; -webkit-user-select: none; }
.act.pressed { transform: scale(.9); filter: brightness(1.5); }
.act-xl { width: 92px; height: 92px; right: 0; bottom: 0; font-size: 14px; }
.act-lg { width: 70px; height: 70px; right: 100px; bottom: 0; }
.act-fire { background: rgba(255,0,85,.75); }
/* Bottom row, right to left: FIRE, HAND-BRAKE, BRAKE. */
.act-drift { background: rgba(0,243,255,.3); font-size: 9px; line-height: 1.15; white-space: normal; }
.act-brake { width: 70px; height: 70px; right: 178px; bottom: 0; font-size: 11px; background: rgba(239,68,68,.8); }
.act-nitro { right: 0; bottom: 100px; font-size: 10px; background: rgba(245,158,11,.8); color: #000; }
.act-msl { right: 62px; bottom: 96px; background: rgba(168,85,247,.75); }
.act-mine { right: 124px; bottom: 78px; background: rgba(71,85,105,.85); }
.act-buy { right: 62px; bottom: 158px; width: 48px; height: 48px; font-size: 10px; background: rgba(52,211,153,.75); color: #000; }

/* building menu */
.prop-menu { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 270px; z-index: 12; padding: 12px; border-radius: 14px;
  background: rgba(8,12,20,.95); border: 1px solid #34d39966; box-shadow: 0 0 24px #000a; display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.prop-menu .pm-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.prop-menu .pm-head b { font-family: Orbitron, sans-serif; font-size: 13px; color: #34d399; }
.prop-menu .pm-rows > div { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; border-bottom: 1px solid #1e293b; }
.prop-menu .pm-rows span { color: var(--muted); }
.prop-menu .pm-ups { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.prop-menu .pm-ups .btn { background: #0b1220; border: 1px solid; font-size: 11px; padding: 6px; }
.prop-menu .btn:disabled { opacity: .4; cursor: not-allowed; }
.prop-menu .pm-status { min-height: 14px; color: #34d399; font-size: 11px; }
.prop-menu .pm-status.bad, .prop-menu .bad { color: #ff0055; }
.prop-menu .pm-pips { display: flex; gap: 3px; align-items: center; }
.prop-menu .pm-pips i { width: 14px; height: 6px; border-radius: 2px; background: #1e293b; border: 1px solid #334155; }
.prop-menu .pm-pips i.on { background: #ffdd00; border-color: #ffdd00; }
.btn-magenta { background: transparent; border: 1px solid #ff0055; color: #ff0055; }
body.mobile .prop-menu { right: calc(200px + env(safe-area-inset-right)); top: calc(8px + env(safe-area-inset-top)); transform: none; width: 250px; max-height: calc(100% - 20px); overflow-y: auto; }
.act-auto { right: 124px; bottom: 142px; width: 48px; height: 48px; font-size: 10px; background: rgba(56,189,248,.75); color: #000; }
.act-auto.on { background: #38bdf8; box-shadow: 0 0 14px #38bdf8; }

/* chat / comm panel */
.chat-box { position: absolute; left: 12px; bottom: 84px; width: min(420px, 44%); display: flex; flex-direction: column; gap: 4px; pointer-events: none; z-index: 6; }
.chat-log { max-height: 150px; overflow: hidden; display: flex; flex-direction: column; gap: 2px; font-size: 12px; line-height: 1.35; }
.chat-log .line { padding: 2px 7px; border-radius: 6px; background: rgba(15,23,42,.78); color: #e2e8f0; overflow-wrap: anywhere; animation: chatFade 20s linear forwards; }
.chat-log .line:first-child { margin-top: auto; }
.chat-log .tag { font: 800 8px Orbitron, sans-serif; margin-right: 5px; padding: 1px 4px; border-radius: 3px; vertical-align: 1px; }
.ch-g .tag { color: #000; background: #34d399; }
.ch-l .tag { color: #000; background: #38bdf8; }
.ch-sys { color: #94a3b8 !important; font-style: italic; }
.ch-sys .tag { color: #94a3b8; border: 1px solid #475569; }
@keyframes chatFade { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }
.chat-row { display: none; gap: 4px; align-items: center; }
.chat-box.open { pointer-events: auto; }
.chat-box.open .chat-log { max-height: 240px; overflow-y: auto; background: rgba(8,12,20,.85); border: 1px solid #334155; border-radius: 10px; padding: 4px; }
.chat-box.open .line { animation: none; opacity: 1; }
.chat-box.open .chat-row { display: flex; }
.chat-row input { flex: 1; min-width: 0; height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid #334155; background: rgba(15,23,42,.95); color: #f1f5f9; font: 13px Inter, sans-serif; }
.chat-row .icon-btn { width: 30px; height: 30px; font-size: 13px; background: rgba(15,23,42,.95); }
.chat-chan { height: 30px; padding: 0 8px; border-radius: 8px; border: 0; cursor: pointer; font: 800 9px Orbitron, sans-serif; color: #000; }
.chat-chan.ch-g { background: #34d399; }
.chat-chan.ch-l { background: #38bdf8; }
body.mobile .chat-box { left: calc(6px + env(safe-area-inset-left)); top: calc(128px + env(safe-area-inset-top)); bottom: auto; width: 46%; }
body.mobile .chat-log { max-height: 90px; font-size: 10px; }
body.mobile .chat-box.open { width: min(460px, 70%); }
body.mobile .chat-box.open .chat-log { max-height: 120px; }
body.mobile .chat-row input { font-size: 16px; } /* >= 16px stops iOS from zooming into the field */

/* navigation */
.nav-box { position: absolute; left: 50%; bottom: 104px; transform: translateX(-50%); pointer-events: none; padding: 5px 12px; border-radius: 10px;
  border: 1px solid #38bdf8aa; background: rgba(15,23,42,.9); font-size: 12px; white-space: nowrap; color: #e2e8f0; }
.nav-box b { color: #38bdf8; }
.nav-box .ap { color: #000; background: #38bdf8; padding: 0 5px; border-radius: 4px; font: 800 10px Orbitron, sans-serif; }
.nav-box .bad, .mv-results .bad { color: #ff0055; }
body.mobile .nav-box { bottom: calc(74px + env(safe-area-inset-bottom)); font-size: 10px; }
.map-view { position: absolute; inset: 8px; z-index: 20; display: flex; flex-direction: column; background: rgba(5,8,16,.97); border: 1px solid #334155; border-radius: 14px; overflow: hidden; }
.map-view canvas { flex: 1; width: 100%; min-height: 0; touch-action: none; cursor: crosshair; }
.mv-top, .mv-bottom { display: flex; gap: 6px; align-items: center; padding: 8px; }
.mv-bottom { justify-content: flex-end; }
.mv-bottom .small { margin-right: auto; }
.mv-top input { flex: 1; background: #0b1220; border: 1px solid #334155; border-radius: 10px; color: #e2e8f0; padding: 8px 10px; font-size: 14px; }
.mv-results { display: flex; flex-direction: column; gap: 4px; padding: 0 8px; max-height: 40%; overflow-y: auto; }
.mv-res { text-align: left; background: #0b1220; border: 1px solid #334155; border-radius: 8px; color: #e2e8f0; padding: 6px 10px; cursor: pointer; display: flex; flex-direction: column; }
.mv-res:hover { border-color: #38bdf8; }
.mv-res span { color: var(--muted); font-size: 11px; }
body.mobile .map-view { inset: calc(4px + env(safe-area-inset-top)) calc(4px + env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) calc(4px + env(safe-area-inset-left)); }
.toll { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); pointer-events: none; font: 800 14px Orbitron, sans-serif; white-space: nowrap; text-shadow: 0 0 10px currentColor; animation: toll 1.8s ease-out forwards; }
@keyframes toll { 0% { opacity: 0; } 10% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -24px); } }

/* menu drawer (the desktop side column slides in from the right) */
body.mobile .side-col { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 88vw); z-index: 30; overflow-y: auto; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) 10px;
  background: rgba(8,12,20,.97); transform: translateX(105%); transition: transform .2s ease; }
body.mobile .side-col.open { transform: none; }
body.mobile .side-col .panel.mobile-only { display: flex; }
body.mobile .log { max-height: 200px; }
.m-menu-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.m-menu-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.m-menu-buttons .btn { padding: 10px 6px; font-size: 13px; }
.m-help { line-height: 1.45; }

/* portrait */
@media (orientation: portrait) {
  body.mobile:not(.portrait-ok) .rotate-hint { display: flex; position: absolute; inset: 0; z-index: 20; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; background: rgba(8,12,20,.93); }
  body.mobile .job-panel { top: calc(150px + env(safe-area-inset-top)); width: 86vw; }
  body.mobile .stick-zone { height: 55%; }
}
