:root {
    --bg-color: #000000;
    --theme-color: #00aaff;
    --theme-rgb: 0, 170, 255;
    --danger-rgb: 255, 0, 0;
    --text-white: #ffffff;
    --accent-green: #00ff40;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background-color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Rajdhani', sans-serif;
    overflow: hidden;
    perspective: 1000px;
}

/* Hardware Bezel Simulation */
.cluster-wrapper {
    width: 95vw;
    max-width: 1400px;
    aspect-ratio: 22 / 9;
    position: relative;
    filter: drop-shadow(0 20px 40px rgba(0,0,0,0.9)) drop-shadow(0 0 15px rgba(var(--theme-rgb), 0.2));
}

.cluster-svg-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* HTML Content Overlay */
.cluster-screen-content {
    position: absolute;
    top: 5%;
    left: 4%;
    width: 92%;
    height: 90%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 10;
}

/* Gauges Container */
.gauge-container {
    width: 32%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* SVG styling for Gauges */
.gauge-container svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.svg-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 60%;
}

/* Typography */
.val-large {
    font-family: 'Rajdhani', sans-serif;
    font-size: 7vw;
    font-style: italic;
    font-weight: 700;
    color: var(--text-white);
    line-height: 1;
    text-shadow: 0 0 20px rgba(255,255,255,0.4), 0 0 40px rgba(var(--theme-rgb), 0.6);
    margin: 5px 0;
}

.val-label {
    font-size: 0.9vw;
    font-weight: 600;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.8);
}

/* Throttle / Brake bars, sitting in the gap at the bottom of each ring */
.aux-bar-wrap {
    position: absolute;
    bottom: 11%;
    left: 50%;
    transform: translateX(-50%);
    width: 44%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    z-index: 15;
}

.aux-bar-label {
    font-size: 0.7vw;
    font-weight: 600;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.55);
}

.aux-bar-track {
    width: 100%;
    height: 0.6vw;
    min-height: 6px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    overflow: hidden;
}

.aux-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 6px;
    transition: width 0.08s linear;
}

.aux-bar-fill.throttle {
    background: rgb(var(--theme-rgb));
    box-shadow: 0 0 8px rgba(var(--theme-rgb), 0.8);
}

.aux-bar-fill.brake {
    background: rgb(var(--danger-rgb));
    box-shadow: 0 0 8px rgba(var(--danger-rgb), 0.8);
}

/* Shift Lights */
.shift-lights {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1.2vw;
    z-index: 20;
}

.shift-dot {
    width: 1.8vw;
    height: 1.8vw;
    border-radius: 50%;
    background-color: #1a1a1a;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.9);
    transition: background-color 0.1s, box-shadow 0.1s;
}

