/* Hardpoint: a dark machine-shop look. Orange for your own machine, HUD green for instruments,
   red for the enemy, amber for warnings. */
:root {
  --bg: #0b0f13;
  --panel: rgba(16, 21, 26, 0.92);
  --panel-2: rgba(26, 33, 40, 0.95);
  --line: #2f3943;
  --ink: #e6ecef;
  --muted: #8d9aa6;
  --accent: #e3812b;
  --accent-2: #ffb36b;
  --hud: #6dffbf;
  --red: #ff4a3a;
  --amber: #ffc34d;
  --blue: #6cc6ff;
  --display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --mono: "Share Tech Mono", ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--display); -webkit-text-size-adjust: 100%; }
canvas#view, canvas#hud { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
canvas#hud { pointer-events: none; z-index: 2; }
canvas#view { z-index: 1; touch-action: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------------- in play ---------------- */
#play { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
#objectives {
  position: absolute; left: max(14px, env(safe-area-inset-left)); top: 44px; max-width: min(340px, 46vw);
  font: 13px/1.35 var(--mono); color: var(--hud); text-shadow: 0 1px 2px #000;
  background: rgba(4, 14, 12, 0.5); border-left: 2px solid var(--hud); padding: 6px 10px;
}
#objectives h3 { margin: 0 0 3px; font: 600 11px var(--mono); letter-spacing: .12em; color: rgba(109,255,191,.6); }
#objectives .o { display: flex; gap: 6px; }
#objectives .o.done { color: rgba(109,255,191,.45); text-decoration: line-through; }
#objectives .o.failed { color: var(--red); }
#objectives .o.opt { color: #b7d8c8; }
#objectives .o i { font-style: normal; flex: none; }
#objectives .prog { color: var(--amber); }
#objectives.collapsed .o:not(.active) { display: none; }
#objectives .lh { margin-top: 6px; }
#objectives .dimtxt { color: rgba(109,255,191,.5); }
#objectives.collapsed .lm, #objectives.collapsed .lh { display: none; }
#radio { position: absolute; left: max(14px, env(safe-area-inset-left)); top: 50%; transform: translateY(-50%); width: min(380px, 44vw); display: flex; flex-direction: column; gap: 6px; }
#radio .msg { font: 13px/1.35 var(--display); background: rgba(6, 10, 14, 0.72); border-left: 3px solid var(--blue); padding: 6px 10px; animation: in .25s ease-out; text-shadow: 0 1px 1px #000; }
#radio .msg b { color: var(--blue); font-weight: 600; margin-right: 6px; letter-spacing: .04em; }
#radio .msg.enemy { border-color: var(--red); } #radio .msg.enemy b { color: var(--red); }
#radio .msg.computer { border-color: var(--hud); font-family: var(--mono); } #radio .msg.computer b { color: var(--hud); }
#radio .msg.fade { opacity: 0; transition: opacity 1s; }
@keyframes in { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
#tip { position: absolute; left: 50%; top: 112px; transform: translateX(-50%); max-width: min(560px, 86vw); text-align: center; background: rgba(40, 24, 6, 0.85); border: 1px solid var(--accent); color: #ffe3c4; padding: 8px 14px; font-size: 14px; border-radius: 3px; }
#tip::before { content: "TIP  "; color: var(--accent); font: 600 12px var(--mono); letter-spacing: .1em; }
#banner { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font: 700 clamp(28px, 6vw, 60px)/1 var(--display); letter-spacing: .14em; text-shadow: 0 2px 18px rgba(0,0,0,.8); }
#banner small { display: block; font: 500 clamp(14px, 2vw, 20px) var(--display); letter-spacing: .2em; color: var(--muted); margin-top: 10px; }
#banner.won { color: var(--hud); } #banner.lost { color: var(--red); }
#capture { position: absolute; left: 50%; top: 74%; transform: translateX(-50%); pointer-events: auto; background: rgba(10,14,18,.85); border: 1px solid var(--hud); color: var(--hud); padding: 10px 18px; font: 600 14px var(--mono); letter-spacing: .08em; cursor: pointer; }

/* touch */
#touch { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }
#t-stick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid rgba(109,255,191,.4); background: rgba(0,0,0,.2); }
#t-knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(109,255,191,.35); }
#touch button { pointer-events: auto; background: rgba(8,14,12,.6); border: 1px solid rgba(109,255,191,.5); color: var(--hud); font: 600 13px var(--mono); border-radius: 8px; touch-action: none; user-select: none; -webkit-user-select: none; }
#touch button.on { background: rgba(109,255,191,.35); }
.t-right { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: 24px; display: grid; grid-template-columns: 64px 64px; gap: 10px; }
.t-right button { height: 64px; }
.t-right .t-fire { font-size: 20px; border-radius: 50%; }
.t-top { position: absolute; right: max(12px, env(safe-area-inset-right)); top: 8px; display: flex; gap: 6px; }
.t-top button { padding: 6px 9px; }

/* ---------------- menus ---------------- */
#menu { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.screen { position: absolute; inset: 0; pointer-events: auto; overflow-y: auto; padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
.screen.dim { background: linear-gradient(90deg, rgba(8,11,14,.94) 0%, rgba(8,11,14,.86) 55%, rgba(8,11,14,.35) 100%); }
.screen.full { background: rgba(8, 11, 14, 0.9); }
.wrap { max-width: 1180px; margin: 0 auto; }
h1, h2, h3 { font-family: var(--display); margin: 0; }
.brand { font: 700 clamp(48px, 10vw, 112px)/.9 var(--display); letter-spacing: .06em; text-transform: uppercase; }
.brand span { color: var(--accent); }
.tagline { color: var(--muted); font-size: clamp(15px, 1.8vw, 19px); max-width: 34rem; margin: 14px 0 28px; }
.title-wrap { min-height: 100%; display: flex; flex-direction: column; justify-content: center; max-width: 1180px; margin: 0 auto; }
.menu-list { display: grid; gap: 8px; width: min(340px, 100%); }
.btn {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); padding: 11px 16px; cursor: pointer;
  font: 600 15px var(--display); letter-spacing: .06em; text-transform: uppercase; text-align: left;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover:not(:disabled), .btn:focus-visible { background: #33404b; border-color: var(--accent); outline: none; }
.btn.primary { background: var(--accent); color: #1a0e02; border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); color: #1a0e02; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn small { font: 400 12px var(--mono); color: var(--muted); text-transform: none; letter-spacing: 0; }
.btn.primary small { color: #4a2a08; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; margin-bottom: 18px; border-bottom: 2px solid var(--accent); padding-bottom: 10px; }
.head h2 { font-size: clamp(24px, 4vw, 36px); text-transform: uppercase; letter-spacing: .05em; }
.head p { margin: 0; color: var(--muted); }
.kicker { font: 600 12px var(--mono); letter-spacing: .16em; color: var(--accent); text-transform: uppercase; }
.panel { background: var(--panel); border: 1px solid var(--line); padding: 16px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* campaign list */
.camps { display: grid; gap: 14px; }
.camp { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 16px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent)); padding: 14px 16px; }
.camp.locked { opacity: .5; }
.camp h3 { font-size: 24px; text-transform: uppercase; letter-spacing: .05em; color: var(--c); }
.camp .world { font: 12px var(--mono); color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
.camp p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.missions { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; align-content: start; }
.mis { text-align: left; background: var(--panel-2); border: 1px solid var(--line); padding: 9px 11px; cursor: pointer; display: grid; gap: 2px; }
.mis:hover:not(:disabled), .mis:focus-visible { border-color: var(--c, var(--accent)); outline: none; }
.mis:disabled { opacity: .45; cursor: not-allowed; }
.mis .n { font: 11px var(--mono); color: var(--muted); }
.mis .t { font-weight: 600; font-size: 15px; }
.mis .st { font-size: 13px; color: var(--amber); letter-spacing: .1em; }
.mis .st i { font-style: normal; color: #3a434c; }
@media (max-width: 760px) { .camp { grid-template-columns: 1fr; } }

/* briefing */
.brief { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.brief .map { width: 100%; aspect-ratio: 1; image-rendering: auto; border: 1px solid var(--line); background: #000; display: block; }
.brief ul { margin: 6px 0 0; padding-left: 18px; }
.brief li { margin: 3px 0; }
.brief .text { font-size: 16px; line-height: 1.55; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--panel-2); border: 1px solid var(--line); padding: 7px 10px; cursor: pointer; display: grid; gap: 1px; min-width: 112px; text-align: left; }
.chip b { font-size: 14px; }
.chip span { font: 11px var(--mono); color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: #3a2814; }
.chip:disabled { opacity: .35; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--line); }
.seg button { background: transparent; border: 0; padding: 6px 12px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #1a0e02; }
.label { font: 600 11px var(--mono); letter-spacing: .14em; color: var(--muted); text-transform: uppercase; margin: 14px 0 6px; }
@media (max-width: 860px) { .brief { grid-template-columns: 1fr; } }

/* mech bay */
.bay { display: grid; grid-template-columns: minmax(0, 440px); gap: 14px; }
.hp { display: grid; grid-template-columns: 58px 24px minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 5px 0; border-bottom: 1px solid #1f262d; }
.hp .sec { font: 12px var(--mono); color: var(--muted); }
.type { font: 700 11px var(--mono); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 3px; }
.type.E { background: #1d3b5a; color: #8fd0ff; } .type.B { background: #4a3a14; color: #ffd27a; } .type.M { background: #4a1f1f; color: #ff9a8a; }
select { background: #0f1418; color: var(--ink); border: 1px solid var(--line); padding: 5px 6px; font: 13px var(--display); width: 100%; }
.grp { display: inline-flex; gap: 2px; }
.grp button { width: 22px; height: 22px; padding: 0; background: #11171c; border: 1px solid var(--line); cursor: pointer; font: 700 11px var(--mono); color: var(--muted); }
.grp button[aria-pressed="true"] { background: var(--hud); color: #04120c; border-color: var(--hud); }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button { width: 26px; height: 26px; background: #11171c; border: 1px solid var(--line); cursor: pointer; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font: 13px var(--mono); }
.stats dt { color: var(--muted); } .stats dd { margin: 0; text-align: right; }
.bar { height: 8px; background: #1b2228; position: relative; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--hud); }
.bar.over i { background: var(--red); }
.warn { color: var(--red); font-size: 13px; }

/* forms */
.form { display: grid; grid-template-columns: minmax(120px, 220px) minmax(0, 1fr); gap: 12px 16px; align-items: center; max-width: 640px; }
.form label { color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
input[type="text"] { background: #0f1418; color: var(--ink); border: 1px solid var(--line); padding: 6px 8px; font: 14px var(--display); }

/* help */
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.keys table { border-collapse: collapse; width: 100%; font-size: 14px; }
.keys td { padding: 4px 6px; border-bottom: 1px solid #1f262d; vertical-align: top; }
.keys td:first-child { white-space: nowrap; width: 1%; }
kbd { font: 12px var(--mono); background: #1b2228; border: 1px solid #36424d; border-bottom-width: 2px; padding: 1px 6px; border-radius: 3px; color: var(--ink); }

/* debrief */
.result { font: 700 clamp(34px, 7vw, 64px)/1 var(--display); letter-spacing: .1em; text-transform: uppercase; }
.result.won { color: var(--hud); } .result.lost { color: var(--red); }
.stars { font-size: 34px; letter-spacing: .1em; color: var(--amber); } .stars i { color: #2c343c; font-style: normal; }
.reward { border: 1px solid var(--accent); background: rgba(227,129,43,.08); padding: 10px 14px; margin-top: 12px; }
.pause-box { max-width: 380px; margin: 14vh auto 0; display: grid; gap: 10px; }

.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); }
.spinner { width: 42px; height: 42px; border: 3px solid #26303a; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { font: 14px var(--mono); color: var(--muted); letter-spacing: .08em; }

@media (max-width: 700px) {
  #objectives { font-size: 11px; top: 40px; max-width: 52vw; }
  #radio { width: 56vw; top: auto; bottom: 150px; transform: none; }
  #radio .msg { font-size: 12px; }
  #tip { top: 86px; font-size: 13px; }
  .screen.dim { background: rgba(8,11,14,.9); }
}
@media (prefers-reduced-motion: reduce) { #radio .msg { animation: none; } .spinner { animation-duration: 3s; } }
