body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #001f4d, #000000); /* Dark blue to black */
    color: #fff;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.game-container {
    position: relative;
    width: 960px; /* Standard game resolution width */
    height: 540px; /* Standard game resolution height (16:9 aspect ratio) */
    background-color: #000;
    border: 5px solid #0056b3; /* Darker blue border */
    box-shadow: 0 0 50px rgba(0, 86, 179, 0.7); /* Darker blue shadow */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Hide anything outside game area */
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #0d001a; /* Default dark background for game */
    display: block;
}

/* Menu Screens */
.menu-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 100; /* Ensure menus are on top */
    transition: opacity 0.5s ease-in-out;
    overflow-y: auto; /* Allow vertical scrolling so buttons never get cut off */
    box-sizing: border-box;
    padding: 40px 10px; /* extra top padding so title and header area have breathing room */
}

.hidden {
    opacity: 0;
    pointer-events: none; /* Disable interaction when hidden */
    display: none; /* Crucial: Remove from layout entirely */
}

.active {
    opacity: 1;
    pointer-events: all; /* Enable interaction when active */
    display: flex; /* Ensure it's displayed as flex when active */
}

.game-title {
    font-size: 1.9em; /* Slightly smaller to improve fit */
    max-width: 92%; /* Keep title within container so it won't overflow */
    line-height: 1.15; /* Slightly looser line height for readability */
    color: #33ccff; /* Bright blue neon glow */
    text-shadow: 0 0 12px #33ccff, 0 0 24px #33ccff;
    margin: 56px 0 16px 0; /* Moved title further down so it is no longer cut off */
    word-wrap: break-word;
    hyphens: auto;
    text-align: center;
}

.version-label {
    font-size: 1em; /* Reduced from 1.2em */
    color: #bbb;
    margin-bottom: 25px; /* Reduced from 40px */
}

.menu-button {
    background-color: #0056b3; /* Darker blue button */
    color: #fff;
    border: 2px solid #3498db; /* Medium blue border */
    padding: 8px 14px; /* Smaller padding to fit more buttons on-screen */
    margin: 6px 6px; /* Reduced margin and allow horizontal spacing for grid */
    font-size: 0.95em; /* Smaller font so labels fit without wrapping */
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.20s ease, transform 0.06s ease, box-shadow 0.20s ease;
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.35);
    min-width: 140px; /* Reduced min width so more buttons can fit */
}

.menu-button:hover {
    background-color: #007bff; /* Brighter blue on hover */
    transform: translateY(-1px); /* Reduced from -2px */
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.7); /* Reduced shadow */
}

.menu-button:active {
    background-color: #003e80; /* Even darker blue on active */
    transform: translateY(0);
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

h2 {
    font-size: 2.5em;
    color: #00bfff; /* Deep sky blue neon glow */
    text-shadow: 0 0 10px #00bfff, 0 0 20px #00bfff;
    margin-bottom: 20px;
}

p {
    font-size: 1.1em;
    margin: 5px 0;
    color: #eee;
}

/* Game HUD */
.hud-display {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 50; /* Above canvas, below menus */
    color: #fff;
    font-size: 1.2em;
    text-shadow: 0 0 5px #000;
}

.hud-item {
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.difficulty-hud {
    position: absolute;
    top: 10px; /* Adjust as needed */
    right: 10px; /* Position in top-right */
    left: auto; /* Override left:10px */
}

.speed-hud {
    position: absolute;
    top: 40px; /* Below difficulty */
    right: 10px; /* Same alignment as difficulty */
    left: auto;
}

/* Game Over Screen Specifics */
#game-over-screen h2 {
    color: #ff33cc; /* Vibrant pink neon */
    text-shadow: 0 0 10px #ff33cc, 0 0 20px #ff33cc;
}

/* Settings Menu */
#settings-menu {
    /* Override default menu-screen properties for a more compact size */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto; /* Allow width to be determined by content and max-width */
    height: auto; /* Allow height to be determined by content and max-height */
    max-width: 450px; /* Make the settings menu itself smaller */
    max-height: 90%; /* Prevent it from taking full height if content is short */
    padding: 20px;
    box-sizing: border-box;
    border-radius: 10px;
    border: 2px solid #00ccff; /* Neon border */
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: flex-start; /* Align content to the top */
    overflow-y: auto; /* Enable scrolling if content overflows vertical space */
}

