body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #f0f0f0;
    font-family: sans-serif;
    margin: 0;
    padding: 20px;
    overflow: hidden; /* Prevent layout shifts from fixed elements */
}

h1 {
    margin-bottom: 20px;
}

canvas {
    border: 1px solid #ccc;
    background-color: #fff;
    cursor: crosshair;
    margin-bottom: 10px;
    /* Ensure canvas takes up defined size */
    width: 600px; /* Increased size */
    height: 600px; /* Increased size */
    position: relative; /* Needed for z-index if other elements are layered */
    z-index: 1; /* Keep canvas above background but below UI overlays */
    touch-action: none; /* Disable default touch actions like scrolling/zooming */
}

p {
    margin-top: 10px;
    font-size: 1.1em;
    text-align: center;
}

#mewCounter {
    margin-top: 10px;
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    z-index: 1; /* Ensure it's above the canvas */
}

/* Style for the Power Up message */
#powerUpMessage {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #4CAF50;
    color: white;
    padding: 15px;
    border-radius: 8px;
    z-index: 1000;
    display: none;
    text-align: center;
    font-size: 1.5em;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    opacity: 0.95;
}

/* Style for the new Distraction Box */
#distractionBox {
    position: fixed; /* Position relative to the viewport */
    padding: 10px;
    background-color: yellow; /* Bright, distracting color */
    border: 2px solid red;
    color: black;
    font-weight: bold;
    font-size: 1.5em;
    z-index: 999; /* High z-index to be on top */
    display: none; /* Hidden by default */
    pointer-events: none; /* Ignore mouse events so it doesn't block clicks */
    text-align: center;
    animation: pulse 1s infinite alternate; /* Add a simple animation */
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.05); opacity: 0.9; }
}

/* Style for the DDLC Girls Distraction Image */
#ddlcGirlsImage {
    position: fixed; /* Position relative to the viewport */
    max-width: 300px; /* Adjust size as needed */
    height: auto;
    display: none; /* Hidden by default */
    z-index: 990; /* Below distraction box, above canvas */
    cursor: pointer; /* Indicate it's clickable */
}

/* Styles for the Ladies event elements */
#ladiesImage {
    max-width: 100%;
    height: auto;
    margin-bottom: 20px;
    display: none;
    position: relative;
    z-index: 1;
}

#calmingContainer {
    display: none;
    text-align: center;
    position: relative;
    z-index: 1;
}

#calmingMessage {
    font-size: 1.3em;
    margin-bottom: 15px;
}

#calmButton {
    padding: 10px 20px;
    font-size: 1.2em;
    cursor: pointer;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

#calmButton:hover {
    background-color: #0056b3;
}

/* Style for the Game Over message */
#gameOverMessage {
    font-size: 3em;
    color: red;
    font-weight: bold;
    display: none;
    text-align: center;
    position: relative;
    z-index: 1;
}

/* Style for the new submit button */
#submitDrawingButton {
    padding: 10px 20px;
    font-size: 1.2em;
    cursor: pointer;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    margin-top: 10px;
    transition: background-color 0.3s ease;
    position: relative;
    z-index: 1;
}

#submitDrawingButton:hover {
    background-color: #218838;
}

/* Ensure instructions are visible */
#tracingInstruction {
    z-index: 1;
    position: relative;
}

/* Initial state hidden elements */
/* These are also managed by JS, but setting display:none initially in CSS is good practice */
#ladiesImage, #calmingContainer, #gameOverMessage, #distractionBox, #ddlcGirlsImage {
    display: none;
}

/* Ensure all main content elements are layered correctly */
body > *:not(#powerUpMessage):not(#distractionBox):not(#shopContainer):not(#ddlcGirlsImage):not(#announcementPopup) {
    position: relative;
    z-index: 1;
}

/* Add styles for the Shop */
#shopButton {
    padding: 10px 20px;
    font-size: 1.2em;
    cursor: pointer;
    background-color: #ffc107; /* Yellowish */
    color: black;
    border: none;
    border-radius: 5px;
    margin-top: 10px;
    transition: background-color 0.3s ease;
    position: relative;
    z-index: 1;
}

#shopButton:hover {
    background-color: #e0a800; /* Darker yellow */
}

#shopContainer {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px; /* Limit max width */
    background-color: #fff;
    border: 2px solid #333;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    z-index: 1001; /* Higher than distractions */
    display: none; /* Hidden by default */
    flex-direction: column;
    align-items: center;
    max-height: 80vh; /* Limit height */
    overflow-y: auto; /* Add scroll if content overflows */
}

#shopContainer h2 {
    margin-top: 0;
    text-align: center;
}

#upgradeList {
    width: 100%;
    margin-top: 15px;
}

.upgrade-item {
    border: 1px solid #ccc;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.upgrade-item div {
    flex-grow: 1; /* Allow info div to take space */
    margin-right: 10px; /* Space between info and button */
}

.upgrade-item h4 {
    margin: 0 0 5px 0;
}

.upgrade-item p {
    margin: 0 0 5px 0;
    font-size: 0.9em;
    text-align: left; /* Align text left within item */
}

.upgrade-item button {
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 3px;
    border: none;
    font-size: 1em;
    flex-shrink: 0; /* Prevent button from shrinking */
}

.upgrade-item .buy-button {
    background-color: #5cb85c; /* Green */
    color: white;
}

.upgrade-item .buy-button:hover:not(:disabled) {
    background-color: #4cae4c;
}

.upgrade-item .buy-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.upgrade-item .purchased-text {
    color: green;
    font-weight: bold;
}

#closeShopButton {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 5px;
    border: 1px solid #ccc;
    background-color: #eee;
    font-size: 1em;
}

#shopMessage {
    margin-top: 10px;
    font-size: 0.9em;
    color: red; /* Default message color */
    text-align: center;
    width: 100%;
}

/* Add style for Mobile Toggle Button */
#mobileToggleButton {
    padding: 10px 20px;
    font-size: 1.1em;
    cursor: pointer;
    background-color: #17a2b8; /* Info color */
    color: white;
    border: none;
    border-radius: 5px;
    margin-top: 10px;
    transition: background-color 0.3s ease;
    position: relative;
    z-index: 1;
}

#mobileToggleButton:hover {
    background-color: #138496;
}

#mobileToggleButton.active {
    background-color: #28a745; /* Green when active */
}

/* Styles for temporary messages (encouragement, anime girl) */
.temporary-message {
    position: fixed;
    top: 10%; /* Adjust position as needed */
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    z-index: 1000; /* Above canvas but below shop */
    display: none; /* Hidden by default */
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    opacity: 0.9;
    pointer-events: none; /* Don't block clicks */
}

/* Specific style for the anime girl popup if it has a different appearance */
#animeGirlPopup.popup {
    background-color: rgba(255, 182, 193, 0.9); /* Light pink */
    color: #333;
    border: 2px solid hotpink;
    padding: 15px;
    font-size: 1.3em;
}

#animeGirlPopup p {
    margin: 0;
}

/* Style for the new announcement popup */
.announcement-popup {
    position: fixed;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 0, 0, 0.9); /* Red with slight transparency */
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 1002; /* Higher than shop and other popups */
    font-size: 1.8em; /* Larger font size */
    font-weight: bold;
    text-align: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}