:root {
    --bg-hud: rgba(8, 13, 24, 0.90);
    --bg-card: rgba(15, 24, 42, 0.88);
    --border-hud: rgba(0, 210, 255, 0.30);
    --accent-primary: #00d2ff;
    --accent-secondary: #3b82f6;
    --accent-glow: rgba(0, 210, 255, 0.45);
    --ok-color: #10b981;
    --warn-color: #f59e0b;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-dim: #64748b;
    --hud-scale: 1;
}

/* Theme 2: Cyberpunk Outlaw (Inspired by kanaya.pages.dev) */
body[data-theme="cyberpunk"] {
    --bg-hud: rgba(14, 7, 22, 0.92);
    --bg-card: rgba(28, 12, 42, 0.88);
    --border-hud: rgba(255, 0, 127, 0.40);
    --accent-primary: #fcee0a;
    --accent-secondary: #ff007f;
    --accent-glow: rgba(255, 0, 127, 0.55);
}

/* Theme 3: NFSU2 Street Tuner (Inspired by yayanigorpunya.pages.dev) */
body[data-theme="nfsu2"] {
    --bg-hud: rgba(7, 16, 12, 0.92);
    --bg-card: rgba(14, 28, 20, 0.88);
    --border-hud: rgba(16, 185, 129, 0.38);
    --accent-primary: #34d399;
    --accent-secondary: #f59e0b;
    --accent-glow: rgba(52, 211, 153, 0.45);
}

/* Theme 4: GT3 Track Pro */
body[data-theme="gt3-red"] {
    --bg-hud: rgba(18, 9, 11, 0.92);
    --bg-card: rgba(32, 14, 18, 0.88);
    --border-hud: rgba(244, 63, 94, 0.38);
    --accent-primary: #fb7185;
    --accent-secondary: #e11d48;
    --accent-glow: rgba(244, 63, 94, 0.45);
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-drag: none;
    margin: 0;
    padding: 0;
}

body {
    background-color: transparent !important;
    font-family: 'Rajdhani', sans-serif;
    color: var(--text-main);
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

.jgvrp-legacy-dom {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    opacity: 0;
    pointer-events: none;
}

/* Floating Quick Toolbar */
.hud-toolbar {
    position: fixed;
    bottom: 245px;
    right: 18px;
    display: flex;
    gap: 6px;
    opacity: 0.20;
    transition: opacity 0.25s ease;
    z-index: 90;
}

.hud-toolbar:hover,
.hud-toolbar.active-bar {
    opacity: 1;
}

.tool-btn {
    background: rgba(9, 14, 26, 0.92);
    color: var(--accent-primary);
    border: 1px solid var(--border-hud);
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    font-weight: 700;
    padding: 4px 9px;
    cursor: pointer;
    clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
    transition: all 0.18s ease;
}

.tool-btn:hover,
.tool-btn.active {
    background: var(--accent-primary);
    color: #050811;
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Speedometer Wrapper (Supports Dynamic Scaling) */
.speedometer-wrapper {
    position: fixed;
    bottom: 16px;
    right: 16px;
    transform: scale(var(--hud-scale));
    transform-origin: bottom right;
    transition: transform 0.18s ease;
    z-index: 50;
}

.tactical-hud {
    position: relative;
    width: 430px;
    background: var(--bg-hud);
    border: 1px solid var(--border-hud);
    clip-path: polygon(
        14px 0,
        calc(100% - 14px) 0,
        100% 14px,
        100% calc(100% - 14px),
        calc(100% - 14px) 100%,
        14px 100%,
        0 calc(100% - 14px),
        0 14px
    );
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.78), inset 0 0 26px rgba(0, 210, 255, 0.06);
    padding: 10px 14px 12px 14px;
    overflow: hidden;
}

/* Scanline texture */
.tactical-hud::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.014) 0px,
        rgba(255, 255, 255, 0.014) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 1;
}

/* Code-3 Police Strobe Bar */
.pursuit-lightbar {
    display: grid;
    grid-template-columns: 1fr 24px 1fr;
    height: 4px;
    margin: -10px -14px 8px -14px;
    background: rgba(0, 0, 0, 0.55);
}

