body {
    margin: 0;
    overflow: hidden;
    background-color: #87ceeb; /* Sky blue background */
    font-family: sans-serif; /* Add a default font */
}

.hidden {
    display: none !important; /* Use !important to override flex/block/etc display styles */
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: absolute; /* Position relative to the body */
    top: 0;
    left: 0;
    z-index: 0; /* Ensure it's behind UI */
    /* Add background or ensure renderer covers it */
}

#game-container.hidden {
     display: none;
}

canvas {
    display: block; /* Ensure canvas doesn't have extra space below it */
    width: 100%; /* Make canvas fill its container */
    height: 100%; /* Make canvas fill its container */
}

/* --- Login Page Styles --- */
#login-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    /* 2013 Roblox background look - use a dark blue gradient */
    background: linear-gradient(to bottom, #1f4c8b 0%, #2a69b2 100%); /* Darker blue gradient */
    color: #fff; /* White text for better contrast */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content vertically */
    align-items: center; /* Center content horizontally */
    z-index: 50; /* Ensure it's above everything else */
    text-align: center; /* Center text horizontally */
    padding: 20px; /* Add padding to prevent text overflow on small screens */
    box-sizing: border-box;
}

/* Increased outline size and changed color */
/* Style for the logo area - applies to both login and home pages */
#logo-area {
    font-family: 'Arial Black', sans-serif; /* Use a bold sans-serif font */
    font-size: 5em; /* Large font size */
    color: white; /* White text */
    text-shadow: -3px -3px 0 #e32d2d, 3px -3px 0 #e32d2d, -3px 3px 0 #e32d2d, 3px 3px 0 #e32d2d; /* Thick red outline */
    margin-bottom: 30px; /* Space below the logo */
    letter-spacing: -2px; /* Reduce letter spacing slightly */
}

#login-panel {
    background-color: rgba(0, 0, 0, 0.3); /* Semi-transparent dark background */
    border: 1px solid rgba(255, 255, 255, 0.2); /* Subtle light border */
    border-radius: 8px; /* Rounded corners */
    padding: 30px; /* Increased padding */
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 400px; /* Limit panel width */
    box-sizing: border-box;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5); /* Larger, softer shadow */
}

/* Style subtitle inside the panel */
#login-panel .home-subtitle {
    margin-bottom: 15px;
    font-size: 1em; /* Smaller font size */
    max-width: none; /* Remove width limit from global style */
    line-height: 1.4; /* Adjust line spacing */
    color: #eee; /* Lighter grey for text */
}

.username-section {
     width: 100%; /* Ensure section takes full panel width */
     display: flex;
     flex-direction: column;
     align-items: center;
     margin-bottom: 20px; /* Space below the username section */
}

#username-prompt {
    color: #eee; /* Lighter grey color */
    margin-bottom: 10px; /* Space below the prompt */
    font-size: 1em; /* Match subtitle size */
}

#username-input {
    padding: 12px;
    margin-bottom: 0; /* Remove margin bottom, handled by section margin */
    border: 1px solid #ccc;
    border-radius: 4px; /* Slightly less rounded than before */
    background-color: #fff;
    color: #333;
    font-size: 1em; /* Standard font size */
    width: 100%; /* Make input fill its container */
    max-width: 280px; /* Limit input width */
    text-align: left; /* Left-align text in input */
    box-sizing: border-box;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

#username-input::placeholder {
    color: #aaa;
}

.home-buttons {
    width: 100%; /* Ensure buttons container takes full panel width */
    display: flex;
    flex-direction: column;
    align-items: center;
}

#login-panel button {
    padding: 12px 25px; /* Adjusted padding */
    border: none;
    border-radius: 5px; /* Standard rounded corners */
    cursor: pointer;
    font-size: 1.1em; /* Slightly larger font */
    font-weight: bold;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    margin-bottom: 10px; /* Space between buttons */
    width: 100%; /* Make buttons fill their container */
    max-width: 250px; /* Limit button width */
    text-align: center;
    box-sizing: border-box;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3); /* Add subtle shadow */
    text-transform: uppercase; /* Make text uppercase */
}

