/* Basic styles for the body to center the game */
body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #3d405b;
    font-family: 'Press Start 2P', cursive;
    color: white;
    overflow: hidden;
    touch-action: none; /* Prevents scrolling on mobile */
}

/* Container for the game canvas and UI elements */
#game-container {
    position: relative;
    border: 8px solid #2a2c3d;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2), 0 6px 6px rgba(0,0,0,0.25);
    overflow: hidden;
    /* Responsive aspect ratio */
    width: 100%;
    max-width: 480px;
    aspect-ratio: 480 / 640;
}

/* The game canvas itself */
canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Overlay for messages like 'Game Over' or 'Start' */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    text-align: center;
    transition: opacity 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}

/* Hide overlay by default */
.hidden {
    display: none !important;
}

/* For showing elements that are hidden by default */
.visible {
    display: flex !important;
}

/* Styling for the main message text */
.game-overlay h1 {
    font-size: clamp(1.8rem, 10vw, 2.5rem); /* Responsive font size */
    margin-bottom: 10px;
    text-shadow: 4px 4px 0px #2a2c3d;
}

/* Styling for subtitles or instructions */
.game-overlay p {
    font-size: clamp(0.8rem, 4vw, 1rem); /* Responsive font size */
    margin-top: 0;
    line-height: 1.5;
}

/* Score display on the top left of the canvas */
#score {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: clamp(1.5rem, 8vw, 2rem); /* Responsive font size */
    text-shadow: 3px 3px 0px #2a2c3d;
}

/* --- Scoreboard & Submission Form Styles --- */
#gameOverContent {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#submission-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 80%;
}

#player-name {
    font-family: 'Press Start 2P', cursive;
    background: #f0f0f0;
    border: 3px solid #2a2c3d;
    border-radius: 8px;
    padding: 10px;
    font-size: 1rem;
    text-align: center;
    width: 100%;
    max-width: 250px;
    color: #333;
}

.button-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.submit-button {
    font-family: 'Press Start 2P', cursive;
    background-color: #8fbc8f;
    color: white;
    border: 3px solid #3e563e;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: clamp(0.7rem, 3.5vw, 0.9rem);
    cursor: pointer;
    text-shadow: 2px 2px 0px #3e563e;
    transition: transform 0.1s ease;
}

.submit-button.secondary {
    background-color: #808080;
    border-color: #4f4f4f;
    text-shadow: 2px 2px 0px #4f4f4f;
}

.submit-button:disabled {
    background-color: #5a7a5a;
    cursor: not-allowed;
}

.submit-button:active {
    transform: translateY(2px);
}

#scoreboard-container {
    width: 90%;
    max-width: 400px;
    flex-direction: column;
    align-items: center;
}

#scoreboard {
    list-style: none;
    padding: 0;
    margin: 15px 0;
    font-size: clamp(0.7rem, 3.5vw, 0.9rem);
    text-align: left;
    width: 100%;
}

#scoreboard li {
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    border-radius: 5px;
    margin-bottom: 5px;
    background: rgba(42, 44, 61, 0.6);
}

#scoreboard li span:first-child {
    margin-right: 10px;
}

#scoreboard li span:last-child {
    font-weight: bold;
}

.fake-data-note, #loading-message {
    font-size: 0.7rem;
    color: #ffcc00;
    margin-top: 10px;
}

/* --- Menu System Styles --- */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.menu-button {
    font-family: 'Press Start 2P', cursive;
    background-color: #8fbc8f;
    color: white;
    border: 3px solid #3e563e;
    border-radius: 8px;
    padding: 15px 30px;
    font-size: clamp(0.9rem, 4vw, 1.2rem);
    cursor: pointer;
    text-shadow: 2px 2px 0px #3e563e;
    transition: transform 0.1s ease, background-color 0.2s ease;
    min-width: 200px;
    text-align: center;
}

.menu-button:hover {
    background-color: #7fa67f;
    transform: translateY(-2px);
}

.menu-button:active {
    transform: translateY(2px);
}

/* Leaderboard screen uses same styling as post-game scoreboard */
#leaderboard-scoreboard-container {
    width: 90%;
    max-width: 400px;
    flex-direction: column;
    align-items: center;
}

#leaderboard-scoreboard {
    list-style: none;
    padding: 0;
    margin: 15px 0;
    font-size: clamp(0.7rem, 3.5vw, 0.9rem);
    text-align: left;
    width: 100%;
}

#leaderboard-scoreboard li {
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    border-radius: 5px;
    margin-bottom: 5px;
    background: rgba(42, 44, 61, 0.6);
}

#leaderboard-scoreboard li span:first-child {
    margin-right: 10px;
}

#leaderboard-scoreboard li span:last-child {
    font-weight: bold;
}

#leaderboard-loading, #leaderboard-error {
    font-size: 0.8rem;
    color: #ffcc00;
    text-align: center;
    margin: 10px 0;
}