:root {
    /* --- BMW Game Standard Bin Colors --- */
    --yellow: #D4AF37; /* Classic Gold */
    --red: #C62828;
    --white: #FFFFFF; /* High-Contrast White */
    --blue: #1565C0;
    --black: #111111; 
}

/* Fullscreen game mode: locks viewport to prevent mobile address bar wiggle */
body.game-fullscreen {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
}

body.game-fullscreen #game-container {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}

#game-container {
    flex: 1; /* Flexibly fill whatever space is left */
    display: flex;
    flex-direction: column;
    justify-content: space-between; 
}

/* =========================================
   Headers & Scoreboards
   ========================================= */
#header {
    text-align: center;
    padding: 10px;
    background: var(--surface);
    border-bottom: 2px solid var(--card-bg);
    z-index: 100;
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 10px;
}

/* NEW: Groups the top left buttons together smoothly */
.top-bar-controls {
    display: flex;
    gap: 8px;
}

#info-btn, #fullscreen-btn, #mute-btn {
    background: var(--card-bg);
    border: 2px solid var(--primary);
    color: var(--text);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

#leaderboard {
    font-size: 0.85rem;
    color: var(--yellow);
    display: flex;
    gap: 15px;
    background: var(--bg);
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid var(--card-bg);
}

#score-board {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-around;
}

.score-highlight { color: var(--primary); }

.high-score-container { 
    color: var(--yellow); 
    text-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

#streak-board {
    font-size: 1rem;
    font-weight: bold;
    min-height: 25px;
    transition: color 0.3s;
    margin-top: 5px;
}

/* =========================================
   Interactive Waste Items (Moved to Top)
   ========================================= */
#item-area {
    flex: 1; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px;
}

.waste-item {
    background: var(--card-bg);
    border: 2px solid var(--primary);
    color: var(--text);
    padding: 15px 25px;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 8px 16px rgba(0,0,0,0.6);
    cursor: grab;
    user-select: none;
    position: absolute;
    z-index: 1000;
    transition: transform 0.1s, box-shadow 0.1s;
    max-width: 80%;
    word-wrap: break-word;
    display: flex;
    flex-direction: column;
    align-items: center;
    touch-action: none; /* ADDED HERE: Prevents screen scroll when dragging an item */
}

.waste-item svg {
    pointer-events: none; /* Prevents SVG from breaking drag logic */
}

.waste-item:active {
    cursor: grabbing;
    box-shadow: 0 12px 24px rgba(0,0,0,0.8);
    border-color: var(--text);
}

/* Targets ONLY waste items that contain an SVG graphic */
.waste-item:has(svg) {
    background: transparent;
    border-color: transparent;
    box-shadow: none; /* Removes the floating square shadow */
}

/* Enhances the grabbing interaction for transparent items */
.waste-item:has(svg):active {
    background: transparent; 
    border: 2px solid transparent; 
    box-shadow: none; 
    border-radius: 8px;
}

.install-btn {
    position: absolute;
    bottom: 20px;
    background: var(--primary);
    color: var(--bg);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

/* =========================================
   BMW Bins Area (Moved to Bottom)
   ========================================= */
#bins-area {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-evenly;
    align-items: flex-end;
    padding: 55px 5px 20px 5px; 
    background: var(--surface);
    border-top: 2px solid var(--card-bg);
}

.bin-wrapper {
    width: 18%;
    max-width: 70px;
    height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
}

.bin-label {
    position: absolute;
    top: -30px;
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #FFFFFF; /* NEW: Forces all text to be white against the navy background */
}

.bin-icon { 
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    z-index: 5;
    opacity: 0.9;
    pointer-events: none;
}

.bin-lid {
    width: 110%;
    height: 15px;
    left: -5%;
    position: absolute;
    top: 0;
    border-radius: 8px 8px 0 0;
    border: 2px solid #000;
    transform-origin: left center;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.3);
}

.bin-body {
    width: 100%;
    height: 100%;
    border: 2px solid #000;
    border-top: none;
    border-radius: 0 0 10px 10px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    clip-path: polygon(2% 0, 98% 0, 100% 100%, 0 100%);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.6);
}

/* Bin Colors applied structurally */
.bin-wrapper[data-color="yellow"] .bin-lid, .bin-wrapper[data-color="yellow"] .bin-body { background: var(--yellow); }
.bin-wrapper[data-color="red"] .bin-lid, .bin-wrapper[data-color="red"] .bin-body { background: var(--red); }
.bin-wrapper[data-color="white"] .bin-lid, .bin-wrapper[data-color="white"] .bin-body { background: var(--white); }
.bin-wrapper[data-color="blue"] .bin-lid, .bin-wrapper[data-color="blue"] .bin-body { background: var(--blue); }
.bin-wrapper[data-color="black"] .bin-lid, .bin-wrapper[data-color="black"] .bin-body { background: var(--black); }