.strobe-red {
    background: linear-gradient(90deg, transparent, #ff1e42, #ff758f);
    opacity: 0.35;
}

.strobe-blue {
    background: linear-gradient(90deg, #60a5fa, #0077ff, transparent);
    opacity: 0.35;
}

.pursuit-lightbar.code3-active .strobe-red {
    animation: strobeRed 0.4s infinite alternate;
}

.pursuit-lightbar.code3-active .strobe-blue {
    animation: strobeBlue 0.4s infinite alternate;
}

@keyframes strobeRed {
    0%, 45% { opacity: 1; filter: brightness(1.5); box-shadow: 0 0 14px #ff1e42; }
    55%, 100% { opacity: 0.15; }
}

@keyframes strobeBlue {
    0%, 45% { opacity: 0.15; }
    55%, 100% { opacity: 1; filter: brightness(1.5); box-shadow: 0 0 14px #0077ff; }
}

/* Header */
.hud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-hud);
    padding-bottom: 5px;
    margin-bottom: 8px;
    position: relative;
    z-index: 2;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-badge {
    font-family: 'Orbitron', sans-serif;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 1.4px;
    color: var(--accent-primary);
}

.shift-pill {
    font-family: 'Orbitron', sans-serif;
    font-size: 8.5px;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 2px;
    background: rgba(239, 68, 68, 0.12);
    color: rgba(239, 68, 68, 0.35);
    border: 1px solid rgba(239, 68, 68, 0.22);
    letter-spacing: 0.8px;
}

.shift-pill.active {
    background: var(--danger);
    color: #fff;
    border-color: #fff;
    box-shadow: 0 0 12px var(--danger);
    animation: blinkFast 0.15s infinite alternate;
}

.turn-ind {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.15);
    transition: all 0.12s ease;
}

.turn-ind.active {
    color: var(--warn-color);
    text-shadow: 0 0 10px var(--warn-color);
    transform: scale(1.2);
}

.odo-chip {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    font-weight: 700;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 6px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Core Grid */
.hud-main-grid {
    display: grid;
    grid-template-columns: 174px 1fr;
    gap: 12px;
    align-items: center;
    position: relative;
    z-index: 2;
}

.gauge-box {
    position: relative;
    width: 172px;
    height: 172px;
}

.tach-svg {
    width: 100%;
    height: 100%;
    transform: rotate(150deg);
}

.ring-decor {
    fill: none;
    stroke: var(--border-hud);
    stroke-width: 1.5;
    stroke-dasharray: 4 7;
}

.tach-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 11;
}

.tach-redzone {
    fill: none;
    stroke: rgba(239, 68, 68, 0.25);
    stroke-width: 11;
}

.tach-fill {
    fill: none;
    stroke-width: 11;
    transition: stroke-dashoffset 0.07s linear;
}

.gauge-center-info {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 6px;
}

.gear-box {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-card);
    border: 1px solid var(--border-hud);
    padding: 1px 8px;
    margin-bottom: 2px;
    clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
}

.gear-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 7.5px;
    color: var(--text-dim);
}

.gear-val {
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    font-weight: 900;
    color: var(--accent-primary);
}

.gear-box.redline {
    background: var(--danger);
    border-color: #fff;
}
.gear-box.redline .gear-label,
.gear-box.redline .gear-val {
    color: #fff;
}

.speed-digital {
    position: relative;
    display: flex;
    align-items: baseline;
    justify-content: center;
    line-height: 1;
    margin: 2px 0;
}

.speed-ghost {
    font-family: 'Orbitron', monospace;
    font-size: 38px;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.04);
    letter-spacing: 1px;
}

.speed-num {
    position: absolute;
    right: 0;
    font-family: 'Orbitron', monospace;
    font-size: 38px;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: 1px;
    text-shadow: 0 0 15px var(--accent-glow);
}

.unit-sub-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.unit-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    font-weight: 800;
    color: var(--accent-primary);
    background: rgba(0, 210, 255, 0.1);
    border: 1px solid var(--border-hud);
    padding: 1px 6px;
    border-radius: 2px;
}

.rpm-mini {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8.5px;
    color: #94a3b8;
}

/* Telemetry Right Section */
.telemetry-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-pills-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.stat-pill {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
}

.pill-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    color: var(--text-dim);
}

.pill-state {
    font-family: 'Orbitron', sans-serif;
    font-size: 9.5px;
    font-weight: 800;
    color: var(--text-dim);
    margin-top: 1px;
}

.stat-pill.on-ok {
    border-color: rgba(16, 185, 129, 0.55);
    box-shadow: inset 0 0 10px rgba(16, 185, 129, 0.16);
}
.stat-pill.on-ok .pill-state {
    color: var(--ok-color);
}

.stat-pill.on-high {
    border-color: var(--accent-primary);
    box-shadow: inset 0 0 10px var(--accent-glow);
}
.stat-pill.on-high .pill-state {
    color: var(--accent-primary);
}

.stat-pill.on-warn {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.18);
    animation: blinkFast 0.4s infinite alternate;
}
.stat-pill.on-warn .pill-label,
.stat-pill.on-warn .pill-state {
    color: var(--danger);
}

/* Segmented Bars */
.tele-bar-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tele-bar-top {
    display: flex;
    justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 700;
}

.tele-name {
    color: #94a3b8;
}

.tele-val {
    color: var(--text-main);
}

.seg-bar-bg {
    position: relative;
    height: 8px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.seg-bar-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent 0px,
        transparent 8px,
        rgba(8, 13, 24, 0.85) 8px,
        rgba(8, 13, 24, 0.85) 10px
    );
    pointer-events: none;
}

.seg-bar-fill {
    height: 100%;
    transition: width 0.09s linear;
}

