* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    background: #1a1a2e;
    color: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 100vw;
    padding: 5px;
}

#gameHeader {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 8px 12px;
    background: #16213e;
    border-radius: 8px;
    border: 2px solid #0f3460;
    width: 100%;
    max-width: 600px;
    justify-content: center;
    flex-wrap: wrap;
}

.header-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-item .label {
    font-size: 10px;
    color: #a0a0a0;
    text-transform: uppercase;
}

.header-item .value {
    font-size: 16px;
    font-weight: bold;
    color: #e94560;
}

.btn {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.2s;
    touch-action: manipulation;
    min-height: 44px;
    min-width: 44px;
}

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

.btn:active {
    transform: scale(0.95);
}

.btn-start {
    background: #e94560;
    color: white;
}

.btn-start:hover {
    background: #ff6b81;
}

.btn-primary {
    background: #4a90d9;
    color: white;
    padding: 12px 30px;
    font-size: 18px;
    touch-action: manipulation;
    min-height: 48px;
}

.btn-primary:hover {
    background: #5ba3ec;
}

#canvasWrapper {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

#gameCanvas {
    border: 2px solid #0f3460;
    border-radius: 8px;
    cursor: crosshair;
    background: #2d5016;
    max-width: 100%;
    touch-action: none;
}

#towerPanel {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    background: #16213e;
    border-radius: 8px;
    border: 2px solid #0f3460;
    width: 100%;
    max-width: 600px;
    justify-content: center;
    flex-wrap: wrap;
}

.tower-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    min-width: 65px;
    min-height: 60px;
    justify-content: center;
    touch-action: manipulation;
}

.tower-option:active {
    transform: scale(0.95);
}

.tower-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tower-option.selected {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.2);
}

.tower-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tower-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.tower-option span {
    font-size: 10px;
}

.tower-cost {
    color: #ffd700;
    font-weight: bold;
}

#gameOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay-screen {
    text-align: center;
    padding: 30px 20px;
    background: #16213e;
    border-radius: 12px;
    border: 3px solid #0f3460;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.overlay-screen h1 {
    font-size: 36px;
    margin-bottom: 12px;
}

.overlay-screen p {
    font-size: 14px;
    margin: 8px 0;
    color: #ccc;
}

.instructions {
    margin: 15px 0;
    text-align: left;
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
}

.instructions h3 {
    color: #e94560;
    margin-bottom: 8px;
    font-size: 14px;
}

.instructions p {
    font-size: 13px;
    margin: 4px 0;
}

.hidden {
    display: none;
}

#towerPanel .tower-option.selected {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.2);
    transform: scale(1.05);
}

/* 모바일 가로 모드 */
@media (max-height: 500px) and (orientation: landscape) {
    #gameContainer {
        gap: 4px;
    }
    
    #gameHeader {
        padding: 4px 8px;
        gap: 8px;
    }
    
    .header-item .label {
        font-size: 8px;
    }
    
    .header-item .value {
        font-size: 13px;
    }
    
    .btn {
        padding: 4px 10px;
        font-size: 11px;
        min-height: 32px;
    }
    
    #towerPanel {
        padding: 4px 6px;
        gap: 4px;
    }
    
    .tower-option {
        padding: 4px 6px;
        min-height: 45px;
        min-width: 55px;
    }
    
    .tower-icon {
        width: 22px;
        height: 22px;
    }
    
    .tower-option span {
        font-size: 8px;
    }
    
    .overlay-screen {
        padding: 15px;
    }
    
    .overlay-screen h1 {
        font-size: 28px;
    }
    
    .overlay-screen p {
        font-size: 12px;
    }
}

/* 매우 작은 모바일 화면 */
@media (max-width: 400px) {
    #gameHeader {
        gap: 6px;
        padding: 6px 8px;
    }
    
    .header-item .value {
        font-size: 14px;
    }
    
    .tower-option {
        min-width: 55px;
        padding: 6px 6px;
    }
    
    .tower-option span {
        font-size: 9px;
    }
}

/* 큰 화면 */
@media (min-width: 768px) {
    #gameContainer {
        gap: 10px;
    }
    
    #gameHeader {
        gap: 20px;
        padding: 10px 20px;
    }
    
    .header-item .label {
        font-size: 11px;
    }
    
    .header-item .value {
        font-size: 18px;
    }
    
    .tower-option {
        min-width: 80px;
        padding: 8px 12px;
    }
    
    .tower-icon {
        width: 30px;
        height: 30px;
    }
    
    .tower-option span {
        font-size: 11px;
    }
}