#login-panel button#proceed-button {
    /* Blue button style */
    background-color: #0099ff; /* Bright blue */
    color: white;
    /* 2013 style gradient and border */
    background: linear-gradient(to bottom, #00ccff 0%, #0099ff 100%); /* Lighter blue to brighter blue */
    border: 1px solid #0077cc; /* Darker blue border */
}

#login-panel button#proceed-button:hover {
    background-color: #0077cc; /* Darker blue */
    background: linear-gradient(to bottom, #00bbee 0%, #0088ee 100%); /* Slightly different gradient on hover */
    border-color: #0055aa; /* Even darker blue border on hover */
}

#login-panel button#join-as-guest-button {
    /* Grey button style */
    background-color: #cccccc; /* Light grey */
    color: #333; /* Dark text */
    /* 2013 style gradient and border */
    background: linear-gradient(to bottom, #eeeeee 0%, #cccccc 100%); /* Light grey to grey */
    border: 1px solid #aaaaaa; /* Darker grey border */
}

#login-panel button#join-as-guest-button:hover {
    background-color: #bbbbbb; /* Darker grey */
    background: linear-gradient(to bottom, #dddddd 0%, #bbbbbb 100%); /* Slightly different gradient on hover */
    border-color: #999999; /* Even darker grey border on hover */
}

/* Last button doesn't need bottom margin */
#login-panel button:last-child {
     margin-bottom: 0;
}

/* --- New Home Page Styles (Metro Style) --- */
#home-page {
    position: fixed; /* Keep fixed for full screen */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    /* Metro background - use a dark solid color */
    background-color: #1e1e1e; /* Dark grey */
    color: #fff;
    display: flex;
    flex-direction: column;
    /* Align items to the start for top-left layout */
    justify-content: flex-start; /* Align content from the top */
    align-items: stretch; /* Allow content to stretch horizontally */
    z-index: 50;
    padding: 0; /* Remove default padding */
    box-sizing: border-box;
    position: relative; /* Added for absolute positioning of the game card */
}

#players-online {
    position: absolute;
    top: 5.5%;
    right: 175px;
    transform: translateY(-50%); /* Center vertically in nav bar */
    color: white;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    height: auto; /* Remove fixed height */
    display: flex;
    align-items: center;
}

/* Adjust logo positioning and size on home page for Metro feel */
#home-page #logo-area {
    font-size: 2.5em;
    text-shadow: -2px -2px 0 #e32d2d, 2px -2px 0 #e32d2d, -2px 2px 0 #e32d2d, 2px 2px 0 #e32d2d;
    letter-spacing: -1px;
    margin-bottom: 0;
}

#welcome-text {
    margin: 0 20px; /* Add horizontal margin to align with nav bar */
    margin-top: 20px; /* Space below nav bar */
}

/* Style for subtitles (used on both login and home pages now) */
.home-subtitle {
    font-size: 1em; /* Standard size */
    line-height: 1.4;
    color: #eee; /* Lighter grey color */
    margin-bottom: 15px; /* Space below subtitle */
    text-shadow: none; /* Remove text shadow for flatter look */
}

/* Add styles for the new game list section text */
#game-list-section {
    margin-top: 15px; /* Space above the section */
    margin-bottom: 15px; /* Space below the section */
    /* Use flexbox to align heading and subtitle */
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Align text to the left */
}

#game-list-section h2 {
    margin: 0; /* Remove default margin */
    font-size: 1.8em; /* Slightly smaller than welcome text */
    color: white;
    text-shadow: none; /* Remove text shadow */
    margin-bottom: 5px; /* Space below the heading */
    font-weight: normal; /* Use normal weight */
}

#game-list-section .home-subtitle {
    margin-bottom: 0; /* Remove bottom margin from subtitle in this section */
    font-size: 0.95em; /* Slightly smaller subtitle */
    color: #ccc; /* Lighter grey */
    text-shadow: none; /* Remove text shadow */
}

