/* Alien Prospectors HUD
   Direction: PMG corporate-issue field kit. Chamfered instrument panels in deep violet,
   PMG gold for money and actions, oxygen cyan reserved for the one thing that kills you. */

:root {
	--ink: #140e22;
	--panel: rgba(22, 15, 38, 0.86);
	--panel-solid: #1a1230;
	--line: #3b2d58;
	--gold: #f2b632;
	--gold-deep: #b9861a;
	--o2: #52e0f0;
	--danger: #ff5a4e;
	--good: #4fe08a;
	--text: #ece6f8;
	--muted: #a598c4;
	--display: "Chakra Petch", "Trebuchet MS", sans-serif;
	--body: "Barlow", "Segoe UI", sans-serif;
	--cut: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #07041a; }
body { font-family: var(--body); color: var(--text); font-size: 15px; user-select: none; -webkit-user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0); }
#ui.pre > :not(#title):not(#modal):not(#intro):not(#mainmenu):not(#farewell) { display: none !important; }
#ui .interactive, #ui button, #ui input, #ui .panel { pointer-events: auto; }

.plate {
	background: var(--panel);
	border: 1px solid var(--line);
	clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
	backdrop-filter: blur(6px);
}

h1, h2, h3, .display { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: 0.01em; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }

/* ── Top left: wallet ─────────────────────────────────────────────── */
#wallet { position: absolute; left: 16px; top: 14px; padding: 10px 16px 10px 14px; min-width: 190px; }
#wallet .amount { font-family: var(--display); font-size: 30px; color: var(--gold); line-height: 1; }
#wallet .sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
#wallet .delta { position: absolute; right: 12px; top: 10px; font-family: var(--display); color: var(--good); font-size: 15px; opacity: 0; transition: opacity .2s; }
#wallet .delta.show { opacity: 1; }

/* ── Top center: compass ──────────────────────────────────────────── */
#compass { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); width: min(560px, 60vw); }
#compass .strip { position: relative; height: 34px; overflow: hidden; }
#compass .tick { position: absolute; top: 4px; width: 1px; height: 8px; background: var(--muted); opacity: .5; }
#compass .card { position: absolute; top: 12px; transform: translateX(-50%); font-family: var(--display); font-size: 13px; color: var(--muted); }
#compass .mark { position: absolute; top: 2px; transform: translateX(-50%); font-family: var(--display); font-size: 12px; white-space: nowrap; padding: 2px 7px; border-radius: 3px; }
#compass .mark.base { background: #e6e4ee; color: var(--ink); }
#compass .mark.drill { background: #4a4d55; color: #fff; }
#compass .mark.bonus { background: var(--gold); color: var(--ink); }
#compass .center { position: absolute; left: 50%; top: 0; width: 2px; height: 34px; background: var(--gold); transform: translateX(-50%); }
#zoneline { text-align: center; margin-top: 6px; font-size: 13.5px; text-shadow: 0 1px 3px #000; }
#zoneline .zone { font-family: var(--display); font-weight: 600; }
#zoneline .clock.night { color: #9fe8ff; }
#zoneline .clock.warn { color: var(--danger); }

/* ── Top right: earners ───────────────────────────────────────────── */
#earners { position: absolute; right: 16px; top: 14px; width: 230px; padding: 10px 14px 12px; }
#earners h3 { font-size: 14px; color: var(--gold); display: flex; justify-content: space-between; align-items: center; }
#earners .dot { width: 8px; height: 8px; border-radius: 50%; background: #6b5a8a; display: inline-block; }
#earners .dot.on { background: var(--good); box-shadow: 0 0 6px var(--good); }
#earners ol { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13.5px; }
#earners li { display: flex; justify-content: space-between; padding: 2px 0; gap: 8px; }
#earners li .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#earners li.me .n { color: var(--gold); }
#earners li span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── Left: gear ───────────────────────────────────────────────────── */
#gear { position: absolute; left: 16px; top: 96px; width: 220px; padding: 12px 14px; font-size: 13.5px; }
#gear .row { display: flex; justify-content: space-between; padding: 3px 0; }
#gear .row b { font-weight: 600; }
#gear .bar { height: 6px; background: #2b2140; margin: 4px 0 6px; }
#gear .bar i { display: block; height: 100%; background: var(--gold); }
#gear .bar.low i { background: var(--danger); }
#gear .state { font-family: var(--display); font-size: 12.5px; }