/* Ensuring label visibility against dark backgrounds */
.bin-wrapper[data-color="yellow"] .bin-label { color: var(--text); }
.bin-wrapper[data-color="white"] .bin-label { color: var(--bg); } /* Dark text for white bin */
.bin-wrapper[data-color="red"] .bin-label, .bin-wrapper[data-color="blue"] .bin-label, .bin-wrapper[data-color="black"] .bin-label { color: var(--text-muted); }

.fill-level {
    width: 100%;
    height: 0%;
    background: rgba(0, 0, 0, 0.75);
    transition: height 0.3s ease-in-out;
    border-top: 2px solid rgba(255,255,255,0.2);
    z-index: 2; 
}

.bin-wrapper.drag-over .bin-lid { transform: rotate(-55deg); }

/* =========================================
   Modals & Popups
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-box {
    background: var(--surface);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    border: 1px solid var(--primary);
    box-shadow: 0 10px 30px rgba(0,0,0,0.9);
}

.modal-box h2 {
    color: var(--primary);
    margin-top: 0;
}

.process-btn, .close-btn {
    display: block;
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--primary);
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: bold;
}

.process-btn:hover, .close-btn:hover { 
    background: var(--primary); 
    color: var(--bg);
}

/* =========================================
   Processing Animations & System Flashes
   ========================================= */
.process-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    z-index: 20;
    border-radius: 0 0 10px 10px;
}

.process-text {
    position: absolute;
    top: -70px;
    width: 200%;
    left: -50%;
    text-align: center;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--primary);
    background: var(--surface);
    padding: 4px;
    border-radius: 4px;
    border: 1px solid var(--primary);
    display: none;
    z-index: 30;
    animation: pulseText 1s infinite;
}

@keyframes pulseText { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* 1. Yellow Bin: Incineration (Flickering Fire & Inner Glow) */
@keyframes burn {
    0%   { background: rgba(255, 80, 0, 0.4); transform: scaleY(1); box-shadow: inset 0 0 10px rgba(255, 50, 0, 0.5); }
    25%  { background: rgba(255, 120, 0, 0.6); transform: scaleY(1.05) skewX(2deg); box-shadow: inset 0 0 20px rgba(255, 100, 0, 0.8); }
    50%  { background: rgba(255, 30, 0, 0.8); transform: scaleY(1.1) skewX(-2deg); box-shadow: inset 0 0 30px rgba(255, 0, 0, 1); }
    75%  { background: rgba(255, 100, 0, 0.7); transform: scaleY(1.05) skewX(1deg); box-shadow: inset 0 0 15px rgba(255, 50, 0, 0.8); }
    100% { background: rgba(255, 80, 0, 0.4); transform: scaleY(1); box-shadow: inset 0 0 10px rgba(255, 50, 0, 0.5); }
}
.anim-fire { 
    display: flex !important; 
    animation: burn 0.5s ease-in-out infinite; 
}

/* 2. Red Bin: Autoclaving (Pulsating Blur & Thick Steam) */
@keyframes steam {
    0%   { background: rgba(255, 255, 255, 0.3); opacity: 0.8; filter: blur(0px); transform: translateY(0); }
    50%  { background: rgba(255, 255, 255, 0.9); opacity: 1; filter: blur(3px); transform: translateY(-5px) scale(1.02); }
    100% { background: rgba(255, 255, 255, 0.3); opacity: 0.8; filter: blur(0px); transform: translateY(0); }
}
.anim-steam { 
    display: flex !important; 
    animation: steam 0.8s ease-in-out infinite; 
}

/* 3. Blue/White Bins: Chemical Disinfection (Frothing & Bubbling) */
@keyframes bubble {
    0%   { background: rgba(0, 150, 255, 0.4); box-shadow: inset 0 0 0px rgba(255, 255, 255, 0); transform: scale(1); }
    50%  { background: rgba(0, 255, 255, 0.8); box-shadow: inset 0 15px 25px rgba(255, 255, 255, 0.7); transform: scale(1.04); }
    100% { background: rgba(0, 150, 255, 0.4); box-shadow: inset 0 0 0px rgba(255, 255, 255, 0); transform: scale(1); }
}
.anim-disinfect { 
    display: flex !important; 
    animation: bubble 0.6s ease-in-out infinite; 
}

/* 4. Black Bin: General Landfill (Heavy Squash and Stretch) */
@keyframes crush {
    0%   { background: rgba(80, 50, 30, 0.5); transform: scale(1, 1); }
    30%  { background: rgba(60, 40, 20, 0.8); transform: scale(1.1, 0.85); } /* Squashes down */
    50%  { background: rgba(80, 50, 30, 0.9); transform: scale(0.95, 1.05); } /* Bounces up */
    70%  { background: rgba(60, 40, 20, 0.8); transform: scale(1.05, 0.95); } /* Settles */
    100% { background: rgba(80, 50, 30, 0.5); transform: scale(1, 1); }
}
.anim-landfill { 
    display: flex !important; 
    animation: crush 1s ease-in-out infinite; 
}

@keyframes flashRed { 0%, 100% { background-color: var(--bg); } 50% { background-color: var(--danger); } }
@keyframes flashGreen { 0%, 100% { background-color: var(--bg); } 50% { background-color: var(--primary); } }
.flash-wrong { animation: flashRed 0.5s ease; }
.flash-correct { animation: flashGreen 0.5s ease; }

/* =========================================
   Rules Text Format
   ========================================= */
#rules-text {
    text-align: left;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-muted);
    margin-bottom: 20px;
}
#rules-text p {
    background: var(--bg);
    padding: 8px;
    border-radius: 6px;
    border-left: 3px solid #555;
}
#rules-text p:nth-child(1) { border-color: var(--yellow); }
#rules-text p:nth-child(2) { border-color: var(--red); }
#rules-text p:nth-child(3) { border-color: var(--white); }
#rules-text p:nth-child(4) { border-color: var(--blue); }
#rules-text p:nth-child(5) { border-color: #888; }
#rules-text span { font-weight: bold; }