/* --- New Game Card Style (Metro Tile) --- */
#test-game-card {
    position: static;
    margin-top: 10; /* Ensure no extra top margin */
    margin-right: auto; /* Keeps it aligned to the left (as align-items is flex-start) */
    width: 250px; /* Fixed width for the card */
    height: 180px; /* Fixed height for the card */
    /* Metro tile background - use a solid dark color */
    background-color: #2d2d2d; /* Darker grey */
    border: none; /* Remove border */
    border-radius: 4px; /* Slightly less rounded corners */
    overflow: hidden; /* Hide anything outside the card */
    cursor: pointer; /* Indicate it's clickable */
    display: flex;
    flex-direction: column;
    box-shadow: none; /* Remove shadow for flatter look */
    transition: background-color 0.1s ease-in-out; /* Add hover effect */
}

#test-game-card:hover {
    transform: none; /* Remove transform effect */
    box-shadow: none; /* Remove shadow effect */
    background-color: #3a3a3a; /* Slightly lighter grey on hover */
}

.game-thumbnail {
    width: 100%; /* Fill card width */
    height: 100px; /* Fixed height for thumbnail area */
    object-fit: cover; /* Cover the area without stretching */
    display: block; /* Remove extra space below image */
}

.game-info {
    flex-grow: 1; /* Take remaining vertical space */
    padding: 10px;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Space out title and player count */
}

.game-info h3 {
    margin: 0;
    font-size: 1.1em;
    font-weight: normal; /* Use normal weight */
    color: #eee; /* Lighter color for title */
}

.game-info .player-count {
    margin: 0;
    font-size: 0.9em;
    color: #bbb; /* Muted color for player count */
}

/* --- New Button: WoBlocks Editor (Top Right) (Metro Style) --- */
#editor-button {
    padding: 8px 15px; /* Reduced padding for more compact look */
    height: 36px; /* Reduced height */
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em; /* Slightly smaller font */
    font-weight: bold;
    text-transform: uppercase;
    transition: background-color 0.2s;
    white-space: nowrap;
    margin: 0;
    background-color: rgba(0, 0, 0, 0.1); /* Match nav bar background */
    color: white;
}

/* Add hover effect */
#editor-button:hover {
   background-color: rgba(255, 255, 255, 0.2); /* Light grey with transparency */
}

/* Remove the specific disabled hover styles */
#editor-button[disabled]:hover {
    /* Keep same background and opacity as the default (non-hover) state when disabled */
    background-color: #4a4a4a; /* Dark grey background */
    opacity: 0.7; /* Reduced opacity */
}

/* --- Game UI Styles (Unchanged) --- */
#menu-button {
    position: fixed; /* Fixed position relative to viewport */
    bottom: 60px; /* Moved up to make space for chat input */
    left: 20px;
    padding: 10px 20px;
    background-color: #212121; /* Dark grey background */
    color: white;
    border: 2px solid #e32d2d; /* Red outline */
    border-radius: 5px;
    cursor: pointer;
    z-index: 10; /* Ensure it's above the game */
    font-size: 18px;
    user-select: none; /* Prevent text selection */
    transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease; /* Add transition for smooth hover effect */
}

#menu-button:hover {
    background-color: #333333; /* Slightly lighter grey */
    border-color: #f43e3e; /* Slightly lighter red */
}

#menu-button.disabled {
    opacity: 0.5; /* Reduce opacity when disabled */
    cursor: not-allowed; /* Change cursor */
    pointer-events: none; /* Disable click events */
}

#menu-button.disabled:hover {
    background-color: #212121; /* Keep background same as default when disabled and hovered */
    border-color: #e32d2d; /* Keep border same as default when disabled and hovered */
}

#menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5); /* 50% opacity black background */
    z-index: 15; /* Between game and menu panel */
}

#menu-overlay.hidden {
    display: none;
}

