* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

body {
    background-color: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.game-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 20px;
    max-width: 650px;
    width: 100%;
    position: relative;
}

.game-description {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 15px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
    gap: 10px;
}

.flex-row {
    display: flex;
    gap: 10px;
}

.game-header-bottom {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    padding-bottom: 10px;
}

.score-display, .shots-display {
    font-size: 1.2rem;
    font-weight: bold;
}

.difficulty-container, .language-container {
    display: flex;
    align-items: center;
}

.difficulty-container label, .language-container label {
    margin-right: 8px;
}

#difficulty, #language {
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto;
    border: 2px solid #ccc;
    border-radius: 4px;
}

.game-controls {
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-controls p {
    font-size: 0.9rem;
    color: #555;
}

/* Mobile controls */
.mobile-controls {
    display: none; /* Hidden by default, visible on small screens */
    margin-top: 15px;
    text-align: center;
}

.aim-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.control-button {
    padding: 12px 16px;
    font-size: 1.2rem;
    background-color: #4a90e2;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
}

.shoot-button {
    background-color: #e74c3c;
    padding: 12px 24px;
    font-weight: bold;
}

.mobile-hint {
    font-size: 0.9rem;
    color: #555;
    margin-top: 5px;
}

/* Media query for mobile devices */
@media (max-width: 768px) {
    .mobile-controls {
        display: block;
    }

    .game-controls p {
        display: none; /* Hide keyboard instructions on mobile */
    }

    /* Make buttons larger on small screens */
    .control-button {
        padding: 15px 20px;
        font-size: 1.4rem;
    }

    .shoot-button {
        padding: 15px 30px;
    }

    /* Adjust header layout for smaller screens */
    .game-header {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .game-header > div {
        margin-bottom: 5px;
    }

    #scoreboardButton {
        margin-top: 5px;
    }
}

button {
    background-color: #4a90e2;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #357abd;
}

#scoreboardButton {
    background-color: #f0ad4e;
}

#scoreboardButton:hover {
    background-color: #ec971f;
}

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-align: center;
    display: none;
    width: 80%;
    max-width: 400px;
}

.game-over h2 {
    margin-bottom: 15px;
    color: #333;
}

.game-over p {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

#highScoreForm {
    margin: 15px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

#playerName {
    display: block;
    width: 100%;
    padding: 8px;
    margin: 10px 0;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#saveScoreButton {
    margin-right: 10px;
}

.scoreboard {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-align: center;
    display: none;
    width: 90%;
    max-width: 500px;
    z-index: 100;
}

.scoreboard h2 {
    margin-bottom: 15px;
    color: #333;
}

.scoreboard-tabs {
    display: flex;
    margin-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.tab-button {
    flex: 1;
    padding: 8px;
    background-color: #f1f1f1;
    border: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    color: #333;
    font-weight: normal;
    margin: 0 2px;
}

.tab-button.active {
    background-color: #4a90e2;
    color: white;
}

#scoreTable {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

#scoreTable th, #scoreTable td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

#scoreTable th {
    background-color: #f8f9fa;
    font-weight: bold;
}

#closeScoreboard {
    margin-top: 15px;
}

/* Sound button styling */
#soundToggleButton {
    background-color: #28a745;
}

#soundToggleButton.muted {
    background-color: #6c757d;
}

/* Confetti styles */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #f00;
    opacity: 0.8;
    animation: fall linear forwards;
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(720deg);
    }
}

/* Rank-specific styling for high score display */
.rank-1 {
    font-size: 1.3em;
    font-weight: bold;
    color: gold;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

.rank-2 {
    font-size: 1.2em;
    font-weight: bold;
    color: silver;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.4);
}

.rank-3 {
    font-size: 1.1em;
    font-weight: bold;
    color: #cd7f32; /* bronze */
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
}
