/* ==========================================================================
   HALLOWEEN PUMPKIN SPEEDOMETER HUD — STYLES
   Demonic Jack-o'-Lantern Speedometer + FiveM NUI Compatible
   Polished, Responsive, High-Performance 60+ FPS Graphics
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: transparent !important;
    background: transparent !important;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
   Original API Compatibility Container (Headless/Integration Safe)
   -------------------------------------------------------------------------- */
main.speedometer {
    position: fixed;
    top: -9999px;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   HUD Container — Fixed Bottom-Right Position for FiveM
   -------------------------------------------------------------------------- */
.speedometer-hud {
    position: fixed;
    right: 2vw;
    bottom: 2vh;
    width: min(42vw, 680px);
    max-width: 720px;
    min-width: 310px;
    height: auto;
    aspect-ratio: 1200 / 860;
    z-index: 9999;
    pointer-events: none;
    filter: drop-shadow(0 14px 32px rgba(0, 0, 0, 0.85)) drop-shadow(0 0 25px rgba(255, 120, 0, 0.45));
    transition: filter 0.3s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.4, 1);
    transform-origin: bottom right;
}

.speedometer-hud svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

/* High Speed Demonic Rage Mode */
.speedometer-hud.demon-rage {
    animation: demonShake 0.16s infinite alternate ease-in-out;
}

@keyframes demonShake {
    0% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(1.5px, -1.5px) rotate(0.35deg); }
    100% { transform: translate(-1.5px, 1px) rotate(-0.35deg); }
}

/* Enable pointer events on interactive SVG controls */
.speedometer-hud .interactive-control {
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.speedometer-hud .interactive-control:hover {
    filter: brightness(1.25) drop-shadow(0 0 10px rgba(255, 170, 0, 0.8));
}

.speedometer-hud .interactive-control:active {
    transform: scale(0.92);
}

/* --------------------------------------------------------------------------
   SVG Gauge Typography & Dynamic Text
   -------------------------------------------------------------------------- */
.gauge-text {
    font-family: 'Outfit', 'Arial Black', Impact, sans-serif;
    font-weight: 900;
    fill: #ffcc66;
    text-anchor: middle;
    filter: url(#glow-orange);
    transition: fill 0.25s ease;
}

.gauge-label {
    font-family: 'Outfit', Arial, sans-serif;
    font-weight: 800;
    fill: #ffaa44;
    text-anchor: middle;
    letter-spacing: 1.5px;
    transition: fill 0.25s ease;
}

.tick-major {
    stroke: #ff9900;
    stroke-width: 4;
    filter: url(#glow-orange);
    transition: stroke 0.25s ease;
}

.tick-minor {
    stroke: #cc5500;
    stroke-width: 2;
    transition: stroke 0.25s ease;
}

/* --------------------------------------------------------------------------
   Needles & Rotation Physics
   -------------------------------------------------------------------------- */
.hud-needle {
    transform-origin: 0 0;
    will-change: transform;
    transition: none !important; /* Continuous delta-time lerp in requestAnimationFrame */
}

/* --------------------------------------------------------------------------
   Status Indicators & Warning Lights
   -------------------------------------------------------------------------- */
.indicator-icon {
    opacity: 0.25;
    transition: opacity 0.15s ease, filter 0.15s ease;
}

.indicator-icon.blinking {
    animation: indicatorFlash 0.5s infinite steps(1, start);
    opacity: 1 !important;
}

@keyframes indicatorFlash {
    0%, 49% {
        opacity: 1;
        filter: url(#glow-green) drop-shadow(0 0 14px #00ff66);
    }
    50%, 100% {
        opacity: 0.2;
        filter: none;
    }
}

/* Seatbelt Warning */
#seatbelt-ind {
    transition: filter 0.25s ease, opacity 0.25s ease;
}

#seatbelt-ind.seatbelt-warning {
    animation: seatbeltPulse 0.9s infinite alternate ease-in-out;
}

#seatbelt-ind.seatbelt-buckled {
    opacity: 0.5;
    filter: none;
}

@keyframes seatbeltPulse {
    0% {
        filter: url(#glow-orange) drop-shadow(0 0 6px rgba(255, 30, 0, 0.4));
        opacity: 0.65;
    }
    100% {
        filter: url(#glow-strong) drop-shadow(0 0 22px rgba(255, 0, 0, 0.95));
        opacity: 1;
    }
}

/* Headlights / Nose */
#highbeam-ind {
    transition: filter 0.25s ease, opacity 0.25s ease;
}

#highbeam-ind.headlights-off {
    opacity: 0.3;
    filter: none;
}

#highbeam-ind.headlights-on {
    opacity: 1;
    filter: url(#glow-orange) drop-shadow(0 0 16px rgba(255, 170, 0, 0.85));
}

#highbeam-ind.headlights-high {
    opacity: 1;
    filter: url(#glow-blue) drop-shadow(0 0 24px rgba(0, 150, 255, 0.95));
}

/* Check Engine */
#engine-ind {
    transition: filter 0.25s ease, opacity 0.25s ease;
}