#menu-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Center the panel */
    width: 400px; /* Example size */
    height: auto; /* Increased height from 300px */
    min-height: 400px; /* Minimum height */
    background-color: rgba(33, 33, 33, 0.35); /* 35% opacity dark grey */
    border: none; /* Removed border */
    border-radius: 10px;
    display: flex; /* Use flexbox for centering content */
    justify-content: flex-start; /* Align items to the top */
    align-items: center; /* Center horizontally */
    z-index: 20; /* Ensure it's above the menu button and overlay */
    flex-direction: column; /* Stack items vertically */
    padding: 20px; /* Add padding */
    box-sizing: border-box; /* Include padding and border in element's total width and height */
}

#menu-panel.hidden {
    display: none;
}

#menu-panel h2 {
    color: white;
    font-weight: bold;
    margin-top: 10px; /* Add a little space from the top edge of the panel */
    margin-bottom: 20px; /* Add space below the title */
}

#menu-panel button {
    padding: 10px 20px;
    background-color: #212121; /* Dark grey background */
    color: white;
    border: 2px solid #4a4a4a; /* Dark grey outline */
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s ease, border-color 0.2s ease; /* Add transition for smooth hover effect */
    user-select: none; /* Prevent text selection */
    width: 250px; /* Set a fixed width for all buttons to make them the same length */
    text-align: center;
    box-sizing: border-box; /* Include padding and border in width */
    margin-bottom: 10px; /* Add margin below buttons */
}

#menu-panel button:hover {
     background-color: #333333; /* Slightly lighter grey */
     border-color: #e32d2d; /* Red outline */
}

#settings-button {
    border-color: #26D926; /* Green outline */
}

#settings-button:hover {
     border-color: #39F239; /* Lighter green outline on hover */
}

#leave-game-button {
     border-color: #e32d2d; /* Red outline */
}

#leave-game-button:hover {
     border-color: #f43e3e; /* Lighter red outline on hover */
}

#settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5); /* 50% opacity black background */
    z-index: 15; /* Between game and settings panel */
}

#settings-overlay.hidden {
    display: none;
}

#settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Center the panel */
    width: 450px; /* Example size - Increased width */
    height: auto; /* Allow height to adjust based on content */
    min-height: 350px; /* Minimum height */
    border: none; /* Removed border */
    border-radius: 10px;
    display: flex; /* Use flexbox for centering content */
    justify-content: flex-start; /* Align items to the top */
    align-items: center; /* Center horizontally */
    z-index: 20; /* Ensure it's above the settings button and overlay */
    flex-direction: column; /* Stack items vertically */
    padding: 20px; /* Add padding */
    box-sizing: border-box; /* Include padding and border in element's total width and height */
    color: white; /* Default text color */
}

#settings-panel.hidden {
    display: none;
}

#settings-panel h2 {
    color: white;
    font-weight: bold;
    margin-top: 10px; /* Add a little space from the top edge of the panel */
    margin-bottom: 20px; /* Add space below the title */
}

#settings-panel button {
    padding: 10px 20px;
    background-color: #212121; /* Dark grey background */
    color: white;
    border: 2px solid #4a4a4a; /* Dark grey outline */
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    user-select: none;
    width: 250px; /* Match width of menu buttons */
    text-align: center;
    box-sizing: border-box;
    margin-bottom: 10px;
}

#settings-panel button:hover {
    background-color: #333333; /* Slightly lighter grey */
    border-color: #e32d2d; /* Red outline */
}

.setting-group {
    width: 100%; /* Take full width of the panel */
    display: flex;
    flex-direction: column; /* Stack label and buttons vertically */
    align-items: center;
    margin-bottom: 20px; /* Space below each setting group */
    padding: 10px; /* Add some padding inside the group */
    border: 1px solid rgba(255, 255, 255, 0.1); /* Subtle border for grouping */
    border-radius: 5px;
    box-sizing: border-box;
}

.setting-group label {
    font-weight: bold;
    margin-bottom: 10px; /* Space below the label */
    font-size: 1.1em;
}

.setting-group button {
    width: 200px; /* Make setting buttons slightly smaller */
    margin-bottom: 5px; /* Less margin between setting buttons */
}

.setting-group button:last-child {
     margin-bottom: 0; /* No margin below the last button in a group */
}

