@font-face {
    font-family: 'ComicSans';
    src: url('../comic-sans.ttf') format('truetype');
}

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    color: #f1f5f9;
    font-family: "ComicSans", "Comic Neue", sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin: 0;
    overflow: hidden;
    user-select: none;
}

.title {
    color: #818cf8;
    font-size: 2.2rem;
    margin-bottom: 5px;
    text-shadow: 0 0 10px rgba(129, 140, 248, 0.3);
    text-align: center;
}

h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #cbd5e1;
    font-weight: normal;
    text-align: center;
}

.game-container {
    position: relative;
    width: 100%;
    max-width: 360px;
    margin: 10px auto;
    aspect-ratio: 360 / 400;
}

canvas {
    background: #1e293b;
    display: block;
    width: 100%;
    height: 100%;
    border: 3px solid #3b82f6;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.game-over {
    border-radius: 10px;
    display: none; /* Changed to grid in JS */
    place-content: center;
    text-align: center;
    backdrop-filter: blur(8px);
    background: rgba(15, 23, 42, 0.85);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid #ef4444;
    z-index: 10;
    padding: 20px;
}

.game-over h2 {
    color: #ef4444;
    font-size: 2.5rem;
    margin-bottom: 15px;
    text-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

.game-over h3 {
    color: #cbd5e1;
    margin-bottom: 20px;
}

.restart {
    padding: 12px 25px;
    border-radius: 8px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: "ComicSans", "Comic Neue", sans-serif;
}

.restart:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6);
}

.controls {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    width: 100%;
    max-width: 360px;
}

.controls button {
    flex: 1;
    padding: 15px 0;
    font-size: 30px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    cursor: pointer;
    font-family: "ComicSans", "Comic Neue", sans-serif;
    touch-action: manipulation;
    transition: transform 0.1s, box-shadow 0.1s;
}

.controls button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.5);
}

.instruction {
    text-align: center;
    margin-top: 15px;
    font-size: 0.95rem;
    color: #94a3b8;
}

/* Responsive details: Hide touch controls on desktop devices, and scale canvas container for large screens */
@media (min-width: 480px) {
    .game-container {
        max-width: 450px;
    }
}

@media (min-width: 780px) {
    .game-container {
        max-width: 540px;
    }
}

@media (min-width: 769px) {
    .controls {
        display: none;
    }
}
