* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overscroll-behavior: none; /* Stops Chrome pull-to-refresh when swiping down */
    touch-action: manipulation; /* Prevents double-tap zoom on fast button taps */
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh; /* Dynamic viewport height accounts for Chrome's address bar */
    padding: 8px;
}

.game-container {
    position: relative; /* Keeps the .game-over modal centered inside the game box */
    text-align: center;
    background: rgba(255, 255, 255, 0.16);
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

h1 {
    color: white;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    font-size: 1.8rem;
    display: none;
}

.score-board {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: white;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

#game-canvas {
    background-color: #14141e;
    border-radius: 10px;
    display: block;
    margin: 0 auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    height: auto;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.controls {
    margin-top: 10px;
}

.controls p {
    display: none;
}

button {
    background: linear-gradient(to right, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    padding: 8px 16px;
    margin: 0 3px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.96);
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 10;
    width: 80%;
    max-width: 300px;
}

.game-over h2 {
    color: #ff6b6b;
    margin-bottom: 10px;
    font-size: 20px;
}

.game-over p {
    color: #333;
    margin-bottom: 10px;
    font-size: 16px;
}

.name-input-container {
    margin: 10px 0;
}

.name-input-container label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
}

#player-name {
    padding: 6px;
    border: 2px solid #4facfe;
    border-radius: 5px;
    font-size: 14px;
    width: 100%;
    text-align: center;
}

.high-scores-container {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #ddd;
}

.high-scores-container h3 {
    color: #333;
    margin-bottom: 5px;
}

.high-scores-container p {
    margin: 2px 0;
    color: #666;
    font-size: 12px;
}

.hidden {
    display: none !important;
}

/* Mobile controls */
.mobile-controls {
    margin-top: 18px;
    padding-bottom: 6px;
    display: none;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 22px;
    margin-bottom: 14px;
}

.control-row:last-child {
    margin-bottom: 0;
}

.control-btn {
    background: linear-gradient(to bottom, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    touch-action: manipulation;
}

.control-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Show mobile controls on smaller screens */
@media (max-width: 768px) {
    #game-canvas {
        width: min(82vw, 45dvh);
        height: min(82vw, 45dvh);
        aspect-ratio: 1 / 1;
    }

    .mobile-controls {
        display: block;
    }

    .control-btn {
        width: 66px;
        height: 66px;
        font-size: 26px;
        user-select: none;
        -webkit-user-select: none;
    }
}

/* Leaderboard styling (shared by game-over screen and scores modal) */
.leaderboard-list {
    list-style: none;
    padding-left: 0;
    max-height: 250px; /* Tall enough to show all 10 scores without scrolling */
    overflow-y: auto;
}

.leaderboard-list li {
    font-size: 13px;
    color: #444;
    margin: 3px 0;
}

/* "See High Scores" button in the score board */
#see-high-scores-btn {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.45);
    color: #fff;
    padding: 4px 10px;
    font-size: 12px;
    margin: 0;
}

#see-high-scores-btn:hover {
    transform: none;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.3);
}

/* Scores modal */
.scores-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.96);
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 20;
    width: 80%;
    max-width: 300px;
}

.scores-modal h3 {
    color: #333;
    margin-bottom: 5px;
}

#close-high-scores-btn {
    margin-top: 10px;
}