body {
    margin: 0; /* Remove default body margin */
    overflow: hidden; /* Hide scrollbars if content overflows */
    background-color: #282c34;
    color: #e0e0e0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh; /* Make body fill the viewport height */
    width: 100vw; /* Make body fill the viewport width */
}

h1 { /* This H1 element is no longer present in index.html, so it can be removed or hidden */
    display: none; /* Hide the H1 as it's no longer part of the layout */
}

/* New class for the game layout, now applied to #gameContainer */
.game-layout {
    display: grid;
    grid-template-columns: 200px 1fr; /* Sidebar width, then the rest for main content */
    height: 100%; /* Fill parent (body) height */
    width: 100%; /* Fill parent (body) width */
}

.sidebar {
    background-color: #3a3f4a;
    padding: 15px;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px; /* Space between buttons */
    overflow-y: auto; /* Enable scrolling if content overflows */
    border-right: 2px solid #61dafb; /* Add a subtle border to separate from canvas */
}

/* Scrollbar styles for Webkit browsers (Chrome, Safari, Edge) */
.sidebar::-webkit-scrollbar {
    width: 10px; /* Width of the vertical scrollbar */
}

.sidebar::-webkit-scrollbar-track {
    background: #2f343d; /* Color of the scrollbar track */
    border-radius: 5px; /* Slightly rounded corners for the track */
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: #61dafb; /* Color of the scrollbar thumb */
    border-radius: 5px; /* Rounded corners for the thumb */
    border: 2px solid #2f343d; /* Padding around the thumb */
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: #4dc2e0; /* Color of the scrollbar thumb on hover */
}

.sidebar h2 {
    color: #61dafb; /* Changed to match theme */
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.6em; /* Slightly larger */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); /* Subtle text shadow */
}

.sidebar hr {
    width: 90%;
    border: none;
    border-top: 1px solid #5b6270;
    margin: 15px 0;
}

.tool-button, .create-custom-button, .create-custom-human-button {
    width: 90%;
    padding: 10px 15px;
    background-color: #4a505c;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    text-align: left; /* Align text to the left for better readability */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); /* Subtle button shadow */
}

.tool-button:hover, .create-custom-button:hover, .create-custom-human-button:hover {
    background-color: #5b6270;
    transform: translateY(-2px); /* More noticeable lift */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); /* Enhanced shadow on hover */
}

.tool-button:active, .create-custom-button:active, .create-custom-human-button:active {
    background-color: #3e444e;
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); /* Reduced shadow on click */
}

.tool-button.active-tool {
    background-color: #61dafb; /* Bright cyan, similar to canvas border */
    color: #000; /* Black text for contrast */
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4), 0 0 15px rgba(97, 218, 251, 0.6); /* Inner shadow and outer glow */
    border: 1px solid #3a3f4a;
    transform: none; /* Ensure active button doesn't move */
    font-weight: bold; /* Make active text bold */
}

#custom-tools-container, #custom-humans-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%; /* Ensure container takes full width */
}

.main-content {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Make sure main-content fills remaining vertical space */
    width: 100%; /* Important for grid item to take full width of its column */
}

canvas {
    border: 2px solid #61dafb;
    background-color: #000;
    image-rendering: pixelated; /* Ensures crisp pixels */
    display: block;
    flex-grow: 1; /* Allow canvas to take up remaining vertical space within main-content */
    width: 100%; /* Ensure canvas takes full width of its container */
}

.controls {
    background-color: #3a3f4a;
    padding: 15px 30px;
    border-radius: 0 0 8px 8px; /* Round bottom corners only for a top-positioned bar */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    text-align: center;
    width: 100%; /* Make controls full width of its container */
    box-sizing: border-box; /* Include padding in width */
    z-index: 10; /* Ensure controls are on top of the canvas */
    flex-shrink: 0; /* Prevent controls from shrinking */
    border-bottom: 2px solid #61dafb; /* Add a subtle border */
}

.controls-sidebar { /* New style for the controls inside the sidebar */
    width: 100%;
    padding: 0 0 10px 0; /* Adjust padding for visual separation */
    text-align: center;
    margin-bottom: 10px;
    border-bottom: 1px solid #5b6270; /* Subtle separator */
}

.controls-sidebar p {
    margin: 5px 0;
    font-size: 0.95em;
}

.controls p {
    margin: 8px 0;
    font-size: 1.1em;
}

.controls ul {
    display: none;
}

.controls li {
    display: none;
}

#currentTool {
    font-weight: bold;
    color: #a2f986; /* Bright green for visibility */
}

/* Tool Description Box Styles */
#toolDescriptionBox {
    width: 90%;
    background-color: #2f343d;
    border: 1px solid #61dafb;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
    text-align: center;
    font-size: 0.9em;
    color: #c0c0c0;
    display: none; /* Initially hidden */
    opacity: 0;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    transform: translateY(-10px); /* Start slightly above for a subtle slide-in */
}

#toolDescriptionBox.visible-description {
    display: block; /* Make it block to take space */
    opacity: 1;
    transform: translateY(0);
}

#toolDescriptionText {
    margin: 0; /* Remove default paragraph margin */
    white-space: pre-wrap; /* Preserve line breaks in description */
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s, opacity 0.3s ease;
}

.modal-overlay.visible {
    visibility: visible;
    opacity: 1;
}

.modal-content {
    background-color: #3a3f4a;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 400px;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border: 1px solid #61dafb; /* Add a subtle border */
}