#settings-menu .setting-group {
    margin-bottom: 15px; /* Slightly reduce margin between groups */
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%; /* Make groups take full width of their container */
    max-width: 380px; /* Limit max width of group content */
}

#settings-menu label {
    font-size: 1.1em; /* Slightly smaller font for labels */
    margin-bottom: 6px;
    color: #00ccff; /* Still a cyan/light blue, good contrast */
}

#settings-menu input[type="range"],
#settings-menu select {
    width: 90%; /* Take more width within its group */
    max-width: 320px; /* Smaller max width for inputs */
    padding: 4px; /* Reduce padding */
    font-size: 0.95em; /* Slightly smaller font */
}

#settings-menu input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px; /* Slightly smaller thumb */
    height: 18px; /* Slightly smaller thumb */
    border-radius: 50%;
    background: #33ccff; /* Bright blue for slider thumb */
    cursor: grab;
    box-shadow: 0 0 6px rgba(51, 204, 255, 0.7);
}
#settings-menu input[type="range"]::-moz-range-thumb {
    width: 18px; /* Slightly smaller thumb */
    height: 18px; /* Slightly smaller thumb */
    border-radius: 50%;
    background: #33ccff; /* Bright blue for slider thumb */
    cursor: grab;
    box-shadow: 0 0 6px rgba(51, 204, 255, 0.7);
}

#settings-menu .error-log {
    background-color: #0d001a;
    border: 1px solid #0056b3; /* Darker blue */
    padding: 8px; /* Reduce padding */
    width: 90%;
    max-width: 320px; /* Smaller max width for log */
    height: 90px; /* Reduce height */
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8em; /* Smaller font for logs */
    text-align: left;
    white-space: pre-wrap; /* Preserve whitespace and wrap text */
    word-wrap: break-word; /* Break long words */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

/* Ensure buttons at the bottom have appropriate margin */
#settings-menu .menu-button {
    margin-top: 15px; /* Add more space above back button */
    min-width: 150px; /* Adjust button size */
    font-size: 1.1em;
    padding: 10px 20px;
}

/* Level Editor */
#level-editor-screen {
    flex-direction: column; /* Keep main screen column */
    justify-content: flex-start; /* Align content to top */
    padding: 20px;
}

#level-editor-screen h2 {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    color: #ffcc00; /* Keeping yellow for editor for contrast */
    text-shadow: 0 0 10px #ffcc00, 0 0 20px #ffcc00;
}

.editor-main-area {
    display: flex; /* Use flexbox for controls, canvas, palette */
    width: 100%;
    height: calc(100% - 120px); /* Adjust height to leave space for title and back button */
    gap: 20px;
    align-items: flex-start; /* Align contents to the top */
    margin-top: 60px; /* Space for the h2 title */
}

.editor-controls {
    flex: 0 0 280px; /* Fixed width for controls */
    height: 100%; /* Take full height of main area */
    overflow-y: auto; /* Scroll if too many controls */
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid #ffcc00;
    border-radius: 8px;
    align-items: center;
    margin-top: 0; /* Remove top margin, handled by editor-main-area */
    display: flex; /* Make sure it's a flex container */
    flex-direction: column; /* Stack controls vertically */
    gap: 10px; /* Space between controls */
}

.editor-theme-select {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}

.editor-theme-select label {
    font-size: 1.1em;
    color: #ffcc00;
    margin-bottom: 5px;
}

#editorThemeSelect {
    width: calc(100% - 20px);
    padding: 8px 10px;
    background-color: #222;
    border: 1px solid #ffcc00;
    color: #fff;
    border-radius: 5px;
    font-size: 1em;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23ffffff%22%20d%3D%22M287%2C197.989L146.2%2C57.189L5.4%2C197.989H287z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 8px top 50%;
    background-size: 10px auto;
}

