/* ========== 기본 리셋 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.screen {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* ========== 인트로 화면 ========== */
.intro-screen {
    background: linear-gradient(135deg, #1a5f1a 0%, #0d3d0d 50%, #1a5f1a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.intro-content {
    text-align: center;
    padding: 20px;
}

.intro-box-image {
    margin-bottom: 30px;
}

.intro-box {
    width: 200px;
    height: auto;
    animation: bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.5));
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.intro-title {
    font-size: 3rem;
    color: #FFD700;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.5);
    margin-bottom: 15px;
}

.intro-desc {
    font-size: 1.5rem;
    color: #fff;
    margin-bottom: 40px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.start-btn {
    background: linear-gradient(180deg, #FF6B6B 0%, #EE5A5A 50%, #DD4444 100%);
    border: 4px solid #FFD700;
    border-radius: 25px;
    padding: 20px 60px;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 0 auto 30px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4), inset 0 2px 0 rgba(255,255,255,0.3);
    transition: all 0.2s ease;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 30px rgba(0,0,0,0.5);
}

.start-btn:active {
    transform: scale(0.98);
}

.btn-icon {
    font-size: 2.5rem;
}

.intro-hint {
    color: rgba(255,255,255,0.7);
    font-size: 1rem;
}

/* ========== 게임 화면 ========== */
.game-screen {
    background-image: url('/api/images/clown-game/background.jpg');
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(255,255,255,0.95);
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    margin-bottom: 15px;
}

.score-board {
    display: flex;
    gap: 30px;
}

.score, .timer {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
}

.score span {
    color: #28a745;
}

.timer span {
    color: #dc3545;
}

.game-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    padding: 10px 20px;
    font-size: 1.1rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:hover {
    transform: scale(1.05);
}

.exit-btn {
    background: #6c757d;
    color: white;
}

/* ========== 게임 보드 ========== */
.game-board {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 20px;
    padding: 20px;
    background: rgba(139, 69, 19, 0.6);
    border-radius: 20px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.3);
}

/* ========== 깜짝상자 컨테이너 ========== */
.jack-in-box-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 250px;
    max-height: 250px;
    margin: auto;
    overflow: hidden;
}

.hole {
    width: 100%;
    height: 100%;
    background-image: url('/api/images/clown-game/jack_in_box_closed.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    position: absolute;
    z-index: 1;
}

.clown {
    width: 60%;
    height: 70%;
    background-image: url('/api/images/clown-game/clown_with_spring.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    position: absolute;
    bottom: -11%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    transition: bottom 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.5);
}

.front-cover {
    width: 53%;
    height: 57%;
    position: absolute;
    top: 40%;
    left: 13%;
    background-image: url('/api/images/clown-game/jack_in_box_front_cover.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center bottom;
    z-index: 10;
    pointer-events: none;
}

/* 피에로 올라온 상태 */
.jack-in-box-container.up .clown {
    bottom: 32%;
    cursor: pointer;
}

.jack-in-box-container.up .hole {
    background-image: url('/api/images/clown-game/jack_in_box_open.png');
}

/* 잡았을 때 효과 */
.jack-in-box-container.caught .clown {
    animation: caught 0.3s ease-out;
}

@keyframes caught {
    0% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.3); }
    100% { transform: translateX(-50%) scale(0); }
}

/* ========== 게임 종료 오버레이 ========== */
.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.game-over-content {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    padding: 40px 60px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: popIn 0.5s ease-out;
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.game-over-content h2 {
    font-size: 3rem;
    color: #333;
    margin-bottom: 20px;
}

.final-score {
    font-size: 2rem;
    color: #333;
    margin-bottom: 30px;
}

.final-score span {
    font-size: 3rem;
    color: #dc3545;
    font-weight: bold;
}

.game-over-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.play-again-btn, .exit-game-btn {
    padding: 15px 40px;
    font-size: 1.3rem;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.play-again-btn {
    background: #28a745;
    color: white;
}

.exit-game-btn {
    background: #6c757d;
    color: white;
}

.play-again-btn:hover, .exit-game-btn:hover {
    transform: scale(1.05);
}

/* ========== 반응형 ========== */
@media (max-width: 768px) {
    .intro-title {
        font-size: 2rem;
    }
    
    .intro-desc {
        font-size: 1.2rem;
    }
    
    .start-btn {
        padding: 15px 40px;
        font-size: 1.5rem;
    }
    
    .game-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .score-board {
        gap: 15px;
    }
    
    .score, .timer {
        font-size: 1.2rem;
    }
    
    .game-board {
        gap: 10px;
        padding: 10px;
    }
    
    .jack-in-box-container {
        max-width: 150px;
        max-height: 150px;
    }
}

@media (max-height: 500px) {
    .game-header {
        padding: 5px 15px;
        margin-bottom: 5px;
    }
    
    .game-board {
        gap: 5px;
        padding: 5px;
    }
}
