html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    flex-direction: column;
    background-color: #202226; /* Grafana dark theme background */
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: #E0E0E0; /* Light grey for text */
    overflow: hidden; /* Prevent scrollbars during gameplay */
}

#header {
    background-color: #1F2124; /* Slightly lighter than panel background */
    padding: 10px 20px;
    text-align: center;
    border-bottom: 1px solid #333;
}

#header h1 {
    margin: 0;
    font-size: 24px;
    color: #E0E0E0;
}

#gameWrapper {
    position: relative; /* Changed to relative to allow header/footer visibility */
    flex-grow: 1; /* Allow it to take available space */
    display: flex; /* Use flexbox to center content */
    align-items: center; /* Center vertically */
    justify-content: center; /* Center horizontally */
    overflow: hidden; /* Hide anything outside the scaled game area */
    background-color: #202226; /* Match body background */
    z-index: 1; /* Ensure it's above body content but below modal */
}

#gameArea {
    position: relative;
    width: 800px;  /* Fixed width for internal game logic */
    height: 500px; /* Fixed height for internal game logic (adjusted for rectangular) */
    background-color: #161719; /* Grafana panel background */
    overflow: hidden; /* Keep game elements contained */
    /* Transform scale will be applied by JavaScript */
    transform-origin: center center; /* Ensure scaling from center */
}

#character {
    position: absolute;
    width: 40px; /* Same as canvas version */
    height: 40px; /* Same as canvas version */
    background-image: url('CloudSurf.png');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 10;
}

#pipesContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
}

.pipe {
    position: absolute;
    background-color: #EAB839; /* Grafana yellow/orange */
    width: 80px; /* Same as canvas version */
}

#chartContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.chart-line-segment {
    position: absolute;
    background-color: #629E51; /* Grafana green */
    height: 2px; /* CHART_LINE_WIDTH */
}

.grid-line {
    position: absolute;
    background-color: #333; /* Darker grey for grid */
}

.horizontal-grid-line {
    width: 100%;
    height: 0.5px;
}

.vertical-grid-line {
    width: 0.5px;
    height: 100%;
}

#legendContainer {
    position: absolute;
    top: 20px; /* Aligned with top-right corner of gameArea */
    right: 30px; /* Adjusted right margin */
    background-color: rgba(0, 0, 0, 0.8);
    padding: 15px; /* 50% increased padding */
    border-radius: 5px;
    z-index: 100;
    color: #E0E0E0;
    font-size: 24px; /* 50% increased font size */
}

#legendContent p {
    margin-top: 0;
    margin-bottom: 10px;
}

#legendContent div {
    margin-bottom: 5px;
    display: flex;
    align-items: center;
}

.legend-color-box {
    width: 12px; /* Reduced size */
    height: 12px; /* Reduced size */
    margin-right: 5px; /* Reduced margin */
    display: inline-block;
}

#scoreDisplay {
    margin-top: 10px;
}


#footer {
    background-color: #1F2124;
    padding: 5px 20px;
    text-align: center;
    border-top: 1px solid #333;
    font-size: 14px;
    color: #999;
}

#footer a {
    color: #E0E0E0; /* Light grey */
    text-decoration: none;
}

#score {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 5px;
    z-index: 100;
}

#game-over-message {
    position: fixed; /* Fixed position relative to the viewport */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7); /* Dark overlay */
    display: flex; /* Use flexbox to center content */
    align-items: center; /* Center vertically */
    justify-content: center; /* Center horizontally */
    z-index: 1000; /* Ensure it's on top of everything */
    visibility: hidden; /* Hidden by default, controlled by script */
    opacity: 0; /* Start fully transparent */
    transition: visibility 0s, opacity 0.3s ease-in-out; /* Smooth transition */
}

