/* ===================================
   键盘钢琴样式表
   Keyboard Piano Stylesheet
   =================================== */

/* 全局样式重置与基础设置 */
* {
    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%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* 主容器 */
.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 100%;
}

/* 标题区域 */
header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.2em;
}

/* 使用说明 */
.instructions {
    text-align: center;
    margin-bottom: 30px;
    padding: 15px;
    background: #f0f0f0;
    border-radius: 10px;
}

.instructions p {
    margin: 10px 0;
    color: #555;
    font-size: 1.1em;
}

kbd {
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: bold;
    margin: 0 3px;
}

/* 钢琴容器 */
.piano {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin: 40px 0;
    padding: 20px;
    background: #1a1a1a;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* 琴键基础样式 */
.key {
    position: relative;
    cursor: pointer;
    transition: all 0.1s ease;
    border-radius: 0 0 10px 10px;
    user-select: none;
}

/* 白键样式 */
.key.white {
    width: 80px;
    height: 250px;
    background: linear-gradient(to bottom, #fff 0%, #f5f5f5 100%);
    border: 2px solid #333;
    z-index: 1;
}

.key.white:hover {
    background: linear-gradient(to bottom, #f0f0f0 0%, #e0e0e0 100%);
}

/* 琴键按下状态 - 视觉反馈 */
.key.white.active {
    background: linear-gradient(to bottom, #ffd700 0%, #ffed4e 100%);
    transform: translateY(5px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* 键位标签 */
.key-label {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
}

.note {
    display: block;
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.key-code {
    display: block;
    font-size: 0.9em;
    color: #666;
    background: #333;
    color: #fff;
    padding: 3px 8px;
    border-radius: 5px;
    font-weight: bold;
}

/* 控制面板 */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f0f0f0;
    padding: 10px 20px;
    border-radius: 10px;
}

.volume-control label {
    font-weight: bold;
    color: #333;
}

#volume {
    width: 150px;
    cursor: pointer;
}

#volume-value {
    font-weight: bold;
    color: #667eea;
    min-width: 40px;
}

/* 八度控制 */
.octave-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f0f0f0;
    padding: 10px 20px;
    border-radius: 10px;
}

.octave-control label {
    font-weight: bold;
    color: #333;
}

#octave-display {
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
    min-width: 30px;
    text-align: center;
}

.octave-btn {
    width: 35px;
    height: 35px;
    border: none;
    border-radius: 50%;
    background: #667eea;
    color: #fff;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.octave-btn:hover {
    background: #764ba2;
    transform: scale(1.1);
}

.octave-btn:active {
    transform: scale(0.95);
}

/* 控制按钮 */
.control-btn {
    padding: 12px 24px;
    font-size: 1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    background: #667eea;
    color: #fff;
    /* 优化触摸体验 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:hover:not(:disabled) {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.control-btn:active:not(:disabled) {
    transform: translateY(0);
}

.control-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 状态显示 */
.status {
    text-align: center;
    padding: 15px;
    background: #f0f0f0;
    border-radius: 10px;
    margin-top: 20px;
}

#current-note {
    font-size: 1.2em;
    color: #333;
    font-weight: bold;
}

#recording-status {
    margin-top: 10px;
    color: #667eea;
    font-weight: bold;
}

/* 动画效果 */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.key.white.active .key-label {
    animation: pulse 0.3s ease;
}

/* 背景音乐面板 */
.bg-music-panel {
    margin: 30px 0;
    padding: 20px;
    background: linear-gradient(135deg, #667eea20, #764ba220);
    border-radius: 15px;
    border: 2px solid #667eea;
}

.bg-music-panel h3 {
    text-align: center;
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.bg-music-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.music-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.music-selector label {
    font-weight: bold;
    color: #333;
}

#bg-music-select {
    padding: 8px 15px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 1em;
    background: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

#bg-music-select:hover {
    border-color: #764ba2;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.music-controls {
    display: flex;
    gap: 10px;
}

.music-volume {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f0f0f0;
    padding: 8px 15px;
    border-radius: 10px;
}

.music-volume label {
    font-weight: bold;
    color: #333;
    font-size: 0.9em;
}

#bg-volume {
    width: 100px;
    cursor: pointer;
}

#bg-volume-value {
    font-weight: bold;
    color: #667eea;
    min-width: 35px;
    font-size: 0.9em;
}

/* 加载状态 */
.loading-status {
    margin-top: 15px;
    text-align: center;
}

.loading-status p {
    color: #667eea;
    font-weight: bold;
    margin-bottom: 10px;
}

.loading-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.loading-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* 分享面板 */
.share-panel {
    margin: 30px 0;
    padding: 20px;
    background: linear-gradient(135deg, #764ba220, #667eea20);
    border-radius: 15px;
    border: 2px solid #764ba2;
}

.share-panel h3 {
    text-align: center;
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.share-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.share-link-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

#share-link {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #764ba2;
    border-radius: 8px;
    font-size: 0.9em;
    background: #fff;
    color: #333;
}

#copy-btn {
    white-space: nowrap;
}

/* 响应式设计 */

/* 平板设备 */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .key.white {
        width: 60px;
        height: 200px;
    }

    .piano {
        gap: 3px;
        padding: 15px;
    }

    .note {
        font-size: 1em;
    }

    .key-code {
        font-size: 0.8em;
        padding: 2px 6px;
    }

    .controls {
        flex-direction: column;
        gap: 15px;
    }

    .volume-control {
        width: 100%;
        justify-content: center;
    }

    .bg-music-controls {
        flex-direction: column;
        gap: 15px;
    }

    .music-selector, .music-controls, .music-volume {
        width: 100%;
        justify-content: center;
    }

    .share-controls {
        flex-direction: column;
    }

    .share-link-container {
        flex-direction: column;
    }
}

/* 手机设备 */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 1em;
    }

    .instructions p {
        font-size: 0.9em;
    }

    .key.white {
        width: 40px;
        height: 150px;
    }

    .piano {
        gap: 2px;
        padding: 10px;
    }

    .key-label {
        bottom: 10px;
    }

    .note {
        font-size: 0.8em;
    }

    .key-code {
        font-size: 0.7em;
        padding: 2px 5px;
    }

    .control-btn {
        padding: 10px 20px;
        font-size: 0.9em;
    }
}

/* 横屏手机优化 */
@media (max-height: 500px) and (orientation: landscape) {
    .key.white {
        height: 120px;
    }

    .piano {
        margin: 20px 0;
    }

    header {
        margin-bottom: 15px;
    }

    .instructions {
        margin-bottom: 15px;
    }
}