.rpm-fill {
    background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
    box-shadow: 0 0 10px var(--accent-glow);
}

.fuel-fill {
    background: linear-gradient(90deg, #0284c7, var(--accent-primary));
}

.health-fill {
    background: linear-gradient(90deg, #059669, var(--ok-color));
}

.tele-bar-item.critical .tele-val {
    color: var(--danger);
    animation: blinkFast 0.35s infinite alternate;
}
.tele-bar-item.critical .seg-bar-fill {
    background: var(--danger);
}

/* Corner Brackets */
.hud-corner {
    position: absolute;
    width: 9px;
    height: 9px;
    border-color: var(--accent-primary);
    pointer-events: none;
}
.hud-corner.tl { top: 5px; left: 4px; border-top: 2px solid; border-left: 2px solid; }
.hud-corner.tr { top: 5px; right: 4px; border-top: 2px solid; border-right: 2px solid; }
.hud-corner.bl { bottom: 4px; left: 4px; border-bottom: 2px solid; border-left: 2px solid; }
.hud-corner.br { bottom: 4px; right: 4px; border-bottom: 2px solid; border-right: 2px solid; }

/* IN-VEHICLE YOUTUBE MUSIC PLAYER WIDGET */
.music-widget {
    position: fixed;
    bottom: 280px;
    right: 18px;
    width: 330px;
    background: var(--bg-hud);
    border: 1px solid var(--border-hud);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8);
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
    z-index: 95;
}

.music-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 7px 10px;
    cursor: move;
    border-bottom: 1px solid var(--border-hud);
}

.music-brand {
    display: flex;
    align-items: center;
    gap: 7px;
}

.drag-dots {
    color: var(--text-dim);
    font-size: 12px;
}

.music-title-bar {
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    font-weight: 800;
    color: var(--accent-primary);
    letter-spacing: 1px;
}

.eq-bars {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 11px;
}

.eq-bars span {
    width: 2.5px;
    height: 3px;
    background: var(--accent-primary);
    transition: height 0.15s ease;
}

.eq-bars.playing span:nth-child(1) { animation: eqBounce 0.45s infinite alternate; }
.eq-bars.playing span:nth-child(2) { animation: eqBounce 0.32s infinite alternate 0.1s; }
.eq-bars.playing span:nth-child(3) { animation: eqBounce 0.52s infinite alternate 0.2s; }
.eq-bars.playing span:nth-child(4) { animation: eqBounce 0.38s infinite alternate 0.15s; }

@keyframes eqBounce {
    0% { height: 3px; }
    100% { height: 11px; }
}

.music-win-btns {
    display: flex;
    gap: 4px;
}

.win-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.15);
    width: 20px;
    height: 20px;
    font-size: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.win-btn.close:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.music-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.music-input-row {
    display: flex;
    gap: 5px;
}

.yt-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid var(--border-hud);
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    padding: 5px 8px;
    outline: none;
}

.yt-load-btn {
    background: var(--accent-primary);
    color: #050811;
    border: none;
    font-family: 'Orbitron', sans-serif;
    font-size: 9.5px;
    font-weight: 800;
    padding: 0 10px;
    cursor: pointer;
}

.preset-chips {
    display: flex;
    gap: 5px;
}

.chip-btn {
    flex: 1;
    background: var(--bg-card);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    padding: 4px;
    cursor: pointer;
}

.chip-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.now-playing-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 7px 9px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.np-status {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    color: var(--accent-primary);
}

.np-track {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.ctrl-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-hud);
    color: #fff;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 11px;
}

.vol-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
}

.vol-slider {
    width: 100%;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.yt-frame-wrap {
    width: 100%;
    height: 110px;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

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

/* SETTINGS MODAL */
.settings-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 120;
}

.settings-card {
    width: 390px;
    background: var(--bg-hud);
    border: 1px solid var(--border-hud);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85);
    clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-hud);
}

.settings-header h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    color: var(--accent-primary);
}

.settings-content {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.setting-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-row label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    font-weight: 700;
    color: #cbd5e1;
}

.row-top {
    display: flex;
    justify-content: space-between;
}

.scale-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--accent-primary);
    font-weight: 800;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.theme-opt, .unit-opt, .toggle-pill {
    background: var(--bg-card);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    font-weight: 700;
    padding: 6px;
    cursor: pointer;
}

.theme-opt.active, .unit-opt.active, .toggle-pill.active {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(0, 210, 255, 0.12);
}

.scale-slider {
    width: 100%;
    accent-color: var(--accent-primary);
}

.scale-Presets {
    display: flex;
    justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    color: var(--text-dim);
}

.setting-row.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.unit-btns, .audio-toggles {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.shortcut-hint {
    font-size: 10.5px;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.04);
    padding: 7px;
    border-left: 2px solid var(--accent-primary);
}

@keyframes blinkFast {
    from { opacity: 1; }
    to { opacity: 0.3; }
}
