* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background: #0f0f23;
    color: #fff;
    font-family: 'Segoe UI', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
}

h1 {
    font-size: 28px;
    margin-bottom: 10px;
    color: #ffd700;
}

.stats {
    display: flex;
    gap: 30px;
    margin-bottom: 15px;
    font-size: 18px;
}

.stats span {
    background: rgba(255,255,255,0.1);
    padding: 8px 16px;
    border-radius: 8px;
}

.tower-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.tower-buttons button {
    background: rgba(255,255,255,0.15);
    border: 2px solid transparent;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.tower-buttons button:hover {
    background: rgba(255,255,255,0.25);
}

.tower-buttons button.selected {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.2);
}

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

#game-canvas {
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    cursor: crosshair;
    background: #1a1a2e;
}

.controls {
    margin-top: 15px;
    display: flex;
    gap: 15px;
}

.controls button {
    background: #4a90d9;
    border: none;
    color: #fff;
    padding: 10px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
}

.controls button:hover {
    background: #5aa0e9;
}

.controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#start-btn {
    background: #4f4;
    border: none;
    color: #000;
    padding: 14px 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    margin: 20px 0;
}

#start-btn:hover {
    background: #5f5;
}

.back-link {
    margin-top: 20px;
    color: #888;
    text-decoration: none;
}

.back-link:hover {
    color: #ffd700;
}

.wave-info {
    margin-top: 10px;
    font-size: 14px;
    color: #aaa;
    text-align: center;
}

/* ====== Mobile (portrait) ====== */
@media (max-width: 850px), (pointer: coarse) {
    body {
        overflow-x: hidden;
        padding: 0 !important;
        gap: 5px;
        width: 100%;
        max-width: 100%;
    }

    h1 {
        font-size: 20px;
        margin-bottom: 2px;
    }

    .stats {
        gap: 6px;
        font-size: 12px;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    .stats span {
        padding: 3px 8px;
        font-size: 12px;
    }

    .tower-buttons {
        gap: 4px;
        margin-bottom: 6px;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    .tower-buttons button {
        padding: 8px 10px;
        font-size: 14px;
        min-width: 48px;
        min-height: 44px;
    }

    #game-canvas {
        width: 100% !important;
        max-width: 100% !important;
        height: auto;
        aspect-ratio: 20 / 15;
        flex-shrink: 0;
        cursor: default;
        touch-action: none;
    }

    .controls {
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    .controls button {
        padding: 10px 20px;
        font-size: 15px;
        min-height: 44px;
    }

    #start-btn {
        padding: 12px 28px;
        font-size: 17px;
        min-height: 44px;
    }

    .back-link {
        margin-top: 6px;
        font-size: 14px;
    }
}
