/* TVD Driving Simulator - Responsive HUD, Controls & Theme */
#tvd-simulator-wrapper {
    --tvd-bg-dark: #09090b;
    --tvd-surface: rgba(9, 9, 11, 0.92);
    --tvd-border: rgba(255, 255, 255, 0.16);
    --tvd-emerald: #10b981;
    --tvd-rose: #f43f5e;
    --tvd-blue: #3b82f6;
    --tvd-amber: #f59e0b;

    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: #09090b;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: #ffffff;
}

#tvd-simulator-wrapper button {
    margin: 0;
    line-height: normal;
    text-transform: none;
    letter-spacing: normal;
    min-height: 0;
    box-sizing: border-box;
    font-family: inherit;
}

#tvd-simulation-canvas {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    z-index: 10;
}

#tvd-simulation-canvas canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* =========================================================
   TOP HUD BAR
========================================================= */
.tvd-hud-top {
    position: absolute;
    top: 12px;
    left: 16px;
    right: 16px;
    z-index: 40;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    gap: 8px;
}

.tvd-top-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.tvd-badge-box {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.92) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 6px 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    gap: 10px;
    color: #ffffff !important;
}

.tvd-score-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 17px;
    font-weight: 800;
}

.tvd-score-pass {
    color: var(--tvd-emerald) !important;
}

.tvd-score-fail {
    color: var(--tvd-rose) !important;
}

.tvd-score-test {
    color: #c084fc !important;
}

.tvd-score-test svg {
    stroke: #c084fc !important;
}

.tvd-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.15);
}

.tvd-timer-badge {
    font-family: monospace;
    font-size: 15px;
    font-weight: 800;
    color: var(--tvd-emerald) !important;
}

.tvd-timer-sub {
    font-family: sans-serif;
    font-size: 11px;
    color: #94a3b8 !important;
    margin-left: 2px;
}

.tvd-exam-btn {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.92) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 6px 14px;
    cursor: pointer;
    color: #ffffff !important;
    gap: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: all 0.15s ease;
}

.tvd-exam-btn:hover {
    border-color: var(--tvd-blue);
    background: rgba(30, 58, 138, 0.4);
}

.tvd-step-pill {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 6px;
}

.tvd-exam-name {
    font-size: 13px;
    font-weight: 800;
}

.tvd-speed-unit {
    font-size: 9px;
    font-weight: 800;
    color: #60a5fa;
    margin-left: 3px;
}

.tvd-rpm-text {
    font-size: 13px;
    font-weight: 800;
    color: var(--tvd-amber);
    margin-left: 4px;
}

/* Engine start button */
.tvd-engine-btn {
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    border: 1px solid;
    transition: all 0.2s ease;
}

.tvd-engine-off {
    background: rgba(136, 19, 55, 0.85);
    border-color: var(--tvd-rose);
    color: #fecdd3;
    animation: tvd-pulse 1.8s infinite;
    box-shadow: 0 0 10px rgba(244, 63, 94, 0.4);
}

.tvd-engine-on {
    background: rgba(6, 78, 59, 0.85);
    border-color: var(--tvd-emerald);
    color: #a7f3d0;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

@keyframes tvd-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.96); opacity: 0.85; }
}

.tvd-settings-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.92) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 8px 14px;
    color: #ffffff !important;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

.tvd-settings-btn.tvd-btn-test-active {
    background: linear-gradient(135deg, #6d28d9, #9333ea) !important;
    border-color: #c084fc !important;
    color: #ffffff !important;
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.6) !important;
    animation: tvd-test-pulse 2s infinite ease-in-out;
}

@keyframes tvd-test-pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(168, 85, 247, 0.4); }
    50% { box-shadow: 0 0 20px rgba(168, 85, 247, 0.85); }
}

/* =========================================================
   NOTIFICATION TOAST
========================================================= */
.tvd-toast-container {
    position: absolute;
    top: 76px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    pointer-events: none;
}

.tvd-toast {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(245, 158, 11, 0.4);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    border-radius: 12px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 700;
    color: #fef08a;
    transition: opacity 0.25s ease;
    opacity: 0;
    pointer-events: none;
}

.tvd-toast-success {
    border-color: var(--tvd-emerald);
    color: #6ee7b7;
}

.tvd-toast-warning {
    border-color: var(--tvd-amber);
    color: #fde047;
}