.shift-dot.green { background-color: #00ff00; box-shadow: 0 0 12px #00ff00; }
.shift-dot.yellow { background-color: #ffff00; box-shadow: 0 0 12px #ffff00; }
.shift-dot.red { background-color: #ff0000; box-shadow: 0 0 18px #ff0000; }

/* Center Console (Gear) */
.center-console {
    width: 24%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 5;
}

.gear-display {
    font-family: 'Rajdhani', sans-serif;
    font-size: 12vw;
    font-style: italic;
    font-weight: 700;
    color: var(--text-white);
    text-shadow: 0 0 20px rgba(255,255,255,0.4), 0 0 40px rgba(var(--theme-rgb), 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Connection status pill */
.conn-status {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    font-family: 'Rajdhani', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.85);
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.15);
    padding: 6px 12px 6px 8px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(4px);
}

.conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #555;
    flex-shrink: 0;
}

.conn-status.live .conn-dot { background: #00ff66; box-shadow: 0 0 6px #00ff66; }
.conn-status.connecting .conn-dot { background: #ffcc00; box-shadow: 0 0 6px #ffcc00; animation: pulse 1s infinite; }
.conn-status.error .conn-dot { background: #ff3333; box-shadow: 0 0 6px #ff3333; }
.conn-status.demo .conn-dot { background: var(--theme-color); }
.conn-status.static .conn-dot { background: #888; }
.conn-status.csv .conn-dot { background: #cc66ff; box-shadow: 0 0 6px #cc66ff; }
.conn-status.manual .conn-dot { background: #ffaa00; box-shadow: 0 0 6px #ffaa00; }
.conn-status.auto .conn-dot { background: #33dd88; box-shadow: 0 0 6px #33dd88; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Settings toggle button */
.settings-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.85);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.settings-toggle:hover { background: rgba(0,0,0,0.75); }

/* Audio toggle button, mirrored on the other side of settings */
.audio-toggle {
    position: fixed;
    top: 16px;
    right: 62px;
    z-index: 100;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.5);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: color 0.15s, border-color 0.15s;
}
.audio-toggle:hover { background: rgba(0,0,0,0.75); }
.audio-toggle.on {
    color: rgb(var(--theme-rgb));
    border-color: rgba(var(--theme-rgb), 0.5);
}
.audio-toggle.loading { opacity: 0.6; cursor: wait; }

/* Settings panel */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: 'Rajdhani', sans-serif;
}
.settings-overlay.open { display: flex; }

.settings-panel {
    width: min(480px, 92vw);
    max-height: 88vh;
    overflow-y: auto;
    background: #0d0d0d;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 20px 24px 24px;
    color: #fff;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.settings-panel h2 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
}
.settings-panel .sub {
    margin: 0 0 18px;
    font-size: 13px;
    color: rgba(255,255,255,0.5);
}

.settings-section {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.settings-section:last-of-type { border-bottom: none; }

.settings-section h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--theme-color);
    margin: 0 0 10px;
}

.field-row {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}
.field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.field label {
    font-size: 12px;
    color: rgba(255,255,255,0.65);
}
.field input, .field select {
    background: #1a1a1a;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #fff;
    padding: 7px 8px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
}
.field input[type="color"] {
    padding: 2px;
    height: 34px;
}
.field-note {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    margin-top: -2px;
}

.csv-dropzone {
    position: relative;
    border: 2px dashed rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 20px 12px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}
.csv-dropzone:hover {
    border-color: rgba(255,255,255,0.35);
}
.csv-dropzone.dragover {
    border-color: var(--theme-color);
    background: rgba(var(--theme-rgb), 0.08);
}
.csv-dropzone-text {
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    pointer-events: none;
}
.csv-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.key-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
}
.key-table td {
    padding: 5px 0;
    color: rgba(255,255,255,0.8);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.key-table td:last-child {
    text-align: right;
}
.key-table kbd {
    display: inline-block;
    min-width: 18px;
    padding: 2px 7px;
    margin-left: 2px;
    background: #1a1a1a;
    border: 1px solid rgba(255,255,255,0.25);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 12px;
    color: #fff;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(255,255,255,0.8);
    margin-top: 10px;
    cursor: pointer;
}
.checkbox-field input {
    width: 16px;
    height: 16px;
}

.source-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}
.source-tab {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    border-radius: 6px;
    background: #1a1a1a;
    border: 1px solid rgba(255,255,255,0.12);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
}
.source-tab.active {
    background: rgba(var(--theme-rgb), 0.25);
    border-color: var(--theme-color);
    color: #fff;
}

.source-panel { display: none; }
.source-panel.active { display: block; }

.panel-buttons {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}
.btn {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: none;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    letter-spacing: 0.5px;
}
.btn-primary { background: var(--theme-color); color: #000; }
.btn-secondary { background: #262626; color: #fff; border: 1px solid rgba(255,255,255,0.15); }

.credits-line {
    margin-top: 14px;
    text-align: center;
    font-size: 11px;
    color: rgba(255,255,255,0.35);
}
.credits-line a {
    color: rgba(255,255,255,0.55);
    text-decoration: underline;
}
.credits-line a:hover { color: rgba(255,255,255,0.8); }
.btn-full { width: 100%; }

.live-status-line {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    margin-top: 8px;
}