#engine-ind.engine-on {
    opacity: 1;
    filter: url(#glow-orange) drop-shadow(0 0 16px rgba(255, 120, 0, 0.85));
}

#engine-ind.engine-off {
    opacity: 0.25;
    filter: none;
}

/* Health Warning (< 25%) */
#health-heart-group.health-warning {
    animation: heartCritPulse 0.45s infinite alternate ease-in-out;
}

@keyframes heartCritPulse {
    0% {
        transform: translate(0, 5px) scale(0.92);
        filter: drop-shadow(0 0 4px #ff0000);
    }
    100% {
        transform: translate(0, 5px) scale(1.15);
        filter: url(#glow-strong) drop-shadow(0 0 24px #ff0022);
    }
}

/* Fuel Warning (< 15%) */
#fuel-pump-icon.fuel-warning {
    animation: fuelCritBlink 0.6s infinite alternate steps(1, start);
}

@keyframes fuelCritBlink {
    0%, 49% {
        fill: #ff0033 !important;
        filter: url(#glow-strong) drop-shadow(0 0 18px #ff0033);
        opacity: 1;
    }
    50%, 100% {
        opacity: 0.25;
        filter: none;
    }
}

/* Lantern Candle Flicker */
#lantern-fire {
    animation: lanternFlicker 2.8s infinite ease-in-out;
    transform-origin: 25px 60px;
}

@keyframes lanternFlicker {
    0%, 100% { transform: scale(1); opacity: 0.95; }
    25% { transform: scale(1.06, 0.96); opacity: 1; }
    50% { transform: scale(0.95, 1.04); opacity: 0.85; }
    75% { transform: scale(1.04, 0.96); opacity: 1; }
}

/* --------------------------------------------------------------------------
   FLOATING SPARK & EMBER PARTICLES IN MOUTH
   -------------------------------------------------------------------------- */
.ember-particle {
    fill: #ffaa00;
    filter: url(#glow-orange);
    animation: floatEmber 1.8s infinite ease-out;
    opacity: 0;
}

@keyframes floatEmber {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(-80px) scale(0.2);
        opacity: 0;
    }
}

/* --------------------------------------------------------------------------
   YOUTUBE CAR RADIO POPUP & LAUNCHER (Halloween Edition)
   -------------------------------------------------------------------------- */
.yt-launcher-btn {
    position: fixed;
    right: 2vw;
    bottom: calc(2vh + min(42vw, 680px) * 0.72 + 20px);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ff7700, #b33600 65%, #380a00);
    border: 2px solid #ffaa00;
    box-shadow: 0 4px 18px rgba(255, 102, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    pointer-events: auto;
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.4, 1), box-shadow 0.2s ease, filter 0.2s ease;
}

.yt-launcher-btn:hover {
    transform: scale(1.1) rotate(6deg);
    box-shadow: 0 6px 26px rgba(255, 110, 0, 0.8), 0 0 16px rgba(255, 200, 0, 0.6);
    filter: brightness(1.2);
}

.yt-launcher-btn:active {
    transform: scale(0.94);
}

.yt-launcher-btn svg {
    width: 24px;
    height: 24px;
    fill: #ffffff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

/* Minimap-Matched Floating YouTube Player */
.yt-player-container {
    position: fixed;
    left: max(20px, 1.5vw);
    bottom: clamp(210px, 24vh, 250px);
    width: clamp(300px, 18vw, 340px);
    height: 215px;
    background: rgba(18, 5, 2, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 2px solid #ff6600;
    border-radius: 14px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.88), 0 0 24px rgba(255, 80, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    pointer-events: auto;
    opacity: 0;
    transform: scale(0.92) translateY(15px);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.2, 0.8, 0.4, 1), height 0.25s ease;
}

.yt-player-container.active {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.yt-player-container.minimized {
    height: 44px;
    width: clamp(260px, 16vw, 300px);
}

.yt-header {
    height: 42px;
    background: linear-gradient(90deg, #3d0d02, #5e1804 50%, #3d0d02);
    border-bottom: 1px solid rgba(255, 102, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    cursor: move;
}

.yt-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.yt-icon-small {
    width: 20px;
    height: 20px;
    fill: #ff4400;
}

.yt-title {
    color: #ffeedd;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.5px;
}

.yt-header-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.yt-header-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 102, 0, 0.4);
    border-radius: 6px;
    color: #ffcc99;
    font-size: 13px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}

.yt-header-btn:hover {
    background: #ff5500;
    color: #ffffff;
    transform: scale(1.08);
}

.yt-iframe-wrap {
    flex: 1;
    width: 100%;
    position: relative;
    background: #000000;
}

.yt-iframe-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Volume Slider Widget in Header */
.yt-volume-control {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 102, 0, 0.35);
    border-radius: 12px;
    padding: 2px 6px;
}

.yt-volume-control input[type="range"] {
    width: 55px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #4a1505;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.yt-volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #ff8800;
    box-shadow: 0 0 6px #ff5500;
    cursor: pointer;
}

/* Live Sync Badges */
.yt-sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    color: #00ff88;
    background: rgba(0, 40, 15, 0.6);
    border: 1px solid rgba(0, 255, 136, 0.4);
    border-radius: 10px;
    padding: 2px 7px;
    letter-spacing: 0.5px;
}

.yt-sync-badge .sync-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #00ff88;
    box-shadow: 0 0 8px #00ff88;
    animation: syncPulse 1.4s infinite alternate ease-in-out;
}