.tvd-toast-info {
    border-color: var(--tvd-blue);
    color: #93c5fd;
}

/* =========================================================
   BOTTOM HUD / CONTROLS BAR
========================================================= */
.tvd-hud-bottom {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    z-index: 40;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    gap: 12px;
}

/* Left: Gear selector */
/* Left: Automotive Gear Shifter Console */
.tvd-gear-console-wrapper {
    position: relative;
    pointer-events: auto;
}

.tvd-gear-console {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
    border: 2px solid rgba(255, 255, 255, 0.16) !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 8px 10px;
    backdrop-filter: blur(12px);
    width: 68px;
    display: flex;
    flex-direction: column;
    align-items: center;
    user-select: none;
}

.tvd-gear-console-title {
    font-size: 9px;
    font-weight: 900;
    color: #94a3b8;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.tvd-gear-gate {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    width: 100%;
}

.tvd-gear-track {
    width: 8px;
    height: 130px;
    background: #020617;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    position: relative;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.9);
}

.tvd-gear-lever-knob {
    position: absolute;
    left: -6px;
    top: 68px; /* N by default */
    width: 20px;
    height: 16px;
    background: linear-gradient(180deg, #e2e8f0 0%, #94a3b8 50%, #475569 100%);
    border: 1px solid #ffffff;
    border-radius: 4px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.8), 0 0 6px rgba(59, 130, 246, 0.5);
    transition: top 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
}

.tvd-gear-slots {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.tvd-gear-slot-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 2px 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tvd-gear-slot-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.tvd-gear-badge {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 900;
    color: #94a3b8;
    background: #1e293b;
    border: 1px solid #334155;
    transition: all 0.2s ease;
}

.tvd-gear-name {
    font-size: 10px;
    font-weight: bold;
    color: #64748b;
}

/* Active Gear Highlights */
.tvd-gear-slot-btn.tvd-gear-active {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

.tvd-gear-slot-btn.tvd-gear-active .tvd-gear-name {
    color: #ffffff;
}

.tvd-gear-slot-btn.tvd-gear-active .tvd-gear-p {
    background: #d97706;
    color: #ffffff;
    border-color: #f59e0b;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
}

.tvd-gear-slot-btn.tvd-gear-active .tvd-gear-r {
    background: #dc2626;
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.7);
}

.tvd-gear-slot-btn.tvd-gear-active .tvd-gear-n {
    background: #059669;
    color: #ffffff;
    border-color: #10b981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.tvd-gear-slot-btn.tvd-gear-active .tvd-gear-d {
    background: #2563eb;
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.6);
}

/* Center: Blinkers & Steering */
.tvd-center-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(15, 23, 42, 0.92) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    backdrop-filter: blur(10px);
    border-radius: 18px;
    padding: 6px 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    gap: 6px;
}

.tvd-blinkers-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.tvd-labeled-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.tvd-btn-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1;
    white-space: nowrap;
    text-transform: uppercase;
}

.tvd-label-amber {
    color: #f59e0b;
}

.tvd-label-red {
    color: #ef4444;
}

.tvd-label-blue {
    color: #38bdf8;
}

.tvd-label-muted {
    color: #94a3b8;
}

.tvd-round-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    color: #ffffff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tvd-round-btn:hover {
    border-color: #ffffff;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.2) !important;
}

.tvd-btn-blinker-off {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(148, 163, 184, 0.3) !important;
    color: #94a3b8 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tvd-btn-blinker-off:hover {
    border-color: #94a3b8;
    background: rgba(148, 163, 184, 0.2) !important;
}

.tvd-btn-blinker-off.tvd-off-hidden {
    opacity: 0.3;
    pointer-events: none;
}

.tvd-active-blinker {
    background: rgba(245, 158, 11, 0.35) !important;
    border-color: var(--tvd-amber) !important;
    color: var(--tvd-amber) !important;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.tvd-steer-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tvd-steer-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    color: #ffffff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: 900;
}

.tvd-steer-btn:active {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: scale(0.95);
}

.tvd-steer-badge {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    min-width: 55px;
    text-align: center;
    color: #94a3b8;
}

/* Right: Pedals (Phanh & Ga) */
.tvd-pedals-group {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    pointer-events: auto;
}

.tvd-pedal {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    border-radius: 14px;
    padding: 8px 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: all 0.1s ease;
    border: 1px solid;
}