/* ── Right: bag ───────────────────────────────────────────────────── */
#bag { position: absolute; right: 16px; top: 214px; width: 230px; padding: 10px 14px 12px; max-height: calc(100vh - 420px); overflow: auto; }
#bag h3 { font-size: 14px; display: flex; justify-content: space-between; }
#bag h3 .cap.full { color: var(--danger); }
#bag ul { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13.5px; }
#bag li { display: grid; grid-template-columns: 20px 1fr auto; gap: 6px; padding: 2px 0; align-items: center; }
#bag li .ct { color: var(--muted); font-variant-numeric: tabular-nums; }
#bag .empty { color: var(--muted); font-size: 13px; margin-top: 6px; }
#bag .worth { margin-top: 8px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 6px; }

#scan { position: absolute; right: 16px; bottom: 150px; width: 230px; padding: 10px 14px 12px; font-size: 13px; display: none; }
#scan.show { display: block; }
#scan h3 { font-size: 14px; color: var(--o2); }
#scan .odds { display: flex; height: 10px; margin: 8px 0 6px; }
#scan .odds i { display: block; height: 100%; }

/* ── Bottom left: guide ───────────────────────────────────────────── */
#guide { position: absolute; left: 16px; bottom: 16px; width: 220px; padding: 10px 14px; font-size: 12.5px; color: var(--muted); }
#guide div { display: flex; justify-content: space-between; padding: 1.5px 0; }
#guide kbd, .prompt kbd, .panel kbd {
	font-family: var(--display); font-size: 11.5px; color: var(--ink); background: var(--gold);
	padding: 0 5px; border-radius: 2px; min-width: 18px; text-align: center; display: inline-block;
}
#guide kbd { background: #d9d2ea; }

/* ── Bottom center: oxygen gauge (the one bold element) ───────────── */
#vitals { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: 300px; text-align: center; }
#o2 { position: relative; width: 220px; height: 120px; margin: 0 auto; }
#o2 svg { width: 220px; height: 120px; overflow: visible; }
#o2 .track { stroke: rgba(30, 22, 52, 0.9); }
#o2 .fill { stroke: var(--o2); transition: stroke .3s; filter: drop-shadow(0 0 6px rgba(82, 224, 240, 0.6)); }
#o2.low .fill { stroke: var(--danger); filter: drop-shadow(0 0 8px rgba(255, 90, 78, 0.8)); }
#o2.safe .fill { stroke: #9ff3ff; }
#o2 .read { position: absolute; left: 0; right: 0; bottom: 6px; }
#o2 .secs { font-family: var(--display); font-size: 40px; line-height: 1; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
#o2 .lbl { font-size: 12.5px; color: var(--muted); }
#o2.low .secs { color: var(--danger); animation: pulse .8s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
#stamina { height: 5px; width: 200px; margin: 6px auto 0; background: rgba(30, 22, 52, 0.9); }
#stamina i { display: block; height: 100%; background: #e6e4ee; }
#stamina.tired i { background: var(--danger); }
#quota { margin: 8px auto 0; width: 260px; padding: 6px 12px 8px; font-size: 12.5px; }
#quota .bar { height: 5px; background: #2b2140; margin-top: 4px; }
#quota .bar i { display: block; height: 100%; background: var(--gold); }
#quota.done .bar i { background: var(--good); }
#fuel { margin: 8px auto 0; width: 260px; padding: 6px 12px 8px; font-size: 12.5px; display: none; }
#fuel.show { display: block; }
#fuel .bar { height: 6px; background: #2b2140; margin-top: 4px; }
#fuel .bar i { display: block; height: 100%; background: #ffb43a; }

/* ── World prompt ─────────────────────────────────────────────────── */
.prompt { position: absolute; transform: translate(-50%, -100%); padding: 7px 12px; font-size: 14px; white-space: nowrap; display: none; }
.prompt.show { display: block; }
.prompt .who { font-family: var(--display); color: var(--gold); font-size: 13px; margin-bottom: 2px; }
.prompt .warn { color: var(--danger); }

