:root {
  --ink: #e8e6f0;
  --ink-dim: rgba(232, 230, 240, 0.55);
  --ink-faint: rgba(232, 230, 240, 0.14);
  --bg: #0a0b12;
  --panel: rgba(10, 11, 18, 0.72);
  --line: rgba(232, 230, 240, 0.16);
  --amber: #f2b35b;
  --amber-dim: rgba(242, 179, 91, 0.5);
  --me: #62d9e8;
  --them: #ff5d55;
  --sans: 'Rajdhani', 'Barlow Semi Condensed', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); }
body { user-select: none; -webkit-user-select: none; touch-action: none; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
button { font-family: var(--sans); }

/* Shared: bracketed panel corners */
.menu-card, .brief, #h-card, .scorebox {
  --c: var(--amber-dim);
  background:
    linear-gradient(var(--c), var(--c)) top left / 10px 1px no-repeat,
    linear-gradient(var(--c), var(--c)) top left / 1px 10px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 10px 1px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 1px 10px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 10px 1px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 1px 10px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 10px 1px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 1px 10px no-repeat,
    var(--panel);
}

/* ================= MENU ================= */
.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 20; flex-direction: column; padding: 16px; }
.screen.on { display: flex; }
.menu-bg { position: absolute; inset: 0; z-index: -1; overflow: hidden;
  background:
    radial-gradient(90% 60% at 70% 110%, rgba(217, 128, 108, 0.22), transparent 70%),
    radial-gradient(60% 50% at 10% 0%, rgba(91, 74, 118, 0.25), transparent 70%),
    linear-gradient(180deg, #0a0b12, #0e0f1a 60%, #15121f);
}
.menu-bg::before { content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(var(--ink-faint) 1px, transparent 1px), linear-gradient(90deg, var(--ink-faint) 1px, transparent 1px);
  background-size: 48px 48px; opacity: 0.25;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%); -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
}
.menu-grid { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 760px); gap: 18px; width: min(1180px, 100%); align-items: stretch; max-height: calc(100vh - 56px); }
.menu-card { padding: 22px 22px 18px; overflow-y: auto; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); }
.menu-card.small { width: min(340px, 100%); display: flex; flex-direction: column; gap: 10px; }
.menu-card.small h2 { margin: 0 0 6px; font-family: var(--mono); font-size: 14px; letter-spacing: 0.3em; color: var(--amber); }
.brand { margin-bottom: 16px; }
.callsign { margin-bottom: 10px; }
.menu-card:has(#panel-loading.on) .callsign, .menu-card:has(#panel-host.on) .callsign { display: none; }
.kicker { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; color: var(--amber); }
#title .nw-title { display: block; margin-top: 6px; font-size: 0.74em; letter-spacing: 0.1em; }
#title .nw-title .t-c { color: #00ffe0; text-shadow: 0 0 18px rgba(0, 255, 224, 0.35); }
#title .nw-title .t-r { color: #ff3048; text-shadow: 0 0 18px rgba(255, 48, 72, 0.4); }
h1 { margin: 6px 0 0; font-size: 46px; line-height: 1; font-weight: 700; letter-spacing: 0.16em; color: var(--ink); }
.tag { margin: 6px 0 0; color: var(--ink-dim); font-size: 15px; font-weight: 500; letter-spacing: 0.04em; }
.panel { display: none; flex-direction: column; gap: 9px; }
.panel.on { display: flex; }
.panel button, #h-card button, .menu-card button {
  appearance: none; position: relative; border: 1px solid var(--line); background: rgba(232, 230, 240, 0.04); color: var(--ink);
  padding: 12px 16px; border-radius: 2px; font-size: 16px; font-weight: 700; letter-spacing: 0.18em; cursor: pointer; text-transform: uppercase; text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.panel button::after, .menu-card button::after { content: '›'; position: absolute; right: 14px; top: 50%; transform: translateY(-52%); opacity: 0.45; font-size: 20px; }
.panel button:hover, .menu-card button:hover { background: rgba(232, 230, 240, 0.09); border-color: rgba(232, 230, 240, 0.35); }
button.primary { background: var(--amber) !important; color: #14110a !important; border-color: var(--amber) !important; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent !important; color: var(--ink-dim) !important; border-color: transparent !important; }
button:active { transform: translateY(1px); }
.field { display: flex; flex-direction: column; gap: 5px; font-family: var(--mono); font-size: 10px; color: var(--ink-dim); letter-spacing: 0.18em; text-transform: uppercase; }
.field em { font-style: normal; opacity: 0.7; text-transform: none; letter-spacing: 0.05em; }
.field input, .field select {
  font-family: var(--sans); font-size: 18px; font-weight: 600; padding: 9px 12px; border-radius: 2px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35); color: var(--ink); outline: none; user-select: text; -webkit-user-select: text; letter-spacing: 0.06em;
}
.field input:focus, .field select:focus { border-color: var(--amber-dim); }
.field input[type='range'] { padding: 0; accent-color: var(--amber); }
/* The mode picker is the headline choice of the menu: a filled amber box like the primary button. */
#field-mode select {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding: 12px 40px 12px 16px; font-size: 16px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase;
  color: #14110a; border-color: var(--amber); text-overflow: ellipsis;
  background: var(--amber) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2314110a' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center;
}
#field-mode select:hover { filter: brightness(1.08); }
#field-mode select:focus { border-color: #fff3dc; }
#field-mode select option { background: #14151f; color: #e8e6f0; text-transform: none; letter-spacing: 0; }
#in-code { text-transform: uppercase; letter-spacing: 0.5em; text-align: center; font-family: var(--mono); font-size: 26px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink-dim); font-size: 15px; font-weight: 500; }
details { border-top: 1px solid var(--line); padding-top: 8px; }
summary { cursor: pointer; color: var(--ink-dim); font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.2em; font-size: 10px; padding: 4px 0; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: '+ '; color: var(--amber); }
details[open] summary::before { content: '− '; }
details[open] { display: flex; flex-direction: column; gap: 10px; }
.controls p, .controls li { font-size: 15px; line-height: 1.4; color: #d6d3e2; font-weight: 500; }
.controls ul { padding-left: 16px; margin: 0; }
.controls table { width: 100%; font-size: 13px; border-collapse: collapse; }
.controls td { padding: 4px 0; border-bottom: 1px solid var(--line); color: var(--ink-dim); font-weight: 500; }
.controls td:last-child { text-align: right; color: var(--ink); font-family: var(--mono); font-size: 11px; }
.code { font-family: var(--mono); font-size: 42px; letter-spacing: 0.35em; text-indent: 0.35em; text-align: center; font-weight: 600; color: var(--amber); padding: 10px 0; border: 1px dashed var(--amber-dim); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.hint { margin: 0; color: var(--ink-dim); font-weight: 500; }
.hint.small { font-family: var(--mono); font-size: 11px; letter-spacing: 0.05em; }
.foot { color: var(--ink-dim); font-family: var(--mono); font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; margin: 12px 0 0; text-align: center; }
.spinner { width: 100%; height: 2px; margin: 18px 0 4px; background: var(--line); position: relative; overflow: hidden; }
.spinner::after { content: ''; position: absolute; top: 0; bottom: 0; width: 30%; background: var(--amber); animation: load 1.1s ease-in-out infinite; }
@keyframes load { from { left: -30%; } to { left: 100%; } }
#loading-text { font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; }

.brief { display: flex; flex-direction: column; border: 1px solid var(--line); padding: 12px; min-height: 0; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.brief-head { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; color: var(--amber); padding-bottom: 10px; gap: 8px; }
.brief-head span:last-child { color: var(--ink-dim); }
.map-wrap { position: relative; flex: 1; min-height: 260px; overflow: hidden; border: 1px solid var(--line); background: #0d0e17; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; }
.sweep { position: absolute; inset: -50%; background: conic-gradient(from 0deg, transparent 0 330deg, rgba(242, 179, 91, 0.08) 355deg, rgba(242, 179, 91, 0.2) 360deg); animation: sweep 6s linear infinite; pointer-events: none; mix-blend-mode: screen; }
@keyframes sweep { to { transform: rotate(360deg); } }
.brief-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding-top: 10px; }
.brief-stats div { border-left: 1px solid var(--amber-dim); padding-left: 8px; }
.brief-stats b { display: block; font-family: var(--mono); font-size: 16px; font-weight: 600; }
.brief-stats span { font-size: 12px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
@media (max-width: 820px) {
  .menu-grid { grid-template-columns: minmax(0, 420px); justify-content: center; }
  .brief { display: none; }
}
@media (max-height: 520px) and (min-width: 821px) {
  h1 { font-size: 34px; }
  .brief-stats { display: none; }
}

/* ================= HUD ================= */
#hud { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 5; font-family: var(--sans); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); }
#hud.on { display: block; }
.lbl { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; color: var(--ink); }
.lbl.dim { color: var(--ink-dim); }
.frame i { position: absolute; width: 18px; height: 18px; border-color: rgba(232, 230, 240, 0.25); border-style: solid; border-width: 0; }
.frame .tl { left: 10px; top: 10px; border-left-width: 1px; border-top-width: 1px; }
.frame .tr { right: 10px; top: 10px; border-right-width: 1px; border-top-width: 1px; }
.frame .bl { left: 10px; bottom: 10px; border-left-width: 1px; border-bottom-width: 1px; }
.frame .br { right: 10px; bottom: 10px; border-right-width: 1px; border-bottom-width: 1px; }
#scope { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
#h-scopeinfo { position: absolute; left: 50%; bottom: max(6vh, 30px); transform: translateX(-50%); display: none; gap: 22px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; color: var(--ink-dim); }
#h-scopeinfo.on { display: flex; }
#h-scopeinfo .rng { color: var(--amber); }
.top { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; width: min(480px, 70vw); }
.timer-row { display: flex; align-items: center; gap: 14px; }
.timer-row .lbl { width: 110px; color: var(--ink-dim); }
.timer-row .lbl:first-child { text-align: right; }
.timer { font-family: var(--mono); font-size: 22px; font-weight: 600; letter-spacing: 0.08em; color: var(--ink); }
#compass { width: 100%; height: 34px; display: block; }
#h-uplinks { display: flex; gap: 18px; margin-top: 2px; }
.uplink { display: flex; flex-direction: column; align-items: center; gap: 0; }
.uplink .dia { position: relative; width: 30px; height: 30px; display: grid; place-items: center; }
.uplink svg { position: absolute; inset: 0; }
.uplink rect { fill: rgba(8, 8, 14, 0.55); stroke-width: 1.5; }
.uplink .bg { stroke: rgba(232, 230, 240, 0.4); }
.uplink .prog { fill: none; stroke: var(--amber); stroke-width: 2.5; transition: stroke-dashoffset 0.15s linear; }
.uplink b { position: relative; font-family: var(--mono); font-weight: 600; font-size: 12px; }
.uplink span { font-family: var(--mono); font-size: 8px; letter-spacing: 0.2em; color: var(--ink-dim); }
.uplink.mine .bg { stroke: var(--me); fill: rgba(98, 217, 232, 0.18); }
.uplink.mine b { color: var(--me); }
.uplink.theirs .bg { stroke: var(--them); fill: rgba(255, 93, 85, 0.18); }
.uplink.theirs b { color: var(--them); }
.uplink.alert .dia, .uplink.hacking .dia { animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.15); filter: drop-shadow(0 0 5px var(--amber)); } }
.scorebox { position: absolute; left: max(22px, env(safe-area-inset-left)); top: max(22px, env(safe-area-inset-top)); padding: 8px 12px; min-width: 170px; display: flex; flex-direction: column; gap: 4px; --c: rgba(232, 230, 240, 0.3); --panel: rgba(8, 9, 15, 0.35); }
.scorebox .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.scorebox .nm { font-weight: 700; font-size: 15px; letter-spacing: 0.1em; text-transform: uppercase; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scorebox .me .nm { color: var(--me); }
.scorebox .them .nm { color: var(--them); }
.scorebox .tag { font-family: var(--mono); font-size: 9px; letter-spacing: 0.2em; color: var(--ink-dim); margin: 0; }
.scorebox .pp { display: flex; gap: 3px; }
.scorebox .pp i { width: 9px; height: 9px; border: 1px solid var(--ink-dim); transform: skewX(-15deg); }
.scorebox .pp i.on.me { background: var(--me); border-color: var(--me); }
.scorebox .pp i.on.them { background: var(--them); border-color: var(--them); }
#h-ping { position: absolute; right: max(24px, env(safe-area-inset-right)); top: max(24px, env(safe-area-inset-top)); font-family: var(--mono); font-size: 9px; letter-spacing: 0.2em; color: var(--ink-dim); }
#h-practice { display: none; position: absolute; bottom: max(26px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); font-size: 13px; font-weight: 600; letter-spacing: 0.05em; color: var(--ink-dim); white-space: nowrap; max-width: 56vw; overflow: hidden; text-overflow: ellipsis; }
#h-practice span { font-family: var(--mono); font-size: 9px; letter-spacing: 0.25em; color: #14110a; background: var(--amber); padding: 2px 6px; margin-right: 8px; text-shadow: none; }
#h-practice.on { display: block; }
#hud.scoped #h-practice, #hud.scoped .frame { display: none; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px; background: rgba(232, 230, 240, 0.9); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }
#hud.scoped .crosshair { display: none; }
#h-hit { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; opacity: 0; }
#h-hit::before, #h-hit::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1.5px; margin-left: -0.75px; background: linear-gradient(#fff 0 32%, transparent 32% 68%, #fff 68%); }
#h-hit::before { transform: rotate(45deg); }
#h-hit::after { transform: rotate(-45deg); }
#h-hit.on { animation: hit 0.45s ease-out; }
#h-hit.head::before, #h-hit.head::after { background: linear-gradient(var(--them) 0 32%, transparent 32% 68%, var(--them) 68%); }
@keyframes hit { 0% { opacity: 1; transform: scale(1.5); } 100% { opacity: 0; transform: scale(1); } }
#h-dmg { position: absolute; inset: 0; opacity: 0; background: radial-gradient(circle, transparent 45%, rgba(170, 0, 20, 0.5)); }
#h-dmg.on { animation: fade 0.9s ease-out; }
#h-dmgdir { position: absolute; left: 50%; top: 50%; width: 240px; height: 240px; opacity: 0; transform: translate(-50%, -50%); }
#h-dmgdir::before { content: ''; position: absolute; left: 50%; top: 0; width: 70px; height: 10px; margin-left: -35px; border-top: 3px solid var(--them); border-radius: 50% 50% 0 0 / 100% 100% 0 0; filter: drop-shadow(0 0 4px var(--them)); }
#h-dmgdir.on { animation: fade 2.2s ease-out; }
@keyframes fade { 0% { opacity: 1; } 100% { opacity: 0; } }
#h-center { position: absolute; left: 0; right: 0; top: 27%; text-align: center; opacity: 0; transition: opacity 0.3s; }
#h-center.on { opacity: 1; }
#h-msg { display: inline-flex; align-items: center; gap: 14px; font-size: clamp(22px, 3.6vw, 36px); font-weight: 700; letter-spacing: 0.3em; text-indent: 0.3em; }
#h-msg::before, #h-msg::after { content: ''; width: clamp(30px, 6vw, 80px); height: 1px; background: linear-gradient(90deg, transparent, var(--amber)); }
#h-msg::after { background: linear-gradient(90deg, var(--amber), transparent); }
#h-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); letter-spacing: 0.2em; margin-top: 6px; text-transform: uppercase; }
#h-hint { position: absolute; left: 50%; bottom: 21%; transform: translateX(-50%); font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; color: var(--amber); text-align: center; white-space: nowrap; text-transform: uppercase; }
#h-hint b { color: #fff; letter-spacing: 0.3em; }
#h-markers { position: absolute; inset: 0; overflow: hidden; }
.marker { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; will-change: transform; }
.marker i { width: 12px; height: 12px; transform: translate(-50%, -50%) rotate(45deg); border: 1.5px solid currentColor; display: block; }
.marker b { transform: translateX(-50%); font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: 0.15em; margin-top: 2px; white-space: nowrap; }
.marker.enemy { color: var(--them); }
.marker.enemy i { animation: pulse 0.4s infinite alternate; background: rgba(255, 93, 85, 0.2); }
.marker.hithead { color: var(--them); }
.marker.hitbody { color: var(--amber); }
.vitals { position: absolute; left: max(26px, env(safe-area-inset-left)); bottom: max(26px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 5px; }
.vitals .lbl span { color: var(--ink); margin-left: 6px; }
.hp { display: flex; gap: 3px; }
.hp i { width: 16px; height: 6px; background: rgba(232, 230, 240, 0.12); transform: skewX(-20deg); }
.hp i.on { background: var(--ink); }
.hp i.on.low { background: var(--them); }
.weapon { position: absolute; right: max(26px, env(safe-area-inset-right)); bottom: max(26px, env(safe-area-inset-bottom)); text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.ammo { display: flex; align-items: flex-end; gap: 10px; height: 26px; }
.ammo .pips { display: flex; gap: 4px; align-items: flex-end; }
.ammo .pips i { width: 5px; height: 22px; border: 1px solid var(--ink-dim); }
.ammo .pips i.on { background: var(--ink); border-color: var(--ink); }
.ammo .pips.cyc i.on { background: var(--amber); border-color: var(--amber); }
.ammo .res { font-family: var(--mono); font-size: 13px; color: var(--ink-dim); }
.ammo em { font-style: normal; font-family: var(--mono); color: var(--amber); font-size: 11px; letter-spacing: 0.25em; }
#h-breath { position: absolute; left: 50%; bottom: calc(max(6vh, 30px) + 22px); width: 140px; height: 2px; margin-left: -70px; background: rgba(232, 230, 240, 0.15); display: none; }
#h-breath.on { display: block; }
#h-breath-fill { height: 100%; background: var(--ink); transform-origin: left; }
#h-breath.lock #h-breath-fill { background: var(--them); }
#h-card { position: fixed; z-index: 10; left: 50%; top: 50%; transform: translate(-50%, -50%); min-width: min(400px, 92vw); padding: 24px 26px 20px; text-align: center; display: none; pointer-events: auto; border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-family: var(--sans); --panel: rgba(8, 9, 15, 0.82); }
#h-card.on { display: flex; flex-direction: column; gap: 12px; animation: cardin 0.35s ease-out; }
#h-card::before { content: '// DEBRIEF'; font-family: var(--mono); font-size: 9px; letter-spacing: 0.3em; color: var(--amber); text-align: left; }
@keyframes cardin { from { opacity: 0; transform: translate(-50%, -46%); } }
#h-card h2 { margin: 0; letter-spacing: 0.25em; font-size: 32px; font-weight: 700; }
#h-card h2.win { color: var(--me); }
#h-card h2.lose { color: var(--them); }
#h-card p { margin: 0; font-family: var(--mono); font-size: 12px; color: var(--ink-dim); letter-spacing: 0.15em; text-transform: uppercase; }
#h-card button { text-align: center; }
#h-card button::after { content: none; }
.sc { display: flex; justify-content: center; gap: 14px; font-size: 20px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.sc .me { color: var(--me); }
.sc .them { color: var(--them); }
.dash { opacity: 0.4; }
.replay-tag { display: none; position: absolute; left: max(26px, env(safe-area-inset-left)); top: calc(9vh + 14px); font-family: var(--mono); color: var(--them); font-size: 11px; letter-spacing: 0.35em; z-index: 1; }
#hud.replay .replay-tag { display: block; animation: blink 0.8s infinite alternate; }
@keyframes blink { to { opacity: 0.35; } }
#hud.replay .vitals, #hud.replay .weapon, #hud.replay .crosshair, #hud.replay #h-hint, #hud.replay #h-breath, #hud.replay .top, #hud.replay .scorebox, #hud.replay .frame, #hud.replay #h-practice { display: none; }
#hud.replay::before, #hud.replay::after { content: ''; position: absolute; left: 0; right: 0; height: 9vh; background: #000; }
#hud.replay::before { top: 0; }
#hud.replay::after { bottom: 0; }



/* Difficulty segmented control */
.seg { display: flex; border: 1px solid var(--line); }
.seg button { flex: 1; text-align: center !important; border: 0 !important; border-radius: 0 !important; font-size: 14px !important; padding: 10px 6px !important; }
.seg button::after { content: none !important; }
.seg button.on { background: var(--amber) !important; color: #14110a !important; }
#pause .menu-card { gap: 10px; }

/* Sandbox panel */
#sandbox { position: fixed; right: 16px; top: 16px; bottom: 16px; width: min(340px, calc(100vw - 32px)); z-index: 15; display: none; overflow-y: auto;
  background: rgba(8, 9, 15, 0.9); border: 1px solid var(--line); padding: 14px 16px; font-family: var(--sans); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#sandbox.on { display: block; }
.sb-head { display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: 11px; letter-spacing: 0.25em; color: var(--amber); }
.sb-x { background: none; border: 0; color: var(--ink); font-size: 22px; cursor: pointer; }
.sb-sec { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.sb-sec h4 { margin: 0; font-family: var(--mono); font-size: 10px; letter-spacing: 0.25em; color: var(--ink-dim); text-transform: uppercase; font-weight: 600; }
.sb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#sandbox button:not(.sb-x) { appearance: none; border: 1px solid var(--line); background: rgba(232, 230, 240, 0.05); color: var(--ink); padding: 8px; font-family: var(--sans); font-weight: 700; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; }
#sandbox button:not(.sb-x):hover { border-color: var(--amber-dim); }
.sb-row { display: flex; flex-direction: column; gap: 4px; }
.sb-row label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.15em; color: var(--ink-dim); text-transform: uppercase; }
.sb-row em { font-style: normal; color: var(--amber); margin-left: 6px; }
.sb-row select { font-family: var(--sans); font-size: 15px; font-weight: 600; padding: 6px 8px; background: rgba(0, 0, 0, 0.4); color: var(--ink); border: 1px solid var(--line); }
.sb-row input[type='range'] { accent-color: var(--amber); }
.sb-chk { display: flex; gap: 8px; align-items: center; font-size: 15px; font-weight: 500; color: #d6d3e2; }
.sb-chk input { accent-color: var(--amber); }
.sb-foot { font-family: var(--mono); font-size: 10px; color: var(--ink-dim); letter-spacing: 0.1em; margin: 12px 0 0; }
#pause { background: rgba(4, 4, 10, 0.55); }
.scorebox .nm { max-width: 130px; }

/* Loadout */
#loadout { position: fixed; inset: 0; z-index: 16; display: none; align-items: center; justify-content: center; background: rgba(4, 4, 10, 0.55); padding: 16px; }
#loadout.on { display: flex; }
.lo-card { width: min(760px, 100%); max-height: 100%; overflow-y: auto; background: rgba(8, 9, 15, 0.92); border: 1px solid var(--line); padding: 14px 16px; }
.lo-body { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.lo-slot { display: flex; flex-direction: column; gap: 6px; }
.lo-head { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--amber); }
.lo-head em { font-style: normal; color: var(--ink-dim); letter-spacing: 0.15em; }
.lo-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 6px; }
.lo-opt { appearance: none; text-align: left !important; display: flex; flex-direction: column; gap: 4px; padding: 9px 10px !important; border: 1px solid var(--line); background: rgba(232, 230, 240, 0.04); color: var(--ink); cursor: pointer; font-family: var(--sans); text-transform: none !important; letter-spacing: 0 !important; }
.lo-opt::after { content: none !important; }
.lo-opt b { font-size: 15px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.lo-opt b i { font-style: normal; color: var(--ink-dim); font-family: var(--mono); font-size: 11px; }
.lo-opt span { font-size: 13px; font-weight: 500; line-height: 1.3; color: var(--ink-dim); }
.lo-opt.on { border-color: var(--amber) !important; background: rgba(242, 179, 91, 0.12) !important; }
.lo-opt.on b { color: var(--amber); }
#panel-loadout .lo-opts { grid-template-columns: 1fr; }
/* Tool chips */
#h-tools { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 4px; }
#h-tools .chip { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; padding: 3px 7px; border: 1px solid var(--line); background: rgba(8, 9, 15, 0.4); }
#h-tools .chip kbd { font-family: var(--mono); color: #14110a; background: var(--amber); padding: 0 4px; margin-right: 5px; }
#h-tools .chip.empty { opacity: 0.4; }
#h-tools .chip.passive { color: var(--ink-dim); }
#h-drone { display: none; position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%); gap: 16px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.15em; color: var(--ink); align-items: center; white-space: nowrap; }
#h-drone.on { display: flex; }
#h-drone b { color: var(--them); }
#h-drone em { font-style: normal; color: var(--ink-dim); }
#hud.droneview .crosshair { display: block; width: 26px; height: 26px; margin: -13px 0 0 -13px; background: none; border: 1px solid rgba(255, 255, 255, 0.7); box-shadow: none; }
#hud.droneview .frame i { border-color: var(--them); width: 40px; height: 40px; }

.ammo .pips .ch { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--ink-dim); align-self: center; }
.ammo .pips .ch.on { background: var(--amber); border-color: var(--amber); }
.ammo .pips .sep { width: 1px; height: 22px; background: var(--line); margin: 0 3px; }
.ammo .pips b { font-family: var(--mono); font-size: 24px; font-weight: 600; line-height: 22px; }

/* ================= TOUCH ================= */
#touch { position: fixed; inset: 0; z-index: 6; display: none; --tc: rgba(232, 230, 240, 0.85); }
#touch.on.active { display: block; }
.stick { position: absolute; left: max(28px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom)); width: 136px; height: 136px; }
.stick .ring { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid rgba(232, 230, 240, 0.32); background: radial-gradient(circle, rgba(8, 9, 15, 0.15), rgba(8, 9, 15, 0.4)); }
.stick .ring::before { content: ''; position: absolute; left: 50%; top: 8px; width: 0; height: 0; margin-left: -6px; border: 6px solid transparent; border-bottom: 8px solid rgba(232, 230, 240, 0.35); border-top: 0; }
.stick .knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; border-radius: 50%; background: rgba(232, 230, 240, 0.28); border: 1.5px solid rgba(232, 230, 240, 0.6); transform: translate(-50%, -50%); }
.stick.active .knob { background: rgba(232, 230, 240, 0.45); }
.stick .lbl-run { position: absolute; left: 50%; top: -18px; transform: translateX(-50%); font-family: var(--mono); font-size: 9px; letter-spacing: 0.2em; color: var(--ink-dim); opacity: 0; transition: opacity 0.15s; }
.stick.run .lbl-run { opacity: 1; color: var(--amber); }
.stick.run .ring { border-color: var(--amber); }
.tb { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border-radius: 50%; background: rgba(8, 9, 15, 0.42); border: 1.5px solid rgba(232, 230, 240, 0.38); color: var(--tc); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.tb i { font-style: normal; font-size: 18px; line-height: 1; }
.tb span { font-family: var(--mono); font-size: 8px; font-weight: 600; letter-spacing: 0.12em; }
.tb.big { width: 84px; height: 84px; }
.tb.big i { font-size: 28px; }
.tb.big span { font-size: 10px; }
.tb.mid { width: 64px; height: 64px; }
.tb.mid.scope { width: 50px; height: 50px; } /* same size as RELOAD */
.tb.mid.scope i { font-size: 18px; }
.tb.mid i { font-size: 22px; }
.tb.sm { width: 50px; height: 50px; }
.tb.fire { border-color: rgba(242, 179, 91, 0.85); color: var(--amber); background: rgba(40, 26, 8, 0.45); }
.tb.down { background: rgba(242, 179, 91, 0.55) !important; color: #14110a; text-shadow: none; }
.tb.on { border-color: var(--amber); color: var(--amber); box-shadow: 0 0 0 3px rgba(242, 179, 91, 0.25), inset 0 0 12px rgba(242, 179, 91, 0.25); }
/* Left thumb */
.tb.fire-l { left: calc(max(28px, env(safe-area-inset-left)) + 152px); bottom: max(26px, env(safe-area-inset-bottom)); width: 70px; height: 70px; }
.tb.breath { left: calc(max(28px, env(safe-area-inset-left)) + 156px); bottom: calc(max(26px, env(safe-area-inset-bottom)) + 84px); }
.tb.crouch { left: max(22px, env(safe-area-inset-left)); bottom: calc(max(22px, env(safe-area-inset-bottom)) + 150px); }
.tb.prone { left: calc(max(22px, env(safe-area-inset-left)) + 60px); bottom: calc(max(22px, env(safe-area-inset-bottom)) + 160px); }
/* Right thumb */
.tb.fire-r { right: max(26px, env(safe-area-inset-right)); bottom: max(30px, env(safe-area-inset-bottom)); }
.tb.scope { right: calc(max(26px, env(safe-area-inset-right)) + 98px); bottom: max(22px, env(safe-area-inset-bottom)); }
.tb.zin { right: calc(max(26px, env(safe-area-inset-right)) + 176px); bottom: calc(max(22px, env(safe-area-inset-bottom)) + 58px); }
.tb.zout { right: calc(max(26px, env(safe-area-inset-right)) + 176px); bottom: max(18px, env(safe-area-inset-bottom)); }
.tb.reload { right: max(30px, env(safe-area-inset-right)); bottom: calc(max(30px, env(safe-area-inset-bottom)) + 98px); }
.tb.jump { right: calc(max(30px, env(safe-area-inset-right)) + 82px); bottom: calc(max(30px, env(safe-area-inset-bottom)) + 84px); }
/* Top bars */
.tbar { position: absolute; display: flex; flex-wrap: wrap; gap: 6px; }
.tbar-r { right: max(12px, env(safe-area-inset-right)); top: calc(max(10px, env(safe-area-inset-top)) + 22px); width: 216px; justify-content: flex-end; }
.tbar-l { left: max(12px, env(safe-area-inset-left)); top: calc(max(10px, env(safe-area-inset-top)) + 78px); }
.pill { min-width: 64px; height: 30px; padding: 0 8px; display: flex; align-items: center; justify-content: center; border: 1px solid rgba(232, 230, 240, 0.34); background: rgba(8, 9, 15, 0.5); color: var(--tc); font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: 0.12em; border-radius: 3px; white-space: nowrap; }
.pill.tool { border-color: rgba(242, 179, 91, 0.6); color: var(--amber); }
.pill.empty { opacity: 0.35; }
.pill.live { border-color: var(--them); color: var(--them); animation: blink 0.6s infinite alternate; }
.pill.down { background: rgba(242, 179, 91, 0.55); color: #14110a; }
body.touch .vitals { left: 50%; transform: translateX(-100%); bottom: 8px; align-items: flex-end; margin-left: -12px; }
body.touch .weapon { right: auto; left: 50%; top: auto; bottom: 8px; margin-left: 12px; align-items: flex-start; text-align: left; }
body.touch #h-tools, body.touch .weapon .lbl.dim, body.touch #h-practice, body.touch .scorebox .tag { display: none; }
body.touch .ammo .pips i { height: 16px; }
body.touch .ammo .pips b { font-size: 18px; line-height: 16px; }
body.touch .crosshair { width: 4px; height: 4px; margin: -2px 0 0 -2px; }
@media (max-height: 430px) {
  .top { transform: translateX(-50%) scale(0.82); transform-origin: top center; }
  .scorebox { transform: scale(0.82); transform-origin: top left; }
}
body.touch #h-scopeinfo { bottom: 74px; }
body.touch #h-breath { bottom: 98px; }
body.touch #h-hint { bottom: 30%; }

/* Arc layout (positions set by Input.layoutTouch) */
#touch .placed { right: auto !important; bottom: auto !important; transform: translate(-50%, -50%); }
#touch .tb.sm.zdn, #touch .tb.sm.zup, #touch .tb.sm.rng, #touch .tb.sm.swp { border-color: rgba(98, 217, 232, 0.5); }
#touch .tb.sm.swp span { font-size: 7px; }
.tbar-r { width: auto; }

/* Sniping style */
.style-opts { grid-template-columns: 1fr !important; }
.style-custom { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
#btn-style em.cur { font-style: normal; font-family: var(--mono); font-size: 10px; letter-spacing: 0.15em; color: var(--amber); margin-left: 8px; }
#touch .tb.sm.bipodb { border-color: rgba(98, 217, 232, 0.5); }

/* Operator preview in the loadout */
.lo-op { display: flex; gap: 12px; align-items: stretch; }
.lo-prev { position: relative; flex: 0 0 44%; min-height: 240px; max-height: 300px; border: 1px solid var(--line); background: radial-gradient(ellipse at 50% 70%, rgba(242, 179, 91, 0.1), rgba(13, 14, 23, 0.6) 70%); }
.lo-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.lo-cap { position: absolute; left: 8px; bottom: 6px; z-index: 1; font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em; color: var(--amber); pointer-events: none; }
.lo-cap i { font-style: normal; color: #9fd8e0; }

.lo-outfits .lo-opts { grid-template-columns: 1fr; }
.lo-list { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 520px) { .lo-op { flex-direction: column; } .lo-prev { flex-basis: auto; height: 230px; } }
#menu-loadout .lo-op { flex-direction: column; }
#menu-loadout .lo-prev { flex-basis: auto; height: 260px; }
.lo-side { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.lo-lens { display: flex; flex-wrap: wrap; gap: 7px; }
.lo-sw { appearance: none; width: 30px !important; height: 30px; min-height: 0 !important; padding: 0 !important; border-radius: 50% !important; border: 2px solid rgba(232, 230, 240, 0.25) !important; background: radial-gradient(circle at 35% 35%, rgba(255,255,255,.45), transparent 45%), var(--c) !important; cursor: pointer; position: relative; flex: none; }
.lo-sw::after { content: none !important; }
.lo-sw.on { border-color: var(--amber) !important; box-shadow: 0 0 0 2px rgba(242, 179, 91, 0.35), 0 0 12px var(--c); }
.lo-custom { display: inline-block; background: conic-gradient(#e0283a, #f2d23c, #3cf28a, #38d6f2, #8a5cff, #f23ca8, #e0283a) !important; }
.lo-custom.on { background: radial-gradient(circle at 35% 35%, rgba(255,255,255,.45), transparent 45%), var(--c) !important; }
.lo-custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.lo-camo { border-radius: 6px !important; }
.lo-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lo-chip { appearance: none; min-height: 0 !important; padding: 6px 11px !important; font-family: var(--mono) !important; font-size: 11px !important; letter-spacing: 0.12em !important; text-transform: uppercase; border: 1px solid var(--line) !important; background: rgba(232, 230, 240, 0.04) !important; color: var(--ink-dim) !important; cursor: pointer; border-radius: 2px; }
.lo-chip::after { content: none !important; }
.lo-chip.on { border-color: var(--amber) !important; color: var(--amber) !important; background: rgba(242, 179, 91, 0.12) !important; }
/* Pause menu fits any screen: the card scrolls instead of running off the bottom. */
#pause .menu-card { max-height: calc(100dvh - 32px); overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Pollo Hermano easter egg */
body.reckoning .tag { color: #f2c81e; }
.lo-opt.pollo.on { border-color: #f2c81e !important; background: rgba(242, 200, 30, 0.14) !important; }
/* Sniping style / distance bars */
.seg-style { display: flex; gap: 4px; flex-wrap: nowrap; }
.seg-style button { flex: 1 1 0; min-width: 0; display: flex !important; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px !important; text-align: center !important; letter-spacing: 0.08em !important; }
.seg-style button::after { content: none !important; }
.seg-style button b { font-size: 13px; }
.seg-style button i { font-style: normal; font-family: var(--mono); font-size: 9px; letter-spacing: 0.04em; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; text-transform: none; }
.seg-style button.on { border-color: var(--amber) !important; background: rgba(242, 179, 91, 0.14) !important; color: var(--amber) !important; }
.seg-desc { margin: 0 0 4px; min-height: 2.4em; }
/* iPad / tablet with a mouse: the touch aim-and-fire buttons step back; stick and pills stay. */
body.mouse-mode #touch .tb.big, body.mouse-mode #touch .tb.mid.scope { opacity: 0.25; }
body.mouse-mode #touch { cursor: crosshair; }