.setting-group button.active-setting {
    border-color: #e32d2d; /* Highlight active button with red */
    background-color: #333333; /* Match hover background */
}

#settings-panel > button:last-child {
    margin-top: auto; /* Push the last button (Return) to the bottom */
    margin-bottom: 0;
}

#health-bar-container {
    position: fixed;
    bottom: 60px; /* Moved up to make space for chat input */
    left: 50%; /* Center horizontally */
    transform: translateX(-50%); /* Adjust for centering */
    width: 200px; /* Fixed width */
    height: 25px; /* Fixed height */
    background-color: #444; /* Dark grey background */
    border-radius: 5px; /* Rounded corners */
    overflow: hidden; /* Hide overflow of the fill bar */
    z-index: 10; /* Above the game */
    border: 1px solid rgba(255, 255, 255, 0.2); /* Subtle white border */
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5); /* Subtle shadow */
    display: flex; /* Use flex for positioning text */
    justify-content: center; /* Center text horizontally */
    align-items: center; /* Center text vertically */
}

#health-bar-fill {
    height: 100%;
    width: 100%; /* Will be updated by JS */
    background-color: #008000; /* Default green fill */
    transition: width 0.3s ease; /* Smooth transition for health changes */
}

#health-bar-text {
    position: absolute; /* Position text over the fill bar */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white; /* White text color */
    font-weight: bold;
    font-size: 0.9em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); /* Add text shadow for readability */
    z-index: 1; /* Ensure text is above the fill bar */
}

/* Chat UI */
#chat-display {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 300px; /* Width of the chat display area */
    max-height: 30vh; /* Maximum height for the chat history */
    overflow-y: auto; /* Add scrollbar if messages exceed max height */
    z-index: 10; /* Above the game */
    color: white;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); /* Add text shadow for readability */
    padding-right: 5px; /* Add padding to the right for scrollbar */
}

#chat-display::-webkit-scrollbar {
    width: 8px; /* Width of the scrollbar */
}

#chat-display::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1); /* Light transparent track */
    border-radius: 4px;
}

#chat-display::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2); /* Transparent white thumb */
    border-radius: 4px;
}

#chat-display::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4); /* More transparent white thumb on hover */
}

#chat-display div {
    margin-bottom: 3px; /* Space between messages */
    word-wrap: break-word; /* Break long words */
}

#chat-input-container {
    position: fixed;
    bottom: 20px; /* Position above the menu button */
    left: 20px; /* Align with menu button */
    width: 300px; /* Match chat display width */
    z-index: 10; /* Above the game */
    background-color: rgba(0, 0, 0, 0.25); /* Set opacity to 25% */
    border-radius: 5px;
    padding: 5px;
    box-sizing: border-box;
}

#chat-input {
    width: 100%; /* Make input fill its container */
    background-color: transparent; /* Make input background invisible */
    color: white; /* White text color */
    border: none; /* Remove border */
    outline: none; /* Remove outline on focus */
    font-size: 14px;
    padding: 0; /* Remove default padding */
    margin: 0; /* Remove default margin */
    box-sizing: border-box;
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.7); /* Slightly transparent placeholder text */
    font-style: italic;
}

/* Chat message and player list color classes - refining the color scheme */
#chat-display .chat-message.red,
#player-list .player-item.red {
    color: #e32d2d; /* Red - for usernames A-H */
}

#chat-display .chat-message.orange,
#player-list .player-item.orange {
    color: #cf7d13; /* Orange - for usernames I-R */
}

#chat-display .chat-message.green,
#player-list .player-item.green {
    color: #26D926; /* Green - for usernames S-Z */
}

#chat-display .chat-message.blue,
#player-list .player-item.blue {
    color: #0099ff; /* Brighter blue - specifically for guest usernames */
}

/* --- Player List UI Styles --- */
#player-list-container {
    position: fixed;
    top: 20px; /* Not too top */
    right: 20px;
    width: 200px; /* Fixed width for the list */
    max-height: 50vh; /* Maximum height */
    background-color: rgba(0, 0, 0, 0.25); /* Semi-transparent background */
    border-radius: 5px;
    padding: 10px;
    box-sizing: border-box;
    z-index: 10; /* Above the game */
    display: flex;
    flex-direction: column;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

