@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    touch-action: none;
}

body {
    background-color: #050510;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 600px;
    max-height: 600px;
    overflow: hidden;
    background: radial-gradient(circle at center, #1a1a3a 0%, #050510 100%);
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.1);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#score-display {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 1.2rem;
    color: #0ff;
    text-shadow: 0 0 10px #0ff;
}

#high-score-display {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 0.9rem;
    color: #f0f;
    text-shadow: 0 0 10px #f0f;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 16, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

h1 {
    font-size: 2.2rem;
    margin-bottom: 20px;
    color: #0ff;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    text-align: center;
    padding: 0 20px;
}

h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #f0f;
    text-shadow: 0 0 20px rgba(255, 0, 255, 0.5);
}

p {
    margin-bottom: 30px;
    color: #aaa;
    font-size: 0.9rem;
}

button {
    padding: 12px 30px;
    font-size: 1.1rem;
    font-family: 'Orbitron', sans-serif;
    background: transparent;
    border: 2px solid #0ff;
    color: #0ff;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 15px;
}

button:hover {
    background: rgba(0, 255, 255, 0.1);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
    transform: scale(1.05);
}

#retry-btn {
    border-color: #f0f;
    color: #f0f;
}

#retry-btn:hover {
    background: rgba(255, 0, 255, 0.1);
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.4);
}

#exit-btn {
    border-color: #666;
    color: #666;
}

#final-score {
    font-size: 1.8rem;
    color: #fff;
    margin-bottom: 30px;
}

/* ============================================
   MOBILE RESPONSIVE OPTIMIZATION (480px and below)
   ============================================ */
@media (max-width: 480px) {
    h1 {
        font-size: 1.8rem; /* 2.2rem → 1.8rem */
        margin-bottom: 15px;
        padding: 0 15px;
    }

    h2 {
        font-size: 2rem; /* 2.5rem → 2rem */
        margin-bottom: 8px;
    }

    p {
        margin-bottom: 20px;
        font-size: 0.85rem;
    }

    button {
        padding: 10px 20px; /* 12px 30px → 10px 20px */
        font-size: 1rem; /* 1.1rem → 1rem */
        letter-spacing: 1px; /* 2px → 1px */
        margin-bottom: 12px;
        width: 90%; /* 버튼 너비 제한으로 겹침 방지 */
        max-width: 280px;
    }

    .overlay {
        padding: 20px;
    }

    #game-container {
        max-width: 100%;
        max-height: 100%;
        /* 캔버스 클램핑: 좁은 화면에서 잘리지 않도록 */
    }

    #score-display,
    #high-score-display {
        font-size: 1rem; /* 1.2rem → 1rem */
        top: 10px;
    }

    #score-display {
        left: 10px;
    }

    #high-score-display {
        right: 10px;
    }

    #final-score {
        font-size: 1.5rem; /* 1.8rem → 1.5rem */
        margin-bottom: 20px;
    }
}

/* ============================================
   SMALL MOBILE (390px and below - iPhone 12/13)
   ============================================ */
@media (max-width: 390px) {
    h1 {
        font-size: 1.5rem;
        margin-bottom: 12px;
    }

    h2 {
        font-size: 1.8rem;
    }

    button {
        padding: 8px 16px;
        font-size: 0.9rem;
        width: 95%;
        max-width: 260px;
    }

    .overlay {
        padding: 15px;
    }
}