* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0D9488 0%, #1E3A5F 50%, #0F172A 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    -webkit-user-select: none;
    user-select: none;
    overflow-x: hidden;
}

h1 {
    color: white;
    margin: 10px 0 5px;
    font-size: 28px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.instructions {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    margin-bottom: 10px;
    text-align: center;
    max-width: 700px;
}

.level-picker {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.level-btn {
    padding: 8px 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    position: relative;
}

.level-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.level-btn.active {
    background: #0D9488;
    color: white;
    border-color: #0D9488;
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.4);
}

.level-btn.solved {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border-color: #4CAF50;
}

.level-btn.solved::after {
    content: '\2713';
    position: absolute;
    top: -8px;
    right: -8px;
    background: #FFD700;
    color: #333;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

#gameCanvas {
    background: #0F172A;
    border: 3px solid rgba(13, 148, 136, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), inset 0 0 40px rgba(13, 148, 136, 0.1);
    cursor: grab;
    border-radius: 8px;
    touch-action: none;
    max-width: 100%;
    height: auto;
}

#gameCanvas:active {
    cursor: grabbing;
}

.game-buttons {
    margin-top: 12px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

.game-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.game-btn.drop-btn {
    background: linear-gradient(135deg, #4ECDC4, #0D9488);
    color: white;
}

.game-btn.drop-btn:hover {
    background: linear-gradient(135deg, #0D9488, #4ECDC4);
}

.game-btn.drop-btn:disabled {
    background: #555;
    color: #999;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.game-btn.reset-btn {
    background: linear-gradient(135deg, #cc6633, #dd7744);
    color: white;
}

.game-btn.reset-btn:hover {
    background: linear-gradient(135deg, #dd7744, #ee8855);
}

.status-msg {
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    margin-top: 8px;
    min-height: 20px;
    text-align: center;
}

/* ─── Modal ─────────────────────────────────────────────── */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #0F172A, #1E3A5F);
    border: 2px solid rgba(13, 148, 136, 0.4);
    border-radius: 16px;
    padding: 30px 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(13, 148, 136, 0.2);
    animation: slideIn 0.3s ease;
}

.modal-content h2 {
    color: #4ECDC4;
    margin: 0 0 10px;
    font-size: 28px;
}

.modal-content p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 16px;
    margin: 0 0 25px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 10px 24px;
    border: 2px solid rgba(13, 148, 136, 0.3);
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.modal-btn.primary {
    background: linear-gradient(135deg, #0D9488 0%, #1E3A5F 100%);
    color: white;
    border: none;
}

.modal-btn.primary:hover {
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.4);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
