/* ===================================
   PSU RACING DASHBOARD - MOBILE
   Landscape-First Design
   =================================== */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors - All Orange Theme */
    --primary-orange: #E47814;
    --primary-orange-dark: #C46410;
    --accent-gold: #E47814;
    --success-green: #E47814;
    --warning-yellow: #E47814;
    --danger-red: #E47814;
    --electric-blue: #E47814;

    /* Backgrounds */
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-glass: rgba(255, 255, 255, 0.05);
    --bg-glass-dark: rgba(0, 0, 0, 0.6);

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;

    /* Fonts */
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Rajdhani', sans-serif;
}

body {
    font-family: var(--font-body);
    background: #000000;
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    position: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Video Container - Full screen background */
.video-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    background: #000000;
    overflow: hidden;
}

/* Camera Feed - Full screen background */
.camera-feed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Canvas Overlay for Racing Line */
.overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Main Layout */
.dashboard-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    padding: 10px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background: transparent;
    z-index: 1;
    pointer-events: none;
}

/* Lap Section (moved to sidebar) */
.lap-container {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 2px solid rgba(228, 120, 20, 0.6);
    padding: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.lap-section {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-family: var(--font-display);
}

.lap-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 2px;
}

.lap-number {
    font-size: 2rem;
    /* Reduced from 2.5rem */
    font-weight: 900;
    color: #E47814;
    text-shadow: 0 0 10px rgba(228, 120, 20, 0.6);
    line-height: 1;
}

.lap-total {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* ===================================
   MAIN GRID LAYOUT - HUD OVERLAY MODE
   =================================== */

.main-grid {
    flex: 1;
    display: flex;
    position: relative;
    min-height: 0;
    /* Transparent to allow camera view through */
    pointer-events: none;
}

/* ===================================
   LEFT PANEL - TRACK MAP (Top-left corner)
   =================================== */

.left-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 120px;
    height: 110px;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    z-index: 10;
}

.track-map-container {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 2px solid rgba(228, 120, 20, 0.6);
    padding: 0;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
}

.track-map {
    width: 100%;
    height: 100%;
}

.track-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    border: 1px solid var(--primary-orange);
    z-index: 1000;
}

.track-name {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-orange);
    text-align: center;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 107, 53, 0.6);
}

/* ===================================
   CENTER PANEL - Guidance/Arrows Only (Middle stays clear for camera)
   =================================== */

.center-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    pointer-events: none;
    z-index: 10;
}

/* Current Container in Sidebar */
.current-container {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    padding: 10px 14px;
    border: 2px solid rgba(0, 204, 255, 0.4);
    box-shadow: 0 4px 20px rgba(0, 204, 255, 0.2);
}

.current-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
}

.current-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: #00ccff;
    text-shadow: 0 0 15px rgba(0, 204, 255, 0.8);
}

.current-unit {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: rgba(0, 204, 255, 0.8);
    letter-spacing: 1px;
}

/* Turn Instruction Banner */
.turn-instruction {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.9), rgba(255, 140, 66, 0.9));
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 2px solid var(--primary-orange);
    box-shadow: 0 8px 32px rgba(255, 107, 53, 0.5),
        0 0 40px rgba(255, 107, 53, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
    min-height: 60px;
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 8px 32px rgba(255, 107, 53, 0.5),
            0 0 40px rgba(255, 107, 53, 0.3);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 8px 40px rgba(255, 107, 53, 0.7),
            0 0 60px rgba(255, 107, 53, 0.5);
        transform: scale(1.02);
    }
}

.turn-icon {
    font-size: 2.5rem;
    animation: turn-bounce 1s ease-in-out infinite;
}

@keyframes turn-bounce {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(5px);
    }
}

.turn-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.turn-direction {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: 2px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.turn-advice {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

/* Speedometer - Compact size for top right */
.speedometer {
    position: relative;
    width: 105px;
    height: 105px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(15px);
    border-radius: 50%;
    border: 2px solid rgba(228, 120, 20, 0.6);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8),
                inset 0 0 20px rgba(228, 120, 20, 0.1);
}

.speedometer-svg {
    width: 100%;
    height: 100%;
}

.speed-value {
    font-family: var(--font-display);
    font-size: 3.2rem;
    font-weight: 900;
    fill: var(--primary-orange);
    filter: drop-shadow(0 0 15px rgba(255, 107, 53, 0.8));
}

.speed-unit {
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    fill: var(--text-muted);
    letter-spacing: 2px;
}

/* Racing Line Guidance Overlay - Top Center */
.racing-line-guidance {
    position: fixed;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 2px solid var(--primary-orange);
    padding: 12px 20px;
    box-shadow: 0 4px 20px rgba(228, 120, 20, 0.5);
    z-index: 150;
    pointer-events: none;
}

.guidance-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.target-speed-label {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 2px;
}

.target-speed-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary-orange);
    text-shadow: 0 0 15px rgba(228, 120, 20, 0.8);
    line-height: 1;
}

