/* ========================================================
   VIOLET DIGITAL SPEEDOMETER — JGVRP HUD
   Pixel-accurate implementation of Figma Node 2:2 (822 × 467)
   ======================================================== */

:root {
    --hud-scale: 0.56;
    --violet-primary: #6025EE;
    --violet-bright: #7651E9;
    --violet-tick: #5922EF;
    --violet-border: #4716B2;
    --ink-dark: #08090B;
    --ink-status: #101114;
    --panel-bg: rgba(245, 245, 247, 0.96);
}

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

html, body {
    width: 100vw;
    height: 100vh;
    background: transparent;
    overflow: hidden;
    font-family: 'Roboto', system-ui, -apple-system, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

.asset-img {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ========================================================
   HUD CONTAINER — Bottom Right Corner (1920x1080)
   ======================================================== */
.hud-container {
    position: fixed;
    right: 25px;
    bottom: 25px;
    width: 822px;
    height: 467px;
    transform-origin: bottom right;
    transform: scale(var(--hud-scale));
    z-index: 9000;
    pointer-events: none;
}

.speedometer-board {
    position: relative;
    width: 822px;
    height: 467px;
    pointer-events: none;
}

/* Instrument Panel Surface (Figma 2:3) */
.instrument-panel {
    position: absolute;
    left: 17px;
    top: 34px;
    width: 788px;
    height: 397px;
    border-radius: 42px;
    background: var(--panel-bg);
    border: 1.5px solid rgba(118, 81, 233, 0.16);
    box-shadow:
        0 14px 36px rgba(10, 10, 22, 0.22),
        0 0 0 1px rgba(255, 255, 255, 0.65) inset;
    pointer-events: auto;
}

/* ========================================================
   TURN SIGNALS (Figma 2:8)
   ======================================================== */
.turn-signals-layer {
    position: absolute;
    left: 48px;
    top: 55px;
    width: 728px;
    height: 26px;
    z-index: 25;
    pointer-events: none;
}

.turn-arrows-svg {
    display: block;
    width: 728px;
    height: 26px;
    overflow: visible;
}

.turn-arrow {
    fill: #070809;
    opacity: 0.22;
    transition: fill 0.18s ease, opacity 0.18s ease, filter 0.18s ease;
}

.turn-arrow.active {
    fill: #6025EE;
    opacity: 1;
    filter: drop-shadow(0 0 8px rgba(96, 37, 238, 0.85));
    animation: turn-arrow-blink 0.72s ease-in-out infinite;
}

@keyframes turn-arrow-blink {
    0%, 100% { opacity: 1; filter: drop-shadow(0 0 9px rgba(96, 37, 238, 0.9)); }
    50% { opacity: 0.25; filter: drop-shadow(0 0 2px rgba(96, 37, 238, 0.25)); }
}

/* ========================================================
   1. SPEED GAUGE (Figma 2:4)
   ======================================================== */
.speed-gauge {
    position: absolute;
    left: 40px;
    top: 55px;
    width: 295px;
    height: 240px;
    z-index: 10;
}

.digital-display-depth {
    position: absolute;
    left: 0;
    top: 0;
    width: 295px;
    height: 240px;
}

.speed-scale-wrap {
    position: absolute;
    left: 0;
    top: 0;
    width: 295px;
    height: 240px;
    overflow: visible;
}

.speed-scale-svg {
    position: absolute;
    left: 4.38px;
    top: 0.39px;
    width: 286.886px;
    height: 216.739px;
    display: block;
    overflow: visible;
}

#speed-ticks-group path {
    transition: stroke 0.08s linear;
}

/* Speed Dial Numbers (Figma 2:197..2:203) */
.speed-num {
    position: absolute;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 17.66px;
    line-height: 1;
    color: var(--ink-dark);
    white-space: nowrap;
}

.sn-0   { left: 58.03px;  top: 181.54px; }
.sn-40  { left: 41.89px;  top: 115.57px; }
.sn-80  { left: 75.39px;  top: 57.56px;  }
.sn-120 { left: 147.5px;  top: 41px; transform: translateX(-50%); }
.sn-160 { left: 198.29px; top: 57.56px;  }
.sn-200 { left: 230.29px; top: 115.57px; }
.sn-240 { left: 218.65px; top: 181.54px; }

.speed-title {
    position: absolute;
    left: 147.5px;
    top: 25px;
    transform: translateX(-50%);
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
    color: var(--ink-dark);
    letter-spacing: 0.6px;
    white-space: nowrap;
}

.digital-speed {
    position: absolute;
    left: 147.5px;
    top: 70.34px;
    transform: translateX(-50%);
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 97.934px;
    line-height: 0.96;
    color: var(--ink-dark);
    text-align: center;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

.digital-speed.overspeed {
    color: #5922EF;
    text-shadow: 0 0 18px rgba(89, 34, 239, 0.38);
}

.speed-unit {
    position: absolute;
    left: 147.5px;
    top: 174.11px;
    transform: translateX(-50%);
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 14.449px;
    line-height: 1;
    color: var(--ink-dark);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* ========================================================
   2. FUEL GAUGE (Figma 2:5)
   ======================================================== */
.fuel-gauge {
    position: absolute;
    left: 343px;
    top: 109px;
    width: 133px;
    height: 73px;
    z-index: 12;
}

.fuel-scale-svg {
    position: absolute;
    left: 0;
    top: 0;
    width: 133px;
    height: 73px;
    display: block;
}

#fuel-dots-group path {
    transition: fill 0.25s ease, opacity 0.25s ease, filter 0.25s ease;
}

.fuel-gauge.low-fuel #fuel {
    color: #D92652;
    animation: low-fuel-pulse 0.9s ease-in-out infinite;
}

@keyframes low-fuel-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.fuel-value {
    position: absolute;
    left: 66.5px;
    top: 26px;
    transform: translateX(-50%);
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 27px;
    line-height: 1;
    color: var(--ink-dark);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.fuel-label {
    position: absolute;
    left: 66.5px;
    top: 56.26px;
    transform: translateX(-50%);
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 12.844px;
    line-height: 1;
    color: var(--ink-dark);
    white-space: nowrap;
}

.fuel-e {
    position: absolute;
    left: 19.91px;
    top: 51.55px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 12.844px;
    line-height: 1;
    color: var(--ink-dark);
}

.fuel-f {
    position: absolute;
    left: 111.56px;
    top: 43.55px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 12.844px;
    line-height: 1;
    color: var(--ink-dark);
}

/* ========================================================
   CENTER MUSIC CONTROL BUTTON (YouTube Music Integration)
   ======================================================== */
.music-control-tile {
    position: absolute;
    left: 363px;
    top: 224px;
    width: 94px;
    height: 76px;
    border-radius: 18px;
    background: #FFFFFF;
    border: 1.5px solid rgba(118, 81, 233, 0.26);
    box-shadow: 0 6px 18px rgba(17, 18, 20, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer !important;
    pointer-events: auto !important;
    z-index: 20;
    outline: none;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-color 0.2s ease,
                box-shadow 0.2s ease,
                background-color 0.2s ease;
}

.music-control-tile:hover {
    transform: translateY(-2px) scale(1.04);
    border-color: #6025EE;
    box-shadow: 0 8px 22px rgba(96, 37, 238, 0.22);
}

.music-control-tile:active {
    transform: scale(0.95);
}

.music-tile-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: rgba(96, 37, 238, 0.08);
    color: #101114;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.music-tile-status {
    display: flex;
    align-items: center;
    gap: 5px;
}

.music-tile-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #111214;
    box-shadow: 0 0 0 3px rgba(17, 18, 20, 0.08);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.music-tile-label {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.7px;
    color: #101114;
    transition: color 0.2s ease;
}

/* Active / Playing State — Glowing Violet matching Figma */
.music-control-tile.active {
    background: #F6F2FF;
    border-color: #6025EE;
    box-shadow: 0 6px 20px rgba(96, 37, 238, 0.28);
}

.music-control-tile.active .music-tile-icon-wrap {
    background: #6025EE;
    color: #FFFFFF;
    box-shadow: 0 0 14px rgba(96, 37, 238, 0.55);
}

.music-control-tile.active .music-tile-dot {
    background: #6025EE;
    box-shadow: 0 0 0 4px rgba(96, 37, 238, 0.2), 0 0 8px rgba(96, 37, 238, 0.8);
}

.music-control-tile.active .music-tile-label {
    color: #6025EE;
}

/* ========================================================
   3. RPM GAUGE (Figma 2:6 + Motion 2:230 / 2:238)
   ======================================================== */
.rpm-gauge {
    position: absolute;
    left: 503px;
    top: 64px;
    width: 269px;
    height: 225px;
    z-index: 10;
}

.rpm-arc-wrap {
    position: absolute;
    left: 0;
    top: 0;
    width: 269px;
    height: 225px;
    overflow: visible;
}

.rpm-recess-layer {
    position: absolute;
    left: 7.54px;
    top: 6.64px;
    width: 256.875px;
    height: 196.27px;
}

.rpm-track-layer {
    position: absolute;
    left: 8.34px;
    top: 7.44px;
    width: 255.27px;
    height: 194.664px;
}

.rpm-dynamic-svg {
    position: absolute;
    left: 8.34px;
    top: 7.44px;
    width: 255.27px;
    height: 194.664px;
    display: block;
    overflow: visible;
}

/* Figma get_motion_context Node 2:230 breathing opacity */
.rpm-glow-animated {
    animation: kf_2_230_opacity_0 2.2s linear infinite;
}

@keyframes kf_2_230_opacity_0 {
    0% {
        animation-timing-function: ease-in-out;
        opacity: 1;
    }
    50% {
        animation-timing-function: ease-in-out;
        opacity: 0.6;
    }
    100% {
        opacity: 1;
    }
}

/* RPM Scale Numbers 0..10 (Figma 2:240..2:250) */
.rpm-num {
    position: absolute;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 17.66px;
    line-height: 1;
    color: var(--ink-dark);
    white-space: nowrap;
}

.rn-0  { left: 51.73px;  top: 169.33px; }
.rn-1  { left: 41.97px;  top: 133.14px; }
.rn-2  { left: 44.44px;  top: 95.3px;   }
.rn-3  { left: 63.47px;  top: 62.34px;  }
.rn-4  { left: 93.76px;  top: 39.98px;  }
.rn-5  { left: 131.48px; top: 32.07px;  }
.rn-6  { left: 168.2px;  top: 39.98px;  }
.rn-7  { left: 199.98px; top: 62.34px;  }
.rn-8  { left: 218.01px; top: 95.3px;   }
.rn-9  { left: 221.99px; top: 133.14px; }
.rn-10 { left: 207.23px; top: 169.33px; }

/* Gear Hexagon (Figma 2:251) */
.gear-hexagon-box {
    position: absolute;
    left: 0;
    top: 0;
    width: 269px;
    height: 225px;
    pointer-events: none;
}

.gear-value {
    position: absolute;
    left: 135.98px;
    top: 130.26px;
    transform: translate(-50%, -50%);
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 46px;
    line-height: 1;
    color: var(--ink-dark);
    text-align: center;
    white-space: nowrap;
}

.rpm-value {
    position: absolute;
    left: 135.98px;
    top: 159.74px;
    transform: translateX(-50%);
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 36.926px;
    line-height: 1;
    color: var(--ink-dark);
    text-align: center;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.rpm-label {
    position: absolute;
    left: 135.98px;
    top: 197.82px;
    transform: translateX(-50%);
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 16.055px;
    line-height: 1;
    color: var(--ink-dark);
    white-space: nowrap;
}

/* ========================================================
   4. BOTTOM VEHICLE STATUS BAR (Figma 2:7)
   Dynamic Violet Active Dots & Changing Labels (On / Off / etc.)
   ======================================================== */
.vehicle-status {
    position: absolute;
    left: 38px;
    top: 351px;
    width: 747px;
    height: 67px;
    z-index: 15;
    display: grid;
    grid-template-columns: 112px 124px 126px 126px 120px 1fr;
    align-items: start;
    padding-top: 14px;
}

.violet-divider {
    position: absolute;
    left: 0;
    top: 0;
    width: 747px;
    height: 1.3px;
    background: var(--violet-bright);
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

.status-item.clickable {
    cursor: pointer !important;
    pointer-events: auto !important;
    border-radius: 10px;
    transition: transform 0.15s ease;
}

.status-item.clickable:hover {
    transform: translateY(-1px);
}

.status-label {
    font-family: 'Roboto', sans-serif;
    font-weight: 400;
    font-size: 16.697px;
    line-height: 1.15;
    color: var(--ink-status);
    white-space: nowrap;
}

.status-value-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 26px;
}

.status-value {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 20.55px;
    line-height: 1;
    color: var(--ink-status);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s ease;
}

/* Indicator Dot + 3 Layered Figma Halos */
.status-dot-wrap {
    position: relative;
    width: 25.688px;
    height: 25.688px;
    flex-shrink: 0;
    display: inline-block;
}

.dot-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: block;
    transition: opacity 0.22s ease, transform 0.22s ease, filter 0.22s ease;
}

.dot-layer.halo-lg { width: 25.688px; height: 25.688px; }
.dot-layer.halo-md { width: 19.266px; height: 19.266px; }
.dot-layer.halo-sm { width: 14.449px; height: 14.449px; }
.dot-layer.dot-core { width: 10.596px; height: 10.596px; }

/* Default OFF state: Show Dark Figma Dot, hide Violet Dot */
.status-item .dot-on {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
}

.status-item .dot-off {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Active ON state: Show Glowing Violet Figma Dot + Halos */
.status-item.is-on .dot-on {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.status-item.is-on .dot-on.dot-core {
    filter: drop-shadow(0 0 6px rgba(96, 37, 238, 0.75));
}

.status-item.is-on .dot-off {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
}

/* High Beam extra vivid glow */
.status-item.is-highbeam .dot-on.dot-core {
    filter: drop-shadow(0 0 10px rgba(96, 37, 238, 1)) brightness(1.15);
}

/* Pulsing dot when turn indicator is active */
.status-item.is-blinking .dot-on {
    animation: dot-violet-blink 0.72s ease-in-out infinite;
}

@keyframes dot-violet-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Low Health warning highlight */
.status-item.is-warning .status-value {
    color: #D92652;
}

/* Reduced motion support (accessibility) */
@media (prefers-reduced-motion: reduce) {
    .rpm-glow-animated,
    .turn-arrow.active,
    .status-item.is-blinking .dot-on,
    .fuel-gauge.low-fuel #fuel {
        animation: none !important;
    }
}

/* ========================================================
   SPEEDOMETER SIZE SETTINGS (GEAR BUTTON & POPUP SLIDER)
   Violet Theme matching Dashboard
   ======================================================== */
.speedo-settings-btn {
    position: fixed;
    right: 25px;
    bottom: calc(25px + (467px * var(--hud-scale)) + 12px);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #141221;
    border: 2px solid rgba(118, 81, 233, 0.55);
    color: #C7B8FF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer !important;
    pointer-events: auto !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 12px rgba(96, 37, 238, 0.3);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
    z-index: 99999;
    outline: none;
}

.speedo-settings-btn:hover {
    transform: scale(1.12) rotate(45deg);
    background: #1F1B33;
    border-color: #7651E9;
    color: #FFFFFF;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55), 0 0 18px rgba(118, 81, 233, 0.65);
}

.speedo-settings-btn.active {
    background: #6025EE;
    border-color: #D8CCFF;
    color: #FFFFFF;
    transform: scale(1.05) rotate(90deg);
    box-shadow: 0 0 18px rgba(96, 37, 238, 0.8);
}

.speedo-settings-btn:active {
    transform: scale(0.94);
}

.speedo-settings-popup {
    position: fixed;
    right: 25px;
    bottom: min(calc(25px + (467px * var(--hud-scale)) + 60px), calc(100vh - 340px));
    width: 310px;
    max-width: calc(100vw - 40px);
    background: #141221;
    border: 2px solid #2F284D;
    border-radius: 18px;
    padding: 16px 18px;
    color: #F4F2FA;
    font-family: 'Roboto', system-ui, sans-serif;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 0 22px rgba(96, 37, 238, 0.3);
    z-index: 100000;
    pointer-events: auto !important;
    transition: opacity 0.22s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.22s;
    user-select: none;
}

.speedo-settings-popup.closed {
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.96);
    pointer-events: none !important;
}

.speedo-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(118, 81, 233, 0.25);
    margin-bottom: 14px;
    cursor: grab;
}

.speedo-settings-header:active {
    cursor: grabbing;
}

.speedo-settings-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14.5px;
    font-weight: 700;
    color: #FFFFFF;
}

