body {
    margin: 0;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #000; /* Black background for the page */
    font-family: Arial, sans-serif;
    color: white;
}

canvas {
    background-color: #000; /* Black background for the game */
    display: block;
    border: 2px solid #333; /* Optional border to define game area */
}

/* Base style for all full-screen overlay screens */
#shopContainer,
#skinPickerScreen,
#mainMenuScreen,
#gameOverScreen,
#levelEditorScreen { /* New: Include level editor screen */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9); /* Semi-transparent dark background */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000; /* Ensure it's on top */
    padding: 20px;
    box-sizing: border-box;
    transition: opacity 0.3s ease-in-out;
}

/* Hidden class for transitions */
.hidden {
    opacity: 0;
    pointer-events: none; /* Disable interaction when hidden */
}

#gameUI {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 20px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    transition: opacity 0.3s ease-in-out;
}

#controls {
    position: absolute;
    bottom: 20px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
    pointer-events: none; /* Allow clicks to pass through to buttons */
    transition: opacity 0.3s ease-in-out;
}

#topRightControls {
    position: absolute;
    top: 10px;
    right: 10px;
    pointer-events: none; /* Allow clicks to pass through to buttons */
    transition: opacity 0.3s ease-in-out;
    display: flex; /* Make buttons arrange horizontally */
    gap: 10px; /* Space between buttons */
}

#dpad {
    display: flex;
    gap: 10px;
}

#rightSideButtons { /* New style for the container of Jump and Dash buttons */
    display: flex;
    flex-direction: column;
    gap: 10px; /* Space between dash and jump buttons */
    align-items: flex-end; /* Align buttons to the right edge of this container */
}

/* General Button Styles for game controls and game over */
#controls button,
#topRightControls button,
#gameOverScreen button { 
    pointer-events: all; /* Make buttons clickable */
    background-color: rgba(255, 255, 255, 0.2); /* Semi-transparent */
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%; /* Make them circular */
    width: 85px; /* Increased size */
    height: 85px; /* Increased size */
    font-size: 36px; /* Increased font size for icons */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none; /* Prevent text selection */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
    touch-action: manipulation; /* Prevent default touch actions like double tap zoom */
    font-weight: bold;
    transition: background-color 0.2s, border-color 0.2s;
}

/* Adjust size for Menu and Shop buttons in topRightControls */
#topRightControls button {
    width: 95px; /* Slightly larger for text labels */
    height: 60px; /* Rectangular shape for text */
    border-radius: 10px; /* Rounded corners for rectangular buttons */
    font-size: 20px; /* Smaller font size for text */
}

#controls button:active,
#topRightControls button:active,
#gameOverScreen button:active {
    background-color: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.8);
}

/* Specific style for the Dash button to adjust font size for "Dash" text */
#dashButton {
    font-size: 24px; /* Smaller font for text label, scaled up */
    padding-top: 5px; /* Adjust padding if needed to center text */
}

#dashButton:disabled {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
}

/* Shop styles */
.shop-header {
    width: 90%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #555;
}

.shop-header h2 {
    margin: 0;
    font-size: 2.5em;
    color: #4CAF50; /* Green theme for shop */
}

#shopCoinsDisplay {
    font-size: 1.5em;
    color: #FFD700; /* Gold color for coins */
}

#closeShopButton {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s;
    border-radius: 50%; /* Make them circular */
    width: 70px; /* Adjust size for close button */
    height: 70px;
}

#closeShopButton:hover {
    color: #f00;
}

#shopItems {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    width: 90%;
    max-width: 600px;
    background-color: #222;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    max-height: 70vh;
    overflow-y: auto;
}

.shop-item {
    background-color: #333;
    padding: 15px;
    border-radius: 5px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #444;
}

.shop-item h3 {
    margin-top: 0;
    font-size: 1.2em;
    color: #FFF;
}

.shop-item p {
    font-size: 0.9em;
    color: #CCC;
    margin: 10px 0;
}

.buy-button {
    background-color: #4CAF50; /* Green buy button */
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s, opacity 0.2s;
    width: 100%;
    box-sizing: border-box;
    height: auto; /* Allow height to adjust based on padding */
    border-radius: 5px; /* Square buttons for shop items */
}

.buy-button:hover:not(:disabled) {
    background-color: #45a049;
}

.buy-button:disabled {
    background-color: #555;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Game Over Screen styles */
#gameOverScreen h2 {
    font-size: 3.5em;
    color: #E74C3C; /* Red for Game Over */
    margin-bottom: 20px;
}

#gameOverScreen p {
    font-size: 1.8em;
    color: white;
    margin: 10px 0;
}

#gameOverScreen button {
    margin-top: 30px;
    background-color: #2ECC71; /* Green for Play Again */
    color: white;
    font-size: 2em;
    padding: 15px 40px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    width: auto; /* Override general button width */
    height: auto; /* Override general button height */
}

#gameOverScreen button:hover {
    background-color: #27AE60;
}

/* Main Menu Screen styles */
#mainMenuScreen {
    z-index: 1002; /* Ensure main menu is above others initially */
}

