/* Inherited Global Reset & Basic Typography from style.css */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #eef2f6;
    height: 100vh;
    display: flex;
    flex-direction: column;
    color: #333;
}

/* Header */
.header {
    padding: 15px 20px;
    background-color: #fcfcfc; /* Very light, almost white background */
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between; /* Space out left group and burger */
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    position: relative; /* For absolute positioning of burger/mobile menu */
}

.header h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 600;
    color: #4a4a4a;
}

.header-left-group {
    display: flex;
    align-items: center;
    gap: 20px; /* Space between title and desktop nav button */
}

.nav-button {
    background-color: #ffffff; /* Primary accent color */
    color: #6a8cff;
    border: 2px solid #6a8cff;
    padding: 8px 15px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 8px rgba(106, 140, 255, 0.2);
    white-space: nowrap;
    display: inline-block;
}

.nav-button:hover {
    background-color: #5377eb;
    color: white;
    box-shadow: 0 4px 12px rgba(106, 140, 255, 0.3);
}

/* Hide mobile-only nav button by default */
.nav-button.mobile-only {
    display: none;
}

/* Burger Menu Button */
.burger-menu-btn {
    display: none; /* Hidden by default on desktop */
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 20;
    position: absolute; /* Position relative to header */
    right: 15px; /* Adjust as needed */
    top: 50%;
    transform: translateY(-50%);
}

.burger-icon {
    display: block;
    width: 25px;
    height: 3px;
    background-color: #4a4a4a;
    margin: 5px 0;
    transition: all 0.3s ease-in-out;
}

/* Animation for burger to 'X' */
.burger-menu-btn.open .burger-icon:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.burger-menu-btn.open .burger-icon:nth-child(2) {
    opacity: 0;
}

.burger-menu-btn.open .burger-icon:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Mobile Menu Container (for Pet VS button) */
.header-mobile-menu {
    display: none; /* Hidden by default */
    position: absolute;
    top: 100%; /* Position below the header */
    right: 0; /* Align to the right */
    background-color: #fcfcfc;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    flex-direction: column;
    padding: 10px 20px;
    gap: 8px;
    z-index: 15;
    border-top: 1px solid #e0e0e0;
    min-width: 150px; /* Ensure it's wide enough for the button */
    align-items: flex-end; /* Align button to the right within the menu */
}

.header-mobile-menu.active {
    display: flex; /* Show when active */
}

/* Ensure mobile-only nav button is displayed when menu is active */
.header-mobile-menu.active .nav-button.mobile-only {
    display: block; /* Change from none to block */
    width: 100%; /* Make it full width in the menu */
    text-align: center; /* Center text */
}

/* Responsive Adjustments for Header */
@media (max-width: 768px) {
    .header {
        flex-direction: row; /* Keep header items in a row initially */
        justify-content: space-between; /* Space out title and burger */
        align-items: center;
        padding: 10px 15px;
    }

    .header-left-group {
        width: auto; /* Allow content to dictate width */
        gap: 10px; /* Smaller gap on mobile */
    }

    .header h1 {
        font-size: 1.4rem;
    }

    .nav-button.desktop-only {
        display: none; /* Hide desktop nav button on mobile */
    }

    .burger-menu-btn {
        display: block; /* Show burger button on mobile */
        position: static; /* Reset position for flexbox flow */
        transform: none; /* Reset transform */
    }

    /* Hide the header-right-group (which doesn't exist in pet-vs.html but good to keep in mind) */
    .header-right-group {
        display: none;
    }

    /* Adjust the mobile menu positioning/sizing */
    .header-mobile-menu.active {
        top: 70px;
        justify-content: center;
        width: 100%;
        left: auto;
        height: 110px;
    }
}

/* Main Layout */
.main-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 20px;
    gap: 20px;
}