.deviation-indicator {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 4px;
}

.deviation-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.deviation-value {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    color: #00ff88;
}

.deviation-value.off-line {
    color: #ff4444;
}

/* Directional Helper Overlay - Center of screen */
.directional-helper {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    z-index: 100;
    filter: drop-shadow(0 0 15px rgba(228, 120, 20, 0.9));
    pointer-events: none;
}

.arrow-svg {
    width: 100%;
    height: 100%;
}

.arrow-path {
    fill: var(--primary-orange);
    stroke: var(--primary-orange-dark);
    stroke-width: 2;
    animation: arrow-pulse 0.8s ease-in-out infinite;
    transform-origin: center;
}

@keyframes arrow-pulse {

    0%,
    100% {
        opacity: 0.8;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.15);
        filter: drop-shadow(0 0 15px rgba(228, 120, 20, 1));
    }
}



/* ===================================
   TOP BAR - Lap, Current, Timer in one row
   =================================== */

.top-bar {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    border-radius: 18px;
    border: 1px solid rgba(228, 120, 20, 0.5);
    padding: 6px 16px;
    pointer-events: auto;
    z-index: 20;
}

.top-bar-item {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.top-bar-label {
    font-family: var(--font-display);
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.top-bar-value {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-orange);
    text-shadow: 0 0 8px rgba(228, 120, 20, 0.6);
}

.top-bar-sub {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.top-bar-unit {
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(0, 204, 255, 0.8);
}

/* ===================================
   RIGHT PANEL - Speedometer at top right
   =================================== */

.right-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
    z-index: 10;
}

#trackMap {
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: 1;
    border-radius: 16px;
    /* Match panel radius */
}

/* Timer Panel (replacing energy panel) */
.timer-panel {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 2px solid rgba(228, 120, 20, 0.6);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.timer-title {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-orange);
    text-align: center;
    letter-spacing: 1.5px;
    text-shadow: 0 0 10px rgba(228, 120, 20, 0.5);
}

.timer-display {
    font-family: var(--font-display);
    font-size: 1.8rem;
    /* Reduced from 2rem */
    font-weight: 900;
    color: #E47814;
    text-align: center;
    text-shadow: 0 0 20px rgba(228, 120, 20, 0.6);
    line-height: 1;
}

.timer-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

/* Efficiency Section */
.efficiency-section {
    margin-top: 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.efficiency-title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-orange);
    text-align: center;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.efficiency-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.efficiency-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    border-left: 3px solid #E47814;
}

.efficiency-lap-label {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.efficiency-value {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    color: #E47814;
}

.no-efficiency {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-style: italic;
    padding: 12px;
}

/* ===================================
   RESPONSIVE TWEAKS
   =================================== */

@media (max-width: 667px) {
    .main-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .turn-instruction {
        flex-direction: column;
        text-align: center;
    }

    .speedometer {
        width: 220px;
        height: 220px;
    }
}

/* Portrait mode fallback */
@media (orientation: portrait) {
    .main-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 0.5fr 1fr 0.5fr;
    }

    .speedometer {
        width: 240px;
        height: 240px;
    }

    .turn-instruction {
        padding: 10px 16px;
        min-height: auto;
    }

    .turn-direction {
        font-size: 1.1rem;
    }
}

/* ===================================
   START/FINISH MARKER
   =================================== */
.start-tooltip {
    background: rgba(0, 255, 136, 0.9) !important;
    border: 2px solid #ffffff !important;
    color: #000000 !important;
    font-family: var(--font-display) !important;
    font-weight: 700 !important;
    font-size: 0.7rem !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.6) !important;
}

/* ===================================
   CAMERA SOURCE TOGGLE
   =================================== */
.camera-toggle {
    position: absolute;
    bottom: 15px;
    left: 15px;
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 2px solid rgba(228, 120, 20, 0.5);
    padding: 6px 10px;
    pointer-events: auto;
    z-index: 20;
}

.cam-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cam-btn:hover {
    background: rgba(228, 120, 20, 0.3);
    border-color: rgba(228, 120, 20, 0.5);
}

.cam-btn.active {
    background: var(--primary-orange);
    border-color: var(--primary-orange);
    color: #000000;
    box-shadow: 0 0 10px rgba(228, 120, 20, 0.5);
}

.cam-btn.connecting {
    background: rgba(255, 200, 0, 0.3);
    border-color: rgba(255, 200, 0, 0.6);
    color: #ffcc00;
    animation: pulse-connect 1s ease-in-out infinite;
}

@keyframes pulse-connect {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}