/* 기본 스타일 및 폰트 설정 */
body {
    font-family: 'Orbitron', sans-serif;
    background-color: #0c0c2c;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    text-align: center;
    background-image: url('https://www.transparenttextures.com/patterns/stardust.png');
    /* 커서를 우주선 모양으로 변경 (이미지 경로) */
    cursor: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIj48ZyBmaWxsPSJub25lIiBzdHJva2U9IiNhMmYyZjIiIHN0cm9rZS13aWR0aD0iMiI+PGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iNiIvPjxwYXRoIGQ9Ik0xNiAwdiAxME0xNiAyMnYxME0wIDE2aDEwTTIyIDE2aDEwIi8+PC9nPjwvc3ZnPg=='), auto;
}

/* 게임 전체 컨테이너 */
.game-container {
    position: relative;
    overflow: hidden; 
    background: rgba(22, 22, 52, 0.8);
    border: 2px solid #7f5af0;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 0 30px #7f5af0, 0 0 10px #fff inset;
    width: 90%;
    max-width: 500px;
}

/* 시간 임박 애니메이션 클래스 */
.game-container.urgent-time {
    animation: urgent-pulse 1s infinite;
}

h1 {
    color: #a2f2f2;
    text-shadow: 0 0 10px #a2f2f2, 0 0 20px #a2f2f2;
    margin-bottom: 20px;
    letter-spacing: 2px;
}

/* 점수 및 타이머 정보 패널 */
.info-panel {
    display: flex;
    justify-content: space-around;
    font-size: 1.2em;
    margin-bottom: 20px;
    background: #161632;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #7f5af0;
}

.score-display, .timer-display {
    color: #f2a2a2;
    text-shadow: 0 0 5px #f2a2a2;
}

/* 게임 보드 (3x3 그리드) */
.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 15px;
    margin-bottom: 20px;
    position: relative;
}

