/**
 * 小小钢琴 — 主样式表（童趣天空风格）
 * 
 * 设计原则：
 *   - 儿童友好：柔和天空渐变、大圆角、药丸按钮、彩虹色带
 *   - 童趣装饰：CSS 云朵、浮动音符、柔和阴影
 *   - 响应式：适配不同屏幕宽度
 *   - 无障碍：高对比度、清晰的视觉反馈
 */

/* ==================== 基础重置 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;
    background: linear-gradient(180deg, #A8E6CF 0%, #B8E6F0 50%, #D4ECFC 100%);
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* ==================== 背景装饰层 ==================== */
.bg-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* 云朵 — 纯 CSS 绘制 */
.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50px;
    filter: blur(1px);
}

.cloud::before,
.cloud::after {
    content: '';
    position: absolute;
    background: inherit;
    border-radius: 50%;
}

.cloud-1 {
    width: 120px;
    height: 40px;
    top: 55%;
    left: 10%;
    animation: floatCloud 20s ease-in-out infinite;
}
.cloud-1::before { width: 50px; height: 50px; top: -25px; left: 20px; }
.cloud-1::after { width: 70px; height: 60px; top: -30px; left: 50px; }

.cloud-2 {
    width: 160px;
    height: 50px;
    top: 65%;
    right: 20%;
    animation: floatCloud 25s ease-in-out infinite reverse;
}
.cloud-2::before { width: 60px; height: 55px; top: -28px; left: 30px; }
.cloud-2::after { width: 80px; height: 65px; top: -32px; left: 70px; }

.cloud-3 {
    width: 100px;
    height: 35px;
    top: 75%;
    left: 55%;
    opacity: 0.5;
    animation: floatCloud 30s ease-in-out infinite;
}
.cloud-3::before { width: 45px; height: 45px; top: -22px; left: 15px; }
.cloud-3::after { width: 55px; height: 50px; top: -25px; left: 40px; }

/* 浮动音符装饰 */
.floating-note {
    position: absolute;
    font-size: 24px;
    opacity: 0.3;
    color: #7EC8E3;
    animation: floatNote 8s ease-in-out infinite;
}