.tvd-pedal:active {
    transform: scale(0.94);
}

.tvd-pedal-brake {
    width: 48px;
    height: 85px;
    background: linear-gradient(to bottom, #27272a, #18181b, #09090b);
    border-color: rgba(244, 63, 94, 0.4);
    box-shadow: 0 0 14px rgba(244, 63, 94, 0.2);
}

.tvd-pedal-brake:active {
    border-color: var(--tvd-rose);
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.6);
}

.tvd-pedal-throttle {
    width: 44px;
    height: 105px;
    background: linear-gradient(to bottom, #27272a, #18181b, #09090b);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.2);
}

.tvd-pedal-throttle:active {
    border-color: var(--tvd-emerald);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.6);
}

.tvd-pedal-text {
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 1px;
}

.tvd-pedal-key {
    font-size: 8px;
    font-family: monospace;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
}

.tvd-pedal-ribs {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 70%;
}

.tvd-rib {
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* =========================================================
   MODALS & OVERLAYS
========================================================= */
.tvd-modal-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.tvd-hidden {
    display: none !important;
}

.tvd-modal-box {
    background: #18181b;
    border: 1px solid var(--tvd-border);
    border-radius: 18px;
    max-width: 620px;
    width: 100%;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    max-height: 90vh;
    overflow-y: auto;
}

.tvd-modal-box h2 {
    color: #ffffff;
    margin-top: 0;
    font-size: 20px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
}

.tvd-guide-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 16px 0;
}

.tvd-guide-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 14px;
}

.tvd-guide-card h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #60a5fa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tvd-guide-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    margin-bottom: 6px;
    color: #cbd5e1;
}

.tvd-kbd {
    background: #27272a;
    border: 1px solid #3f3f46;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-weight: 700;
    color: #ffffff;
    font-size: 11px;
}

.tvd-modal-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: var(--tvd-emerald);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    margin-top: 16px;
    text-align: center;
    text-decoration: none;
}

.tvd-modal-btn:hover {
    background: #059669;
}

/* Result Modal */
.tvd-result-status {
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 900;
    font-size: 16px;
    display: inline-block;
    margin: 12px 0;
}

.tvd-status-pass {
    background: rgba(16, 185, 129, 0.2);
    color: var(--tvd-emerald);
    border: 1px solid var(--tvd-emerald);
}

.tvd-status-fail {
    background: rgba(244, 63, 94, 0.2);
    color: var(--tvd-rose);
    border: 1px solid var(--tvd-rose);
}

.tvd-penalty-list {
    list-style: none;
    padding: 0;
    margin: 14px 0;
    max-height: 180px;
    overflow-y: auto;
}

.tvd-penalty-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid var(--tvd-rose);
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 13px;
}

.tvd-penalty-pts {
    color: var(--tvd-rose);
    font-weight: 800;
}

/* Debug panel repositioned to NOT overlap GPS Mini-Map */
.tvd-debug-panel {
    position: absolute;
    top: 72px;
    right: 18px;
    background: rgba(0, 0, 0, 0.88);
    border: 1px solid #3b82f6;
    border-radius: 8px;
    padding: 8px 12px;
    font-family: monospace;
    font-size: 11px;
    color: #60a5fa;
    z-index: 38;
    line-height: 1.4;
    pointer-events: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .tvd-guide-grid {
        grid-template-columns: 1fr;
    }
    .tvd-hud-top {
        left: 8px;
        right: 8px;
    }
    .tvd-hud-bottom {
        left: 8px;
        right: 8px;
        bottom: 8px;
    }
    .tvd-exam-name {
        display: none;
    }
    .tvd-settings-btn span {
        display: none;
    }
}

/* =========================================================
   DUAL REARVIEW SIDE MIRRORS (Gương chiếu hậu 2 bên: Trái & Phải)
========================================================= */
.tvd-mirrors-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 35;
}

.tvd-mirror-frame {
    position: absolute;
    width: 210px;
    height: 130px;
    background: transparent !important;
    border: 2px solid rgba(56, 189, 248, 0.85);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), inset 0 0 10px rgba(56, 189, 248, 0.2);
    overflow: hidden;
    transition: all 0.25s ease;
}

