/* --- CORE STYLES --- */
body {
    overscroll-behavior: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.piano-container {
    perspective: 800px;
}

/* --- KEYS 3D CSS --- */
.key {
    transition: background-color 0.1s, transform 0.05s, box-shadow 0.05s;
    transform-origin: top;
}

.white-key {
    height: 100%;
    z-index: 1;
    border: 1px solid #ccc;
    border-top: none;
    background: linear-gradient(to bottom, #fff 0%, #eee 100%);
    border-radius: 0 0 5px 5px;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}

.white-key:active,
.white-key.active {
    background: linear-gradient(to bottom, #f0f0f0 0%, #ddd 100%);
    transform: rotateX(-2deg) scale(0.99);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    border-bottom: 4px solid #ddd;
}

.black-key {
    position: absolute;
    top: 0;
    height: 60%;
    width: 8%;
    z-index: 2;
    background: linear-gradient(to bottom, #333 0%, #000 100%);
    border-radius: 0 0 3px 3px;
    box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.4);
}

.black-key:active,
.black-key.active {
    background: linear-gradient(to bottom, #222 0%, #111 100%);
    transform: scale(0.98);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.key-label {
    pointer-events: none;
}

/* --- UI COMPONENTS --- */
#layout-modal {
    transition: opacity 0.3s ease-in-out;
}

#layout-modal.hidden-modal {
    opacity: 0;
    pointer-events: none;
}

.pad-btn {
    transition: all 0.2s ease;
}

.pad-active {
    background-color: #2563eb;
    /* blue-600 */
    border-color: #3b82f6;
    /* blue-500 */
    color: white;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.5);
}

.pad-inactive {
    background-color: #1e293b;
    /* slate-800 */
    border-color: #334155;
    /* slate-700 */
    color: #94a3b8;
    /* slate-400 */
}

.pad-inactive:hover {
    background-color: #334155;
    /* slate-700 */
    color: white;
}

.octave-slot {
    width: 16px;
    height: 4px;
    border-radius: 2px;
    background-color: #334155;
    transition: all 0.2s;
}

.octave-slot.active {
    background-color: #3b82f6;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
}

.octave-slot:hover {
    background-color: #475569;
}

/* Loading Spinner */
.spinner {
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-left-color: #3b82f6;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    animation: spin 1s linear infinite;
    display: none;
}

.spinner.loading {
    display: block;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* --- DEBUG CONSOLE --- */
#debug-console {
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    line-height: 1.2;
    text-shadow: 1px 1px 0 #000;
}

/* --- MINI KEYBOARD VISUALIZER --- */
.kb-row {
    display: flex;
    justify-content: center;
    gap: 2px;
    margin-bottom: 2px;
}

.kb-key {
    background: #334155;
    border-radius: 2px;
    height: 12px;
    width: 12px;
    font-size: 0;
}

.kb-key.active {
    background: #3b82f6;
    box-shadow: 0 0 4px #3b82f6;
}

.kb-key.wide {
    width: 18px;
}

.kb-key.space {
    width: 60px;
}

/* Gradient Ring Logic */
@keyframes gradientBorder {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 200% 50%;
    }
}

@keyframes glowPulse {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1.0);
    }

    50% {
        opacity: 0.95;
        transform: scale(1.02);
    }
}

.mapping-ring {
    position: relative;
    /* No hard box-shadow */
}

.mapping-ring::after {
    content: '';
    position: absolute;
    inset: -2px;
    /* Slight overlap */
    border-radius: 12px;
    background: linear-gradient(45deg, #f59e0b, #ef4444, #fbbf24);
    background-size: 200% 200%;
    z-index: -1;
    filter: blur(15px);
    /* Soft diffuse glow */
    animation: gradientSpin 3s linear infinite, glowPulse 4s ease-in-out infinite;
}

@keyframes gradientSpin {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Orientation Warning for Mobile Portrait */
@media (pointer: coarse) and (orientation: portrait) {
    #rotate-overlay {
        display: flex;
    }
}