:root {
    --bg: #0f1115;
    --bg-panel: #1a1d24;
    --bg-card: #232730;
    --text: #ffffff;
    --text-muted: #8b9bb4;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: #2e3440;
    --header-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Force desktop min-width for large screens only */
@media (min-width: 1281px) {
    body {
        min-width: 1280px;
    }
}

#mobile-warning {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

#mobile-warning svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    color: var(--accent);
}

#mobile-warning h2 {
    margin-bottom: 0.5rem;
}

#mobile-warning p {
    color: var(--text-muted);
}

@media (max-width: 1280px) {
    header, main, footer {
        display: none !important;
    }
    #mobile-warning {
        display: flex !important;
    }
}

header {
    height: var(--header-height);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    justify-content: space-between;
    background: rgba(15, 17, 21, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
}

header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    margin: 0;
}

header .controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn:hover:not(:disabled) {
    background: var(--border);
    border-color: var(--text-muted);
    color: var(--text);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
    box-shadow: 0 0 12px var(--accent-glow);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1px;
    background: var(--border);
    overflow: hidden;
    min-height: 0;
}

.video-container {
    background: var(--bg);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    height: 100%;
}

.video-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2px;
    background: #000;
    position: relative;
    min-height: 0;
    overflow: hidden;
    padding: 2px;
}

.video-cell {
    position: relative;
    background: #111;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-cell video,
.video-cell canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-label {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.8);
    pointer-events: none;
    z-index: 5;
}

.drop-zone {
    position: absolute;
    top: 2rem;
    left: 2rem;
    right: 2rem;
    bottom: 80px;

    border: 2px dashed var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(26, 29, 36, 0.95);
    transition: all 0.2s;
    cursor: pointer;
    z-index: 20;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(26, 29, 36, 0.98);
}

.drop-zone.hidden {
    display: none;
}

.drop-zone svg {
    width: 48px;
    height: 48px;
    fill: var(--text-muted);
    margin-bottom: 1rem;
}

.video-controls {
    height: 60px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 10px 1.5rem;
    gap: 1rem;
    box-sizing: border-box;
    z-index: 30;
}

input[type=range] {
    flex: 1;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: -6px;
    box-shadow: 0 0 10px var(--accent-glow);
}

.dashboard {
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1.5rem;
    gap: 1.5rem;
    border-left: 1px solid var(--border);
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    position: relative;
    width: 100%;
}

.card-label {
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: block;
}

.speed-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 1rem 0;
}

.speed-value {
    font-size: 3.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    background: linear-gradient(180deg, #fff, #a5b4fc);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.speed-unit {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.steering-container {
    display: flex;
    justify-content: center;
    position: relative;
    height: 140px;
}

.steering-wheel-path {
    transition: transform 0.1s cubic-bezier(0.2, 0, 0, 1);
    transform-origin: center;
}

.blinker {
    position: absolute;
    top: 50%;
    width: 24px;
    height: 24px;
    margin-top: -12px;
    fill: var(--text-muted);
    opacity: 0.2;
    transition: all 0.2s;
}

.blinker.active {
    fill: var(--success);
    animation: blinker-flash 0.5s infinite;
}

@keyframes blinker-flash {

    0%,
    49% {
        opacity: 1;
        filter: drop-shadow(0 0 5px var(--success));
    }

    50%,
    100% {
        opacity: 0.2;
        filter: none;
    }
}

.blinker-left {
    left: 10px;
}

.blinker-right {
    right: 10px;
}

.pedal-group {
    display: flex;
    gap: 1rem;
    height: 120px;
}

.pedal {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
}

.pedal-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--text-muted);
    transition: height 0.1s linear;
    opacity: 0.8;
}

.pedal.accel .pedal-fill {
    background: linear-gradient(0deg, var(--accent), #60a5fa);
    box-shadow: 0 0 15px var(--accent-glow);
}

.pedal.brake .pedal-fill {
    background: linear-gradient(0deg, var(--danger), #f87171);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

.gear-strip {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.gear {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
    opacity: 0.4;
    transition: all 0.2s;
}

.gear.active {
    color: var(--text);
    opacity: 1;
    text-shadow: 0 0 10px white;
    transform: scale(1.1);
}

.ap-status {
    text-align: center;
    padding: 0.5rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
    border: 1px solid transparent;
}

.ap-status.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    font-size: 0.8rem;
}

.data-item {
    display: flex;
    flex-direction: column;
}

.data-val {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text);
}

.form-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 8px;
    border-radius: 4px;
}

footer {
    height: auto;
    min-height: 40px;
    padding: 1rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    z-index: 10;
}

.nav-controls {
    display: flex;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}