/* Left Mirror: Positioned on middle-left (below minimap, above gear shifter) */
.tvd-mirror-left {
    top: calc(50% - 65px);
    left: 18px;
    border-top-left-radius: 18px;
    border-bottom-left-radius: 6px;
}

/* Right Mirror: Positioned on middle-right (below debug panel, completely above pedals) */
.tvd-mirror-right {
    top: calc(50% - 65px);
    right: 18px;
    border-top-right-radius: 18px;
    border-bottom-right-radius: 6px;
}

.tvd-mirror-header {
    position: absolute;
    top: 6px;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.88);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
    color: #e0f2fe;
    letter-spacing: 0.5px;
    border: 1px solid rgba(56, 189, 248, 0.4);
    z-index: 2;
    pointer-events: none;
}

.tvd-mirror-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
    animation: tvd-pulse 1.2s infinite;
}

.tvd-mirror-glass-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: none;
}

@media (max-width: 900px) {
    .tvd-mirror-frame {
        width: 140px;
        height: 88px;
    }
    .tvd-mirror-left {
        top: calc(50% - 44px);
        left: 8px;
    }
    .tvd-mirror-right {
        top: calc(50% - 44px);
        right: 8px;
    }
}

/* =========================================================
   COCKPIT / CABIN INTERIOR OVERLAY (First-Person View)
========================================================= */
.tvd-cockpit-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 25;
    pointer-events: none;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    opacity: 1;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s ease;
}

.tvd-cockpit-overlay.tvd-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    transform: scale(0.98);
}

#tvd-cockpit-svg {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Steering Wheel & Driver Hands */
#tvd-cockpit-steering-group {
    transform-origin: 0px 0px;
    transform-box: view-box;
    will-change: transform;
}

/* Instrument Gauge Needles */
#tvd-cockpit-needle-rpm {
    transform-origin: 0px 0px;
    transform-box: view-box;
    will-change: transform;
}

#tvd-cockpit-needle-speed {
    transform-origin: 0px 0px;
    transform-box: view-box;
    will-change: transform;
}

/* Turn Indicator Blinkers on Cockpit LCD */
.tvd-cockpit-blink-on {
    fill: #22c55e !important;
    filter: drop-shadow(0 0 6px #22c55e) !important;
}

/* Hazard active blink state */
.tvd-cockpit-hazard-on {
    fill: #ef4444 !important;
    filter: drop-shadow(0 0 8px #ef4444) !important;
}

/* Responsive scaling for mobile & narrow screens */
@media (max-width: 900px) {
    .tvd-cockpit-overlay {
        transform-origin: bottom center;
    }
}

/* =========================================================
   MOUSE STEERING HUD & WHEEL HITBOX (Racing Limits Style)
========================================================= */
#tvd-cockpit-wheel-hitbox {
    pointer-events: auto !important;
    cursor: grab !important;
    touch-action: none;
}

#tvd-cockpit-wheel-hitbox:active {
    cursor: grabbing !important;
}

.tvd-mouse-steer-hud {
    position: absolute;
    top: 68px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 45;
    background: rgba(15, 23, 42, 0.92);
    border: 1.5px solid rgba(56, 189, 248, 0.6);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.7), 0 0 16px rgba(56, 189, 248, 0.35);
    border-radius: 14px;
    padding: 6px 18px 8px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    backdrop-filter: blur(12px);
    pointer-events: none;
    transition: all 0.25s ease;
    min-width: 330px;
}

.tvd-mouse-steer-hud.tvd-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateX(-50%) translateY(-12px);
}

.tvd-mshud-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 800;
    color: #e0f2fe;
    letter-spacing: 0.5px;
}

.tvd-mshud-sub {
    font-size: 10px;
    font-weight: normal;
    color: #94a3b8;
    margin-left: 4px;
}

.tvd-mshud-gauge {
    position: relative;
    width: 280px;
    height: 14px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    overflow: visible;
}

.tvd-mshud-center-line {
    position: absolute;
    left: 50%;
    top: -2px;
    bottom: -2px;
    width: 2px;
    background: #facc15;
    transform: translateX(-50%);
    box-shadow: 0 0 6px #facc15;
    z-index: 2;
}

.tvd-mshud-notch {
    font-size: 8px;
    font-weight: 800;
    color: #64748b;
    z-index: 1;
    user-select: none;
}

