:root {
  --hud: #8ff4ff;
  --hud-dim: rgba(143, 244, 255, 0.55);
  --panel: rgba(12, 16, 20, 0.45);
  --warn: #ffb347;
  --danger: #ff5a3c;
  --mono: 'Share Tech Mono', ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a0f0a; color: var(--hud); font-family: var(--mono); }
canvas#game { display: block; width: 100vw; height: 100vh; }
.hidden { display: none !important; }

#vignette, #damage { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.4s; }
#vignette { background: radial-gradient(ellipse at center, transparent 45%, rgba(120, 20, 0, 0.75) 100%); }
#damage { background: radial-gradient(ellipse at center, transparent 30%, rgba(255, 60, 30, 0.6) 100%); transition: opacity 0.15s; }

#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 0 0 6px rgba(80, 230, 255, 0.5); }

#compass { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); width: min(460px, 80vw); height: 38px;
  overflow: hidden; background: var(--panel); border: 1px solid rgba(143,244,255,0.25); border-radius: 4px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent); mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent); }
#compass-strip { position: absolute; inset: 0; }
#compass-strip .tick { position: absolute; top: 6px; transform: translateX(-50%); font-size: 12px; color: var(--hud-dim); white-space: nowrap; }
#compass-strip .tick.major { color: var(--hud); font-size: 16px; top: 4px; }
#compass-strip .marker { position: absolute; bottom: 2px; transform: translateX(-50%); font-size: 10px; color: var(--warn); white-space: nowrap; text-shadow: 0 0 6px rgba(255,170,60,0.6); }
#compass-needle { position: absolute; left: 50%; top: 0; width: 2px; height: 8px; background: var(--hud); transform: translateX(-50%); }

#log { position: absolute; top: 18px; left: 18px; width: min(460px, 60vw); font-size: 14px; line-height: 1.5; }
#log .line { transition: opacity 1.2s; }
#log .line.warn { color: var(--warn); text-shadow: 0 0 6px rgba(255,170,60,0.5); }
#log .line.danger { color: var(--danger); }
#log .line.story { color: #f3e2c8; text-shadow: 0 0 6px rgba(0,0,0,0.8); }
#log .line.fade { opacity: 0; }

#crosshair { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: var(--hud); box-shadow: 0 0 6px var(--hud); opacity: 0.8; }
#prompt { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); font-size: 16px; padding: 6px 12px; background: var(--panel); border: 1px solid rgba(143,244,255,0.3); border-radius: 3px; opacity: 0; transition: opacity 0.2s; }
#prompt.on { opacity: 1; }
#status { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); font-size: 18px; letter-spacing: 3px; font-family: 'Rajdhani', var(--mono); font-weight: 700; }
#status.warn { color: var(--warn); }
#status.danger { color: var(--danger); animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

#stats { position: absolute; left: 18px; bottom: 18px; width: 290px; padding: 12px 14px; background: var(--panel); border: 1px solid rgba(143,244,255,0.25); border-radius: 4px; }
#stats .unit { font-family: 'Rajdhani', var(--mono); font-weight: 700; letter-spacing: 2px; margin-bottom: 8px; font-size: 15px; }
#stats .dim { color: var(--hud-dim); font-weight: 500; letter-spacing: 0; font-family: var(--mono); font-size: 12px; }
.stat { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 13px; }
.stat .label { width: 38px; color: var(--hud-dim); }
.stat .bar { flex: 1; height: 8px; background: rgba(143,244,255,0.12); border-radius: 1px; overflow: hidden; }
.stat .fill { height: 100%; width: 100%; background: var(--hud); box-shadow: 0 0 8px var(--hud); transition: width 0.15s linear, background 0.3s; }
.stat .val { width: 30px; text-align: right; }
.stat.warn .fill { background: var(--warn); box-shadow: 0 0 8px var(--warn); } .stat.warn .val { color: var(--warn); }
.stat.danger .fill { background: var(--danger); box-shadow: 0 0 8px var(--danger); } .stat.danger .val { color: var(--danger); }
#stat-heat .fill { background: #ff9a5a; box-shadow: 0 0 8px #ff9a5a; }
.coords { margin-top: 8px; font-size: 11px; color: var(--hud-dim); }

#overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(40, 18, 10, 0.55), rgba(10, 5, 3, 0.9)); }
#overlay .panel { text-align: center; max-width: 520px; }
#overlay h1 { font-family: 'Rajdhani', var(--mono); font-weight: 700; font-size: clamp(42px, 9vw, 76px); letter-spacing: 10px; margin: 0 0 8px; color: #f4d9bd; text-shadow: 0 0 24px rgba(255, 140, 70, 0.5); }
#overlay .sub { color: #d7b89a; line-height: 1.6; margin: 0 0 28px; }
#overlay button { font-family: var(--mono); font-size: 18px; letter-spacing: 3px; color: #10161a; background: var(--hud); border: none; padding: 12px 34px; border-radius: 3px; cursor: pointer; box-shadow: 0 0 20px rgba(143,244,255,0.5); }
#overlay button:hover { filter: brightness(1.1); }
#overlay .controls { margin-top: 30px; display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px 16px; color: #c9a98a; font-size: 13px; }
#overlay .controls b { color: var(--hud); font-weight: normal; }

@media (max-width: 600px) {
  #stats { width: auto; right: 18px; }
  #log { font-size: 12px; top: 64px; }
}

#shiftlock { position: absolute; right: 18px; bottom: 18px; font-size: 12px; letter-spacing: 1px; padding: 6px 10px; background: var(--panel); border: 1px solid rgba(143,244,255,0.35); border-radius: 3px; }
#shiftlock.off { color: var(--hud-dim); border-color: rgba(143,244,255,0.15); }
body.cursor-free #crosshair { opacity: 0.25; }
body.cursor-free canvas#game { cursor: grab; }
body.cursor-free canvas#game:active { cursor: grabbing; }
@media (max-width: 600px) { #shiftlock { bottom: auto; top: 64px; } }

/* ---------- Milestone 2 UI ---------- */
#grade { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(25, 8, 2, 0.38) 100%); }
#overlay button.link { background: none; box-shadow: none; color: #c9a98a; font-size: 13px; letter-spacing: 1px; padding: 10px; margin-top: 6px; text-decoration: underline; }

.icon svg { width: 100%; height: 100%; display: block; }

#objective { position: absolute; top: 16px; right: 18px; width: 300px; padding: 10px 14px 12px; background: var(--panel); border: 1px solid rgba(143,244,255,0.25); border-left: 3px solid var(--warn); border-radius: 4px; }
#objective .obj-title { font-size: 11px; letter-spacing: 3px; color: var(--warn); text-shadow: 0 0 6px rgba(255,170,60,0.5); }
#objective .obj-text { font-family: 'Rajdhani', var(--mono); font-weight: 700; font-size: 18px; color: #f3e2c8; margin-top: 4px; line-height: 1.15; text-shadow: none; }
#objective .obj-progress { font-size: 14px; margin-top: 4px; }
#objective .obj-progress:empty { display: none; }
#objective .obj-hint { font-size: 12px; color: #c9a98a; margin-top: 6px; line-height: 1.4; text-shadow: none; }
#objective.flash { animation: objflash 1.2s ease-out; }
@keyframes objflash { 0% { border-color: #8fdfa8; box-shadow: 0 0 30px rgba(120,255,170,0.6); } 100% { box-shadow: none; } }

#target { position: absolute; left: 50%; top: calc(50% + 30px); transform: translateX(-50%); text-align: center; opacity: 0; transition: opacity 0.15s; min-width: 180px; padding: 5px 10px 6px; background: rgba(8,12,16,0.55); border-radius: 3px; text-shadow: 0 1px 2px #000; }
#target.on { opacity: 1; }
#target .t-name { font-size: 12px; letter-spacing: 2px; }
#target .t-bar { width: 140px; height: 4px; margin: 5px auto; background: rgba(143,244,255,0.15); border-radius: 2px; overflow: hidden; }
#target .t-bar div { height: 100%; background: var(--hud); box-shadow: 0 0 6px var(--hud); transition: width 0.1s linear; }
#target .t-hint { font-size: 11px; color: var(--hud-dim); }

#toasts { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.toast { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; background: rgba(12,16,20,0.6); border: 1px solid rgba(143,244,255,0.25); border-radius: 3px; font-size: 13px; animation: toastin 0.25s ease-out; transition: opacity 0.4s, transform 0.4s; }
.toast .icon { width: 28px; height: 28px; }
.toast b { color: #f3e2c8; font-weight: normal; text-shadow: none; }
.toast i { font-style: normal; color: var(--hud-dim); margin-left: 6px; }
.toast.msg { padding: 7px 12px; }
.toast.warn { color: var(--warn); border-color: rgba(255,170,60,0.4); }
.toast.good { color: #8fdfa8; border-color: rgba(143,223,168,0.4); }
.toast.bump { animation: toastbump 0.25s ease-out; }
.toast.out { opacity: 0; transform: translateX(20px); }
@keyframes toastin { from { opacity: 0; transform: translateX(30px); } }
@keyframes toastbump { 50% { transform: scale(1.07); } }

#hotbar { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 8px; }
#hotbar .slot { position: relative; width: 58px; height: 58px; background: var(--panel); border: 1px solid rgba(143,244,255,0.3); border-radius: 4px; overflow: hidden; }
#hotbar .slot .icon { position: absolute; inset: 9px; }
#hotbar .slot .key { position: absolute; left: 4px; top: 2px; font-size: 10px; color: var(--hud-dim); z-index: 2; }
#hotbar .slot .count { position: absolute; right: 4px; bottom: 2px; font-size: 13px; z-index: 2; }
#hotbar .slot.empty .icon { opacity: 0.25; filter: grayscale(1); }
#hotbar .slot .cool { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0,0,0,0.6); }
#hotbar .cargo-slot { width: 86px; }
#hotbar .cargo-slot .icon { inset: 6px 30px 18px 30px; }
#hotbar .cargo-slot .count { left: 0; right: 0; text-align: center; font-size: 12px; }
#hotbar .cargo-slot.full { border-color: var(--danger); }
#hotbar .cargo-slot.full .count { color: var(--danger); }
#status { bottom: 92px; }

.modal { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto;
  background: linear-gradient(180deg, rgba(14, 22, 28, 0.94), rgba(10, 14, 18, 0.94)); border: 1px solid rgba(143,244,255,0.35); border-radius: 6px; pointer-events: auto;
  box-shadow: 0 0 60px rgba(0,0,0,0.6), 0 0 30px rgba(95,240,255,0.08) inset; text-shadow: none; animation: modalin 0.18s ease-out; }
@keyframes modalin { from { opacity: 0; transform: translate(-50%, -48%); } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid rgba(143,244,255,0.18); font-family: 'Rajdhani', var(--mono); font-weight: 700; letter-spacing: 3px; font-size: 16px; }
.modal-head .cargo { margin-left: auto; font-family: var(--mono); font-weight: normal; letter-spacing: 1px; font-size: 12px; color: var(--hud-dim); }
.modal-head .close { margin-left: auto; background: none; border: 1px solid rgba(143,244,255,0.3); color: var(--hud); width: 28px; height: 28px; border-radius: 3px; cursor: pointer; font-size: 14px; }
.modal-head .cargo + .close { margin-left: 0; }
.modal .sub-title { font-size: 11px; letter-spacing: 3px; color: var(--hud-dim); margin: 14px 0 8px; }
.modal .dim { color: var(--hud-dim); font-size: 12px; }

.craft-body { display: grid; grid-template-columns: 260px 1fr; gap: 0; }
.recipe-list { border-right: 1px solid rgba(143,244,255,0.12); padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.recipe { display: flex; align-items: center; gap: 10px; padding: 6px 8px; background: transparent; border: 1px solid transparent; border-radius: 4px; color: #9fb8c0; text-align: left; cursor: pointer; font-family: var(--mono); }
.recipe:hover { background: rgba(143,244,255,0.06); }
.recipe.sel { border-color: rgba(143,244,255,0.45); background: rgba(143,244,255,0.08); }
.recipe .icon { width: 34px; height: 34px; flex: none; opacity: 0.55; }
.recipe.can .icon, .recipe.sel .icon { opacity: 1; }
.recipe .r-text { display: flex; flex-direction: column; flex: 1; }
.recipe .r-text b { color: #e8eef0; font-weight: normal; font-size: 13px; }
.recipe .r-text span { font-size: 11px; color: var(--hud-dim); }
.recipe .r-state { font-size: 10px; letter-spacing: 1px; color: #8fdfa8; }
.recipe.done .r-state { color: var(--hud-dim); }
.recipe-detail { padding: 16px 18px; }
.rd-top { display: flex; gap: 14px; align-items: center; }
.rd-icon { width: 72px; height: 72px; flex: none; padding: 8px; border: 1px solid rgba(143,244,255,0.2); border-radius: 6px; background: rgba(143,244,255,0.04); }
.rd-name { font-family: 'Rajdhani', var(--mono); font-weight: 700; font-size: 22px; color: #f3e2c8; }
.rd-desc { font-size: 12px; color: #b9c9cd; line-height: 1.5; margin-top: 2px; }
.ing { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; color: #d8e4e6; }
.ing .icon { width: 28px; height: 28px; }
.ing b { margin-left: auto; font-weight: normal; }
.ing.ok b { color: #8fdfa8; }
.ing.miss b { color: var(--danger); }
.rd-actions { display: flex; gap: 8px; margin-top: 16px; }
.rd-actions button { font-family: var(--mono); letter-spacing: 2px; font-size: 14px; padding: 10px 22px; border-radius: 3px; border: none; background: var(--hud); color: #0c1418; cursor: pointer; box-shadow: 0 0 16px rgba(95,240,255,0.35); }
.rd-actions .craft5 { background: transparent; color: var(--hud); border: 1px solid rgba(143,244,255,0.4); box-shadow: none; padding: 10px 14px; }
.rd-actions button:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
.queue-wrap { border-top: 1px solid rgba(143,244,255,0.12); padding: 0 16px 14px; }
.queue { display: flex; gap: 8px; min-height: 52px; align-items: center; }
.q-item { width: 48px; }
.q-item .icon { width: 40px; height: 40px; margin: 0 auto; opacity: 0.5; }
.q-item.active .icon { opacity: 1; }
.q-bar { height: 3px; background: rgba(143,244,255,0.15); margin-top: 3px; }
.q-bar div { height: 100%; width: 0; background: var(--warn); box-shadow: 0 0 6px var(--warn); }

.inv-body { display: grid; grid-template-columns: 1fr 260px; gap: 20px; padding: 16px; }
.inv-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.inv-slot { position: relative; aspect-ratio: 1; border: 1px solid rgba(143,244,255,0.25); border-radius: 4px; background: rgba(143,244,255,0.04); }
.inv-slot.blank { border-style: dashed; border-color: rgba(143,244,255,0.1); background: none; }
.inv-slot .icon { position: absolute; inset: 14%; }
.inv-slot .count { position: absolute; right: 5px; bottom: 2px; font-size: 13px; }
.inv-slot:hover:not(.blank) { border-color: var(--hud); }
.inv-cargo { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 12px; color: var(--hud-dim); }
.inv-cargo .bar { flex: 1; height: 6px; background: rgba(143,244,255,0.12); }
.inv-cargo .bar div { height: 100%; background: var(--hud); }
.inv-cargo b { color: var(--hud); font-weight: normal; }
.inv-desc { margin-top: 12px; min-height: 48px; font-size: 12px; color: #b9c9cd; line-height: 1.5; }
.inv-desc b { display: block; color: #f3e2c8; font-size: 14px; font-weight: normal; }
.tool-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; font-size: 12px; }
.tool-row .icon { width: 38px; height: 38px; flex: none; }
.tool-row b { display: block; color: #e8eef0; font-weight: normal; font-size: 13px; }
.tool-row span { color: var(--hud-dim); font-size: 11px; line-height: 1.3; }
.tool-row.locked { opacity: 0.4; filter: grayscale(1); }
.tips div { font-size: 12px; color: #b9c9cd; padding: 3px 0; }
.tips b { display: inline-block; min-width: 22px; color: var(--hud); font-weight: normal; }

@media (max-width: 700px) {
  .craft-body, .inv-body { grid-template-columns: 1fr; }
  .recipe-list { border-right: none; border-bottom: 1px solid rgba(143,244,255,0.12); }
  #objective { width: auto; left: 18px; top: 64px; }
  #hotbar .slot { width: 46px; height: 46px; }
  #hotbar .cargo-slot { width: 70px; }
}

#compass-strip .marker.obj { color: #ffe08a; font-weight: bold; }
#compass-strip .marker.res-iron { color: #b9c4d0; text-shadow: 0 0 6px rgba(180,200,220,0.6); }
#compass-strip .marker.res-copper { color: #f0a060; }
#compass-strip .marker.res-crystal { color: #8fe8ff; text-shadow: 0 0 6px rgba(140,230,255,0.7); }
#compass-strip .marker.res-scrap { color: #d8dde2; }

/* ---------- Milestone 3: build mode ---------- */
body.build-mode #hotbar { display: none; }
body.build-mode #crosshair { width: 10px; height: 10px; margin: -5px 0 0 -5px; background: none; border: 2px solid var(--hud); border-radius: 2px; transform: rotate(45deg); }
#buildbar { position: absolute; left: 326px; right: 230px; bottom: 14px; max-width: 720px; margin: 0 auto; pointer-events: none; }
.bb-info { background: rgba(10,14,18,0.72); border: 1px solid rgba(143,244,255,0.3); border-bottom: none; border-radius: 5px 5px 0 0; padding: 8px 12px; text-shadow: none; }
.bb-head { display: flex; align-items: baseline; gap: 10px; }
.bb-mode { font-size: 10px; letter-spacing: 3px; color: var(--warn); }
.bb-name { font-family: 'Rajdhani', var(--mono); font-size: 18px; color: #f3e2c8; }
.bb-reason { margin-left: auto; font-size: 12px; color: #8fdfa8; }
.bb-reason.bad { color: var(--danger); }
.bb-cost { display: flex; flex-wrap: wrap; gap: 12px; margin: 6px 0 4px; font-size: 12px; }
.bb-cost .c { display: flex; align-items: center; gap: 4px; color: #8fdfa8; }
.bb-cost .c.miss { color: var(--danger); }
.bb-cost .c .icon { width: 20px; height: 20px; }
.bb-cost .desc { color: #b9c9cd; flex-basis: 100%; font-size: 11px; }
.bb-keys { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; color: var(--hud-dim); }
.bb-keys b { color: var(--hud); font-weight: normal; }
.bb-slots { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; background: rgba(10,14,18,0.72); border: 1px solid rgba(143,244,255,0.3); border-radius: 0 0 5px 5px; padding: 6px; }
.bb-slot { position: relative; aspect-ratio: 1; border: 1px solid rgba(143,244,255,0.18); border-radius: 4px; background: rgba(143,244,255,0.03); }
.bb-slot .icon { position: absolute; inset: 14%; }
.bb-slot .key { position: absolute; left: 4px; top: 1px; font-size: 10px; color: var(--hud-dim); }
.bb-slot.sel { border-color: var(--hud); background: rgba(143,244,255,0.12); box-shadow: 0 0 12px rgba(95,240,255,0.35) inset; }
.bb-slot.cant .icon { opacity: 0.35; filter: grayscale(0.8); }

#gridinfo { position: absolute; left: 18px; bottom: 178px; width: 290px; padding: 8px 12px; background: var(--panel); border: 1px solid rgba(143,244,255,0.25); border-radius: 4px; font-size: 12px; }
#gridinfo .gt { font-size: 10px; letter-spacing: 3px; color: var(--hud-dim); margin-bottom: 4px; }
#gridinfo .row { display: flex; justify-content: space-between; }
#gridinfo .up { color: #8fdfa8; } #gridinfo .down { color: var(--warn); } #gridinfo .bad { color: var(--danger); }
#gridinfo .bar { height: 5px; background: rgba(143,244,255,0.12); margin-top: 5px; }
#gridinfo .bar div { height: 100%; background: var(--hud); box-shadow: 0 0 6px var(--hud); }
@media (max-width: 700px) { #gridinfo { display: none; } .bb-slots { grid-template-columns: repeat(4, 1fr); } }

@media (max-width: 1150px) {
  #log { top: 64px; width: min(380px, 45vw); font-size: 12px; }
  #objective { top: 64px; width: 270px; }
  #hotbar { left: auto; right: 18px; bottom: 58px; transform: none; }
  #gridinfo { bottom: auto; top: 50%; }
}

@media (max-width: 1150px) {
  #buildbar { right: 18px; }
  body.build-mode #shiftlock { display: none; }
}
@media (max-width: 700px) {
  #buildbar { left: 18px; bottom: 150px; }
}

/* ---------- Milestone 4: day/night + combat ---------- */
#clock { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; font-size: 12px; padding: 3px 10px; background: var(--panel); border: 1px solid rgba(143,244,255,0.2); border-radius: 3px; }
#clock .sol { color: #f3e2c8; letter-spacing: 2px; }
#clock .phase { letter-spacing: 2px; }
#clock .phase.night { color: #c9a0ff; text-shadow: 0 0 6px rgba(190,140,255,0.6); }
#clock .phase.dusk, #clock .phase.dawn { color: var(--warn); }
#clock .cbar { width: 60px; height: 3px; background: rgba(143,244,255,0.15); }
#clock .cbar div { height: 100%; background: var(--hud); }
#hitdir { position: absolute; left: 50%; top: 50%; width: 220px; height: 220px; margin: -110px 0 0 -110px; border-radius: 50%; pointer-events: none; opacity: 0;
  background: conic-gradient(from -20deg, rgba(255,60,30,0.85) 0deg, rgba(255,60,30,0) 40deg, transparent 40deg);
  -webkit-mask: radial-gradient(circle, transparent 86px, #000 88px, #000 104px, transparent 106px); mask: radial-gradient(circle, transparent 86px, #000 88px, #000 104px, transparent 106px);
  transition: opacity 0.6s; }
#deathscreen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(60,0,0,0.75), rgba(5,0,0,0.95)); color: #ffb0a0; pointer-events: none; animation: deathin 0.4s; }
#deathscreen h2 { font-family: 'Rajdhani', var(--mono); font-size: clamp(36px, 7vw, 64px); letter-spacing: 8px; margin: 0; color: #ff5a3c; text-shadow: 0 0 20px rgba(255,60,30,0.7); animation: blink 0.7s steps(2) infinite; }
#deathscreen .loss { color: #d8b0a0; font-size: 13px; }
@keyframes deathin { from { opacity: 0; } }
#hotbar .slot.equipped { border-color: var(--hud); box-shadow: 0 0 12px rgba(95,240,255,0.4) inset; }
#hotbar .slot.equipped .key { color: var(--hud); }
@media (max-width: 1150px) { #clock { top: 58px; } #log, #objective { top: 92px; } }

/* ---------- Milestone 5: chassis + upgrades ---------- */
.recipe-list { max-height: min(460px, calc(100vh - 220px)); overflow-y: auto; }
.recipe-cat { font-size: 10px; letter-spacing: 3px; color: var(--hud-dim); padding: 8px 8px 2px; }
#chassis-panel { width: min(860px, calc(100vw - 32px)); }
.chs-body { display: grid; grid-template-columns: 330px 1fr; gap: 18px; padding: 14px 16px 16px; }
.chs-view { position: relative; height: 430px; border: 1px solid rgba(143,244,255,0.18); border-radius: 6px;
  background: radial-gradient(ellipse at 50% 70%, rgba(95,240,255,0.10), rgba(0,0,0,0) 60%), linear-gradient(180deg, #121a20, #0a0e12); overflow: hidden; }
.chs-view canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.chs-view canvas:active { cursor: grabbing; }
.chs-hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 10px; letter-spacing: 2px; color: var(--hud-dim); pointer-events: none; }
.chs-slot { padding: 8px 0 10px; border-bottom: 1px solid rgba(143,244,255,0.1); }
.chs-slot .sl-head { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: 3px; color: var(--hud-dim); }
.chs-slot .sl-head b { color: #f3e2c8; letter-spacing: 0; font-weight: normal; font-size: 13px; }
.chs-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chs-opt { display: flex; align-items: center; gap: 6px; padding: 4px 9px 4px 4px; border: 1px solid rgba(143,244,255,0.22); border-radius: 4px; background: rgba(143,244,255,0.03); color: #d8e4e6; font-family: var(--mono); font-size: 12px; cursor: pointer; }
.chs-opt .icon { width: 26px; height: 26px; }
.chs-opt.on { border-color: var(--hud); background: rgba(143,244,255,0.14); box-shadow: 0 0 12px rgba(95,240,255,0.3) inset; color: #fff; }
.chs-opt.locked { opacity: 0.35; cursor: default; filter: grayscale(0.8); }
.chs-opt.stock { padding-left: 9px; }
.chs-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.chs-stats span { font-size: 11px; padding: 3px 8px; border-radius: 10px; background: rgba(143,223,168,0.12); color: #8fdfa8; }
.chs-stats .none { background: none; color: var(--hud-dim); }
.chs-where.away { color: var(--warn); }
#radar { position: absolute; right: 18px; bottom: 150px; width: 170px; height: 170px; border-radius: 50%; }
#nvlabel { position: absolute; left: 50%; top: 92px; transform: translateX(-50%); font-size: 11px; letter-spacing: 4px; color: #6fff8a; text-shadow: 0 0 8px rgba(80,255,120,0.7); }
@media (max-width: 1150px) { #radar { bottom: 130px; width: 140px; height: 140px; } #nvlabel { top: 124px; } }
@media (max-width: 760px) { .chs-body { grid-template-columns: 1fr; } .chs-view { height: 300px; } }

.modal { z-index: 10; }
body.menu-open #radar, body.menu-open #stats, body.menu-open #hotbar, body.menu-open #gridinfo, body.menu-open #objective, body.menu-open #log, body.menu-open #toasts { visibility: hidden; }

/* ---------- Vance Station log reader ---------- */
#reader-panel { width: min(620px, calc(100vw - 32px)); }
.reader-body { padding: 18px 24px 8px; min-height: 220px; }
.rd-date { font-size: 12px; letter-spacing: 3px; color: var(--warn); margin-bottom: 12px; }
.rd-text { font-family: 'Rajdhani', var(--mono); font-size: 19px; line-height: 1.5; color: #f0e4d0; white-space: pre-line; }
.rd-text .sig { display: block; margin-top: 14px; color: #c9a98a; font-style: italic; }
.reader-nav { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px 14px; border-top: 1px solid rgba(143,244,255,0.12); }
.reader-nav button { font-family: var(--mono); font-size: 13px; letter-spacing: 1px; color: var(--hud); background: transparent; border: 1px solid rgba(143,244,255,0.35); border-radius: 3px; padding: 7px 14px; cursor: pointer; }
.reader-nav button:disabled { opacity: 0.3; cursor: default; }

/* ---------- loading screen ---------- */
#loading { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 120%, #7a3418 0%, #3a160b 35%, #120705 75%); transition: opacity 0.9s ease; }
#loading.out { opacity: 0; pointer-events: none; }
#loading .ld-glow { position: absolute; left: 50%; bottom: -30vh; width: 120vw; height: 60vh; transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,150,80,0.25), rgba(255,150,80,0) 70%); filter: blur(10px); animation: ldpulse 6s ease-in-out infinite; }
@keyframes ldpulse { 50% { opacity: 0.55; } }
.ld-center { position: relative; text-align: center; width: min(520px, 100%); }
.ld-center h1 { font-family: 'Rajdhani', var(--mono); font-weight: 700; font-size: clamp(44px, 9vw, 80px); letter-spacing: 12px; margin: 14px 0 4px; color: #f4d9bd; text-shadow: 0 0 28px rgba(255, 140, 70, 0.45); }
.ld-sub { color: #c9a98a; letter-spacing: 4px; font-size: 12px; margin-bottom: 34px; }
.ld-bar { height: 4px; border-radius: 4px; background: rgba(143,244,255,0.12); overflow: hidden; }
.ld-bar div { height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, #3fd0ea, #8ff4ff); box-shadow: 0 0 12px rgba(95,240,255,0.7); }
.ld-row { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12px; letter-spacing: 1px; color: var(--hud-dim); }
.ld-pct { color: var(--hud); }
.ld-radar { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; border: 2px solid rgba(143,244,255,0.5); position: relative; overflow: hidden;
  background: radial-gradient(circle, rgba(95,240,255,0.08), rgba(0,0,0,0) 70%); box-shadow: 0 0 20px rgba(95,240,255,0.2); }
.ld-radar span { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, rgba(95,240,255,0.55), rgba(95,240,255,0) 25%); animation: ldspin 1.6s linear infinite; }
.ld-radar::after { content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #e8feff; box-shadow: 0 0 8px #8ff4ff; }
@keyframes ldspin { to { transform: rotate(360deg); } }
.ld-tip { position: absolute; left: 50%; bottom: 7vh; transform: translateX(-50%); width: min(640px, calc(100% - 32px)); display: flex; gap: 14px; align-items: center;
  padding: 14px 18px; border-radius: 10px; background: rgba(10, 14, 18, 0.55); border: 1px solid rgba(143,244,255,0.2); }
.ld-tip-label { flex: none; font-size: 11px; letter-spacing: 3px; color: var(--warn); padding: 4px 8px; border: 1px solid rgba(255,179,71,0.4); border-radius: 6px; }
.ld-tip-text { color: #e8dccb; font-size: 14px; line-height: 1.5; transition: opacity 0.35s; }

#clickhint { position: absolute; left: 50%; top: calc(50% + 40px); transform: translateX(-50%); padding: 8px 16px; border-radius: 20px; font-size: 13px; letter-spacing: 1px;
  background: rgba(10,14,18,0.6); border: 1px solid rgba(143,244,255,0.35); animation: hintpulse 1.6s ease-in-out infinite; }
@keyframes hintpulse { 50% { opacity: 0.55; } }
.ov-row { display: flex; gap: 18px; justify-content: center; }

/* softer corners on every HUD panel */
#stats, #objective, #gridinfo, #compass, #clock, #shiftlock, #target, .toast, .bb-info { border-radius: 10px; }
.bb-info { border-radius: 10px 10px 0 0; } .bb-slots { border-radius: 0 0 10px 10px; }
#hotbar .slot, .bb-slot, .inv-slot, .rd-icon, .chs-view { border-radius: 8px; }
.modal { border-radius: 12px; }
#prompt { border-radius: 8px; }
.recipe, .chs-opt, .rd-actions button, .reader-nav button, #overlay button { border-radius: 8px; }

/* ---------- settings menu ---------- */
#settings-panel { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(5, 3, 2, 0.6); backdrop-filter: blur(4px); }
.st-card { width: min(640px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; border-radius: 14px; overflow: hidden;
  background: linear-gradient(180deg, rgba(16, 24, 30, 0.97), rgba(10, 14, 18, 0.97)); border: 1px solid rgba(143,244,255,0.3); box-shadow: 0 20px 60px rgba(0,0,0,0.6); animation: modalin2 0.18s ease-out; }
@keyframes modalin2 { from { opacity: 0; transform: translateY(8px); } }
.st-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid rgba(143,244,255,0.15); font-family: 'Rajdhani', var(--mono); font-weight: 700; letter-spacing: 3px; color: var(--hud); }
.st-tabs { display: flex; gap: 4px; margin-left: auto; background: rgba(143,244,255,0.06); padding: 3px; border-radius: 9px; }
.st-tab { font-family: var(--mono); font-size: 12px; letter-spacing: 1px; color: var(--hud-dim); background: none; border: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.st-tab.on { color: #0c1418; background: var(--hud); }
.st-close { background: none; border: 1px solid rgba(143,244,255,0.3); color: var(--hud); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; }
.st-body { padding: 6px 18px 12px; overflow-y: auto; }
.st-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid rgba(143,244,255,0.07); }
.st-label { color: #e8eef0; font-size: 13px; }
.st-label span { display: block; color: var(--hud-dim); font-size: 11px; margin-top: 2px; }
.st-ctl { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.st-seg { font-family: var(--mono); font-size: 12px; color: #b9c9cd; background: rgba(143,244,255,0.05); border: 1px solid rgba(143,244,255,0.18); padding: 6px 10px; border-radius: 7px; cursor: pointer; }
.st-seg.on { color: #0c1418; background: var(--hud); border-color: var(--hud); }
.st-seg:disabled { opacity: 0.35; cursor: default; }
.st-toggle { width: 44px; height: 24px; border-radius: 12px; border: 1px solid rgba(143,244,255,0.3); background: rgba(143,244,255,0.08); position: relative; cursor: pointer; transition: background 0.15s; }
.st-toggle span { position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #9fb8c0; transition: left 0.15s, background 0.15s; }
.st-toggle.on { background: rgba(95,240,255,0.35); border-color: var(--hud); }
.st-toggle.on span { left: 23px; background: #e8feff; }
.st-ctl input[type=range] { width: 170px; accent-color: #5ff0ff; }
.st-ctl b { min-width: 52px; text-align: right; font-weight: normal; color: var(--hud); font-size: 12px; }
.st-info { margin-top: 12px; font-size: 11px; color: var(--hud-dim); line-height: 1.5; }
.st-foot { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid rgba(143,244,255,0.12); }
.st-reset { font-family: var(--mono); font-size: 12px; color: var(--hud); background: none; border: 1px solid rgba(143,244,255,0.35); padding: 7px 12px; border-radius: 8px; cursor: pointer; }
.st-note { font-size: 11px; color: var(--hud-dim); }
#fps { position: fixed; right: 18px; bottom: 58px; z-index: 5; font-size: 12px; padding: 4px 9px; border-radius: 8px; background: rgba(10,14,18,0.6); border: 1px solid rgba(143,244,255,0.25); color: #8fdfa8; pointer-events: none; }
#fps.slow { color: var(--warn); } #fps.bad { color: var(--danger); }
@media (max-width: 560px) { .st-row { flex-direction: column; align-items: flex-start; } .st-ctl { justify-content: flex-start; } }

@media (max-width: 1150px) { #fps { bottom: auto; top: 4px; right: auto; left: 50%; transform: translateX(-50%); padding: 2px 8px; font-size: 11px; } }

/* rover speed / battery readout */
#roverhud { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); padding: 8px 16px; background: var(--panel); border: 1px solid rgba(143,244,255,0.3); border-radius: 4px; font-size: 13px; letter-spacing: 2px; color: #cfeff5; white-space: nowrap; }
#roverhud.low { color: #ffb066; border-color: rgba(255,176,102,0.5); }