#editorCanvas {
    background-color: #1a1a1a;
    border: 2px solid #ffcc00; /* Keeping yellow for editor for contrast */
    cursor: cell;
    /* Remove fixed width/height, let JS control internal resolution, CSS makes it flexible */
    flex-grow: 1; /* Canvas takes remaining space */
    min-width: 320px; /* Minimum width for canvas */
    min-height: 180px; /* Minimum height for canvas */
    max-width: 100%;
    max-height: 100%;
    /* Ensure it has a default CSS size to be visible */
    width: 600px;
    height: 400px;
}

.editor-canvas-size {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    justify-content: center;
    margin-top: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}
.editor-canvas-size label {
    font-size: 0.9em;
    color: #ffcc00;
    white-space: nowrap;
    margin-bottom: 0;
}
.editor-canvas-size input[type="number"] {
    width: 70px;
    padding: 5px;
    background-color: #222;
    border: 1px solid #ffcc00;
    color: #fff;
    border-radius: 5px;
    font-size: 0.9em;
    -moz-appearance: textfield; /* Hide arrows for Firefox */
}
.editor-canvas-size input[type="number"]::-webkit-outer-spin-button,
.editor-canvas-size input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Object Palette (New) */
.object-palette {
    flex: 0 0 200px; /* Fixed width for palette */
    height: 100%; /* Take full height of main area */
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid #ffcc00;
    border-radius: 8px;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.object-palette h3 {
    margin: 5px 0 10px 0;
    font-size: 1.2em;
    color: #ffcc00;
    text-shadow: 0 0 8px #ffcc00;
}

#paletteSearchInput {
    width: calc(100% - 10px);
    padding: 5px;
    margin-bottom: 10px;
    background-color: #222;
    border: 1px solid #ffcc00;
    color: #fff;
    border-radius: 5px;
    font-size: 0.9em;
}

.palette-buttons-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Two columns for palette items */
    gap: 8px;
    width: 100%;
    overflow-y: auto; /* Make scrollable */
    flex-grow: 1; /* Allow container to grow and take space */
    padding-right: 5px; /* For scrollbar */
}

.palette-btn {
    background-color: #333;
    color: #eee;
    border: 1px solid #555;
    padding: 5px; /* Smaller padding */
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60px; /* Fixed height for consistent button size */
    position: relative;
}

.category-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    color: white;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
}

.palette-btn:hover {
    background-color: #555;
}

.palette-btn.active {
    background-color: #ffcc00; /* Keeping yellow for editor for contrast */
    color: #000;
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.7);
}
.palette-btn img {
    max-width: 40px; /* Size of image inside button */
    max-height: 40px;
    object-fit: contain;
    margin-bottom: 3px;
    image-rendering: pixelated; /* Ensure pixel-perfect rendering for retro assets */
}
.palette-btn span {
    font-size: 0.7em; /* Smaller text */
    text-align: center;
    white-space: nowrap; /* Prevent wrapping */
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%; /* Ensure text fills container to use ellipsis */
}

#levelNameInput {
    width: calc(100% - 20px);
    padding: 8px 10px;
    background-color: #222;
    border: 1px solid #ffcc00; /* Keeping yellow for editor for contrast */
    color: #fff;
    border-radius: 5px;
    margin-bottom: 10px;
    font-size: 1em;
}

#savedLevelsDropdown {
    width: calc(100% - 20px);
    padding: 8px 10px;
    background-color: #222;
    border: 1px solid #ffcc00; /* Keeping yellow for editor for contrast */
    color: #fff;
    border-radius: 5px;
    font-size: 1em;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23ffffff%22%20d%3D%22M287%2C197.989L146.2%2C57.189L5.4%2C197.989H287z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 8px top 50%;
    background-size: 10px auto;
}

#editorBackBtn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
}

/* Help Screens */
.help-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80%;
    max-width: 600px;
    text-align: left;
}

.controls-section, .objective-section, .mechanics-section, .difficulty-section {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid rgba(0, 191, 255, 0.3);
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.3);
    width: 100%;
}

.controls-section h3, .objective-section h3, .mechanics-section h3, .difficulty-section h3 {
    color: #00bfff;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.controls-section p, .objective-section p, .difficulty-section p {
    margin: 8px 0;
    font-size: 1.1em;
    color: #eee;
}

.mechanic-item {
    margin: 10px 0;
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 5px;
    font-size: 1em;
    color: #eee;
}

.mechanic-item strong {
    color: #00bfff;
}