/* ── Messages ─────────────────────────────────────────────────────── */
#toasts { position: absolute; left: 50%; top: 92px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { padding: 7px 16px; font-size: 14.5px; animation: toastIn .25s ease-out; text-shadow: 0 1px 2px #000; }
.toast.good { border-color: #2f7a4c; }
.toast.bad { border-color: #8a2f2a; color: #ffd2cc; }
.toast.pmg { border-color: var(--gold-deep); }
.toast.fade { opacity: 0; transition: opacity .5s; }
@keyframes toastIn { from { transform: translateY(-6px); opacity: 0; } }

#banner { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); padding: 14px 28px; text-align: center; display: none; border-color: var(--gold-deep); }
#banner.show { display: block; animation: toastIn .3s ease-out; }
#banner .k { font-size: 13px; color: var(--muted); }
#banner h2 { font-size: 26px; color: var(--gold); margin: 2px 0; }
#banner .d { font-size: 14px; }

#bigwarn { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-family: var(--display); font-size: 26px; color: var(--danger); text-shadow: 0 2px 12px #000; display: none; text-align: center; }
#bigwarn.show { display: block; }
#bigwarn small { display: block; font-family: var(--body); font-size: 15px; color: var(--text); margin-top: 4px; }

#vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(200, 20, 30, 0.55) 100%); }
#flash { position: absolute; inset: 0; background: #e8f4ff; opacity: 0; pointer-events: none; }
#fade { position: absolute; inset: 0; background: #07041a; opacity: 0; pointer-events: none; transition: opacity .6s; display: flex; align-items: center; justify-content: center; text-align: center; }
#fade.show { opacity: 1; pointer-events: auto; }
#fade h2 { font-size: 34px; color: var(--danger); }
#fade p { color: var(--muted); max-width: 440px; margin: 10px auto 0; line-height: 1.5; }

/* ── Panels ───────────────────────────────────────────────────────── */
#modal { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(7, 4, 26, 0.45); pointer-events: auto; }
#modal.show { display: flex; }
.panel { width: min(720px, 94vw); max-height: 86vh; display: flex; flex-direction: column; background: var(--panel-solid); --cut: 16px; }
.panel header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.panel header h2 { font-size: 22px; color: var(--gold); }
.panel header .meta { color: var(--muted); font-size: 14px; }
.panel .body { padding: 14px 20px; overflow: auto; }
.panel footer { padding: 12px 20px 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.tabs { display: flex; gap: 4px; padding: 10px 20px 0; flex-wrap: wrap; }
.tabs button { background: transparent; color: var(--muted); border: 1px solid var(--line); border-bottom: none; padding: 7px 14px; font-family: var(--display); font-size: 14px; cursor: pointer; }
.tabs button.on { background: #2a1f44; color: var(--text); }

.btn { font-family: var(--display); font-weight: 600; font-size: 14px; cursor: pointer; border: none; padding: 8px 16px; background: var(--gold); color: var(--ink); clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px); }
.btn:hover { filter: brightness(1.1); }
.btn:focus-visible, .tabs button:focus-visible, input:focus-visible { outline: 2px solid var(--o2); outline-offset: 2px; }
.btn.ghost { background: #2a1f44; color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn[disabled] { background: #2b2140; color: #6f6390; cursor: default; filter: none; }
.btn.big { font-size: 17px; padding: 11px 26px; }

.rows { display: flex; flex-direction: column; gap: 2px; }
.rowi { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 12px; align-items: center; padding: 9px 10px; background: rgba(255,255,255,0.025); }
.rowi .ic { font-size: 22px; text-align: center; }
.rowi .nm { font-weight: 600; }
.rowi .ds { color: var(--muted); font-size: 13px; margin-top: 1px; }
.rowi .pr { font-family: var(--display); color: var(--gold); min-width: 70px; text-align: right; }
.rowi.owned .pr { color: var(--good); }
.rowi .acts { display: flex; gap: 6px; }

.outfits { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.outfit { padding: 12px; background: rgba(255,255,255,0.03); border: 1px solid var(--line); }
.outfit .sw { display: flex; height: 56px; margin-bottom: 10px; }
.outfit .sw i { flex: 1; }
.outfit .sw i.acc { flex: .25; }
.outfit .nm { font-weight: 700; }
.outfit .ds { color: var(--muted); font-size: 13px; min-height: 34px; margin: 4px 0 8px; }
.outfit .tier { font-size: 12px; color: #c86bff; }
.outfit.on { border-color: var(--gold); }

.hb-page h3 { font-size: 20px; color: #8fd0ff; margin-bottom: 10px; }
.hb-page p { line-height: 1.55; margin: 0 0 10px; max-width: 64ch; }
.hb-page b { color: var(--text); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--muted); cursor: pointer; }

.streak { display: flex; gap: 6px; justify-content: center; margin: 6px 0 14px; }
.streak div { width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; font-family: var(--display); border: 1px solid var(--line); color: #6f6390; background: #1f1636; }
.streak div.got { background: #1f4a30; color: var(--good); border-color: #2f7a4c; }
.streak div.today { border: 2px solid var(--gold); color: var(--gold); background: #3a2a12; }

/* ── Title and character creator ─────────────────────────────────── */
#title { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-start; padding: 3vh 0 3vh 5vw; pointer-events: none; background: linear-gradient(90deg, rgba(7, 4, 26, 0.82) 0%, rgba(7, 4, 26, 0.45) 40%, rgba(7, 4, 26, 0) 65%); }
#title.hide { display: none; }
#title .wrap { width: min(440px, 92vw); pointer-events: auto; max-height: 100%; overflow: auto; }
#title .co { font-family: var(--display); color: var(--gold); font-size: 15px; }
#title h1 { font-size: clamp(38px, 5.4vw, 70px); line-height: .92; margin: 4px 0 14px; color: #fff; text-shadow: 0 4px 30px rgba(140, 60, 255, 0.5); }
#title h1 span { display: block; color: var(--gold); }
.reg { padding: 14px 16px 16px; --cut: 14px; }
.reghead { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.reghead h2 { font-size: 18px; color: var(--text); margin-bottom: 2px; }
.reghead .muted { font-size: 13px; line-height: 1.35; }
#badgepic { width: 64px; height: 64px; flex: none; border: 2px solid var(--gold); background: #1a1230; }
.reg label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 5px; }
.reg input { font-family: var(--body); font-size: 16px; padding: 8px 10px; width: 100%; background: #120c22; color: var(--text); border: 1px solid var(--line); }
.ctabs { display: flex; gap: 4px; margin-top: 14px; border-bottom: 1px solid var(--line); }
.ctabs button { background: transparent; color: var(--muted); border: none; border-bottom: 2px solid transparent; padding: 6px 12px; font-family: var(--display); font-size: 14px; cursor: pointer; }
.ctabs button.on { color: var(--text); border-bottom-color: var(--gold); }
.copts { min-height: 210px; }
.sw-row, .chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 26px; height: 26px; border: 2px solid rgba(255,255,255,0.12); cursor: pointer; padding: 0; }
.swatch.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--gold); }
.chip { background: #241a3c; color: var(--text); border: 1px solid var(--line); padding: 5px 10px; font-family: var(--body); font-size: 13px; cursor: pointer; }
.chip.on { background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight: 600; }
.swatch:focus-visible, .chip:focus-visible, .ctabs button:focus-visible { outline: 2px solid var(--o2); outline-offset: 2px; }
.cbtns { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
#title .fine { font-size: 12.5px; color: var(--muted); margin-top: 10px; }

/* ── Portraits and profile ────────────────────────────────────────── */
#earners img.pp { width: 20px; height: 20px; vertical-align: -5px; margin-right: 6px; border: 1px solid var(--line); }
#wallet { cursor: pointer; }
.profile-top { display: grid; grid-template-columns: 160px 1fr; gap: 18px; align-items: start; }
.bigpic { width: 160px; height: 160px; border: 3px solid var(--gold); }
.kv { display: grid; grid-template-columns: 1fr; gap: 3px; font-size: 14px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid rgba(59,45,88,0.6); padding: 3px 0; }
.achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.ach { padding: 8px 10px; background: rgba(255,255,255,0.025); border: 1px solid var(--line); opacity: .55; }
.ach.got { opacity: 1; border-color: var(--gold-deep); }
.ach .nm { font-weight: 600; font-size: 14px; }
.ach.got .nm { color: var(--gold); }
.ach .ds { color: var(--muted); font-size: 12.5px; }

@media (max-width: 600px) {
	.profile-top { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
	#gear, #guide { display: none; }
	#earners { width: 180px; }
	#bag { width: 180px; }
}
@media (prefers-reduced-motion: reduce) {
	.toast, #banner.show { animation: none; }
	#o2.low .secs { animation: none; }
}

/* ── Inventory (Tab) ──────────────────────────────────────────────── */
#modal.light { background: rgba(7, 4, 26, 0.18); }
.panel.inv { width: min(900px, 96vw); }
.inv-body { display: grid; grid-template-columns: 280px 1fr; gap: 20px; }
.inv-avatar { position: relative; background: radial-gradient(ellipse at 50% 40%, #3a2a6a 0%, #140e22 75%); border: 1px solid var(--line); }
.inv-avatar canvas { display: block; width: 280px; height: 380px; cursor: grab; }
.inv-name { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 18px; color: var(--gold); pointer-events: none; }
.inv-head { display: flex; justify-content: space-between; align-items: baseline; }
.inv-main h3 { font-size: 16px; color: var(--gold); margin-bottom: 8px; }
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.tile { position: relative; padding: 8px 8px 7px; min-height: 92px; background: #1f1636; border: 1px solid var(--line); border-top: 3px solid var(--tc, var(--line)); cursor: grab; touch-action: none; }
.tile:hover { background: #2a1f44; }
.tile.empty { background: rgba(255,255,255,0.02); border-style: dashed; cursor: default; border-top-width: 1px; }
.tile .ic { font-size: 24px; }
.tile .ct { position: absolute; right: 8px; top: 8px; font-family: var(--display); font-size: 14px; }
.tile .nm { font-size: 13px; font-weight: 600; line-height: 1.2; margin-top: 4px; color: var(--tc); }
.tile .vl { font-size: 12px; color: var(--muted); }
.inv-gear { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; }
.inv-gear > div { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: center; padding: 4px 0; }
.inv-gear .ic { font-size: 18px; text-align: center; }
.inv-gear .nm { font-size: 14px; font-weight: 600; }
.inv-gear .ds { font-size: 12.5px; color: var(--muted); }
.drag-ghost { position: fixed; z-index: 50; transform: translate(-50%, -50%); font-size: 30px; pointer-events: none; padding: 6px 8px; background: rgba(26,18,48,0.9); border: 2px solid var(--line); }
.drag-ghost.drop { border-color: var(--danger); }
.drag-ghost.drop::after { content: "Drop"; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); font-family: var(--display); font-size: 12px; color: var(--danger); white-space: nowrap; }
@media (max-width: 760px) { .inv-body { grid-template-columns: 1fr; } .inv-avatar canvas { margin: 0 auto; width: 180px; height: 244px; } }

/* ── Fixed-size shop with themed scrollbars ───────────────────────── */
.panel.shop { height: min(620px, 86vh); }
.panel.shop .body { flex: 1; min-height: 0; overflow-y: auto; }
.panel .body, #bag, #title .wrap { scrollbar-width: thin; scrollbar-color: var(--gold-deep) #120c22; }
.panel .body::-webkit-scrollbar, #bag::-webkit-scrollbar, #title .wrap::-webkit-scrollbar { width: 10px; }
.panel .body::-webkit-scrollbar-track, #bag::-webkit-scrollbar-track, #title .wrap::-webkit-scrollbar-track { background: #120c22; border-left: 1px solid var(--line); }
.panel .body::-webkit-scrollbar-thumb, #bag::-webkit-scrollbar-thumb, #title .wrap::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); border: 2px solid #120c22; border-radius: 2px; }
.panel .body::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ── Scanner rows ─────────────────────────────────────────────────── */
.odds-rows { margin: 4px 0 2px; }
.odds-rows div { display: flex; justify-content: space-between; padding: 2px 0; border-bottom: 1px solid rgba(59,45,88,0.6); }
.odds-rows b { font-family: var(--display); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* ── Options ──────────────────────────────────────────────────────── */
.set-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid rgba(59,45,88,0.6); }
.set-row b { font-family: var(--display); font-weight: 600; min-width: 60px; text-align: right; color: var(--gold); }
.set-row input[type=range] { width: 180px; accent-color: var(--gold); }
.set-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--gold); }
.set-row select { background: #120c22; color: var(--text); border: 1px solid var(--line); padding: 5px 8px; font-family: var(--body); }

/* Scroll areas never chain scrolling out to the page or the itch.io frame */
html, body { overscroll-behavior: none; }
.panel .body, #bag, #title .wrap { overscroll-behavior: contain; }

/* ── PMG Outfitters ───────────────────────────────────────────────── */
.panel.outfitter { width: min(1060px, 96vw); height: min(680px, 88vh); }
.out-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 280px 1fr; grid-template-rows: minmax(0, 1fr); gap: 18px; overflow: hidden !important; }
.out-preview { position: relative; background: radial-gradient(ellipse at 50% 40%, #3a2a6a 0%, #140e22 75%); border: 1px solid var(--line); align-self: start; }
.out-preview canvas { display: block; width: 280px; height: 380px; cursor: grab; }
.out-hint { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 13px; color: var(--muted); pointer-events: none; padding: 0 10px; }
.out-grid { min-height: 0; max-height: 100%; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; align-content: start; padding-right: 6px; scrollbar-width: thin; scrollbar-color: var(--gold-deep) #120c22; overscroll-behavior: contain; }
.out-grid::-webkit-scrollbar { width: 10px; }
.out-grid::-webkit-scrollbar-track { background: #120c22; border-left: 1px solid var(--line); }
.out-grid::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); border: 2px solid #120c22; }
.ocard { padding: 10px 12px; background: #1f1636; border: 1px solid var(--line); border-top: 3px solid var(--rc); cursor: pointer; display: flex; flex-direction: column; }
.ocard:hover { background: #271c44; }
.ocard.on { border-color: var(--gold); border-top-color: var(--rc); }
.ocard.try { outline: 2px solid var(--o2); outline-offset: -2px; }
.oc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.oc-icon { font-size: 26px; line-height: 1; min-width: 32px; }
.oc-icon .sw2 { display: inline-block; width: 30px; height: 30px; border: 1px solid rgba(255,255,255,0.15); }
.oc-icon .sw2.ring { border-radius: 50%; border: 5px solid; background: transparent; width: 26px; height: 26px; }
.oc-icon .ptxt { font-family: var(--display); font-size: 13px; padding: 4px 6px; border: 2px solid var(--gold-deep); border-radius: 50%; }
.oc-rar { font-family: var(--display); font-size: 12px; color: var(--rc); }
.ocard .nm { font-weight: 700; }
.ocard .ds { color: var(--muted); font-size: 12.5px; margin: 3px 0 8px; flex: 1; }
.oc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.oc-foot .pr { font-family: var(--display); color: var(--gold); font-size: 14px; }
.oc-foot .btn { padding: 6px 12px; font-size: 13px; }
@media (max-width: 760px) { .out-body { grid-template-columns: 1fr; } .out-preview canvas { width: 180px; height: 244px; margin: 0 auto; } }

/* ── Field kit (Tab): tabs for inventory, profile, handbook ───────── */
.panel.kit { width: min(980px, 96vw); height: min(680px, 88vh); }
.kit-tabs { padding-top: 14px; border-bottom: 1px solid var(--line); }
.kit-body { flex: 1; min-height: 0; overflow-y: auto; }
.kit-handbook { overflow: hidden; display: flex; }
.hb-wrap { display: grid; grid-template-columns: 230px 1fr; gap: 20px; flex: 1; min-height: 0; }
.hb-menu { overflow-y: auto; border-right: 1px solid var(--line); padding-right: 10px; display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: var(--gold-deep) #120c22; overscroll-behavior: contain; }
.hb-group { font-family: var(--display); font-size: 12.5px; color: var(--gold); margin: 12px 0 4px; }
.hb-group:first-child { margin-top: 0; }
.hb-link { text-align: left; background: transparent; border: none; color: var(--muted); padding: 6px 8px; font-family: var(--body); font-size: 14px; cursor: pointer; border-left: 2px solid transparent; }
.hb-link:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.hb-link.on { color: var(--text); border-left-color: var(--gold); background: #241a3c; }
.hb-wrap .hb-page { overflow-y: auto; padding-right: 8px; scrollbar-width: thin; scrollbar-color: var(--gold-deep) #120c22; overscroll-behavior: contain; }
@media (max-width: 760px) { .hb-wrap { grid-template-columns: 1fr; } .hb-menu { max-height: 160px; border-right: none; border-bottom: 1px solid var(--line); } }

/* ── Water meter (bottom right) ───────────────────────────────────── */
#water { position: absolute; right: 16px; bottom: 16px; width: 230px; padding: 9px 14px 11px; font-size: 13.5px; }
#water .wt { display: flex; justify-content: space-between; }
#water .wt b { font-family: var(--display); font-weight: 600; }
#water .bar { height: 7px; background: #2b2140; margin-top: 6px; }
#water .bar i { display: block; height: 100%; background: linear-gradient(90deg, #3a8cff, #52e0f0); transition: width .5s; }
#water .wh { display: none; font-size: 12px; color: #ffd2cc; margin-top: 6px; }
#water.low .bar i { background: var(--danger); }
#water.low .wh { display: block; }
#water.low { animation: pulse 1.6s infinite; }
#scan { bottom: 100px; }

/* ── Vehicle customizer ───────────────────────────────────────────── */
.panel.customizer { width: min(980px, 96vw); height: min(640px, 88vh); }
.cust-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 440px 1fr; gap: 18px; }
.cust-preview { background: radial-gradient(ellipse at 50% 45%, #3a2a6a 0%, #140e22 75%); border: 1px solid var(--line); align-self: start; }
.cust-preview canvas { display: block; width: 440px; height: 300px; cursor: grab; }
.cust-opts { overflow-y: auto; padding-right: 6px; }
.cust-opts label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 6px; }
.cust-opts label:first-child { margin-top: 0; }
.swatch.big { width: 34px; height: 34px; font-size: 13px; line-height: 1; color: #fff; text-shadow: 0 1px 2px #000; }
.swatch.holo { background: linear-gradient(135deg, #ff5ad0, #52e0f0, #ffe08a, #9b4bff) !important; }
.lock { font-family: var(--display); font-size: 11.5px; color: var(--gold); margin-left: 4px; }
.chip .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
@media (max-width: 860px) { .cust-body { grid-template-columns: 1fr; } .cust-preview canvas { width: 100%; height: auto; } }

/* ── Intro, main menu, pause ──────────────────────────────────────── */
#intro { position: absolute; inset: 0; background: #07041a; display: flex; align-items: center; justify-content: center; pointer-events: auto; cursor: pointer; z-index: 20; transition: opacity .5s; }
#intro.out { opacity: 0; }
#intro.hide, #mainmenu.hide, #farewell.hide, #title.hide { display: none !important; }
.intro-inner { text-align: center; animation: introIn 1.4s ease-out both; }
.intro-name { font-family: var(--display); font-weight: 700; font-size: clamp(48px, 9vw, 120px); color: #fff; letter-spacing: 0.02em; text-shadow: 0 0 40px rgba(122, 255, 154, 0.35); }
.intro-sub { font-family: var(--body); color: var(--muted); font-size: 18px; margin-top: 6px; opacity: 0; animation: introIn 1s ease-out .9s both; }
.intro-skip { position: absolute; bottom: 32px; left: 0; right: 0; text-align: center; color: #6f6390; font-size: 13px; }
@keyframes introIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
#mainmenu { position: absolute; inset: 0; display: flex; align-items: center; padding-left: 8vw; pointer-events: auto; background: linear-gradient(90deg, rgba(7, 4, 26, 0.85) 0%, rgba(7, 4, 26, 0.35) 45%, rgba(7, 4, 26, 0) 70%); }
#mainmenu .co { font-family: var(--display); color: var(--gold); font-size: 16px; }
#mainmenu h1 { font-size: clamp(48px, 7.5vw, 104px); line-height: .92; margin: 6px 0 30px; color: #fff; text-shadow: 0 4px 30px rgba(140, 60, 255, 0.5); }
#mainmenu h1 span { display: block; color: var(--gold); }
.mm-buttons { display: flex; flex-direction: column; gap: 10px; width: 260px; }
.mm-buttons .btn { text-align: left; padding-left: 22px; }
#farewell { position: absolute; inset: 0; background: rgba(7, 4, 26, 0.92); display: flex; align-items: center; justify-content: center; text-align: center; pointer-events: auto; }
#farewell h2 { font-size: 34px; color: var(--gold); }
#farewell p { color: var(--muted); margin: 10px 0 20px; }
.panel.pause { width: min(380px, 92vw); }
.pause-body { display: flex; flex-direction: column; gap: 10px; }
.pause-body .btn { width: 100%; }

/* Main menu on the right so the base shows on the left; menus always on top of it */
#mainmenu { justify-content: flex-end; padding-left: 0; padding-right: 8vw; text-align: right; background: linear-gradient(270deg, rgba(7, 4, 26, 0.85) 0%, rgba(7, 4, 26, 0.35) 45%, rgba(7, 4, 26, 0) 70%); }
.mm-buttons { margin-left: auto; align-items: stretch; }
.mm-buttons .btn { text-align: right; padding-left: 18px; padding-right: 22px; }
#modal { z-index: 50; }

/* ── Scanner layers ───────────────────────────────────────────────── */
#scan { width: 300px; }
#scan .layers { margin: 4px 0 8px; }
#scan .lay { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 5px 0; border-bottom: 1px solid rgba(59,45,88,0.6); font-size: 13px; line-height: 1.35; }
#scan .lay.deep { opacity: 0.75; }
#scan .ln { font-family: var(--display); font-weight: 700; color: var(--gold); text-align: center; }
#scan .lname { font-size: 11.5px; color: var(--muted); }
#scan .lay b { font-family: var(--display); float: right; }

/* Multiplayer */
#compass .mark.find { background: #c86bff; color: #fff; }
#worldline { font-size: 12px; margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }

/* Profile photo lines up with the name */
.profile-top .bigpic { margin-top: 8px; }

/* Inventory: shorter character view with item selectors underneath */
.inv-left { display: flex; flex-direction: column; gap: 10px; }
.inv-avatar canvas { width: 280px; height: 300px; }
.inv-sels { display: flex; flex-direction: column; gap: 4px; }
.sel-row { display: grid; grid-template-columns: 58px 30px 1fr 30px; gap: 6px; align-items: center; }
.sel-lab { font-size: 13px; color: var(--muted); }
.sel-btn { height: 30px; background: #241a3c; color: var(--text); border: 1px solid var(--line); cursor: pointer; font-size: 12px; }
.sel-btn:hover:not([disabled]) { background: #34265a; color: var(--gold); }
.sel-btn[disabled] { opacity: 0.35; cursor: default; }
.sel-val { text-align: center; line-height: 1.1; min-width: 0; }
.sel-val b { display: block; font-family: var(--display); font-size: 14px; }
.sel-val span { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Inventory layout v3: no scrolling ────────────────────────────── */
.kit-inventory { overflow: hidden !important; display: flex; }
.kit-inventory .inv-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 282px 1fr; gap: 20px; }
.inv-left { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.inv-avatar canvas { width: 280px; height: 300px; }
.inv-sels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 6px; }
.sel { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.sel-lab { font-size: 12px; color: var(--muted); }
.sel-ctl { display: flex; align-items: center; gap: 4px; }
.sel-ctl .sel-btn { width: 26px; height: 26px; padding: 0; font-size: 11px; }
.sel-num { font-family: var(--display); font-size: 16px; min-width: 22px; text-align: center; }
.inv-main { display: flex; flex-direction: column; min-height: 0; }
.inv-equip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.inv-equip > div { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: center; padding: 8px 10px; background: #1f1636; border: 1px solid var(--line); }
.inv-equip .ic { font-size: 22px; text-align: center; }
.inv-equip .nm { font-size: 14px; font-weight: 600; }
.inv-equip .nm b { font-family: var(--display); color: var(--gold); }
.inv-equip .ds { font-size: 12px; color: var(--muted); }
.kit-inventory .inv-grid { flex: 1; min-height: 0; overflow-y: auto; align-content: start; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--gold-deep) #120c22; overscroll-behavior: contain; }
.kit-inventory .tile { min-height: 82px; }

/* ── Inventory layout v4: bigger character, selectors at the bottom, collection scrolls by itself ── */
.kit-inventory .inv-body { grid-template-columns: 332px 1fr; }
.kit-inventory .inv-left { justify-content: space-between; gap: 12px; }
.kit-inventory .inv-avatar canvas { width: 330px; height: 420px; }
.kit-inventory .inv-sels { gap: 10px 6px; padding-bottom: 2px; }
.kit-inventory .inv-grid { border: 1px solid var(--line); background: rgba(10, 6, 22, 0.35); padding: 8px; }
@media (max-height: 760px) { .kit-inventory .inv-avatar canvas { height: 330px; } }
@media (max-height: 640px) { .kit-inventory .inv-avatar canvas { height: 250px; } }

/* ── Water meter moves under the stats panel; chat takes the bottom right ── */
#water { right: auto; left: 16px; bottom: auto; top: 330px; width: 220px; }
#chat { position: absolute; right: 16px; bottom: 16px; width: 380px; padding: 0; display: flex; flex-direction: column; pointer-events: auto; background: rgba(20, 14, 36, 0.72); }
.chat-tabs { display: flex; border-bottom: 1px solid var(--line); }
.chat-tabs button { flex: 1; background: transparent; border: none; color: var(--muted); padding: 7px 0; font-family: var(--display); font-size: 13px; cursor: pointer; position: relative; }
.chat-tabs button.on { color: var(--gold); box-shadow: inset 0 -2px 0 var(--gold); }
.chat-tabs button i { font-style: normal; font-size: 11px; color: #fff; background: var(--danger); border-radius: 8px; padding: 0 5px; margin-left: 5px; }
.chat-tabs button i:empty { display: none; }
.chat-log { height: 150px; overflow-y: auto; padding: 6px 10px; font-size: 13.5px; line-height: 1.35; scrollbar-width: thin; scrollbar-color: var(--gold-deep) transparent; overscroll-behavior: contain; }
.chat-log b { color: var(--gold); font-weight: 600; }
.chat-log .sys { color: var(--muted); font-style: italic; }
.chat-input { margin: 0; border: none; border-top: 1px solid var(--line); background: rgba(10, 6, 22, 0.6); color: var(--text); padding: 8px 10px; font-family: var(--body); font-size: 14px; outline: none; }
#chat:not(.typing) .chat-input { color: var(--muted); }
#chat.typing { background: rgba(20, 14, 36, 0.92); }
#chat.typing .chat-input { box-shadow: inset 0 0 0 1px var(--gold); }
#scan { bottom: 250px; }
#chat.hidden { display: none; }

/* Backspace hides the HUD; menus, prompts for rescue and fades still show */
#ui.hud-off > *:not(#modal):not(#fade):not(#flash):not(#vignette):not(#intro):not(#mainmenu):not(#farewell):not(#title) { visibility: hidden !important; }

/* Profile: tighter rows so it fits without scrolling */
.kit-profile .kv { gap: 1px; }
.kit-profile .kv div { padding: 2px 0; }
.kit-profile .kv div > :last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; text-align: right; }
.kit-profile .achs { gap: 5px; }
.kit-profile .ach { padding: 5px 10px; }
.kit-profile h3 { margin-top: 12px; margin-bottom: 8px; }
