/* ===== リセット & 基本設定 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    overflow: hidden;
    height: 100vh;
}

/* ===== ローディング画面 ===== */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
}

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

.loading-content {
    text-align: center;
}

.loading-content h1 {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse 2s ease-in-out infinite;
}

.loading-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid #ffffff;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ===== メインアプリ ===== */
#app {
    display: none;
    height: 100vh;
    position: relative;
}

#app.ready {
    display: block;
}

/* ===== ヘッダー ===== */
header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.controls {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
}

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

/* ===== 3Dキャンバス ===== */
#canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
}

#canvas-container canvas {
    display: block;
    cursor: grab;
}

#canvas-container canvas:active {
    cursor: grabbing;
}

/* ===== サイドバー ===== */
#sidebar {
    position: absolute;
    top: 100px;
    right: 2rem;
    width: 320px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.panel {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.panel h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel h4 {
    font-size: 1.1rem;
    margin: 1.5rem 0 0.75rem 0;
}

.instructions {
    font-size: 0.95rem;
    line-height: 1.6;
    opacity: 0.9;
    margin-bottom: 1.5rem;
}

/* ===== サウンド情報（テキスト形式） ===== */
.sound-info {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.sound-info p {
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
    opacity: 0.9;
    text-align: center;
}

/* ===== 統計情報 ===== */
.stats {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.95rem;
}

.stat-row span:last-child {
    font-weight: 600;
    color: #4ecdc4;
}

/* ===== コントロール ===== */
.control-group {
    margin-bottom: 1.5rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 0.5rem;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #4ecdc4;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    background: #45b7d1;
    transform: scale(1.2);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #4ecdc4;
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

#volumeValue,
#reverbValue,
#attackValue,
#releaseValue,
#filterValue {
    font-weight: 600;
    color: #4ecdc4;
}

/* ===== シンセサイザーコントロール ===== */
.synth-select {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.synth-select:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.synth-select:focus {
    outline: none;
    border-color: #4ecdc4;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.2);
}

.synth-select option {
    background: #1a1a2e;
    color: #ffffff;
}

/* ===== フッター ===== */
footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.8;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===== スクロールバーのカスタマイズ ===== */
#sidebar::-webkit-scrollbar {
    width: 8px;
}

#sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* ===== レスポンシブ対応 ===== */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    #sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 40vh;
        border-radius: 16px 16px 0 0;
        display: flex;
        flex-direction: column;
    }
    
    /* 明示的に順番を指定 */
    #sidebar .panel:nth-child(1) {
        order: 1;  /* シンセサイザーを1番目 */
    }
    
    #sidebar .panel:nth-child(2) {
        order: 2;  /* コントロールを2番目 */
    }
    
    #sidebar .panel:nth-child(3) {
        order: 3;  /* Statsを3番目 */
    }

    .controls {
        width: 100%;
        justify-content: center;
    }

    footer {
        display: none;
    }
}

/* ===== アニメーション用クラス ===== */
.cube-clicked {
    animation: cubeClick 0.3s ease;
}

@keyframes cubeClick {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}