/* Level Select Screen */
#level-select-screen {
    position: relative; /* Ensure children can be positioned absolutely within it */
    padding-top: 60px; /* Add padding to make space for the top-left back button */
    box-sizing: border-box; /* Include padding in element's total width and height */
}

#levelSelectBackBtn {
    position: absolute;
    top: 20px; /* Position from the top */
    left: 20px; /* Position from the left */
    margin: 0; /* Remove default button margins */
    min-width: unset; /* Allow button to size based on content */
    padding: 8px 15px; /* Adjust padding for a smaller button */
    font-size: 1em; /* Adjust font size */
    z-index: 120; /* Ensure it's above other elements on the screen */
}

#level-buttons-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px; /* Spacing between level selection buttons */
    margin-top: 20px; /* Space below the mode label */
    flex-grow: 1; /* Allow it to take up available vertical space */
    width: 80%; /* Limit width for a cleaner look */
    max-width: 400px;
    padding: 10px;
    overflow-y: auto; /* Enable scrolling if levels exceed height */
    box-sizing: border-box;
    /* Optional: styling for the container itself */
    border: 1px solid rgba(0, 191, 255, 0.5); /* Keeping this blue */
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.3);
}

/* Multiplayer Lobby */
#multiplayer-lobby h2 {
    color: #00ccff; /* Light blue neon (keeping this, it's already blue) */
    text-shadow: 0 0 10px #00ccff, 0 0 20px #00ccff;
}

#multiplayer-lobby .color-picker-container {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#multiplayer-lobby #playerColorPicker {
    width: 100px;
    height: 40px;
    border: none;
    background: none;
    cursor: pointer;
    margin-top: 10px;
    border: 2px solid #00ccff; /* Keeping this blue */
    border-radius: 5px;
}

#multiplayer-lobby #playerList {
    list-style: none;
    padding: 0;
    margin: 15px 0 30px 0;
    font-size: 1.1em;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 204, 255, 0.5); /* Keeping this blue */
    border-radius: 5px;
    max-height: 150px;
    overflow-y: auto;
    width: 80%;
    max-width: 300px;
    text-align: left;
}

#multiplayer-lobby #playerList li {
    padding: 8px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#multiplayer-lobby #playerList li:last-child {
    border-bottom: none;
}

/* Loading Screen */
#loading-screen {
    background-color: rgba(0, 0, 0, 0.98);
    z-index: 150; /* Above all other menus */
}

#loading-screen h2 {
    color: #00e6e6; /* Aqua neon */
    text-shadow: 0 0 10px #00e6e6, 0 0 20px #00e6e6;
    margin-bottom: 15px;
}

#loading-screen p {
    font-size: 1.2em;
    color: #aaffaa;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #00e6e6; /* Spinner color */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Difficulty Selector */
.difficulty-selector {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    position: absolute; /* Position it on the level select screen */
    bottom: 20px; /* Aligned to bottom-left */
    left: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid #00bfff;
    border-radius: 8px;
    padding: 10px;
    z-index: 110; /* Above regular menu screens but below loading */
    min-width: 180px;
}

.difficulty-selector h3 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
    color: #00bfff; /* Deep sky blue neon glow */
    text-shadow: 0 0 8px #00bfff;
}