/* VS Section - Top Area */
.vs-section {
    flex: 1; /* Allows it to grow and take space, but respects min-height */
    min-height: 40vh; /* Minimum height for the VS display */
    display: flex; /* Already flex */
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 20px;
    position: relative;
    background-color: #fcfcfc; /* Add background and shadow here for consistency */
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.pet-slot {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Align image to bottom */
    align-items: center;
    background-color: #fcfcfc;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    min-height: 300px;
    position: relative;
    padding: 20px;
    text-align: center;
    cursor: pointer; /* To allow clicking to deselect */
    border: 3px solid transparent;
    transition: all 0.2s ease-in-out;
    overflow: hidden; /* Ensure image doesn't overflow rounded corners */
}

.pet-slot:hover:not(.selected):not(.active-target) {
    border-color: #6a8cff;
}

.pet-slot.selected {
    border-color: #6a8cff;
    box-shadow: 0 5px 20px rgba(106, 140, 255, 0.4);
}

/* New style for active target slot */
.pet-slot.active-target {
    border-color: #4CAF50; /* Green highlight for active slot */
    box-shadow: 0 5px 20px rgba(76, 175, 80, 0.4);
}


.pet-slot img {
    max-height: 80%;
    max-width: 90%;
    object-fit: contain;
    position: absolute;
    bottom: 20px;
    cursor: grab; /* Indicate draggable */
    touch-action: none; /* Prevent browser touch actions */
}

.pet-slot .pet-name {
    margin-top: 10px;
    font-size: 1.2rem;
    font-weight: 600;
    color: #4a4a4a;
    position: absolute;
    top: 20px;
}

.pet-slot p {
    font-size: 1.2rem;
    color: #999;
    font-style: italic;
}

.vs-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: 2rem;
    font-weight: 600;
    color: #4a4a4a;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

#battleBtn {
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    background-color: #6a8cff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 4px 10px rgba(106, 140, 255, 0.2);
}

#battleBtn:hover {
    background-color: #5377eb;
    box-shadow: 0 6px 15px rgba(106, 140, 255, 0.3);
}

#battleBtn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.results-display {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 500;
    color: #4a4a4a;
    margin: 10px 0;
    min-height: 30px;
}

.results-display .winner {
    color: #4CAF50; /* Green for winner */
    font-weight: 600;
}

/* Selection Section - Bottom Area */
.selection-section {
    /* Changed from flex: 1; to a fixed height for better control on desktop */
    height: 45vh; /* Adjust this value as needed to fit the screen */
    display: flex; /* Ensure it's a flex container for its children */
    flex-direction: column;
    background-color: #fcfcfc;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    padding: 20px;
}

.controls-row {
    margin-bottom: 15px;
}

.search-bar {
    width: 100%;
    padding: 10px 15px;
    font-size: 0.95rem;
    border-radius: 8px;
    border: 1px solid #dcdfe4;
    background-color: #fcfcfc;
    color: #4a4a4a;
    transition: all 0.2s ease-in-out;
    outline: none;
}

.library-container {
    flex-grow: 1; /* This will make it take up remaining space in selection-section */
    overflow-y: auto; /* Enable scrolling */
    padding-right: 5px; /* Space for scrollbar */
}

.animal-library {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    justify-items: center;
}

.library-item {
    width: 120px; /* Fixed width for each item */
    text-align: center;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    background-color: #fefefe;
    border: 1px solid #e9ecef;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, border-color 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.library-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.library-item.unavailable {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.library-item img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 5px;
    pointer-events: none;
}

.library-item p {
    margin: 0;
    font-size: 0.85rem;
    color: #4a4a4a;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Remove Indicator */
.remove-indicator {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #dc3545;
    color: white;
    padding: 12px 25px;
    border-radius: 8px;
    display: none;
    z-index: 100;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Ghost Image (when dragging from slot or library) */
.pet-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.7; /* Slightly more transparent */
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.2)); /* Clearer shadow */
    transform-origin: top left;
    max-height: 150px; /* Limit ghost size */
    max-width: 150px;
    object-fit: contain;
}


/* Responsive Adjustments */
@media (max-width: 768px) {
    .vs-section {
        flex-direction: column;
        gap: 10px;
        min-height: 65vh; /* Adjust for mobile */
    }
    .pet-slot {
        min-height: 180px; /* Smaller slots on mobile */
        width: 100%;
        min-width: unset;
        max-width: unset;
        padding: 15px;
    }
    .pet-slot img {
        max-height: 70%;
        bottom: 15px;
    }
    .pet-slot .pet-name {
        font-size: 1rem;
        top: 15px;
    }
    .vs-divider {
        flex-direction: row;
        gap: 15px;
        font-size: 1.5rem;
    }
    #battleBtn {
        padding: 10px 20px;
        font-size: 1rem;
    }
    .main-container {
        padding: 10px;
        gap: 10px;
    }
    /* On mobile, allow selection section to take available space */
    .selection-section {
        height: auto; /* Reset fixed height for mobile */
        flex-grow: 1; /* Allow it to grow */
    }
    .animal-library {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); /* Smaller items */
        gap: 10px;
    }
    .library-item {
        width: 100px;
    }
    .library-item img {
        width: 60px;
        height: 60px;
    }
    .library-item p {
        font-size: 0.75rem;
    }
    .results-display {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .animal-library {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    .library-item {
        width: 90px;
    }
}