.speedo-drag-grip {
    color: #7D749E;
    font-size: 16px;
    line-height: 1;
}

.speedo-settings-close-btn {
    background: #221D38;
    border: 1px solid #3A315E;
    color: #CFC6EC;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.18s ease;
    outline: none;
}

.speedo-settings-close-btn:hover {
    background: #E11D48;
    border-color: #E11D48;
    color: #FFFFFF;
}

.speedo-setting-row {
    margin-bottom: 14px;
}

.speedo-setting-row:last-child {
    margin-bottom: 0;
}

.setting-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.setting-title-text {
    font-size: 13px;
    font-weight: 600;
    color: #E3DEF5;
}

.setting-val-badge {
    background: #231C3E;
    border: 1px solid #7651E9;
    color: #D2C4FF;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 12px;
}

.speedo-scale-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: #211C38;
    border-radius: 6px;
    outline: none;
    border: 1px solid #39305C;
    cursor: pointer;
}

.speedo-scale-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: #7651E9;
    border: 2.5px solid #FFFFFF;
    box-shadow: 0 0 10px rgba(118, 81, 233, 0.85);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.speedo-scale-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.scale-tick-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10.5px;
    color: #8E85AD;
    margin-top: 5px;
    font-weight: 600;
}

.setting-sub-heading {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #A89EC9;
    margin-bottom: 6px;
}

.speedo-scale-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.scale-preset-btn {
    background: #201B36;
    border: 1px solid #39315C;
    border-radius: 8px;
    padding: 6px 0;
    font-size: 11px;
    font-weight: 700;
    color: #D2C9EC;
    cursor: pointer;
    text-align: center;
    transition: all 0.16s ease;
    outline: none;
}

.scale-preset-btn:hover {
    background: #2E264F;
    border-color: #7651E9;
    color: #FFFFFF;
}

.scale-preset-btn.active {
    background: #6025EE;
    border-color: #A68BFF;
    color: #FFFFFF;
    box-shadow: 0 0 10px rgba(96, 37, 238, 0.55);
}

.speedo-reset-btn {
    width: 100%;
    background: #201B36;
    border: 1px solid #39315C;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    color: #E3DEF5;
    cursor: pointer;
    transition: all 0.18s ease;
    outline: none;
}

.speedo-reset-btn:hover {
    background: #6025EE;
    border-color: #A68BFF;
    color: #FFFFFF;
}