/* =========================================
   High Score Name Entry Popup
   ========================================= */
.name-entry-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    backdrop-filter: blur(5px);
}

.name-entry-box {
    background: var(--surface);
    padding: 30px 20px;
    border-radius: 12px;
    text-align: center;
    width: 90%;
    max-width: 350px;
    border: 2px solid var(--yellow);
    box-shadow: 0 10px 30px rgba(0,0,0,0.9);
}

.name-entry-box h2 {
    color: var(--yellow);
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.name-entry-box p {
    color: var(--text);
    margin-bottom: 20px;
    font-size: 1rem;
}

#player-name-input {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 1.2rem;
    font-weight: bold;
    box-sizing: border-box;
    text-align: center;
    margin-bottom: 20px;
    text-transform: capitalize;
}

#submit-score-btn {
    width: 100%;
    padding: 15px;
    background-color: var(--primary);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
}
#submit-score-btn:hover { background-color: #00CCCC; }

/* =========================================
   New Drag Hint & Full Screen Process
   ========================================= */
.drag-hint {
    position: absolute;
    font-size: 3rem;
    z-index: 999;
    pointer-events: none;
    text-align: center;
    color: var(--primary);
    text-shadow: 0 4px 6px rgba(0,0,0,0.6);
    animation: dragDropMotion 3.5s ease-in-out forwards;
}

@keyframes dragDropMotion {
    0% { transform: translateY(-30px); opacity: 0; }
    15% { transform: translateY(-30px); opacity: 1; }  /* Appear on item */
    45% { transform: translateY(120px); opacity: 1; }  /* Drag down to bins */
    60% { transform: translateY(120px); opacity: 1; }  /* Stop at bins */
    70% { transform: translateY(120px); opacity: 0; }  /* Disappear */
    100% { transform: translateY(-30px); opacity: 0; }
}

.full-screen-process-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
}

.giant-bin {
    width: 250px !important;
    max-width: 250px !important;
    height: 400px !important;
    margin-bottom: 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border-radius: 0 0 20px 20px;
}

.giant-bin .bin-lid {
    border-radius: 16px 16px 0 0;
    height: 30px;
    border-width: 4px;
}

.giant-bin .bin-body {
    border-width: 4px;
    border-top: none;
    border-radius: 0 0 20px 20px;
}

.giant-bin .bin-icon {
    font-size: 6rem;
}

.giant-bin .fill-level {
    transition: height 2.5s ease-in-out; /* slower drain */
}

.giant-bin .process-overlay {
    font-size: 8rem;
    border-radius: 0 0 16px 16px;
}

#process-text-large {
    color: var(--primary);
    font-size: 2.5rem;
    text-transform: uppercase;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
    animation: pulseText 1s infinite;
}

/* =========================================
   Panic Mode & Outbreak Mode Styles
   ========================================= */

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake-screen {
    animation: shake 0.5s;
}
