:root {
    --bg-color: #f0f9ff;
    --game-bg: #e0f2fe;
    --primary-color: #0ea5e9;
    --accent-color: #7dd3fc;
    --text-color: #0f172a;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Pretendard', -apple-system, sans-serif;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden; /* 스크롤 방지 */
    touch-action: none; /* 모바일에서 스크롤/줌 방지 */
}

.game-container {
    text-align: center;
    width: 100%;
    max-width: 800px;
    padding: 20px;
    position: relative; /* 조이스틱 배치를 위해 */
}

h1 {
    color: var(--text-color);
    margin-bottom: 10px;
}

#score-board {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

#game-area {
    width: 100%;
    max-width: 600px; /* 정사각형 비율 유지를 위해 너비 제한 */
    aspect-ratio: 1 / 1; /* 정사각형 비율 */
    margin: 0 auto;
    background-color: var(--game-bg);
    border: 4px solid var(--primary-color);
    border-radius: 10px;
    position: relative;
    overflow: hidden; 
    cursor: pointer;
    background-image: linear-gradient(#e0f2fe 1px, transparent 1px), linear-gradient(90deg, #e0f2fe 1px, transparent 1px);
    background-size: 20px 20px;
}

#player {
    position: absolute;
    top: 0;
    left: 0;
    width: 18px; /* 9px -> 18px (2배 확대) */
    height: 18px;
    z-index: 10;
    background-image: url('명박.PNG');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    will-change: transform; /* 성능 최적화 */
    transition: width 0.3s, height 0.3s; /* 크기 변화 애니메이션 */
}

.poop {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 18px; /* 6px * 3 */
    width: 18px;
    height: 18px;
    line-height: 18px;
    z-index: 5;
    will-change: transform; 
}

.hamburger {
    position: absolute;
    font-size: 15px; /* 햄버거 크기 축소 18px -> 15px */
    width: 15px;
    height: 15px;
    line-height: 15px;
    z-index: 6;
    will-change: transform;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* 무적 상태 */
.immune {
    opacity: 0.5;
    filter: drop-shadow(0 0 5px gold);
    animation: blink 0.2s infinite;
}

@keyframes blink {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}

.controls {
    margin-top: 20px;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.1s, background-color 0.2s;
}

button:hover {
    background-color: #0284c7;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(1px);
}

.mobile-controls {
    color: #64748b;
    font-size: 0.9rem;
    margin-top: 10px;
}

/* Modal Styles */
.hidden {
    display: none !important;
}

#game-over-modal, #ranking-modal, #description-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    text-align: center;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 85vh; /* 모바일 키보드 등 고려하여 높이 제한 */
    overflow-y: auto; /* 내용이 넘치면 스크롤 */
    box-sizing: border-box;
}

@media (max-width: 600px) {
    .modal-content {
        padding: 20px;
        width: 95% !important; /* 인라인 스타일 덮어쓰기 위해 */
    }
}

.modal-content h2 {
    color: #ef4444;
    margin-top: 0;
}

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