#game-over-message.visible {
    visibility: visible;
    opacity: 1;
}
.game-over-content {
    background-color: #1F2124; /* Dark background for the modal box */
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    text-align: center;
    color: #E0E0E0; /* Light text color */
    font-size: 24px;
    font-weight: bold;
    max-width: 90%; /* Max width to prevent overflow on small screens */
    width: 500px; /* Increased width for the modal to fit long messages */
    border: 1px solid #333; /* Subtle border */
}

.game-over-content span {
    display: block; /* Make spans block-level for proper spacing */
    margin-top: 10px;
}

.game-over-content .pun-message {
    font-size: 32px; /* Larger for the main message */
    color: #E0E0E0; /* Light grey for the pun message */
    margin-bottom: 15px;
}

.game-over-content .good-pun-message {
    font-size: 24px; /* Slightly smaller than main pun, larger than instructions */
    color: #629E51; /* Green for good puns */
    margin-top: 5px; /* Small margin above it */
    margin-bottom: 10px; /* Margin below it */
}

.game-over-content span:nth-of-type(2) { /* This will now target the "Click or Space to Restart" span */
    font-size: 20px; /* For restart instruction */
    color: #629E51; /* Green for action prompt */
}

#pun-banner {
    position: fixed;
    top: 50%; /* Center vertically */
    left: 50%;
    transform: translate(-50%, -50%); /* Center both horizontally and vertically */
    background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent dark background */
    color: #E0E0E0; /* Light text color */
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    z-index: 999; /* Below game over modal, but above game elements */
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Prevent clicks from registering on the banner */
    transition: opacity 0.5s ease-in-out, visibility 0s linear 0.5s; /* Fade out after 0.5s */
}

#pun-banner.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease-in-out; /* Fade in */
}

.game-over-content span:nth-of-type(3) {
    font-size: 16px; /* For share message */
    color: #999; /* Subtler color */
}

/* Styles for the initial banner */
.banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.85); /* Slightly darker background */
    color: #E0E0E0;
    padding: 30px 60px; /* Increased padding */
    border-radius: 12px; /* Slightly larger border-radius */
    font-size: 32px; /* Larger font size */
    font-weight: bold;
    text-align: center;
    z-index: 100; /* Above game elements */
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.7); /* More prominent shadow */
    border: 2px solid #629E51; /* Green border */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); /* Text shadow for readability */
    display: flex; /* Ensure it's displayed as a flex container */
    align-items: center; /* Center content vertically */
    justify-content: center; /* Center content horizontally */
}

.banner p {
    margin: 0; /* Remove default paragraph margin */
    animation: pulse 2s infinite alternate; /* Apply pulsing animation */
}

#initialBanner {
    visibility: visible; /* Initially visible */
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        color: #E0E0E0;
    }
    100% {
        transform: scale(1.05);
        color: #629E51; /* Pulse to green */
    }
}

/* Styles for the pause button */
.game-button {
    position: absolute;
    bottom: 20px; /* Adjusted distance from bottom of gameArea */
    right: 30px; /* Adjusted right margin */
    background-color: rgba(0, 0, 0, 0.7);
    color: #E0E0E0;
    padding: 10px; /* Adjusted padding for 2x icons */
    border-radius: 8px;
    cursor: pointer;
    z-index: 100; /* Above game elements */
    border: 1px solid #333;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    visibility: hidden; /* Hidden by default */
    opacity: 0;
    display: flex; /* Use flexbox to center icons */
    align-items: center;
    justify-content: center;
}

.game-button:hover {
    background-color: rgba(0, 0, 0, 0.9);
    border-color: #629E51;
}

.game-button .icon {
    width: 48px; /* 2x bigger (24px * 2) */
    height: 48px; /* 2x bigger (24px * 2) */
    fill: currentColor; /* Use the parent's color */
}

.hidden {
    display: none; /* Class to hide elements */
}

#pauseButton.visible {
    visibility: visible;
    opacity: 1;
}

/* Debugging: Force z-index for pause button */
#pauseButton {
    z-index: 9999 !important; 
}
