* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #0a0a2a, #1a1a3e);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 6px;
    touch-action: manipulation;
}

.game-container {
    background: rgba(0, 0, 0, 0.6);
    border-radius: 20px;
    padding: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    width: 100%;
    max-width: 100vw;
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
}

.game-header {
    text-align: center;
    margin-bottom: 6px;
    flex-shrink: 0;
}

h1 {
    background: linear-gradient(135deg, #ff6b35, #ffd700, #ff6b35);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 1.5em;
    letter-spacing: 2px;
}

.subtitle {
    color: #aaa;
    font-size: 0.55em;
    margin-top: -3px;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 4px 0;
}

.stat {
    background: rgba(0,0,0,0.7);
    padding: 2px 10px;
    border-radius: 30px;
    color: white;
    font-weight: bold;
    font-size: 0.7em;
    border: 1px solid rgba(255,255,255,0.2);
}

.controls {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    padding: 4px 12px;
    border-radius: 30px;
    color: white;
    font-weight: bold;
    font-size: 0.75em;
    cursor: pointer;
    transition: transform 0.1s;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.95);
}

.sound-btn {
    background: linear-gradient(135deg, #f093fb, #f5576c);
}

.shake-btn {
    background: linear-gradient(135deg, #ff6b35, #ffa502);
}

.game-board-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 4px 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 1;
}

.game-canvas {
    display: block;
    margin: 0 auto;
    border-radius: 16px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    cursor: pointer;
    touch-action: none;
    background: rgba(0, 0, 0, 0.4);
    transition: all 0.3s;
}

.game-canvas.shaking {
    animation: shakeCanvas 0.3s ease-in-out 0s 2;
}

@keyframes shakeCanvas {
    0% { transform: translateX(0) translateY(0); }
    25% { transform: translateX(-5px) translateY(-3px); }
    50% { transform: translateX(5px) translateY(3px); }
    75% { transform: translateX(-3px) translateY(-2px); }
    100% { transform: translateX(0) translateY(0); }
}

/* ===== 메시지 영역 - 고정 높이 (화면 밀림 방지) ===== */
.message-area {
    text-align: center;
    margin-top: 5px;
    flex-shrink: 0;
    /* 고정 높이 - 메시지 유무와 관계없이 동일한 공간 차지 */
    min-height: 48px;
    height: 48px;
}

.message {
    text-align: center;
    font-size: 0.8em;
    padding: 4px;
    border-radius: 20px;
    font-weight: bold;
    /* 메시지가 없을 때도 투명하게 공간 유지 */
    opacity: 0;
    transition: opacity 0.2s ease;
    /* 고정 높이 내에서 표시 */
    line-height: 1.4;
    max-height: 44px;
    overflow: hidden;
}

/* 메시지가 있을 때만 표시 */
.message:not(:empty) {
    opacity: 1;
}

.message.success {
    background: rgba(0,255,0,0.3);
    color: #90ff90;
    animation: messagePop 0.3s;
}

.message.fail {
    background: rgba(255,0,0,0.3);
    color: #ff9090;
}

.message.shake {
    background: rgba(255,165,0,0.3);
    color: #ffcc66;
}

@keyframes messagePop {
    0% { transform: scale(0.8); opacity: 0; }
    80% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes stageClearFlash {
    0% { filter: brightness(1); }
    50% { filter: brightness(1.5); }
    100% { filter: brightness(1); }
}

@media (max-width: 600px) {
    .game-container {
        padding: 5px;
    }
    .stat {
        font-size: 0.6em;
        padding: 2px 6px;
    }
    h1 {
        font-size: 1.3em;
    }
    .btn {
        padding: 3px 8px;
        font-size: 0.7em;
    }
    /* 모바일에서 메시지 영역 높이 약간 줄임 */
    .message-area {
        min-height: 40px;
        height: 40px;
    }
    .message {
        font-size: 0.7em;
        max-height: 38px;
    }
}