.modal-content h3 {
    margin-top: 0;
    color: #61dafb;
    font-size: 1.8em;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.modal-content label {
    font-weight: bold;
    margin-bottom: 5px;
    color: #b0c4de; /* Lighter color for labels */
}

.modal-content input[type="text"],
.modal-content input[type="color"],
.modal-content textarea { /* Added textarea */
    width: calc(100% - 20px);
    padding: 10px;
    border: 1px solid #5b6270;
    border-radius: 4px;
    background-color: #282c34;
    color: #e0e0e0;
    font-size: 1em;
    box-sizing: border-box; /* Include padding in width */
    outline: none; /* Remove default outline */
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    resize: vertical; /* Allow vertical resizing for textareas */
}

.modal-content input[type="text"]:focus,
.modal-content input[type="color"]:focus,
.modal-content textarea:focus { /* Added textarea */
    border-color: #61dafb; /* Highlight on focus */
    box-shadow: 0 0 5px rgba(97, 218, 251, 0.5);
}

.modal-content fieldset {
    border: 1px solid #5b6270;
    border-radius: 4px;
    padding: 15px;
    margin-top: 10px;
    background-color: #31353f; /* Slightly darker background for fieldset */
}

.modal-content legend {
    font-weight: bold;
    color: #e0e0e0;
    padding: 0 5px;
}

.modal-content input[type="radio"] {
    margin-right: 8px;
    accent-color: #61dafb; /* Style radio buttons */
}

.modal-content .modal-buttons {
    display: flex;
    justify-content: space-around;
    gap: 15px;
    margin-top: 20px;
}

.modal-content .modal-buttons button {
    flex-grow: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.modal-content .modal-buttons button#createCustomPixelBtn,
.modal-content .modal-buttons button#createCustomHumanBtn {
    background-color: #4CAF50; /* Green for create */
}

.modal-content .modal-buttons button#createCustomPixelBtn:hover,
.modal-content .modal-buttons button#createCustomHumanBtn:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.modal-content .modal-buttons button#cancelCustomPixelBtn,
.modal-content .modal-buttons button#cancelCustomHumanBtn {
    background-color: #f44336; /* Red for cancel */
}

.modal-content .modal-buttons button#cancelCustomPixelBtn:hover,
.modal-content .modal-buttons button#cancelCustomHumanBtn:hover {
    background-color: #da190b;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* New: Main Menu Overlay Styles */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Enhanced background with radial gradient */
    background: radial-gradient(circle at center, #2e343e 0%, #1e222a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    flex-direction: column; /* To stack logo and button vertically */
    /* Optional: subtle backdrop blur */
    backdrop-filter: blur(3px); 
}

/* New: Styles for the video background container */
.menu-background-videos {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -2; /* Position behind other menu content and the overlay's background */
}

/* New: Styles for individual video elements */
.menu-background-video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    object-fit: cover; /* Ensures video covers the area without distortion */
    opacity: 0; /* Initially hidden */
    transition: opacity 1s ease-in-out; /* Smooth fade effect */
}

/* Style for the currently active video */
.menu-background-video.active {
    opacity: 1; /* Active video is fully visible */
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px; /* Space between logo and button */
    padding: 50px; /* Padding inside the content box */
    background-color: rgba(36, 40, 48, 0.8); /* Slightly transparent, darker background */
    border-radius: 15px; /* Rounded corners for the content box */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), /* Stronger shadow */
                0 0 0 2px rgba(97, 218, 251, 0.3); /* Cyan outline glow */
    border: 1px solid rgba(97, 218, 251, 0.1); /* Subtle border */
    animation: fadeInScale 0.8s ease-out forwards; /* Initial animation */
}

.menu-logo {
    max-width: 80%;
    height: auto;
    max-height: 300px;
    animation: pulse 2s infinite alternate; /* Existing pulse animation */
    /* Add a subtle glow/shadow to the logo */
    filter: drop-shadow(0 0 15px rgba(97, 218, 251, 0.6)) drop-shadow(0 0 5px rgba(255, 255, 255, 0.4));
}

.menu-button {
    padding: 18px 50px; /* Slightly larger padding */
    font-size: 2em; /* Larger font size */
    background-color: #61dafb; /* Bright cyan */
    color: #000;
    border: none;
    border-radius: 10px; /* More rounded corners */
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), /* Deeper shadow */
                0 0 0 3px rgba(97, 218, 251, 0.5); /* Outer glow on button */
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3); /* Text shadow for pop */
    font-weight: bold;
    letter-spacing: 1px;
    animation: popIn 0.5s ease-out forwards 0.5s; /* Pop in after logo */
    opacity: 0; /* Start hidden for popIn animation */
}

.menu-button:hover {
    background-color: #4dc2e0;
    transform: translateY(-4px) scale(1.02); /* More pronounced hover effect */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6),
                0 0 0 5px rgba(97, 218, 251, 0.7);
}

.menu-button:active {
    background-color: #3aadc5;
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3),
                0 0 0 2px rgba(97, 218, 251, 0.4);
}

/* New: Tutorial Modal Styles */
.modal-content.tutorial-video-content {
    max-width: 90vw; /* Adjust max-width for video */
    max-height: 90vh; /* Adjust max-height for video */
    width: auto;
    height: auto;
    padding: 20px;
    gap: 10px;
    background-color: #282c34; /* Darker background for video modal */
}

.modal-content.tutorial-video-content video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 5px;
}

.modal-content.tutorial-video-content button {
    margin-top: 10px;
    align-self: center; /* Center the close button */
    padding: 10px 30px;
    font-size: 1.2em;
    background-color: #f44336; /* Red for close */
    color: #fff;
}

.modal-content.tutorial-video-content button:hover {
    background-color: #da190b;
}

@keyframes pulse {
    from { transform: scale(1); opacity: 0.9; }
    to { transform: scale(1.05); opacity: 1; }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    80% {
        opacity: 1;
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Helper class to hide elements */
.hidden {
    display: none !important;
}