#player-list-container h2 {
    margin: 0 0 10px 0; /* Margin only at the bottom */
    font-size: 1.1em;
    font-weight: bold;
    text-align: center; /* Center the header */
}

#player-list {
    flex-grow: 1; /* Allow the list to take available space */
    overflow-y: auto; /* Add scrollbar if players exceed max height */
    font-size: 0.9em;
    /* Reuse scrollbar styles from chat */
}

#player-list::-webkit-scrollbar {
    width: 8px;
}

#player-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

#player-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

#player-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

#player-list .player-item {
    margin-bottom: 3px; /* Space between player names */
    word-wrap: break-word; /* Break long names */
}

/* --- Editor Page Styles --- */
#editor-page {
    position: fixed; /* Fixed position relative to viewport */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #87ceeb; /* Sky blue background */
    z-index: 50; /* Ensure it's above other pages */
    display: flex;
    flex-direction: column; /* Use flex column to position children */
    align-items: center; /* Center content horizontally */
    justify-content: center; /* Center content vertically */
}

/* Container for the editor canvas */
#editor-canvas-container {
    width: 100vw;
    height: 100vh;
    position: absolute; /* Position absolute to fill the page */
    top: 0;
    left: 0;
    z-index: 0; /* Ensure it's behind the UI buttons */
}

#editor-canvas-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Style for the editor UI buttons (e.g., Return to Home) */
.editor-ui-button {
    position: absolute; /* Position relative to the #editor-page container */
    top: 20px; /* Distance from the top */
    left: 20px; /* Distance from the left */
    padding: 10px 20px;
    background-color: #212121; /* Dark grey background */
    color: white;
    border: 2px solid #e32d2d; /* Red outline */
    border-radius: 5px;
    cursor: pointer;
    z-index: 10; /* Ensure it's above the canvas */
    font-size: 18px;
    user-select: none; /* Prevent text selection */
    transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
    box-sizing: border-box;
    text-align: center;
}

.editor-ui-button:hover {
    background-color: #333333; /* Slightly lighter grey */
    border-color: #f43e3e; /* Slightly lighter red */
}

/* --- Editor Toolbar Styles --- */
#editor-toolbar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(33, 33, 33, 0.85);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.editor-tools-group {
    display: flex;
    gap: 5px;
}

.editor-tool-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 15px;
    background-color: #444;
    border: none;
    border-radius: 5px;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.editor-tool-button:hover {
    background-color: #555;
}

.editor-tool-button.active {
    background-color: #e32d2d;
}

.tool-icon {
    font-size: 1.5em;
    margin-bottom: 4px;
}

/* Tool Properties Panel */
#tool-properties {
    position: absolute;
    top: 100px;
    right: 20px;
    background-color: rgba(33, 33, 33, 0.85);
    border-radius: 8px;
    padding: 15px;
    width: 250px;
    color: white;
    z-index: 100;
}

.tool-panel {
    display: none;
}

.tool-panel.active {
    display: block;
}

.tool-panel h3 {
    margin: 0 0 15px 0;
    font-size: 1.2em;
    color: #e32d2d;
}

/* Axis Controls */
.axis-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.axis-button {
    flex: 1;
    padding: 8px;
    background-color: #444;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
}

