:root {
    --bg-dark: #000000;
    --card-bg: rgba(21, 21, 30, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: 20px;
    --f1-red: #E10600;
    --f1-white: #FFFFFF;
    --f1-black: #000000;
    --f1-grey: #949498;
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;
    --easing: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #000;
    /* Outer space black */
    color: var(--f1-white);
    font-family: var(--font-body);
    overflow: hidden;
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    /* Dynamic Height */
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.mobile-layout {
    width: 100%;
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    /* Dynamic Height */
    background-color: var(--f1-red);
    background-image: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('background.png');
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Desktop/Tablet Mode: Simulate iPhone 15 Pro */
@media (min-width: 500px) {
    .mobile-layout {
        width: 393px;
        /* iPhone 15 Pro Width */
        height: 852px;
        /* iPhone 15 Pro Height */
        max-height: 95vh;
        /* Ensure it fits on smaller laptop screens */
        /* Ensure it fits on smaller laptop screens */
    }
}

/* --- Top Navigation Bar (Fixed Top) --- */
.top-bar {
    width: 100%;
    max-width: 400px;
    /* Constrain width on larger screens */
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
    flex-shrink: 0;
    /* Header doesn't shrink */
}

.app-logo-img {
    height: 20px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    display: block;
}

/* Right Icons */
.top-icons {
    display: flex;
    align-items: center;
    gap: 0;
}

.garage-toggle-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    cursor: pointer;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    pointer-events: auto;
    /* Ensure clickable */
    transition: transform 0.2s ease;
}

.garage-toggle-icon:active {
    transform: scale(0.9);
}

/* --- App Container (The Feed Area) --- */
.app-container {
    flex: 1;
    /* Take remaining height */
    width: calc(100% - 40px);
    /* 20px Left + 20px Right */
    margin: 0 20px 20px 20px;
    /* Top, Right, Bottom, Left */
    max-width: 480px;
    /* Mobile width constraint */
    position: relative;
    overflow: hidden;
    /* Card Style */
    background: #000;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* .app-container stays full width within the mobile-layout */

/* --- Play/Pause Animation Overlay --- */
.play-pause-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

.play-pause-overlay .icon-box {
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

.play-pause-overlay.animate {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.play-pause-overlay svg {
    width: 40px;
    height: 40px;
    fill: currentColor;
}

/* --- Garage Menu (Bottom Sheet) --- */
/* --- Feed (Scrollable) --- */
.feed {
    width: 100%;
    height: 100%;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
    display: flex;
    flex-direction: column;
}

.feed::-webkit-scrollbar {
    display: none;
}

/* --- Video Slide --- */
.video-slide {
    width: 100%;
    height: 100%;
    min-height: 100%;
    /* Force full container height */
    scroll-snap-align: start;
    scroll-snap-stop: always;
    position: relative;
    background: #333;
    /* Grey Placeholder */
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Gradient Overlay for Text Readability */
.video-slide::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    /* Covers bottom 40% */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%);
    z-index: 20;
    /* Above video (1) & interaction (10), below text (50) */
    pointer-events: none;
}

.video-wrapper {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    pointer-events: none;
}

.video-wrapper iframe {
    width: 100%;
    height: 100%;
    border: 0;
    /* Zoom 1.25x and shift UP to hide top chrome */
    transform: scale(1.25) translateY(-50px);
    transform-origin: center top;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    /* Interact via layer */
}

.user-interaction-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

/* --- Mute/Unmute Toggle --- */
.mute-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 50;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s;
}

.mute-btn:hover {
    background: rgba(0, 0, 0, 0.6);
}

.mute-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* --- Right Action Bar --- */
.actions-bar {
    position: absolute;
    right: 8px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 50;
    pointer-events: auto;
    padding-bottom: 8px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: #fff;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}

.action-btn svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    transition: fill 0.3s ease;
}

/* Like State: Toggle Icons */
.action-btn.liked .icon-outline {
    display: none !important;
}

.action-btn.liked .icon-filled {
    display: block !important;
    fill: #8c41f3;
    /* User Specific Purple */
    transform: scale(1.1);
    /* Subtle Pop */
}



.action-count {
    font-size: 0.75rem;
    font-family: var(--font-body);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* --- Bottom Info Area --- */
.video-info {
    position: absolute;
    bottom: 24px;
    left: 16px;
    right: 70px;
    /* Space for actions */
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    color: #fff;
    justify-content: flex-end;
    padding-bottom: 8px;
}

.info-title {
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 13px;
    /* Smaller */
    line-height: 1.2;
    text-transform: none;
    /* Respect JSON casing */
}

.info-body {
    display: none !important;
    /* Force hide */
}

/* --- Loader (Small Overlay in Feed if needed) --- */
.loader-overlay {
    /* If reintroduced later */
    display: none;
}

/* --- Purple Sector (Hidden by default) --- */
.purple-sector {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(135deg, #4b0082, #A020F0);
    padding: 20px 40px;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(160, 32, 240, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.purple-sector span {
    color: #fff;
    font-family: var(--font-heading);
    font-weight: 900;
    font-style: italic;
    font-size: 2rem;
    text-transform: uppercase;
}

.purple-sector.animate {
    animation: purplePop 0.8s var(--easing) forwards;
}

@keyframes purplePop {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    40% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }

    60% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(0.9);
    }
}

/* --- Garage Overlay --- */
.garage-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    /* Darker overlay */
    z-index: 150;
    /* Below garage (200), above content */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s var(--easing);
}

.garage-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* --- The Garage (Menu) --- */
.garage {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    /* Full glass card styling */
    background: rgba(21, 21, 30, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top: 1px solid var(--glass-border);
    border-radius: 24px 24px 0 0;
    padding: 24px 24px 24px 24px;
    /* Reduced bottom padding */
    z-index: 200;
    transform: translateY(110%);
    transition: transform 0.4s var(--easing);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
}

.garage.open {
    transform: translateY(0);
}

.garage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 16px;
}

.garage h3 {
    font-family: var(--font-heading);
    font-weight: 900;
    text-transform: uppercase;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
}

.garage h3::before {
    content: '';
    display: block;
    width: 4px;
    height: 16px;
    background: var(--f1-red);
    border-radius: 2px;
}

.filter-group {
    margin-bottom: 24px;
}

/* Label 'Mode' removed, styling kept minimal if reused or just delete */
.filter-group label {
    display: none;
}

/* Chips as Rows similar to Starting Grid */
.chips {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #dfdfdf;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 16px;
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chip svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    opacity: 0.7;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chip.active {
    background: rgba(225, 6, 0, 0.1);
    border-color: var(--f1-red);
    color: #fff;
}

.chip.active svg {
    opacity: 1;
    fill: var(--f1-red);
}

.chip.active::after {
    content: '●';
    color: var(--f1-red);
    font-size: 0.8rem;
    margin-left: auto;
    /* Push to right */
}

/* .garage-toggle previously hidden here, now used in header */

/* Hidden button */
.hidden {
    display: none !important;
}

/* --- Mobile Full Bleed Fix --- */
/* --- Mobile Full Bleed Fix --- */
@media (max-width: 500px) {
    .mobile-layout {
        height: 100vh;
        /* Fallback */
        height: 100dvh;
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        /* Start from top */
        padding-top: env(safe-area-inset-top, 20px);
        padding-bottom: env(safe-area-inset-bottom, 20px);
        background-color: var(--f1-red);
        /* Ensure red bg is visible */
    }

    .top-bar {
        width: 100%;
        max-width: none !important;
        flex-shrink: 0;
        /* Keep size */
        padding: 0 16px;
        min-height: 50px;
        margin-bottom: 0;
    }

    .app-container {
        flex: 1;
        /* Take remaining space */
        min-height: 0;
        /* Allow shrinking */
        width: calc(100% - 24px) !important;
        /* Margin on sides */
        margin: 0 12px 12px 12px !important;
        border-radius: 20px !important;
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4) !important;
        max-width: none !important;
        height: auto !important;
        /* Let flex handle height */
        padding-bottom: 0;
    }

    .feed {
        padding-bottom: 0;
        /* Scroll inside container */
    }
}