.tvd-mshud-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #38bdf8;
    border: 2px solid #ffffff;
    box-shadow: 0 0 10px #38bdf8, 0 0 18px rgba(56, 189, 248, 0.8);
    transform: translate(-50%, -50%);
    transition: left 0.05s linear;
    z-index: 3;
}

/* Mini-Map Radar Container */
.tvd-minimap-container {
    position: absolute;
    top: 72px;
    left: 18px;
    z-index: 36;
    pointer-events: auto;
}

.tvd-minimap-wrapper {
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    transition: all 0.25s ease;
}

.tvd-minimap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 10px;
    font-weight: 800;
    color: #93c5fd;
    letter-spacing: 0.5px;
}

.tvd-minimap-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tvd-radar-ping {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #38bdf8;
    animation: tvd-pulse 1.5s infinite;
}

.tvd-minimap-toggle {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 4px;
    border-radius: 4px;
}

.tvd-minimap-toggle:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.tvd-minimap-canvas {
    display: block;
    border-radius: 8px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tvd-minimap-footer {
    font-family: monospace;
    font-size: 9px;
    color: #64748b;
    text-align: right;
    margin-top: 4px;
}

/* Replay Bar */
.tvd-replay-bar {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 860px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(139, 92, 246, 0.5);
    border-radius: 14px;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 50;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    pointer-events: auto;
}

.tvd-replay-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tvd-replay-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #7c3aed;
    border: none;
    color: #ffffff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s;
}

.tvd-replay-btn:hover {
    background: #6d28d9;
    transform: scale(1.05);
}

.tvd-replay-badge {
    background: rgba(124, 58, 237, 0.3);
    color: #c4b5fd;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 6px;
    letter-spacing: 1px;
}

.tvd-replay-time {
    font-family: monospace;
    font-size: 12px;
    font-weight: bold;
    color: #e2e8f0;
    min-width: 90px;
}

.tvd-replay-center {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.tvd-replay-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: #334155;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.tvd-replay-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #a78bfa;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 0 8px rgba(167, 139, 250, 0.8);
}

.tvd-replay-flags {
    position: absolute;
    top: -6px;
    left: 0;
    right: 0;
    height: 6px;
    pointer-events: none;
}

.tvd-replay-flag {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    border: 1px solid #ffffff;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.9);
}

