:root {
    --font-family: 'Fredoka One', sans-serif;
    --heading-font: 'Fredoka One', cursive, sans-serif;
}

h1 {
    font-family: var(--heading-font);
    font-weight: 400;
    font-size: 3rem;
}

.game-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

#gameCanvas {
    background-color: rgba(247, 246, 246, 0.8);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 4px solid rgba(255, 255, 255, 0.5);
}

.scoreboard {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 15px;
    margin-top: 20px;
    width: 100%;
    max-width: 600px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    box-sizing: border-box;
    text-align: center;
}

.stat-box {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    flex: 1 1 30%;
    color: white;
    font-family: var(--font-family);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    font-family: var(--heading-font);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.controls-info {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    margin-top: 1.5rem;
    font-weight: 500;
}

.game-btn {
    font-family: var(--font-family);
    font-size: 1.2rem;
    border-radius: 5px;
    transition: all 0.2s;
    background-color: #ff6b6b;
    color: rgb(255, 255, 255);
    padding: 10px 20px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 0 #d35454;
    transform: translateY(0);
    margin-top: 10px;
    width: 100%;
    max-width: 200px;
}

.game-btn:hover {
    background-color: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #d35454;
}

.game-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #d35454;
}

.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    text-decoration: none;
    color: white;
    font-family: var(--font-family);
    font-size: 1.5rem;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 10px 15px;
    border-radius: 5px;
    transition: background-color 0.3s;
    backdrop-filter: none;
}

.back-btn:hover {
    background-color: rgba(0, 0, 0, 0.4);
    transform: none;
}

@media (max-width: 640px) {
    #gameCanvas {
        width: 80vw;
        height: 160vw;
        /* Keep 1:2 aspect ratio */
        max-width: 300px;
        max-height: 600px;
    }

    .back-btn {
        font-size: 1rem;
        padding: 8px 12px;
    }
}

/* Responsive Layout for Large Screens */
@media (min-width: 1250px) {
    .game-content {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: flex-start;
        position: relative;
        margin-top: 2rem;
        max-width: 1400px;
        width: 95%;
    }

    #gameCanvas {
        margin: 0;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    }

    .scoreboard {
        position: absolute;
        right: 0;
        top: 0;
        margin-top: 0;
        width: 300px;
        height: auto;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-content: flex-start;
        gap: 10px;
    }

    .stat-box {
        flex: 1 1 45%;
        width: auto;
    }

    .game-btn {
        width: 100%;
        margin-top: 1rem;
        margin-left: auto;
        margin-right: auto;
    }

    .controls-info {
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* Game Message Overlay */
.game-message {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(225, 240, 250, 0.6);
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    animation: fade-in 200ms ease;
    animation-fill-mode: both;
    border-radius: 10px;
    padding-bottom: 40px;
}

.game-message p {
    font-size: 60px;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 20px;
    font-family: var(--heading-font);
    color: #555151;
}

.game-message.game-over {
    display: flex;
}

.retry-btn {
    font-family: var(--font-family);
    font-size: 1.2rem;
    border-radius: 5px;
    transition: all 0.2s;
    background-color: #ff6b6b;
    color: white;
    padding: 10px 20px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 0 #d35454;
    transform: translateY(0);
}

.retry-btn:hover {
    background-color: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #d35454;
}

.retry-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #d35454;
}

@keyframes fade-in {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}