.difficulty-button {
    background-color: #003366; /* Dark blue */
    color: #fff;
    border: 1px solid #0066cc; /* Medium blue */
    padding: 8px 15px;
    margin: 5px 0;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

.difficulty-button:hover {
    background-color: #004488;
}

.difficulty-button.active {
    background-color: #00bfff; /* Bright blue for active */
    color: #000;
    border-color: #fff;
    box-shadow: 0 0 10px rgba(0, 191, 255, 0.7);
}

/* Version and Copyright Info */
.version-info, .copyright-info {
    position: absolute;
    color: #888; /* Soft grey for subtle text */
    font-size: 0.8em; /* Small font size */
    text-shadow: 0 0 2px rgba(0,0,0,0.5);
    padding: 5px;
    z-index: 1;
    white-space: normal;
    max-width: 42%;
    overflow-wrap: break-word;
}

/* Replace textual top-left/top-right credits with a subtle ambient pulsing glow */
.top-left-info, .top-right-info {
    position: absolute;
    width: 120px;
    height: 36px;
    z-index: 2;
    pointer-events: none;
    border-radius: 8px;
    mix-blend-mode: screen; /* blend nicely with background */
    filter: blur(12px) saturate(120%);
    opacity: 0.9;
}

/* ambient-light helper class used for pulsing gradient panels */
.ambient-light {
    background: linear-gradient(90deg, rgba(51,204,255,0.14), rgba(0,120,212,0.22), rgba(51,204,255,0.10));
    box-shadow: 0 8px 30px rgba(0,120,212,0.24), inset 0 0 30px rgba(51,204,255,0.06);
    animation: ambientPulse 6s ease-in-out infinite;
}

/* position specifics */
.top-left-info { top: 12px; left: 12px; transform: translateZ(0); }
.top-right-info { top: 12px; right: 12px; transform: translateZ(0); }

/* slow subtle pulsing that slightly brightens and dims the gradient */
@keyframes ambientPulse {
    0% { opacity: 0.65; transform: scale(0.985); filter: blur(12px) saturate(100%); }
    45% { opacity: 1; transform: scale(1.02); filter: blur(8px) saturate(140%); }
    100% { opacity: 0.7; transform: scale(0.99); filter: blur(12px) saturate(110%); }
}

.version-info {
    bottom: 10px;
    left: 10px;
}

.copyright-info {
    bottom: 10px;
    right: 10px;
    text-align: right;
}

.top-left-info {
    top: 10px;
    left: 10px;
    text-align: left;
}

.top-right-info {
    top: 10px;
    right: 10px;
    text-align: right;
}

/* Main Menu Button Container */
.main-menu-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr)); /* segment into two compact columns */
    gap: 8px 10px; /* vertical and horizontal gaps */
    width: 100%;
    max-width: 420px; /* wider to accommodate two columns */
    justify-items: center;
    align-items: start;
    padding: 6px 8px;
    box-sizing: border-box;
}

/* New style for top-left menu buttons on the main menu */
.top-left-menu-buttons {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 101; /* Ensure it's above other menu elements */
}

.top-left-menu-buttons .menu-button {
    padding: 8px 15px; /* Adjust padding for a smaller button */
    font-size: 1em; /* Adjust font size */
    min-width: unset; /* Allow button to size based on content */
    margin: 0; /* Remove default button margins */
}

/* New style for top-right menu buttons on the main menu */
.top-right-main-menu-buttons {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 101; /* Ensure it's above other menu elements */
}

.top-right-main-menu-buttons .menu-button {
    padding: 8px 15px; /* Adjust padding for a smaller button */
    font-size: 1em; /* Adjust font size */
    min-width: unset; /* Allow button to size based on content */
    margin: 0; /* Remove default button margins */
}

/* How To Play Screen */
#how-to-play-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 100;
    transition: opacity 0.5s ease-in-out;
    padding: 20px;
    box-sizing: border-box;
}

#how-to-play-screen h2 {
    margin-top: 20px;
    margin-bottom: 20px;
    color: #ffd700; /* Gold neon */
    text-shadow: 0 0 10px #ffd700, 0 0 20px #ffd700;
}

.how-to-play-content {
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid #ffd700;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    max-width: 700px;
    width: 90%;
    height: calc(100% - 140px); /* Adjust height to leave space for title and button */
    overflow-y: auto;
    text-align: left;
    color: #eee;
    font-size: 1em;
    line-height: 1.5;
}

.how-to-play-content h3 {
    color: #ffa500; /* Orange neon */
    margin-top: 15px;
    margin-bottom: 8px;
    font-size: 1.2em;
    text-shadow: 0 0 5px #ffa500;
}

.how-to-play-content ul {
    list-style-type: disc;
    margin-left: 20px;
    padding-left: 0;
    margin-bottom: 15px;
}

.how-to-play-content li {
    margin-bottom: 5px;
}

/* Game Mechanics Screen */
#game-mechanics-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 100;
    transition: opacity 0.5s ease-in-out;
    padding: 20px;
    box-sizing: border-box;
}

#game-mechanics-screen h2 {
    margin-top: 20px;
    margin-bottom: 20px;
    color: #ffd700; /* Gold neon */
    text-shadow: 0 0 10px #ffd700, 0 0 20px #ffd700;
}