.tvd-replay-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tvd-replay-speed-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 800;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.tvd-replay-speed-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.tvd-replay-close-btn {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.tvd-replay-close-btn:hover {
    background: rgba(239, 68, 68, 0.4);
}

@media (max-width: 640px) {
    .tvd-minimap-container {
        top: 60px;
        left: 8px;
    }
    .tvd-replay-bar {
        bottom: 8px;
        width: 95%;
        padding: 8px 12px;
        gap: 8px;
    }
}

/* ==========================================================================
   OFFICIAL EXAM CERTIFICATE MODAL & PRINT STYLES
   ========================================================================== */
.tvd-certificate-wrapper {
    max-width: 820px;
    width: 100%;
    max-height: 94vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 10px;
}

.tvd-certificate-sheet {
    background: #ffffff;
    color: #111827;
    font-family: 'Times New Roman', Times, serif;
    width: 100%;
    padding: 36px 44px;
    border-radius: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    box-sizing: border-box;
    line-height: 1.4;
}

.tvd-cert-header {
    display: none !important; /* Hidden per user request */
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.tvd-cert-header-left {
    text-align: center;
}

.tvd-cert-org {
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
}

.tvd-cert-suborg {
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
}

.tvd-cert-id {
    font-size: 12px;
    margin-top: 4px;
    color: #4b5563;
}

.tvd-cert-header-right {
    text-align: center;
}

.tvd-cert-country {
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
}

.tvd-cert-motto {
    font-size: 13px;
    font-weight: bold;
    margin-top: 2px;
}

.tvd-cert-rule-line {
    width: 120px;
    height: 1px;
    background: #111827;
    margin: 4px auto 6px auto;
}

.tvd-cert-date {
    font-size: 12px;
    font-style: italic;
    color: #374151;
}

.tvd-cert-title-block {
    display: none !important; /* Hidden per user request */
    text-align: center;
    margin: 18px 0 16px 0;
}

.tvd-cert-title {
    font-size: 20px;
    font-weight: bold;
    color: #1e3a8a;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tvd-cert-subtitle {
    font-size: 12px;
    font-style: italic;
    color: #4b5563;
    margin-top: 4px;
}

.tvd-cert-grid-info {
    display: none !important; /* Hidden per user request */
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    font-size: 14px;
    border-top: 1px dashed #cbd5e1;
    border-bottom: 1px dashed #cbd5e1;
    padding: 10px 0;
    margin-bottom: 14px;
}

.tvd-cert-info-col div {
    margin-bottom: 4px;
}

.tvd-cert-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 16px;
}

.tvd-cert-banner.tvd-cert-pass {
    border-color: #10b981;
    background: #f0fdf4;
}

.tvd-cert-banner.tvd-cert-fail {
    border-color: #ef4444;
    background: #fef2f2;
}

.tvd-cert-score-label {
    font-size: 13px;
    font-weight: bold;
    color: #475569;
    display: block;
}

.tvd-cert-score-num {
    font-size: 26px;
    font-weight: 900;
    color: #0f172a;
}

.tvd-cert-banner-result {
    font-size: 18px;
    font-weight: 900;
    padding: 6px 18px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

.tvd-cert-pass .tvd-cert-banner-result {
    background: #10b981;
    color: #ffffff;
}

.tvd-cert-fail .tvd-cert-banner-result {
    background: #ef4444;
    color: #ffffff;
}

.tvd-cert-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 16px;
}

.tvd-cert-table th,
.tvd-cert-table td {
    border: 1px solid #94a3b8;
    padding: 6px 8px;
}

.tvd-cert-table th {
    background: #f1f5f9;
    font-weight: bold;
    color: #0f172a;
}

.tvd-cert-penalty-box {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 0;
    background: #fafafa;
}

.tvd-cert-penalty-title {
    font-weight: bold;
    font-size: 12px;
    color: #334155;
    margin-bottom: 4px;
}

.tvd-cert-penalty-content {
    font-size: 12px;
    color: #64748b;
}

.tvd-cert-footer-signatures {
    display: none !important; /* Hidden per user request */
    justify-content: space-between;
    margin-top: 24px;
    padding: 0 30px;
}

.tvd-cert-sig-box {
    text-align: center;
    width: 220px;
}

.tvd-cert-sig-title {
    font-size: 13px;
    font-weight: bold;
}

.tvd-cert-sig-sub {
    font-size: 11px;
    font-style: italic;
    color: #6b7280;
    margin-bottom: 25px;
}

.tvd-cert-sig-sign {
    font-family: 'Brush Script MT', cursive, sans-serif;
    font-size: 24px;
    color: #1e3a8a;
    min-height: 40px;
}

.tvd-cert-stamp {
    position: relative;
    display: inline-block;
}

.tvd-stamp-circle {
    width: 100px;
    height: 100px;
    border: 2px solid #dc2626;
    border-radius: 50%;
    color: #dc2626;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    text-transform: uppercase;
    transform: rotate(-12deg);
    opacity: 0.85;
    box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.2);
}

.tvd-stamp-circle strong {
    font-size: 11px;
    margin: 2px 0;
    border-top: 1px solid #dc2626;
    border-bottom: 1px solid #dc2626;
    padding: 1px 4px;
}

.tvd-cert-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.tvd-btn-print {
    background: #0284c7 !important;
    flex: 1;
}

.tvd-btn-close-cert {
    background: #475569 !important;
    flex: 1;
}

/* ==========================================================================
   EMERGENCY SITUATION ALERT BANNER
   ========================================================================== */
.tvd-emergency-banner {
    position: absolute;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    width: 90%;
    max-width: 620px;
    background: rgba(185, 28, 28, 0.95);
    border: 2px solid #ef4444;
    border-radius: 12px;
    padding: 12px 18px;
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.65), 0 8px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    animation: tvdEmergencyPulse 0.7s infinite alternate ease-in-out;
    pointer-events: auto;
}

@keyframes tvdEmergencyPulse {
    from {
        box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
        border-color: #ef4444;
    }
    to {
        box-shadow: 0 0 35px rgba(239, 68, 68, 0.95), 0 0 10px #ffffff;
        border-color: #fca5a5;
    }
}

.tvd-emergency-content {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: space-between;
}

.tvd-emergency-icon {
    font-size: 28px;
    animation: tvdShake 0.4s infinite;
}