.axis-button[data-axis="x"] { color: #ff4444; }
.axis-button[data-axis="y"] { color: #44ff44; }
.axis-button[data-axis="z"] { color: #4444ff; }

/* Scale and Rotation Controls */
.scale-controls,
.rotation-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scale-input,
.rotation-input {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.scale-input input,
.rotation-input input {
    width: 80px;
    padding: 5px;
    background-color: #444;
    border: 1px solid #666;
    border-radius: 4px;
    color: white;
}

/* Collision Toggle */
.collision-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.collision-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Ensure the canvas container stays behind the UI */
#editor-canvas-container {
    z-index: 0;
}

/* New Properties Panel Styles */
.properties-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.property-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.property-item label {
    color: #eee;
    font-size: 0.9em;
}

.property-item input[type="text"],
.property-item input[type="number"] {
    background-color: #444;
    border: 1px solid #666;
    border-radius: 4px;
    color: white;
    padding: 5px;
}

.vector-input {
    display: flex;
    gap: 5px;
}

.vector-input input {
    width: 60px;
}

.property-item input[type="color"] {
    width: 100%;
    height: 30px;
    background-color: #444;
    border: 1px solid #666;
    border-radius: 4px;
}

.property-item input[type="range"] {
    width: 100%;
}

/* Warning Text Style */
#editor-warning {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 0, 0, 0.2);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
    text-align: center;
    z-index: 100;
    pointer-events: none;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Navigation Bar Styles - Updated for consistency */
.navigation-bar {
    width: 100%;
    padding: 10px 40px; /* Adjusted padding to be consistent */
    box-sizing: border-box;
    display: flex;
    align-items: center; /* Center items vertically */
    gap: 10px; /* Reduced from 20px for more compact buttons */
    background-color: rgba(0, 0, 0, 0.1); /* Subtle background */
    height: 80px; /* Set explicit height for consistency */
}

/* Logo style in navigation - consistent across pages */
.navigation-bar #logo-area {
    font-size: 2.5em; /* Consistent font size */
    margin: 0;
    flex-shrink: 0;
    line-height: 1; /* Add line height to help with vertical centering */
    text-shadow: -2px -2px 0 #e32d2d, 2px -2px 0 #e32d2d, -2px 2px 0 #e32d2d, 2px 2px 0 #e32d2d; /* Add consistent text shadow */
    letter-spacing: -1px; /* Add consistent letter spacing */
}

/* Navigation button styles - consistent across pages */
.nav-button {
    padding: 8px 15px; /* Reduced padding for more compact look */
    height: 36px; /* Reduced height */
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em; /* Slightly smaller font */
    font-weight: bold;
    text-transform: uppercase;
    transition: background-color 0.2s;
    white-space: nowrap;
    margin: 0;
    background-color: rgba(0, 0, 0, 0.1); /* Match nav bar background */
    color: white;
}

/* Consistent hover and active states */
.nav-button:hover {
    background-color: rgba(255, 255, 255, 0.2); /* Light grey with transparency */
}

.nav-button.active {
    background-color: rgba(0, 0, 0, 0.3); /* Darker background for active state */
}

.nav-button:disabled {
    background-color: rgba(0, 0, 0, 0.05);
    opacity: 0.7;
    cursor: not-allowed;
}

/* Settings Page Styles */
#settings-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #1e1e1e;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    z-index: 50;
    padding: 0; /* Remove default padding */
    box-sizing: border-box;
}

.settings-content {
    width: 100%;
    max-width: 800px;
    margin: 40px auto;
    padding: 0 40px;
    margin-top: 20px;
    overflow-y: auto; /* Add scrollbar if content exceeds height */
}

.settings-section {
    background-color: #2d2d2d;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
}

.settings-section h2 {
    color: white;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.5em;
    font-weight: normal;
}

.settings-option {
    margin-bottom: 15px;
    padding: 10px;
    background-color: #3a3a3a;
    border-radius: 4px;
}

.settings-option label {
    display: block;
    margin-bottom: 10px;
    color: #eee;
    font-size: 1.1em;
}

.settings-option select {
    width: 200px;
    padding: 8px;
    background-color: #444;
    color: white;
    border: 1px solid #666;
    border-radius: 4px;
}

/* Style for color input settings options */
.settings-option.color-setting {
     display: flex; /* Use flex to align label and input horizontally */
     justify-content: space-between; /* Space out label and input */
     align-items: center; /* Center vertically */
}

.settings-option.color-setting label {
     margin-bottom: 0; /* Remove bottom margin */
     flex-shrink: 0; /* Prevent label from shrinking */
     margin-right: 10px; /* Add space between label and input */
}

.settings-option.color-setting input[type="color"] {
    /* Adjust size and style for color input */
    width: 80px; /* Fixed width for color picker */
    height: 30px;
    padding: 0; /* Remove padding */
    border: none; /* Remove default border */
    background-color: transparent; /* Make background transparent */
    border-radius: 4px;
    overflow: hidden; /* Hide default color input styling borders */
}

.settings-option.color-setting input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.settings-option.color-setting input[type="color"]::-webkit-color-swatch {
    border: 1px solid #666; /* Add a visible border to the color swatch */
    border-radius: 4px;
}

#settings-page #logo-area {
    font-size: 2.5em;
    text-shadow: -2px -2px 0 #e32d2d, 2px -2px 0 #e32d2d, -2px 2px 0 #e32d2d, 2px 2px 0 #e32d2d;
    letter-spacing: -1px;
    margin-bottom: 0;
}