/* 분화구 스타일 */
.crater {
    aspect-ratio: 1 / 1; 
    position: relative;
    background: radial-gradient(circle, #2d2d4c 60%, #1d1d3c);
    border-radius: 50%;
    border: 3px solid #2d2d4c;
    box-shadow: inset 0 5px 15px rgba(0,0,0,0.6), 0 0 10px #0c0c2c;
    cursor: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIj48ZyBzdHJva2U9IiNmMmEyYTIiIHN0cm9rZS13aWR0aD0iMiI+PGNpcmNsZSBmaWxsPSIjZjJhMmEyIiBjeD0iMTYiIGN5PSIxNiIgcj0iNiIvPjxwYXRoIGZpbGw9Im5vbmUiIGQ9Ik0xNiAwdiAxME0xNiAyMnYxME0wIDE2aDEwTTIyIDE2aDEwIi8+PC9nPjwvc3ZnPg=='), auto;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.1s ease-out;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* 분화구 호버 효과 */
.crater:hover {
    transform: scale(1.02);
    box-shadow: inset 0 5px 15px rgba(0,0,0,0.6), 0 0 15px #7f5af0;
}

/* 분화구 클릭 효과 */
.crater:active {
    transform: scale(0.95);
    box-shadow: inset 0 5px 15px rgba(0,0,0,0.8), 0 0 20px #f2a2a2;
}

/* 분화구 클릭 시 플래시 효과 */
.crater.clicked {
    animation: crater-flash 0.2s ease-out;
}

/* 외계인이 있는 분화구 강조 */
.crater.up {
    border-color: #a2f2f2;
    box-shadow: inset 0 5px 15px rgba(0,0,0,0.6), 0 0 15px #a2f2f2, 0 0 25px #a2f2f2;
    animation: alien-glow 1s ease-in-out infinite alternate;
}

/* 외계인 이미지 스타일 */
.alien {
    width: 80%;
    height: 80%;
    /* 기본적으로 보이지 않게 처리 */
    transform: scale(0);
    opacity: 0;
    transition: transform 0.15s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.1s ease-out;
}

/* 외계인이 나타날 때의 스타일 */
.crater.up .alien {
    transform: scale(1);
    opacity: 1;
}

.alien.whacked {
    animation: whacked-effect 0.4s ease-out forwards;
    filter: brightness(1.5) contrast(1.2);
}

/* 외계인 잡힘 시 추가 효과 */
.crater.hit {
    animation: hit-effect 0.3s ease-out;
}

/* 성공 시 점수 표시 애니메이션 */
.score-popup {
    position: absolute;
    color: #a2f2f2;
    font-weight: bold;
    font-size: 1.2em;
    text-shadow: 0 0 10px #a2f2f2;
    pointer-events: none;
    z-index: 10;
    animation: score-popup 0.8s ease-out forwards;
}

/* 버튼 스타일 */
.control-button {
    background: linear-gradient(45deg, #7f5af0, #a2f2f2);
    color: #0c0c2c;
    border: none;
    padding: 15px 30px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2em;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px #7f5af0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.control-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 0 25px #a2f2f2, 0 0 10px #a2f2f2;
}

.control-button:disabled {
    background: #555;
    color: #888;
    box-shadow: none;
    cursor: not-allowed;
}

/* 게임 오버 모달 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: none; /* 기본적으로 숨김 */
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: #161632;
    padding: 30px;
    border-radius: 20px;
    border: 2px solid #7f5af0;
    box-shadow: 0 0 30px #7f5af0;
    animation: fadeIn 0.5s ease-in-out;
}

.modal-content h2 {
    margin-top: 0;
    color: #a2f2f2;
    text-shadow: 0 0 10px #a2f2f2;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
}

#laser-beam {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #f2a2a2, rgba(255, 255, 255, 0));
    box-shadow: 0 0 10px #f2a2a2, 0 0 20px #f2a2a2;
    transform: scaleY(0);
    transform-origin: top;
    opacity: 0;
    pointer-events: none;
}

#laser-beam.fire {
    animation: laser-fire 0.15s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* 외계인 잡혔을 때 애니메이션 */
@keyframes whacked-effect {
    0% { transform: scale(1) rotate(0deg); opacity: 1; }
    100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

/* 시간 임박 깜박임 애니메이션 */
@keyframes urgent-pulse {
    0% { border-color: #7f5af0; box-shadow: 0 0 30px #7f5af0, 0 0 10px #fff inset; }
    50% { border-color: #f2a2a2; box-shadow: 0 0 30px #f2a2a2, 0 0 15px #f2a2a2 inset; }
    100% { border-color: #7f5af0; box-shadow: 0 0 30px #7f5af0, 0 0 10px #fff inset; }
}

@keyframes laser-fire {
    0% { transform: scaleY(0); opacity: 1; }
    100% { transform: scaleY(1); opacity: 0; }
}

/* 분화구 클릭 플래시 효과 */
@keyframes crater-flash {
    0% { 
        background: radial-gradient(circle, #2d2d4c 60%, #1d1d3c);
        box-shadow: inset 0 5px 15px rgba(0,0,0,0.6), 0 0 10px #0c0c2c;
    }
    50% { 
        background: radial-gradient(circle, #4d4d6c 60%, #3d3d5c);
        box-shadow: inset 0 5px 15px rgba(0,0,0,0.4), 0 0 25px #f2a2a2, 0 0 35px #f2a2a2;
    }
    100% { 
        background: radial-gradient(circle, #2d2d4c 60%, #1d1d3c);
        box-shadow: inset 0 5px 15px rgba(0,0,0,0.6), 0 0 10px #0c0c2c;
    }
}

/* 외계인 글로우 효과 */
@keyframes alien-glow {
    0% { 
        box-shadow: inset 0 5px 15px rgba(0,0,0,0.6), 0 0 15px #a2f2f2, 0 0 25px #a2f2f2;
    }
    100% { 
        box-shadow: inset 0 5px 15px rgba(0,0,0,0.6), 0 0 20px #a2f2f2, 0 0 35px #a2f2f2, 0 0 45px #a2f2f2;
    }
}

/* 외계인 잡힘 효과 강화 */
@keyframes whacked-effect {
    0% { 
        transform: scale(1) rotate(0deg); 
        opacity: 1; 
        filter: brightness(1) contrast(1);
    }
    25% { 
        transform: scale(1.2) rotate(90deg); 
        opacity: 1; 
        filter: brightness(2) contrast(1.5);
    }
    50% { 
        transform: scale(0.8) rotate(180deg); 
        opacity: 0.8; 
        filter: brightness(1.5) contrast(1.2);
    }
    100% { 
        transform: scale(0) rotate(360deg); 
        opacity: 0; 
        filter: brightness(1) contrast(1);
    }
}

/* 분화구 히트 효과 */
@keyframes hit-effect {
    0% { 
        transform: scale(1);
        border-color: #a2f2f2;
    }
    50% { 
        transform: scale(1.1);
        border-color: #f2a2a2;
        box-shadow: inset 0 5px 15px rgba(0,0,0,0.6), 0 0 30px #f2a2a2, 0 0 40px #f2a2a2;
    }
    100% { 
        transform: scale(1);
        border-color: #a2f2f2;
    }
}

/* 점수 팝업 애니메이션 */
@keyframes score-popup {
    0% { 
        opacity: 0; 
        transform: translateY(0) scale(0.5);
        color: #a2f2f2;
    }
    25% { 
        opacity: 1; 
        transform: translateY(-20px) scale(1.2);
        color: #f2a2a2;
    }
    50% { 
        opacity: 1; 
        transform: translateY(-40px) scale(1);
        color: #a2f2f2;
    }
    100% { 
        opacity: 0; 
        transform: translateY(-60px) scale(0.8);
        color: #7f5af0;
    }
}