@keyframes tvdShake {
    0% { transform: scale(1); }
    50% { transform: scale(1.15) rotate(-5deg); }
    100% { transform: scale(1); }
}

.tvd-emergency-body {
    flex: 1;
    color: #ffffff;
}

.tvd-emergency-title {
    font-size: 15px;
    font-weight: 900;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tvd-emergency-sub {
    font-size: 12px;
    color: #fee2e2;
    margin-top: 2px;
}

.tvd-emergency-hazard-btn {
    background: #ffffff !important;
    color: #b91c1c !important;
    font-size: 12px;
    font-weight: 900;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.tvd-emergency-hazard-btn:hover {
    background: #fef2f2 !important;
    transform: scale(1.04);
}

.tvd-emergency-hazard-btn.tvd-hazard-active {
    background: #22c55e !important;
    color: #ffffff !important;
}

/* ==========================================================================
   VEHICLE SELECTOR MODAL
   ========================================================================== */
.tvd-modal-vehicles-box {
    max-width: 680px !important;
}

.tvd-vehicle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 16px 0;
}

.tvd-vehicle-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 14px 12px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tvd-vehicle-card:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateY(-2px);
}

.tvd-vehicle-card.tvd-vehicle-selected {
    background: rgba(59, 130, 246, 0.2) !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.4);
}

.tvd-vehicle-badge {
    font-size: 10px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
    background: #2563eb;
    color: #ffffff;
    margin-bottom: 8px;
}

.tvd-badge-green {
    background: #059669 !important;
}

.tvd-badge-amber {
    background: #d97706 !important;
}

.tvd-vehicle-preview-icon {
    font-size: 34px;
    margin: 4px 0 8px 0;
}

.tvd-vehicle-name {
    font-size: 13px;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 4px;
}

.tvd-vehicle-desc {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.35;
    margin-bottom: 8px;
    flex: 1;
}

.tvd-vehicle-specs {
    font-size: 10px;
    color: #38bdf8;
    background: rgba(0, 0, 0, 0.25);
    padding: 4px 6px;
    border-radius: 6px;
    width: 100%;
}

/* Color Swatches */
.tvd-color-picker-section {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.04);
    padding: 10px 14px;
    border-radius: 10px;
    margin-top: 10px;
}

.tvd-color-label {
    font-size: 12px;
    font-weight: bold;
    color: #cbd5e1;
}

.tvd-color-swatches {
    display: flex;
    gap: 8px;
}

.tvd-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: transform 0.15s ease;
    outline: none;
}

.tvd-swatch:hover {
    transform: scale(1.18);
}

.tvd-swatch.tvd-swatch-selected {
    border: 2px solid #38bdf8 !important;
    box-shadow: 0 0 10px #38bdf8;
    transform: scale(1.15);
}

/* ==========================================================================
   LEADERBOARD / HALL OF FAME MODAL
   ========================================================================== */
.tvd-modal-leaderboard-box {
    max-width: 640px !important;
}

.tvd-leaderboard-scroll {
    max-height: 380px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tvd-leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.tvd-leaderboard-table th {
    background: rgba(15, 23, 42, 0.95);
    color: #94a3b8;
    padding: 10px 12px;
    font-weight: 700;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.tvd-leaderboard-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.tvd-leaderboard-table tr:hover td {
    background: rgba(255, 255, 255, 0.04);
}

.tvd-rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 11px;
}

.tvd-rank-1 {
    background: #facc15;
    color: #854d0e;
    box-shadow: 0 0 8px rgba(250, 204, 21, 0.5);
}

.tvd-rank-2 {
    background: #e2e8f0;
    color: #334155;
}

.tvd-rank-3 {
    background: #fb923c;
    color: #7c2d12;
}

.tvd-rank-other {
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
}

/* ==========================================================================
   PRINT MEDIA STYLES - A4 CLEAN EXPORT
   ========================================================================== */
@media print {
    body * {
        visibility: hidden !important;
    }

    #tvd-modal-certificate,
    #tvd-certificate-print-area,
    #tvd-certificate-print-area * {
        visibility: visible !important;
    }

    #tvd-modal-certificate {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
    }

    .tvd-certificate-wrapper {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .tvd-certificate-sheet {
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 20mm 15mm !important;
        width: 100% !important;
        color: #000000 !important;
    }

    .tvd-cert-actions {
        display: none !important;
    }
}
