/* ── HUD Layout ── */
.hud {
    position: absolute; inset: 0; z-index: 10; pointer-events: none;
    display: grid;
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 230px 1fr 230px;
    grid-template-areas: "top top top" "left . right" "btm btm btm";
    padding: 0;
}

/* Top bar */
.hud-top {
    grid-area: top; pointer-events: auto;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: rgba(7,9,15,0.88);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(59,130,246,0.14);
    padding: 8px 14px;
}
.hud-title {
    font-size: 0.72em; font-weight: 800; letter-spacing: 3px;
    color: #fff; white-space: nowrap; flex-shrink: 0;
    opacity: 0.9;
}

.stat-row { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.stat-chip {
    display: flex; flex-direction: column; align-items: center;
    background: rgba(255,255,255,0.035);
    border: 1px solid rgba(255,255,255,0.07); border-radius: 8px;
    padding: 4px 9px; min-width: 58px;
    transition: border-color 0.2s;
}
.stat-chip:hover { border-color: rgba(59,130,246,0.25); }
.stat-lbl {
    font-size: 0.52em; font-weight: 700; letter-spacing: 1px;
    color: var(--text3); text-transform: uppercase;
}
.stat-val { font-size: 0.8em; font-weight: 700; line-height: 1.4; color: #fff; }
.stat-val.green  { color: #22c55e; }
.stat-val.cyan   { color: #06b6d4; }
.stat-val.red    { color: #ef4444; }
.stat-val.yellow { color: #f59e0b; }

/* Panels */
.panel {
    pointer-events: auto;
    display: flex; flex-direction: column; gap: 4px;
    background: rgba(7,9,15,0.88);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(59,130,246,0.12);
    padding: 8px 9px 6px;
    margin: 8px 6px;
    border-radius: 14px; overflow: hidden;
    max-height: calc(100vh - 114px);
}
.panel-left  { grid-area: left;  height: calc(100vh - 114px); }
.panel-right { grid-area: right; height: calc(100vh - 114px); overflow-y: auto; }

.panel-title {
    font-size: 0.6em; font-weight: 700; letter-spacing: 2px;
    color: var(--blue); text-transform: uppercase;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(59,130,246,0.14);
    margin-bottom: 2px;
    flex-shrink: 0;
}

/* Bottom bar — wraps to a second row when buttons overflow */
.hud-bottom {
    grid-area: btm; pointer-events: auto;
    display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
    background: rgba(7,9,15,0.88);
    backdrop-filter: blur(18px);
    border-top: 1px solid rgba(59,130,246,0.14);
    padding: 6px 12px;
}

/* ── Tab system ── */
.tab-bar {
    display: flex; gap: 2px; flex-shrink: 0;
    border-bottom: 1px solid rgba(59,130,246,0.14);
    margin-bottom: 6px; padding-bottom: 0;
}
.tab-btn {
    flex: 1;
    background: none; border: none;
    border-bottom: 2px solid transparent;
    color: var(--text3);
    font-family: inherit; font-size: 0.6em; font-weight: 700;
    letter-spacing: 1.5px; text-transform: uppercase;
    padding: 5px 4px 6px;
    cursor: pointer; transition: all 0.15s ease;
    pointer-events: auto;
}
.tab-btn:hover { color: #94a3b8; }
.tab-btn.active {
    color: #60a5fa;
    border-bottom-color: #3b82f6;
}
.tab-content {
    display: flex; flex-direction: column;
    flex: 1; min-height: 0; overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(59,130,246,0.3) transparent;
}
.tab-content.hidden { display: none; }

/* ── Arsenal Items ── */
.arsenal-list { display: flex; flex-direction: column; gap: 4px; overflow-y: visible; flex-shrink: 0; }
.arsenal-item {
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.07); border-radius: 8px;
    padding: 5px 8px; cursor: pointer; user-select: none;
    transition: all 0.15s ease;
}
.arsenal-item:hover { background: rgba(59,130,246,0.07); border-color: rgba(59,130,246,0.28); }
.arsenal-item.selected {
    background: rgba(59,130,246,0.22);
    border-color: rgba(59,130,246,0.90);
    box-shadow: 0 0 12px rgba(59,130,246,0.45), inset 0 0 8px rgba(59,130,246,0.12);
    outline: 1px solid rgba(59,130,246,0.50);
}
.arsenal-item.laser-ready   { }
.arsenal-item.laser-cooling { opacity: 0.5; }
.arsenal-item.locked        { opacity: 0.38; filter: grayscale(55%); cursor: not-allowed; }
.arsenal-item.locked:hover  { background: rgba(255,255,255,0.025); border-color: rgba(255,255,255,0.07); box-shadow: none; }
.arsenal-item.disabled      { opacity: 0.35; cursor: not-allowed; }

.lock-badge {
    margin-left: auto; font-size: 0.58em; color: var(--text3);
    border: 1px solid #1e293b; border-radius: 4px; padding: 1px 5px;
}

.arsenal-header { display: flex; gap: 5px; align-items: center; margin-bottom: 1px; }
.arsenal-key {
    font-size: 0.56em; color: var(--text3); border: 1px solid #1e293b;
    padding: 1px 4px; border-radius: 4px; flex-shrink: 0;
}
.arsenal-name { font-size: 0.74em; font-weight: 700; }
.arsenal-cost { font-size: 0.64em; color: var(--amber); margin-bottom: 1px; font-weight: 600; }
.arsenal-desc { font-size: 0.60em; color: var(--text3); line-height: 1.3; }

/* 2-column grid for effectiveness bars — compact layout */
.arsenal-eff { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; margin-top: 3px; }
.eff-row { display: flex; align-items: center; gap: 3px; }
.eff-label { font-size: 0.54em; color: var(--text3); width: 20px; font-weight: 600; flex-shrink: 0; }
.eff-bar-bg { flex: 1; height: 3px; background: rgba(255,255,255,0.05); border-radius: 2px; overflow: hidden; }
.eff-bar-fill { height: 100%; border-radius: 2px; }
.eff-pct { font-size: 0.54em; color: var(--text3); width: 24px; text-align: right; }

/* ── Arsenal info icon + tooltip ── */
.arsenal-info-btn {
    margin-left: auto; width: 14px; height: 14px; border-radius: 50%;
    border: 1px solid rgba(59,130,246,0.35); background: rgba(59,130,246,0.08);
    color: rgba(59,130,246,0.75); font-size: 0.55em; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0; line-height: 1;
    transition: all 0.15s ease;
}
.arsenal-info-btn:hover { background: rgba(59,130,246,0.22); color: #60a5fa; border-color: #60a5fa; }

.arsenal-tooltip {
    display: none;
    background: rgba(7,9,15,0.97);
    border: 1px solid rgba(59,130,246,0.3);
    border-radius: 10px; padding: 8px 10px; margin-top: 4px;
    animation: fadeIn 0.12s ease;
}
.arsenal-tooltip.visible { display: block; }
.arsenal-tooltip-title {
    font-size: 0.62em; font-weight: 700; color: #60a5fa;
    letter-spacing: 1px; text-transform: uppercase; margin-bottom: 5px;
    border-bottom: 1px solid rgba(59,130,246,0.15); padding-bottom: 3px;
}
.arsenal-tooltip-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px;
}
.arsenal-tooltip-stat {
    display: flex; align-items: center; gap: 3px; font-size: 0.58em;
}
.arsenal-tooltip-stat .ts-label { color: var(--text3); width: 28px; flex-shrink: 0; font-weight: 600; }
.arsenal-tooltip-stat .ts-bar-bg { flex: 1; height: 3px; background: rgba(255,255,255,0.05); border-radius: 2px; overflow: hidden; }
.arsenal-tooltip-stat .ts-bar-fill { height: 100%; border-radius: 2px; }
.arsenal-tooltip-stat .ts-pct { color: var(--text3); width: 26px; text-align: right; }
.arsenal-tooltip-meta {
    display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-top: 5px;
    padding-top: 4px; border-top: 1px solid rgba(255,255,255,0.05);
}
.arsenal-tooltip-meta .tm-item { font-size: 0.58em; color: var(--text3); }
.arsenal-tooltip-meta .tm-item span { color: var(--text); font-weight: 600; }

@keyframes fadeIn { from { opacity:0; transform: translateY(-3px); } to { opacity:1; transform: none; } }

/* ── Legend modal ── */
.legend-modal {
    position: fixed; inset: 0; z-index: 800;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    pointer-events: auto;
    animation: fadeIn 0.15s ease;
}
.legend-modal.hidden { display: none; }
.legend-modal-box {
    background: rgba(7,9,15,0.97);
    border: 1px solid rgba(59,130,246,0.35);
    border-radius: 16px;
    width: min(480px, 92vw);
    max-height: 80vh;
    display: flex; flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,0.7);
    overflow: hidden;
}
.legend-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px 12px;
    border-bottom: 1px solid rgba(59,130,246,0.18);
    font-size: 0.68em; font-weight: 800; letter-spacing: 2px; color: #60a5fa;
    text-transform: uppercase; flex-shrink: 0;
}
.legend-close-btn {
    background: rgba(239,68,68,0.10); border: 1px solid rgba(239,68,68,0.30);
    color: rgba(239,68,68,0.80); font-family: inherit; font-size: 0.78em;
    font-weight: 700; letter-spacing: 1px; padding: 4px 12px; border-radius: 7px;
    cursor: pointer; pointer-events: auto; transition: all 0.15s ease;
}
.legend-close-btn:hover { background: rgba(239,68,68,0.22); color: #ef4444; border-color: #ef4444; }
.legend-modal-body {
    padding: 14px 18px 18px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(59,130,246,0.3) transparent;
}

/* ── Music Player popup ── */
.music-player {
    position: fixed;
    bottom: 52px; right: 8px;
    z-index: 600;
    background: rgba(7,9,15,0.96);
    border: 1px solid rgba(59,130,246,0.30);
    border-radius: 12px;
    padding: 10px 14px 10px;
    display: flex; flex-direction: column; gap: 8px;
    min-width: 200px; max-width: 260px;
    backdrop-filter: blur(20px);
    box-shadow: 0 4px 24px rgba(0,0,0,0.6);
    pointer-events: auto;
    animation: fadeIn 0.15s ease;
}
.music-player.hidden { display: none; }
.music-player-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: -2px;
}
.music-player-label {
    font-size: 0.55em; font-weight: 700; letter-spacing: 2px;
    color: var(--text3); text-transform: uppercase;
}
.music-player-close {
    background: none; border: none; color: var(--text3);
    font-size: 0.75em; cursor: pointer; padding: 2px 4px;
    border-radius: 4px; line-height: 1; pointer-events: auto;
    transition: color 0.15s;
}
.music-player-close:hover { color: #ef4444; }

.music-player-track {
    font-size: 0.62em; font-weight: 600; color: #60a5fa;
    letter-spacing: 0.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    text-align: center;
    border-bottom: 1px solid rgba(59,130,246,0.15);
    padding-bottom: 7px;
}
.music-player-controls {
    display: flex; justify-content: center; gap: 8px;
}
.music-ctrl-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text2); font-size: 1em;
    width: 34px; height: 34px; border-radius: 8px;
    cursor: pointer; pointer-events: auto;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s ease;
}
.music-ctrl-btn:hover { background: rgba(59,130,246,0.15); border-color: rgba(59,130,246,0.45); color: #fff; }
.music-ctrl-btn:active { transform: scale(0.93); }
.music-ctrl-play { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.40); color: #60a5fa; }
.music-ctrl-stop { border-color: rgba(239,68,68,0.30); color: rgba(239,68,68,0.70); }
.music-ctrl-stop:hover { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.55); color: #ef4444; }

/* Threats section — sits naturally after the tab content which fills remaining space */
.left-threats-section {
    border-top: 1px solid rgba(59,130,246,0.14);
    padding-top: 4px;
    flex-shrink: 0;
    max-height: 38%;
    overflow-y: auto;
}
#activeThreatList {
    display: flex; flex-direction: column; gap: 3px;
    overflow-y: auto; max-height: 130px;
}

/* Threat Legend — scrolling handled by parent tab-content */
#threatLegend {
    display: flex; flex-direction: column; gap: 3px;
    padding-right: 2px;
}
.legend-item {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.67em; color: var(--text2); padding: 3px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-name { flex: 1; color: var(--text); font-weight: 500; }
.legend-dmg { font-weight: 600; font-size: 0.9em; }

/* Active Threat List */
.no-threats { font-size: 0.68em; color: var(--text3); text-align: center; padding: 10px 0; font-style: italic; }
.threat-row {
    display: flex; align-items: center; gap: 5px; font-size: 0.67em;
    padding: 4px 6px; background: rgba(239,68,68,0.05);
    border-radius: 6px; border: 1px solid rgba(239,68,68,0.10);
}
.threat-type { color: #fff; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.threat-bar-bg { flex: 1; min-width: 0; height: 3px; background: rgba(255,255,255,0.07); border-radius: 2px; overflow: hidden; }
.threat-bar-fill { height: 100%; border-radius: 2px; max-width: 100%; }
.threat-pct { font-size: 0.88em; color: var(--text2); width: 28px; flex-shrink: 0; text-align: right; }
.tracked-badge {
    font-size: 0.8em; color: var(--green); font-weight: 700;
    background: rgba(34,197,94,0.10); padding: 1px 4px; border-radius: 3px;
}

/* Kill Board */
.kill-board { display: flex; flex-direction: column; gap: 2px; }
.kill-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.63em; padding: 2px 4px; }
.kill-label { font-weight: 700; letter-spacing: 1px; }
.kill-count { color: #fff; font-weight: 700; min-width: 24px; text-align: right; }

/* Status Log */
.status-log { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; max-height: 150px; }
.status-msg { font-size: 0.63em; line-height: 1.55; padding: 2px 0 2px 7px; color: var(--text3); border-left: 2px solid transparent; }
.status-success { color: #4ade80; border-left-color: var(--green); }
.status-warning { color: #fbbf24; border-left-color: var(--amber); }
.status-error   { color: #f87171; border-left-color: var(--red); }
.status-wave    { color: #60a5fa; border-left-color: var(--blue); font-weight: 600; }
.status-info    { color: var(--text3); }

/* EW Jammer button */
.ew-btn { background: rgba(0,180,255,0.07); border-color: rgba(0,180,255,0.30); color: #38bdf8; }
.ew-btn:hover { background: rgba(0,180,255,0.14); border-color: #38bdf8; }

/* Battery disabled state in arsenal */
.arsenal-item.battery-disabled { opacity: 0.45; border-color: rgba(255,50,50,0.35) !important; }
.battery-badge {
    margin-left: auto; font-size: 0.56em; color: #f87171;
    border: 1px solid rgba(255,80,80,0.35); border-radius: 4px; padding: 1px 5px;
    animation: blink-badge 1.2s infinite;
}
@keyframes blink-badge { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
