:root {
    --primary: #c20606;
    --primary-container: #ffee00;
    --on-primary: #4a6600;
    --secondary: #c97cff;
    --tertiary: #8ff5ff;
    --on-tertiary: #003640;
    --surface: #0e0e0e;
    --surface-low: #131313;
    --surface-mid: #1a1a1a;
    --surface-high: #20201f;
    --surface-highest: #262626;
    --on-surface: #ffffff;
    --on-surface-variant: #adaaaa;
    --outline-variantW: #484847;
    --primary-glow: rgba(233, 255, 185, 0.15);
    --bg-darker: #0e0e0e;
}

html {
    -webkit-text-size-adjust: 100%;
    transition: all 0.5s ease;
}

body {
    background-color: var(--bg-darker);
    color: #ffffff;
    overscroll-behavior-y: none;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    background-attachment: fixed;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle at 50% 50%, var(--primary-glow) 0%, transparent 40%);
    pointer-events: none;
    z-index: -1;
    transition: all 1s ease;
}

.mirror-mode {
    transform: scaleX(-1);
}

.camera-select-dropdown option {
    background-color: var(--surface-mid);
    color: white;
    padding: 10px;
}

select {
    color-scheme: dark;
}

select option {
    background-color: var(--surface-mid);
    color: #ffffff;
    font-weight: 700;
    padding: 10px;
}

select:focus option {
    background-color: var(--surface-mid);
    color: #ffffff;
}

.safe-nav-pad {
    padding-top: max(0.75rem, env(safe-area-inset-top));
}

.pb-safe-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mb-player-safe {
    margin-bottom: env(safe-area-inset-bottom, 0px);
}

/* Glassmorphism Card */
.glass-card {
    background: rgba(15, 15, 15, 0.6);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.film-search-input {
    background-color: var(--primary);
}

/* Chips / Tags (No @apply) */
.chip-option {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--on-surface-variant);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    user-select: none;
}

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

.chip-option.active {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Badge Styles (No @apply) */
.badge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s;
    cursor: help;
    position: relative;
}

.badge-card:hover {
    transform: scale(1.1);
}

.badge-card.locked {
    filter: grayscale(1);
    opacity: 0.3;
}

.badge-card .badge-icon {
    font-size: 1.875rem;
    margin-bottom: 0.25rem;
    transition: transform 0.3s;
}

.badge-card:hover .badge-icon {
    transform: rotate(12deg);
}

.badge-glow {
    box-shadow: 0 0 20px -5px var(--primary);
}

.xp-bar-inner {
    transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Scrollbar An/Hien */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

@keyframes flash {
    0% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.animate-flash {
    animation: flash 0.3s ease-out;
}

@keyframes countdown-pop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
        opacity: 1;
    }

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

.animate-countdown {
    animation: countdown-pop 1s ease-in-out forwards;
}

.pb-layout-btn.active {
    border-color: var(--primary);
    background: rgba(233, 255, 185, 0.2);
}

.pb-filter-btn.active {
    background-color: var(--primary);
    border-color: var(--primary);
}

.filter-bw {
    filter: grayscale(1);
}

.filter-vintage {
    filter: sepia(0.5) contrast(1.2) brightness(0.9);
}

.filter-bright {
    filter: brightness(1.2) contrast(1.1) saturate(1.1);
}

.filter-cold {
    filter: hue-rotate(180deg) saturate(0.8) brightness(1.1);
}

/* Sliders */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: -6px;
    border: 2px solid white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(-20px) scale(1.2);
    }
    100% {
        transform: translateY(-200px) scale(1);
        opacity: 0;
    }
}

.floating-reaction {
    animation: floatUp 3s ease-out forwards;
}

/* Animation */
.animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.99);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scan-line {
    height: 2px;
    background: linear-gradient(to right, transparent, var(--primary), transparent);
    position: absolute;
    width: 100%;
    top: 0;
    animation: scan 3s linear infinite;
}

@keyframes scan {
    0% {
        top: 0%;
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        top: 100%;
        opacity: 0;
    }
}

