* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

canvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

/* Simple Navbar Styles - Won't break mobile UX */
#simple-navbar {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    gap: 12px;
}

#profile-nav-btn, #animations-nav-btn, #games-nav-btn {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

#profile-nav-btn:hover, #animations-nav-btn:hover, #games-nav-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.95);
}

/* Mobile adjustments for simple navbar */
@media (max-width: 768px) {
    #simple-navbar {
        top: 10px;
        right: 10px;
        flex-direction: column;
        gap: 8px;
    }
    
    #profile-nav-btn, #animations-nav-btn, #games-nav-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    }
    
    /* Ensure character UI is not overlapped */
    #character-ui {
        z-index: 900;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    #simple-navbar {
        top: 8px;
        right: 8px;
        gap: 6px;
    }
    
    #profile-nav-btn, #animations-nav-btn, #games-nav-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}


/* Hide animation UI by default */
#animation-ui-container {
    display: none !important;
}

/* Show animation buttons ONLY when in game */
body.in-game #animation-ui-container {
    display: flex !important;
}

/* Optional: Double hide in character creator (just in case) */
body.in-character-creator #animation-ui-container {
    display: none !important;
}
/* Character Selection UI - Desktop (unchanged) */
#character-ui {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 300px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1000;
}

#character-ui h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 20px;
}

.control-group {
    margin-bottom: 15px;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: bold;
    font-size: 14px;
}

.color-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.color-btn {
    width: 40px;
    height: 40px;
    border: 3px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: #333;
}

.color-btn.active {
    border-color: #000;
    transform: scale(1.15);
}

.style-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.style-btn {
    padding: 10px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.style-btn:hover {
    background: #f0f0f0;
}

.style-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.select-btn {
    width: 100%;
    padding: 15px;
    margin-top: 10px;
    background: #2ecc71;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.select-btn:hover {
    background: #27ae60;
    transform: scale(1.05);
}

.info {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 8px;
    color: #333;
    font-size: 14px;
}

/* Game UI */
.game-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.instructions {
    margin-bottom: 15px;
    color: #333;
}

.instructions p {
    margin: 5px 0;
}

/* Hamburger Menu */
.hamburger-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.3s ease;
}

.hamburger-btn span {
    width: 25px;
    height: 3px;
    background: #333;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.hamburger-btn:hover span {
    background: #667eea;
}

.hamburger-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Dropdown Menu */
.menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    min-width: 220px;
    overflow: hidden;
    animation: slideDown 0.3s ease;
}

.menu-dropdown.show {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.menu-item {
    width: 100%;
    padding: 12px 20px;
    background: white;
    border: none;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    transition: all 0.2s ease;
    color: #333;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: #f5f5f5;
    color: #667eea;
}

.menu-item:active {
    background: #e8e8e8;
}

/* Mobile Styles - Rearranged layout */
@media (max-width: 768px) {
    #character-ui {
        /* Move to bottom 1/3 of screen */
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: none;
        max-height: 50vh; /* Takes bottom 1/3 of screen */
        padding: 12px;
        border-radius: 15px 15px 0 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        display: flex;
        flex-direction: column;
    }

    #character-ui h2 {
        font-size: 16px;
        margin-bottom: 10px;
        text-align: center;
        order: 1; /* Title stays at top */
    }

    /* Start Game Button at the top */
    #select-character-btn {
        order: 2; /* Button comes right after title */
        margin: 0 0 12px 0; /* Remove top margin, add bottom margin */
        padding: 12px;
        font-size: 14px;
    }

    /* Character Styles Section */
    .control-group:last-of-type {
        order: 3; /* Character styles come after button */
        margin-bottom: 12px;
    }

    .control-group:last-of-type label {
        font-size: 12px;
        margin-bottom: 5px;
        text-align: center;
    }

    .style-options {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .style-btn {
        padding: 8px 4px;
        font-size: 10px;
        line-height: 1.2;
        min-height: 35px;
    }

    /* Color Sections - Stacked at the bottom */
    .control-group:not(:last-of-type) {
        order: 4; /* All color options go to the bottom */
        margin-bottom: 8px;
    }

    .control-group:not(:last-of-type) label {
        font-size: 11px;
        margin-bottom: 3px;
        text-align: center;
    }

    /* Compact color options */
    .color-options {
        grid-template-columns: repeat(6, 1fr);
        gap: 5px;
    }

    .color-btn {
        width: 28px;
        height: 28px;
        border-width: 2px;
    }

    /* Hide info panel on mobile during character selection */
    .info {
        display: none;
    }

    /* Ensure canvas takes full screen but character is centered in top 2/3 */
    canvas {
        height: 50vh; /* Top 2/3 for character */
    }

    /* Additional body styling to handle the layout */
    body {
        height: 100vh;
        display: flex;
        flex-direction: column;
    }
}

/* Very small mobile devices */
@media (max-width: 480px) {
    #character-ui {
        padding: 10px;
        max-height: 35vh; /* Slightly more space on very small screens */
    }

    #select-character-btn {
        padding: 10px;
        font-size: 13px;
        margin-bottom: 10px;
    }

    .color-options {
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
    }

    .color-btn {
        width: 25px;
        height: 25px;
    }

    .style-options {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    .style-btn {
        font-size: 9px;
        padding: 6px 2px;
        min-height: 32px;
    }

    .control-group:not(:last-of-type) label {
        font-size: 10px;
    }
}

/* Small height devices */
@media (max-height: 600px) and (max-width: 768px) {
    #character-ui {
        max-height: 40vh; /* More space for controls on short screens */
    }
    
    canvas {
        height: 60vh;
    }
    
    .style-options {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Hunger/Health UI adjustments for mobile */
#hunger-health-ui {
    z-index: 1000;
}

#health-bar, #hunger-bar {
    transition: width 0.3s ease, background-color 0.3s ease;
}

#death-message {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Mobile Hamburger Menu Styles */
@media (max-width: 768px) {
    .game-controls {
        padding: 15px;
    }
    
    .hamburger-btn span {
        width: 22px;
    }
    
    .menu-dropdown {
        min-width: 180px;
    }
    
    .menu-item {
        padding: 10px 15px;
        font-size: 13px;
    }
}

/* Prevent body scroll on mobile */
@media (max-width: 768px) {
    body {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}