/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow-x: hidden;
    touch-action: manipulation;
}

/* Piano styles */
.piano-container {
    overflow-x: auto;
    overflow-y: hidden;
    margin-bottom: 20px;
    min-height: 180px; /* Ensure minimum height for piano container */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.piano-keyboard {
    position: relative;
    display: flex;
    height: 140px; /* Reduced height for better fit */
    min-width: 700px; /* Ensure minimum width */
    user-select: none;
}

.piano-key {
    position: relative;
    cursor: pointer;
    transition: background-color 0.1s ease, transform 0.1s ease;
}

.piano-key.white {
    width: 60px;
    height: 100%;
    background: #f9f9f9;
    border: 1px solid #2A2A2A;
    border-right: none;
    border-radius: 0 0 5px 5px;
    z-index: 1;
}

.piano-key.white:last-child {
    border-right: 1px solid #2A2A2A;
}

.piano-key.black {
    width: 40px;
    height: 60%;
    background: #0A0A0A;
    margin-left: -20px;
    margin-right: -20px;
    z-index: 2;
    border-radius: 0 0 5px 5px;
}

.piano-key.active {
    transform: translateY(5px);
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
}

.piano-key.white.active {
    background-color: #e0e0e0;
}

.piano-key.black.active {
    background-color: #222;
}

.key-label {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 12px;
    font-weight: medium;
}

.piano-key.white .key-label {
    color: #2A2A2A;
}

.piano-key.black .key-label {
    color: #f9f9f9;
}

/* Audio visualizer */
#audio-visualizer {
    display: flex;
    align-items: flex-end;
}

.visualizer-bar {
    flex: 1;
    background: linear-gradient(to top, #4361EE, #a9c9ff);
    margin: 0 1px;
    border-radius: 2px 2px 0 0;
    transition: height 0.1s ease;
}

/* Custom range inputs */
input[type="range"] {
    -webkit-appearance: none;
    background: transparent;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: #4361EE;
    cursor: pointer;
    margin-top: -6px;
}

input[type="range"]::-moz-range-thumb {
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: #4361EE;
    cursor: pointer;
    border: none;
}

input[type="range"]:focus {
    outline: none;
}

/* Animation for active character theme */
.character-theme.active {
    outline: 3px solid white;
    transform: scale(0.95);
}

/* Loading overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 10, 0.8);
    z-index: 10;
    transition: opacity 0.5s ease;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: #4361EE;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Select styling */
select {
    appearance: none;
    color: #F9F9F9;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Fonts */
.font-geist-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Stage glow effect */
.stage-glow {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 20px;
    background: radial-gradient(ellipse at center, rgba(67, 97, 238, 0.3) 0%, rgba(10, 10, 10, 0) 70%);
    filter: blur(8px);
    pointer-events: none;
}

/* Enhanced animation effects */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse-effect {
    animation: pulse 0.5s ease-in-out;
}

/* Explicitly set renderer canvas to fill container */
#three-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    outline: none;
    touch-action: none; /* Ensures touch events are properly captured */
}

/* Volume control slider styling */
#volume-slider {
    height: 2px;
}

#volume-slider::-webkit-slider-thumb {
    height: 12px;
    width: 12px;
}

#volume-slider::-moz-range-thumb {
    height: 12px;
    width: 12px;
}

/* Fix for overflow issues */
.container {
    max-height: 100vh;
}

/* Make sure piano container is visible and properly sized */
@media (max-width: 768px) {
    .piano-keyboard {
        height: 120px; /* Smaller height on mobile */
    }
    
    .piano-container {
        margin-bottom: 10px;
    }
}

/* Add a visible scrollbar to the piano container for mobile */
@media (max-width: 768px) {
    .piano-container::-webkit-scrollbar {
        height: 4px;
    }
    
    .piano-container::-webkit-scrollbar-track {
        background: #2A2A2A;
        border-radius: 2px;
    }
    
    .piano-container::-webkit-scrollbar-thumb {
        background: #4361EE;
        border-radius: 2px;
    }
}

/* Prevent text selection on UI elements */
.piano-key, button, .key-label {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Remove cursor changes on 3D container to indicate no drag controls */
#three-container {
    cursor: default;
}
