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 */
}

#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);
}

#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 */
}

#topRightControls {
    position: absolute;
    top: 10px;
    right: 10px;
    pointer-events: none; /* Allow clicks to pass through to 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 */
}

#controls button,
#topRightControls button,
#gameOverScreen button { /* Apply styles to buttons in both control containers and game over screen */
    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;
}

#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 */
#shopContainer {
    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;
}

#shopContainer.hidden {
    opacity: 0;
    pointer-events: none; /* Disable interaction when hidden */
}

.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 {
    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: 1001; /* Above shop */
    padding: 20px;
    box-sizing: border-box;
    transition: opacity 0.3s ease-in-out;
}

#gameOverScreen.hidden {
    opacity: 0;
    pointer-events: none;
}

#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;
}