.yt-sync-badge.disconnected {
    color: #ffaa33;
    background: rgba(50, 25, 0, 0.6);
    border-color: rgba(255, 170, 51, 0.4);
}

.yt-sync-badge.disconnected .sync-dot {
    background: #ffaa33;
    box-shadow: 0 0 8px #ffaa33;
    animation: none;
}

@keyframes syncPulse {
    0% { opacity: 0.4; transform: scale(0.85); }
    100% { opacity: 1; transform: scale(1.2); }
}

/* --------------------------------------------------------------------------
   YOUTUBE URL INPUT MODAL
   -------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    width: min(92vw, 480px);
    background: linear-gradient(135deg, #240a02, #3d1205 60%, #170401);
    border: 2px solid #ff7700;
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 35px rgba(255, 100, 0, 0.45);
    padding: 24px;
    color: #ffeedd;
    transform: scale(0.92) translateY(15px);
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.4, 1);
}

.modal-overlay.active .modal-card {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    border-bottom: 1px solid rgba(255, 119, 0, 0.3);
    padding-bottom: 10px;
}

.modal-title {
    font-size: 18px;
    font-weight: 800;
    color: #ffaa33;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.5px;
}

.modal-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 119, 0, 0.4);
    border-radius: 8px;
    color: #ffcc99;
    font-size: 15px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.modal-close:hover {
    background: #ff4400;
    color: #ffffff;
    transform: scale(1.1);
}

.modal-input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(10, 2, 0, 0.8);
    border: 1.5px solid #8f2d08;
    border-radius: 10px;
    color: #ffffff;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-input:focus {
    border-color: #ff8800;
    box-shadow: 0 0 14px rgba(255, 136, 0, 0.5);
}

.modal-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 18px 0;
}

.preset-chip {
    background: rgba(255, 102, 0, 0.12);
    border: 1px solid rgba(255, 102, 0, 0.35);
    border-radius: 14px;
    padding: 5px 12px;
    font-size: 11.5px;
    color: #ffbb66;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}

.preset-chip:hover {
    background: #ff6600;
    color: #ffffff;
    transform: translateY(-1px);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-primary {
    background: linear-gradient(135deg, #ff7700, #c43300);
    border: 1px solid #ffa333;
    border-radius: 10px;
    color: #ffffff;
    font-weight: 800;
    font-size: 14px;
    padding: 10px 22px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(255, 85, 0, 0.4);
    transition: transform 0.15s, filter 0.15s;
}

.btn-primary:hover {
    filter: brightness(1.15);
    transform: scale(1.03);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: #ffccaa;
    font-weight: 700;
    font-size: 14px;
    padding: 10px 18px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.16);
}


