/* 기본 설정 */
body {
    margin: 0;
    overflow: hidden;
    background-color: #2c3e50;
    font-family: 'Segoe UI', sans-serif;
    touch-action: none;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 480px;
    height: 100%;
    background: linear-gradient(to bottom, #87CEEB, #E0F7FA);
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

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

/* --- 상단 헤더 (홈버튼 + 언어) --- */
.header-ui {
    position: absolute;
    top: 10px;
    left: 0;
    width: 100%;
    padding: 0 15px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 50; /* UI보다 위에, 스크린보다는 아래 */
    pointer-events: auto;
}

.home-btn {
    text-decoration: none;
    font-size: 24px;
    background-color: rgba(255, 255, 255, 0.8);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: transform 0.1s;
}
.home-btn:active { transform: scale(0.9); }

#lang-select {
    padding: 5px 10px;
    border-radius: 15px;
    border: none;
    background-color: rgba(255, 255, 255, 0.8);
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* UI 오버레이 */
.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-box {
    font-size: 50px;
    font-weight: 900;
    color: white;
    text-shadow: 3px 3px 0 #000;
    margin-top: 50px; /* 헤더 공간 확보 */
}

.timer-container {
    width: 80%;
    height: 12px;
    background-color: rgba(0,0,0,0.3);
    border-radius: 6px;
    margin-top: 10px;
    overflow: hidden;
    display: none;
}

.timer-bar {
    width: 100%;
    height: 100%;
    background-color: #00ff00;
    transition: width 0.1s linear;
}

/* 안내 문구 (PC용) */
.pc-hint {
    position: absolute;
    bottom: 120px;
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    text-shadow: 1px 1px 2px black;
}
.key-icon {
    border: 1px solid white;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: bold;
}

/* 화면들 (시작, 게임오버) */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 100;
    pointer-events: auto;
}
.screen.active { display: flex; }

.screen h1 { font-size: 40px; margin-bottom: 10px; color: #f1c40f; text-shadow: 2px 2px 0 #000; }
.final-score { font-size: 60px; font-weight: bold; margin: 20px 0; }

.btn {
    padding: 15px 40px;
    font-size: 18px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    margin: 10px;
    font-weight: bold;
    transition: transform 0.1s;
    width: 220px;
}
.btn:active { transform: scale(0.95); }
.primary { background-color: #e74c3c; color: white; }
.secondary { background-color: #3498db; color: white; }
.restart { background-color: #2ecc71; color: white; }
.home { background-color: #95a5a6; color: white; }

/* 모바일 컨트롤 (하단) */
.mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    display: flex;
    pointer-events: auto;
}

.control-btn {
    flex: 1;
    background: none;
    border: none;
    font-size: 0;
}
.control-btn:active {
    background-color: rgba(255,255,255,0.1);
}

@media (hover: none) and (pointer: coarse) {
    .pc-hint { display: none; }
}