/* ════════════════════════════════════════════════════════════════
   BFM 1v1 Tactical Simulator — Stylesheet
   ════════════════════════════════════════════════════════════════ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', 'Microsoft JhengHei', Tahoma, sans-serif;
    background: #0a0e27;
    color: #f1f5f9;
}

#viewport {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
}

/* ── HUD panels ─────────────────────────────────────────────── */

.hud {
    position: absolute;
    z-index: 10;
    backdrop-filter: blur(10px);
    background: rgba(13, 18, 45, 0.92);
    border: 1px solid rgba(120, 170, 255, 0.35);
    border-radius: 10px;
    padding: 16px;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.top-left      { top: 14px; left: 14px; width: 208px; }
.top-center    { top: 14px; left: 50%; transform: translateX(-50%); width: 340px; text-align: center; }
.top-right     { top: 14px; right: 14px; width: 460px; }
.bottom-left   { bottom: 14px; left: 14px; width: 300px; }
.bottom-center { bottom: 14px; left: 50%; transform: translateX(-50%); width: 380px; }
.bottom-right  { bottom: 14px; right: 14px; width: 320px; }

.hud-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(120, 170, 255, 0.25);
    display: flex;
    align-items: center;
    gap: 6px;
}

.hud-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
    font-size: 15px;
}

.hud-label {
    color: #b8c2d9;
    font-weight: 400;
}

.hud-value {
    color: #ffffff;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.hud-unit {
    color: #8794b0;
    font-size: 12px;
    margin-left: 3px;
}

/* ── side identity colors ──────────────────────────────────── */