.note-1 { top: 58%; left: 5%; animation-delay: 0s; font-size: 28px; }
.note-2 { top: 80%; right: 8%; animation-delay: 2s; color: #FFB7B2; }
.note-3 { top: 70%; left: 15%; animation-delay: 4s; font-size: 20px; color: #B5EAD7; }
.note-4 { top: 85%; right: 25%; animation-delay: 6s; font-size: 22px; color: #C7CEEA; }
.note-5 { top: 90%; right: 12%; animation-delay: 1s; font-size: 26px; color: #FFB7B2; }
.note-6 { top: 95%; left: 8%; animation-delay: 3s; font-size: 22px; color: #B5EAD7; }

/* 闪烁星星 */
.sparkle {
    position: absolute;
    pointer-events: none;
    animation: twinkle 2s ease-in-out infinite;
}
.sparkle-1 { top: 52%; left: 5%; font-size: 20px; animation-delay: 0s; color: #FFD700; }
.sparkle-2 { top: 62%; right: 8%; font-size: 16px; animation-delay: 0.5s; color: #FFD700; }
.sparkle-3 { top: 72%; left: 3%; font-size: 14px; animation-delay: 1s; color: #FFA500; }
.sparkle-4 { bottom: 5%; right: 5%; font-size: 18px; animation-delay: 1.5s; color: #FFD700; }
.sparkle-5 { top: 82%; right: 15%; font-size: 12px; animation-delay: 0.8s; color: #FFA500; }

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* 小彩虹 */
.mini-rainbow {
    position: absolute;
    pointer-events: none;
    border-radius: 80px 80px 0 0;
    opacity: 0.2;
}
.rainbow-1 { top: 88%; right: 3%; width: 100px; height: 50px; background: linear-gradient(180deg, #FF6B6B, #FFA07A, #FFD700, #98FB98, #87CEEB, #9370DB); }
.rainbow-2 { bottom: 2%; left: 2%; width: 70px; height: 35px; background: linear-gradient(180deg, #FF6B6B, #FFA07A, #FFD700, #98FB98, #87CEEB, #9370DB); }

@keyframes floatCloud {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(30px); }
}

@keyframes floatNote {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-15px) rotate(10deg); }
    75% { transform: translateY(10px) rotate(-5deg); }
}

/* ==================== 启动引导页 ==================== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #A8E6CF 0%, #B8E6F0 50%, #D4ECFC 100%);
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.splash-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.splash-content {
    text-align: center;
    color: #4A90D9;
}

.splash-piano-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.splash-title {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 10px;
    color: #4A90D9;
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.8);
}

.splash-subtitle {
    font-size: 20px;
    color: #5BA4CF;
    opacity: 1;
    margin-bottom: 40px;
}

.splash-start-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 48px;
    font-size: 24px;
    font-weight: 600;
    color: #4A90D9;
    background: white;
    border: 3px solid #4A90D9;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(74, 144, 217, 0.3);
}

.splash-start-btn:hover {
    transform: scale(1.05);
    background: #4A90D9;
    color: white;
    box-shadow: 0 6px 20px rgba(74, 144, 217, 0.4);
}

.splash-start-btn:active {
    transform: scale(0.98);
}

.btn-icon {
    font-size: 28px;
}

.splash-hint {
    margin-top: 20px;
    font-size: 14px;
    color: #6BAED6;
    opacity: 0.8;
}

/* ==================== 加载提示 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #A8E6CF 0%, #B8E6F0 50%, #D4ECFC 100%);
    z-index: 999;
    transition: opacity 0.3s ease;
}

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

.loading-content {
    text-align: center;
    color: #4A90D9;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(74, 144, 217, 0.2);
    border-top-color: #4A90D9;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

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

.loading-bar {
    width: 200px;
    height: 6px;
    background: rgba(74, 144, 217, 0.2);
    border-radius: 3px;
    margin: 15px auto 0;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    background: #4A90D9;
    border-radius: 3px;
    width: 0%;
    animation: loading 1.5s ease-in-out forwards;
}

@keyframes loading {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* ==================== 主应用 ==================== */
.app {
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

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

/* ==================== 顶部工具栏 ==================== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 1100;
}

.toolbar-left {
    flex-shrink: 0;
}

.app-title {
    font-size: 20px;
    font-weight: 700;
    color: #4A90D9;
    text-shadow: none;
}

.toolbar-center {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==================== 控制按钮 ==================== */
.ctrl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 36px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    background: white;
    border: 2px solid #DDD;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* 悬浮提示气泡 */
.ctrl-btn::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: rgba(74, 144, 217, 0.9);
    color: #FFF;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    max-width: none;
    text-align: center;
    border-radius: 10px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1100;
}

.ctrl-btn:hover::after {
    opacity: 1;
}

.ctrl-btn:hover {
    border-color: #4A90D9;
    color: #4A90D9;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(74, 144, 217, 0.15);
}

.ctrl-btn:active {
    transform: translateY(0);
    background: #F0F7FF;
}

.ctrl-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* 八度控制 */
.octave-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.octave-display {
    color: #4A90D9;
    font-size: 14px;
    font-weight: 600;
    min-width: 80px;
    text-align: center;
    background: rgba(74, 144, 217, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1.5px solid rgba(74, 144, 217, 0.3);
}

/* 标注模式按钮 */
.label-btn {
    font-size: 14px;
}

/* ==================== 示范曲目区域 ==================== */
.demo-panel {
    position: relative;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 12px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border-bottom: 2px solid rgba(74, 144, 217, 0.1);
}

/* 曲目轮播容器 */
.song-carousel {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

/* 曲目列表：一行排列，不换行 */
.song-list {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    flex: 1;
    scroll-behavior: smooth;
    padding: 4px 0;
    /* 隐藏滚动条 */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.song-list::-webkit-scrollbar {
    display: none;
}

/* 曲目卡片：固定宽度不压缩 */
.song-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.song-item:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.song-item.selected {
    border-color: #4A90D9;
    background: #F0F7FF;
}

.song-emoji {
    font-size: 28px;
}

.song-info {
    display: flex;
    flex-direction: column;
}

.song-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.song-meta {
    font-size: 12px;
    color: #888;
}

/* 轮播箭头按钮 */
.carousel-arrow {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #ddd;
    background: white;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    position: relative;
    z-index: 2;
}

.carousel-arrow:hover {
    background: #4A90D9;
    border-color: #4A90D9;
    color: white;
}

.demo-controls {
    display: flex;
    gap: 8px;
}

.demo-controls .ctrl-btn {
    color: #4A90D9;
    background: white;
    border-color: #4A90D9;
    border-radius: 20px;
}

.demo-controls .ctrl-btn:hover {
    background: #4A90D9;
    color: white;
}

/* ==================== 轻松弹模式 ==================== */

/* 琴键闪烁高亮效果 */
.piano-key.guide-highlight {
    animation: guidePulse 0.8s ease-in-out infinite;
}

.white-key.guide-highlight {
    background: linear-gradient(to bottom, #E8F8E8 0%, #B8E6CF 100%);
    box-shadow: 0 0 15px 5px rgba(74, 217, 142, 0.4);
}

.black-key.guide-highlight {
    background: linear-gradient(to bottom, #55E6C1 0%, #3CC09F 100%);
    box-shadow: 0 0 15px 5px rgba(74, 217, 142, 0.4);
}

@keyframes guidePulse {
    0%, 100% {
        box-shadow: 0 0 10px 3px rgba(74, 217, 142, 0.2);
    }
    50% {
        box-shadow: 0 0 20px 8px rgba(74, 217, 142, 0.5);
    }
}

/* 按键提示气泡 */
.guide-hint {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    background: #55E6C1;
    color: #FFF;
    font-size: 13px;
    font-weight: 700;
    border-radius: 10px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 2px 8px rgba(74, 217, 142, 0.3);
}

.guide-hint::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #55E6C1;
}

/* 完成评分提示 */
.guide-score {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    text-align: center;
    padding: 15px 25px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.5s ease;
    transition: opacity 0.5s ease;
}

.guide-score-stars {
    font-size: 32px;
    margin-bottom: 8px;
}

.guide-score-text {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}

.guide-score-sub {
    font-size: 13px;
    color: #888;
}

/* ==================== 钢琴键盘 ==================== */
.piano-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 15px 10px;
    min-height: 0;
    z-index: 1;
}

.piano {
    position: relative;
    width: 100%;
    max-width: 1200px;
    height: 220px;
    display: flex;
}

/* ==================== 琴键样式 ==================== */
.piano-key {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    cursor: pointer;
    transition: background-color 0.1s ease, transform 0.05s ease;
}

/* 白键 */
.white-key {
    flex: 1;
    background: linear-gradient(to bottom, #FFFFFF 0%, #F8F8F8 100%);
    border: 1.5px solid #E0E0E0;
    border-radius: 0 0 10px 10px;
    z-index: 1;
    margin: 0 1.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.white-key:hover {
    background: linear-gradient(to bottom, #FFFFFF 0%, #F0F7FF 100%);
}

.white-key.active {
    background: linear-gradient(to bottom, #E8F4FD 0%, #D1ECFA 100%);
    transform: scaleY(0.98);
    transform-origin: top;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 黑键 */
.black-key {
    position: absolute;
    top: 0;
    height: 60%;
    background: linear-gradient(to bottom, #4A4A4A 0%, #2D2D2D 100%);
    border: 1px solid #222;
    border-radius: 0 0 8px 8px;
    z-index: 2;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
}

.black-key:hover {
    background: linear-gradient(to bottom, #555 0%, #3A3A3A 100%);
}

.black-key.active {
    background: linear-gradient(to bottom, #5B8DEF 0%, #4A90D9 100%);
    transform: scaleY(0.97);
    transform-origin: top;
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.4);
}

/* 琴键底部彩色条纹（彩虹色带，匹配设计稿） */
.key-color-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 8px;
    border-radius: 0 0 8px 8px;
    opacity: 0.9;
}

.black-key .key-color-bar {
    height: 4px;
    border-radius: 0 0 6px 6px;
    opacity: 0.7;
}

/* 琴键标注文字 */
.key-label {
    font-size: 13px;
    font-weight: 700;
    color: #555;
    margin-bottom: 32px;
    pointer-events: none;
    line-height: 1.2;
}

.black-key .key-label {
    font-size: 10px;
    color: #CCC;
    margin-bottom: 30px;
}

/* 键盘快捷键提示 */
.key-shortcut {
    position: absolute;
    bottom: 14px;
    font-size: 10px;
    font-weight: 600;
    color: #666;
    background: rgba(255, 255, 255, 0.85);
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
}

.black-key .key-shortcut {
    bottom: 8px;
    font-size: 9px;
    color: #DDD;
    background: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* ==================== 键盘映射提示 ==================== */
.keyboard-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.8);
}

.hint-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 13px;
}

.hint-label {
    font-weight: 600;
    color: #555;
}

.hint-keys {
    display: flex;
    gap: 4px;
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    color: #555;
    background: rgba(255, 255, 255, 0.8);
    border: 1.5px solid #DDD;
    border-radius: 6px;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
}

/* ==================== 动画辅助 ==================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==================== 响应式适配 ==================== */
@media (max-width: 768px) {
    .toolbar {
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 8px;
        background: rgba(255, 255, 255, 0.85);
    }

    .app-title {
        font-size: 16px;
    }

    .piano {
        height: 180px;
    }

    .key-label {
        font-size: 10px;
    }

    .key-shortcut {
        font-size: 8px;
    }

    .keyboard-hint {
        display: none;
    }

    .splash-title {
        font-size: 36px;
    }

    .splash-start-btn {
        padding: 12px 36px;
        font-size: 20px;
    }

    /* 移动端琴键区域缩小左右间距 */
    .piano-wrapper {
        padding: 0 8px 10px;
    }

    /* 移动端保留装饰但缩小尺寸 */
    .bg-decorations {
    }

    .sparkle {
        font-size: 12px !important;
    }

    .mini-rainbow {
        display: none;
    }

    .cloud {
        transform: scale(0.6) !important;
    }

    .floating-note {
        font-size: 16px !important;
    }

    /* 示范曲目区域移动端适配 */
    .demo-panel {
        padding: 8px 12px;
    }

    .song-emoji {
        font-size: 22px;
    }

    .song-name {
        font-size: 13px;
    }

    .song-meta {
        font-size: 11px;
    }

    .song-item {
        padding: 6px 10px;
        gap: 6px;
    }

    .carousel-arrow {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }

    .demo-controls {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .toolbar-right {
        gap: 4px;
    }

    .ctrl-btn {
        min-width: 34px;
        height: 32px;
        padding: 0 10px;
        font-size: 14px;
        border-radius: 16px;
    }

    .piano {
        height: 150px;
    }

    /* 小屏手机进一步缩小曲目区域 */
    .demo-panel {
        padding: 6px 8px;
    }

    .song-emoji {
        font-size: 18px;
    }

    .song-name {
        font-size: 12px;
    }

    .song-meta {
        font-size: 10px;
    }

    .song-item {
        padding: 5px 8px;
        gap: 4px;
        border-radius: 8px;
    }
}