#mainMenuScreen h1 {
    font-size: 4em;
    color: #FFF;
    margin-bottom: 40px;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.7);
}

#mainMenuScreen button {
    background-color: #007bff; /* Blue for main menu buttons */
    color: white;
    font-size: 2em;
    padding: 15px 40px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    margin: 10px 0;
    transition: background-color 0.2s, transform 0.1s;
    width: 250px; /* Fixed width for consistency */
}

#mainMenuScreen button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

#mainMenuScreen button:active {
    transform: translateY(0);
}

/* Skin Picker Screen styles */
#skinPickerScreen {
    z-index: 1001; /* Above game, below main menu if main menu is present */
}

.skin-picker-header {
    width: 90%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #555;
}

.skin-picker-header h2 {
    margin: 0;
    font-size: 2.5em;
    color: #17A2B8; /* Cyan/Teal theme for skin picker */
}

#skinPickerCoinsDisplay {
    font-size: 1.5em;
    color: #FFD700;
}

#closeSkinPickerButton {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s;
    border-radius: 50%;
    width: 70px;
    height: 70px;
}

#closeSkinPickerButton:hover {
    color: #f00;
}

#skinItems {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); /* Slightly smaller items */
    gap: 15px; /* Smaller gap */
    width: 90%;
    max-width: 600px;
    background-color: #222;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    max-height: 70vh;
    overflow-y: auto;
}

.skin-item {
    background-color: #333;
    padding: 10px; /* Slightly less padding */
    border-radius: 5px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #444;
}

.skin-item h3 {
    margin-top: 0;
    font-size: 1em; /* Smaller font */
    color: #FFF;
}

.skin-preview {
    width: 60px;
    height: 60px;
    border: 2px solid #FFF;
    margin: 10px 0;
    display: flex; /* For centering content like images */
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Hide overflow for images */
}

.skin-preview.default-square-preview {
    background-color: var(--default-player-color); /* This will be set by JS using COLOR_PLAYER */
    border-radius: 5px; /* Square shape */
}

.skin-preview.skin-image-preview {
    border-radius: 5px; /* Square shape for images */
    object-fit: contain; /* Ensure image fits */
    width: 100%; /* Fill container */
    height: 100%; /* Fill container */
}

.skin-item p {
    font-size: 0.8em; /* Smaller font */
    color: #CCC;
    margin: 5px 0;
}

.skin-button {
    background-color: #17A2B8; /* Cyan/Teal buy/select button */
    color: white;
    border: none;
    padding: 8px 12px; /* Smaller padding */
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s, opacity 0.2s;
    width: 100%;
    box-sizing: border-box;
    height: auto;
}

.skin-button:hover:not(:disabled) {
    background-color: #138496;
}

.skin-button:disabled {
    background-color: #555;
    cursor: not-allowed;
    opacity: 0.7;
}

/* New: Level Editor Styles */
#levelEditorScreen {
    z-index: 1003; /* Above all other screens */
    padding: 10px; /* Reduce padding slightly to make room for toolbar */
    justify-content: flex-start; /* Align content to top */
}

.editor-header {
    width: 100%;
    max-width: 800px; /* Match canvas width */
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid #555;
}

.editor-header h2 {
    margin: 0;
    font-size: 2.2em;
    color: #E6B800; /* Gold/Yellow theme for editor */
}

#closeEditorButton {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s;
    border-radius: 50%;
    width: 60px;
    height: 60px;
}

#closeEditorButton:hover {
    color: #f00;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap; /* Allow buttons to wrap */
    gap: 8px; /* Spacing between buttons */
    margin-bottom: 15px;
    justify-content: center;
    width: 100%;
    max-width: 800px; /* Match canvas width */
    background-color: #333;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.editor-tool-button {
    background-color: #555;
    color: white;
    border: 1px solid #777;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s, border-color 0.2s;
    flex-shrink: 0; /* Prevent shrinking */
}

.editor-tool-button:hover:not(.active) {
    background-color: #666;
}

.editor-tool-button.active {
    background-color: #E6B800; /* Active tool highlight */
    border-color: #FFD700;
    color: black;
    font-weight: bold;
}

.editor-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
    max-width: 800px;
    justify-content: center;
}

.editor-controls button {
    background-color: #2ECC71; /* Green for action buttons */
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.2s;
}

.editor-controls button:hover {
    background-color: #27AE60;
}

/* New: Info Popup Styles */
#infoPopup {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1004; /* Above all other screens */
    padding: 20px;
    box-sizing: border-box;
    transition: opacity 0.3s ease-in-out;
}

.info-popup-content {
    background-color: #333;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0,0,0,0.7);
    max-width: 400px;
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#infoPopupMessage {
    font-size: 1.8em;
    color: #FFD700; /* Gold color for message */
    margin: 0;
}

#infoPopupCloseButton {
    background-color: #007bff;
    color: white;
    font-size: 1.5em;
    padding: 10px 30px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    width: auto;
    height: auto;
}

#infoPopupCloseButton:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

#infoPopupCloseButton:active {
    transform: translateY(0);
}