/* Add style for points counter */
#points-display, #players-online {
    display: flex;
    align-items: center;
    color: white;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    white-space: nowrap; /* Prevent wrapping */
}

#points-display {
    position: absolute;
    top: 50%;
    right: 150px; /* Adjusted position for compact layout */
    transform: translateY(-50%);
}

#points-display .points-symbol {
    color: #00aba9;
    font-weight: bold;
    margin-right: 4px;
}

#players-online {
    position: absolute;
    top: 50%;
    right: 15px; /* Adjusted position for compact layout */
    transform: translateY(-50%);
}

/* Make navigation bar position relative for absolute positioning of counters */
.navigation-bar {
    position: relative;
}

/* Marketplace Page Styles */
#marketplace-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #1e1e1e;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    z-index: 50;
    padding: 0;
    box-sizing: border-box;
}

.marketplace-content {
    width: 100%;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 40px;
    margin-top: 20px;
    overflow-y: auto;
}

.marketplace-content h2 {
    font-size: 2em;
    margin-bottom: 10px;
}

.marketplace-subtitle {
    color: #ccc;
    margin-bottom: 30px;
}

/* Categories Section */
.marketplace-categories {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

.category-button {
    padding: 10px 20px;
    background-color: #2d2d2d;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

.category-button:hover {
    background-color: #3a3a3a;
}

.category-button.active {
    background-color: #00aba9;
}

/* Items Grid */
.marketplace-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.marketplace-item {
    background-color: #2d2d2d;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s;
}

.marketplace-item:hover {
    transform: translateY(-5px);
}

.item-image-placeholder {
    width: 100%;
    height: 150px;
    background-color: #3a3a3a;
}

.item-info {
    padding: 15px;
}

.item-info h3 {
    margin: 0;
    font-size: 1.1em;
    color: white;
}

.item-price {
    color: #00aba9;
    font-weight: bold;
    margin: 10px 0;
}

.buy-button {
    width: 100%;
    padding: 8px;
    background-color: #00aba9;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

.buy-button:hover {
    background-color: #008c8a;
}

/* Add consistent marketplace button styles */
#marketplace-nav-button,
#marketplace-nav-button-marketplace {
    padding: 8px 15px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    text-transform: uppercase;
    transition: background-color 0.2s;
    white-space: nowrap;
    margin: 0;
    background-color: rgba(0, 0, 0, 0.1);
    color: white;
}

#marketplace-nav-button:hover,
#marketplace-nav-button-marketplace:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

#marketplace-nav-button.active,
#marketplace-nav-button-marketplace.active {
    background-color: rgba(0, 0, 0, 0.3);
}

/* Inventory UI Styles */
#inventory-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    padding: 5px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    z-index: 10;
}

.inventory-slot {
    width: 50px;
    height: 50px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer; /* Indicate clickable */
    transition: border-color 0.1s ease, background-color 0.1s ease;
}

.inventory-slot:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.inventory-slot.selected {
    border-color: #e32d2d;
    background-color: rgba(255, 255, 255, 0.2);
}

.inventory-slot img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.inventory-slot .item-count {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 12px;
    color: white;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}

/* Move health bar up to make room for inventory */
#health-bar-container {
    bottom: 90px;
}