.blue        { color: #5fd4f0; }
.blue .hud-title { color: #5fd4f0; }
.red         { color: #ff8a8a; }
.red .hud-title { color: #ff8a8a; }

.status-good    { color: #4ade80; }
.status-warn    { color: #fbbf24; }
.status-neutral { color: #93c5fd; }

/* ── central tactical readout ─────────────────────────────── */

.top-center .hud-title { justify-content: center; color: #fbbf24; }

.metric-big {
    font-size: 28px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.1;
}

.metric-label {
    font-size: 12px;
    color: #a8b4cc;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.metric-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-top: 6px;
}

.metric-cell {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    padding: 8px 4px;
}

.phase-badge {
    display: inline-block;
    margin-top: 10px;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.phase-ingress { background: rgba(147, 197, 253, 0.15); color: #93c5fd; border: 1px solid rgba(147, 197, 253, 0.4); }
.phase-merge   { background: rgba(251, 191, 36, 0.15); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.4); }

.fight-badge {
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1.4;
}

.fight-none { background: rgba(148, 163, 184, 0.1); color: #94a3b8; border: 1px dashed rgba(148, 163, 184, 0.35); }
.fight-one  { background: rgba(74, 222, 128, 0.12); color: #4ade80; border: 1px solid rgba(74, 222, 128, 0.4); }
.fight-two  { background: rgba(192, 132, 252, 0.14); color: #c084fc; border: 1px solid rgba(192, 132, 252, 0.4); }

/* ── heading compass ──────────────────────────────────────── */

#compass-canvas {
    display: block;
    margin: 0 auto;
}

.compass-readout {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 13px;
}

.compass-readout .blue, .compass-readout .red { font-weight: 600; }
.compass-readout b { font-variant-numeric: tabular-nums; }

/* ── object table (Tacview-style) ─────────────────────────── */

.obj-table-wrap { overflow-x: auto; }

.obj-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.obj-table th {
    text-align: right;
    color: #8794b0;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.4px;
    padding: 4px 6px;
    border-bottom: 1px solid rgba(120, 170, 255, 0.25);
}

.obj-table th:first-child, .obj-table td:first-child { text-align: left; }

.obj-table td {
    text-align: right;
    padding: 6px 6px;
    color: #ffffff;
    font-weight: 600;
}

.obj-table tr.row-blue .obj-tag { color: #5fd4f0; }
.obj-table tr.row-red  .obj-tag { color: #ff8a8a; }

.obj-table tbody tr:not(:last-child) td {
    border-bottom: 1px solid rgba(120, 170, 255, 0.12);
}

/* ── telemetry graph ──────────────────────────────────────── */

#telemetry-canvas {
    display: block;
    width: 100%;
    height: 110px;
}

.telemetry-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    font-size: 12px;
    color: #b8c2d9;
}

.telemetry-legend .blue { color: #5fd4f0; font-weight: 600; }
.telemetry-legend .red  { color: #ff8a8a; font-weight: 600; }
.telemetry-sub { margin-left: auto; color: #8794b0; font-size: 11px; }

/* ── controls panel ────────────────────────────────────────── */

.control-block {
    margin-bottom: 14px;
}

.control-block:last-child { margin-bottom: 0; }

.control-label {
    display: block;
    margin-bottom: 6px;
    color: #b8c2d9;
    font-size: 13px;
    font-weight: 600;
}

select {
    width: 100%;
    background: #1a2544;
    border: 1px solid rgba(120, 170, 255, 0.4);
    color: #ffffff;
    padding: 9px 10px;
    font-family: inherit;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
}

select:focus { outline: 2px solid #5fd4f0; outline-offset: 1px; }

.btn-row {
    display: flex;
    gap: 8px;
}

button {
    background: #1c3d63;
    border: 1px solid #5fd4f0;
    color: #eaf7ff;
    padding: 10px 14px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    transition: background 0.15s, box-shadow 0.15s;
    flex: 1;
}

button:hover {
    background: #2c5c8f;
    box-shadow: 0 0 10px rgba(95, 212, 240, 0.4);
}

button:active { transform: translateY(1px); }

button.is-playing {
    background: #1e5a3a;
    border-color: #4ade80;
    color: #eafff1;
}

.timeline-wrap {
    position: relative;
    padding-bottom: 10px;
}

input[type="range"] {
    width: 100%;
    accent-color: #5fd4f0;
    height: 22px;
    cursor: pointer;
}

.timeline-ticks {
    position: relative;
    height: 8px;
    margin-top: 1px;
}

.timeline-tick {
    position: absolute;
    top: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fbbf24;
    transform: translateX(-50%);
    cursor: help;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #8794b0;
    margin-top: 2px;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #dbe4f5;
    cursor: pointer;
}

input[type="checkbox"] {
    width: 17px;
    height: 17px;
    cursor: pointer;
    accent-color: #5fd4f0;
}

hr.sep {
    border: none;
    border-top: 1px solid rgba(120, 170, 255, 0.2);
    margin: 12px 0;
}

/* ── briefing panel ────────────────────────────────────────── */

.scenario-name {
    font-size: 15px;
    font-weight: 700;
    color: #fbbf24;
    margin-bottom: 8px;
}

.scenario-desc {
    background: rgba(251, 191, 36, 0.08);
    border-left: 3px solid #fbbf24;
    border-radius: 4px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.6;
    color: #e2e8f0;
}

.legend-note {
    margin-top: 10px;
    font-size: 12px;
    color: #8794b0;
    line-height: 1.5;
}

.legend-note b { color: #b8c2d9; }

.event-log {
    max-height: 120px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-right: 2px;
}

.event-log::-webkit-scrollbar { width: 6px; }
.event-log::-webkit-scrollbar-thumb { background: rgba(120, 170, 255, 0.3); border-radius: 3px; }

.event-item {
    font-size: 12px;
    line-height: 1.4;
    color: #9aa6c0;
    padding: 4px 8px;
    border-left: 2px solid rgba(120, 170, 255, 0.25);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0 4px 4px 0;
}

.event-item .event-time {
    color: #fbbf24;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-right: 6px;
}

.event-item.latest {
    color: #eaf2ff;
    border-left-color: #5fd4f0;
    background: rgba(95, 212, 240, 0.08);
}

.event-item.side-blue .event-time { color: #5fd4f0; }
.event-item.side-red  .event-time { color: #ff8a8a; }

.event-log-empty {
    font-size: 12px;
    color: #5c6788;
    font-style: italic;
}

/* ── responsive: stack panels on small screens ───────────────── */

@media (max-width: 1300px) {
    .top-right { width: 380px; font-size: 11.5px; }
}

@media (max-width: 900px) {
    .hud { font-size: 13px; padding: 10px; }
    .top-left, .top-right, .bottom-left, .bottom-right { width: 44vw; }
    .top-center, .bottom-center { width: 90vw; }
    .metric-big { font-size: 20px; }
    .obj-table { font-size: 11px; }
}