/* Gacha Animation */
.gacha-item-reveal {
    opacity: 0;
    transform: translateY(20px);
    animation: reveal 0.5s forwards;
}

@keyframes reveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Game Hub Styles */
.game-card {
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.game-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5), 0 0 20px rgba(233, 255, 185, 0.1);
}

.game-card.active {
    background: linear-gradient(135deg, rgba(233, 255, 185, 0.15), rgba(233, 255, 185, 0.05));
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(233, 255, 185, 0.2);
}

.game-card.active::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 30%;
    background: var(--primary);
    left: 0;
    top: 35%;
    border-radius: 0 4px 4px 0;
}

.game-icon-container {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.game-card:hover .game-icon-container {
    background: var(--primary);
    transform: rotate(-8deg);
}

.game-card:hover .game-icon-container span {
    color: #4a6600;
}

.game-badge {
    font-size: 8px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
}

.game-card:hover .game-badge {
    background: rgba(233, 255, 185, 0.2);
    color: var(--primary);
}

/* Generic Game HUD */
.game-hud {
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    letter-spacing: 2px;
}

.btn-game-control {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    color: white;
    transition: all 0.2s;
}

.btn-game-control:active {
    transform: scale(0.9);
    background: var(--primary);
    color: #4a6600;
}

/* Watchlist Badge */
.watchlist-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 20;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.film-card:hover .watchlist-btn {
    transform: scale(1);
}

.watchlist-btn.active {
    background: var(--primary);
    color: #000;
}

/* Progress Bar on Card */
.progress-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
    border-radius: 0 0 12px 12px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

/* PWA Mobile Optimization */
@media (max-width: 640px) {

    /* Prevent pull-to-refresh on mobile */
    body {
        overscroll-behavior-y: contain;
    }

    /* Fixed Bottom Navigation for Mobile */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(10, 10, 10, 0.85);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
        z-index: 100;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    }

    .mobile-bottom-nav button {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        color: var(--on-surface-variant);
        padding: 8px;
        background: transparent;
        border: none;
        width: 100%;
    }

    .mobile-bottom-nav button.active {
        color: var(--primary);
    }

    .mobile-bottom-nav button span.material-icons-round {
        font-size: 24px;
    }

    .mobile-bottom-nav button span.label {
        font-size: 10px;
        font-weight: 700;
    }

    /* Hide horizontal scroll nav on mobile since we use bottom nav */
    nav .glass-panel {
        display: none !important;
    }

    /* Adjust main padding for bottom nav */
    body {
        padding-bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    }

    /* Show mobile bottom nav only on mobile */
    .mobile-bottom-nav {
        display: flex !important;
    }

    /* Mobile More Menu */
    .mobile-more-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 150;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .mobile-more-overlay.show {
        opacity: 1;
        pointer-events: auto;
    }
    .mobile-more-sheet {
        position: absolute;
        bottom: calc(70px + env(safe-area-inset-bottom));
        left: 0;
        right: 0;
        background: #111;
        border-radius: 24px 24px 0 0;
        padding: 16px 20px 24px;
        border-top: 1px solid rgba(255,255,255,0.1);
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
    }
    .mobile-more-overlay.show .mobile-more-sheet {
        transform: translateY(0);
    }
    .mobile-more-handle {
        width: 40px;
        height: 4px;
        background: rgba(255,255,255,0.2);
        border-radius: 2px;
        margin: 0 auto 16px;
    }
    .mobile-more-title {
        font-size: 14px;
        font-weight: 700;
        color: #fff;
        margin-bottom: 20px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        text-align: center;
    }
    .mobile-more-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
    .mobile-more-grid button {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        background: none;
        border: none;
        color: var(--on-surface-variant);
        width: 100%;
        padding: 0;
    }
    .mobile-more-grid .mob-more-icon {
        width: 48px;
        height: 48px;
        border-radius: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .mobile-more-grid .mob-more-icon span {
        font-size: 24px;
    }
    .mobile-more-grid span:not(.material-icons-round) {
        font-size: 11px;
        font-weight: 600;
    }
}