.mechanics-content {
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid #ffd700;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    max-width: 700px;
    width: 90%;
    height: calc(100% - 140px); /* Adjust height to leave space for title and button */
    overflow-y: auto;
    text-align: left;
    color: #eee;
    font-size: 1em;
    line-height: 1.5;
}

.mechanics-content h3 {
    color: #ffa500; /* Orange neon */
    margin-top: 15px;
    margin-bottom: 8px;
    font-size: 1.2em;
    text-shadow: 0 0 5px #ffa500;
}

.mechanics-content ul {
    list-style-type: disc;
    margin-left: 20px;
    padding-left: 0;
    margin-bottom: 15px;
}

.mechanics-content li {
    margin-bottom: 5px;
}

/* Patch Notes Screen */
#patch-notes-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align content to the top */
    align-items: center;
    text-align: center;
    z-index: 100;
    transition: opacity 0.5s ease-in-out;
    padding: 20px;
    box-sizing: border-box;
}

#patch-notes-screen h2 {
    margin-top: 20px;
    margin-bottom: 20px;
    color: #ffd700; /* Gold neon */
    text-shadow: 0 0 10px #ffd700, 0 0 20px #ffd700;
}

.patch-notes-content {
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid #ffd700;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    max-width: 700px;
    width: 90%;
    height: calc(100% - 140px); /* Adjust height to leave space for title and button */
    overflow-y: auto;
    text-align: left;
    color: #eee;
    font-size: 1em;
    line-height: 1.5;
}

.patch-notes-content h3 {
    color: #ffa500; /* Orange neon */
    margin-top: 15px;
    margin-bottom: 8px;
    font-size: 1.2em;
    text-shadow: 0 0 5px #ffa500;
}

.patch-notes-content ul {
    list-style-type: disc;
    margin-left: 20px;
    padding-left: 0;
    margin-bottom: 15px;
}

.patch-notes-content li {
    margin-bottom: 5px;
}

/* Responsive Design (Optional, but good for production-ready) */
@media (max-width: 992px) {
    .game-container {
        width: 100vw;
        height: 56.25vw; /* Maintain 16:9 aspect ratio */
        max-height: 100vh;
        max-width: 177.78vh; /* Maximize within viewport */
    }

    .game-title {
        font-size: 3em;
    }

    .menu-button {
        padding: 10px 20px;
        font-size: 1.1em;
        min-width: 180px;
    }

    h2 {
        font-size: 2em;
    }

    .hud-display {
        font-size: 1em;
    }

    #level-editor-screen {
        flex-direction: column;
        overflow-y: auto;
        padding-top: 80px; /* Adjust for title */
    }

    .editor-main-area {
        flex-direction: column; /* Stack editor parts vertically on small screens */
        height: auto; /* Allow height to adjust */
    }

    .editor-controls {
        margin-top: 0;
        width: 90%;
        max-width: 400px;
        flex: none; /* Disable flex-grow */
    }

    #editorCanvas {
        width: 90%;
        height: 300px;
        flex: none; /* Disable flex-grow */
        margin-top: 20px;
    }

    .object-palette {
        flex: none;
        width: 90%;
        max-width: 400px;
        margin-top: 20px;
    }
    .palette-buttons-container {
        grid-template-columns: repeat(3, 1fr); /* More columns for objects on smaller screens */
    }

    #editorBackBtn {
        position: static;
        transform: none;
        margin-top: 20px;
    }
    #settings-menu {
        max-width: 90%; /* Allow settings menu to expand more on smaller screens */
    }

    #level-select-screen {
        padding-top: 50px; /* Adjust padding for smaller screens */
    }

    #levelSelectBackBtn {
        top: 10px;
        left: 10px;
        padding: 6px 12px;
        font-size: 0.9em;
    }

    #level-buttons-container {
        margin-top: 10px; /* Adjust for smaller screens */
        max-height: calc(100% - 120px); /* Adjust max height */
    }

    .top-left-menu-buttons {
        top: 10px;
        left: 10px;
    }

    .top-left-menu-buttons .menu-button {
        padding: 6px 12px;
        font-size: 0.9em;
    }

    .difficulty-selector {
        bottom: 10px;
        left: 10px;
        padding: 8px;
        min-width: 150px;
    }

    #stats-screen { /* Renamed from account-screen */
        max-width: 90%;
    }

    /* Adjust text size for smaller screens */
    .version-info, .copyright-info, .top-left-info, .top-right-info {
        font-size: 0.7em;
        bottom: 5px;
        padding: 3px;
    }
    .version-info {
        left: 5px;
    }
    .copyright-info {
        right: 5px;
    }
    .top-left-info {
        top: 5px;
        left: 5px;
    }
    .top-right-info {
        top: 5px;
        right: 5px;
    }

    .top-right-roadmap {
        top: 60px; /* Adjust position for smaller screens to avoid overlap */
        right: 5px;
        font-size: 0.8em;
        max-width: 200px;
        padding: 8px 12px;
    }
    .top-right-roadmap h3 {
        font-size: 1em;
    }
    .top-right-roadmap p, .top-right-roadmap li {
        font-size: 0.85em;
    }
}

