@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

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

html, body {
    background: #080814;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #e2e8f0;
    user-select: none;
}

/* ─── Flexible Viewport Layout ───────────────────────────────────────────── */
#simContainer {
    display: flex;
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

#carPanel {
    flex: 1;
    height: 100vh;
    position: relative;
    background: #0f172a;
    min-width: 0;
}

#networkPanel {
    width: 380px;
    height: 100vh;
    position: relative;
    background: linear-gradient(180deg, #0b0f19 0%, #030712 100%);
    border-left: 1px solid rgba(56, 189, 248, 0.12);
    flex-shrink: 0;
}

#carCanvas, #networkCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ─── HUD Overlay Panel (Top-Left) ───────────────────────────────────────── */
#hud {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

#infoPanel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(15, 23, 42, 0.88);
    color: #f8fafc;
    padding: 16px 22px;
    border-radius: 14px;
    font: 600 13px/1.4 'Inter', sans-serif;
    letter-spacing: 0.02em;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(56, 189, 248, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    pointer-events: auto;
}

#genDisplay {
    color: #38bdf8;
    font-size: 16px;
    font-weight: 700;
}

#aliveDisplay {
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
}

#bestDistDisplay {
    color: #10b981;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 700;
}

/* ─── Action Buttons Bar ────────────────────────────────────────────────── */
#storageButtons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    pointer-events: auto;
}

.btn {
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    background: rgba(30, 41, 59, 0.85);
    color: #cbd5e1;
    font: 600 12px/1 'Inter', sans-serif;
    letter-spacing: 0.03em;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(148, 163, 184, 0.2);
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background: rgba(56, 189, 248, 0.2);
    color: #ffffff;
    border-color: rgba(56, 189, 248, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(56, 189, 248, 0.25);
}

.btn:active {
    transform: translateY(0px) scale(0.97);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.6);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.25);
}

/* ─── Toast Notification Popup ────────────────────────────────────────── */
.toast {
    background: rgba(16, 185, 129, 0.95);
    color: #ffffff;
    padding: 10px 16px;
    border-radius: 8px;
    font: 600 12px/1.3 'Inter', sans-serif;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

.toast.hidden {
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
}

/* ─── Color Swatch Legend ──────────────────────────────────────────────── */
#legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(15, 23, 42, 0.85);
    padding: 12px 16px;
    border-radius: 10px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(148, 163, 184, 0.15);
    font: 500 12px/1.3 'Inter', sans-serif;
    color: #94a3b8;
    pointer-events: auto;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-swatch {
    width: 14px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* ─── Controls Bar (Bottom-Left) ───────────────────────────────────────── */
#controlsBar {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(15, 23, 42, 0.88);
    padding: 12px 20px;
    border-radius: 12px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(56, 189, 248, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font: 600 11px/1 'Inter', sans-serif;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="range"] {
    width: 90px;
    accent-color: #38bdf8;
    cursor: pointer;
}

.value-badge {
    font: 700 13px/1 'JetBrains Mono', monospace;
    color: #38bdf8;
    min-width: 30px;
}

/* ─── Responsive Media Query ────────────────────────────────────────────── */
@media (max-width: 800px) {
    #networkPanel {
        display: none;
    }
}