@media (max-width: 768px) {
    .game-container {
        border-width: 3px;
        box-shadow: 0 0 30px rgba(0, 86, 179, 0.7);
    }

    .game-title {
        font-size: 2.5em;
    }

    .menu-button {
        padding: 8px 18px;
        font-size: 1em;
        min-width: 150px;
    }

    h2 {
        font-size: 1.8em;
    }

    .hud-display {
        font-size: 1em;
    }

    #level-select-screen {
        padding-top: 40px; /* Further adjust padding for very small screens */
    }

    #levelSelectBackBtn {
        top: 5px;
        left: 5px;
        padding: 5px 10px;
        font-size: 0.8em;
    }

    #settings-menu input[type="range"],
    #settings-menu select {
        width: 90%; /* Adjust for very small screens */
    }

    #settings-menu .error-log {
        width: 90%;
        height: 100px; /* Adjust for very small screens */
    }

    .top-left-menu-buttons {
        top: 5px;
        left: 5px;
    }

    .top-right-main-menu-buttons {
        top: 5px;
        right: 5px;
    }

    .top-left-menu-buttons .menu-button,
    .top-right-main-menu-buttons .menu-button {
        padding: 5px 10px;
        font-size: 0.8em;
    }

    .difficulty-selector {
        bottom: 5px;
        left: 5px;
        padding: 8px;
        min-width: 120px;
    }
    .difficulty-selector h3 {
        font-size: 1em;
        margin-bottom: 5px;
    }
    .difficulty-button {
        padding: 6px 10px;
        font-size: 0.8em;
    }

    /* Further adjust text size for very small screens */
    .version-info, .copyright-info, .top-left-info, .top-right-info {
        font-size: 0.6em;
    }

    /* New Roadmap Screen styles */
    #roadmap-screen {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.95);
        display: flex;
        flex-direction: column;
        justify-content: flex-start; /* Align content to the top */
        align-items: center;
        text-align: center;
        z-index: 100;
        transition: opacity 0.5s ease-in-out;
        padding: 20px;
        box-sizing: border-box;
    }

    #roadmap-screen h2 {
        margin-top: 20px;
        margin-bottom: 20px;
        color: #00bfff; /* Deep sky blue neon glow */
        text-shadow: 0 0 10px #00bfff, 0 0 20px #00bfff;
    }

    .roadmap-content {
        background-color: rgba(0, 0, 0, 0.7);
        border: 2px solid #00bfff;
        border-radius: 8px;
        padding: 15px;
        margin-bottom: 20px;
        max-width: 700px;
        width: 90%;
        height: calc(100% - 140px); /* Adjust height to leave space for title and button */
        overflow-y: auto;
        text-align: left;
        color: #eee;
        font-size: 1em;
        line-height: 1.5;
    }

    .roadmap-content h3 {
        color: #33ccff; /* Bright blue neon */
        margin-top: 15px;
        margin-bottom: 8px;
        font-size: 1.2em;
        text-shadow: 0 0 5px #33ccff;
    }

    .roadmap-content ul {
        list-style-type: disc;
        margin-left: 20px;
        padding-left: 0;
        margin-bottom: 15px;
    }

    .roadmap-content li {
        margin-bottom: 5px;
    }
}