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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    width: 95%;
    max-width: 600px;
    text-align: center;
    position: relative;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
}

.header {
    margin-bottom: 15px;
    position: relative;
}

.title {
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 24px;
    font-weight: 700;
}

.subtitle {
    color: #6c757d;
    font-size: 14px;
    margin-bottom: 10px;
}

.header-buttons {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon-btn:hover {
    background: #f8f9fa;
}

/* 进度条样式 */
.progress-container {
    margin: 10px 0;
    width: 100%;
    padding: 0 20px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.progress-value {
    font-weight: bold;
    color: #333;
}

.progress-bar-bg {
    width: 100%;
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    transition: width 0.3s ease, background 0.3s ease;
}

.pass-message {
    color: #28a745;
    font-weight: bold;
    margin-top: 5px;
    font-size: 14px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 通用 Overlay */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* 改为从顶部开始，以便长内容滚动 */
    padding-top: 40px;
    transition: opacity 0.3s ease;
    opacity: 1;
    pointer-events: auto;
    overflow-y: auto; /* 允许滚动 */
}

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

.overlay-content {
    width: 90%;
    max-width: 500px;
    background: white;
    padding-bottom: 40px;
}

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.overlay-header h2 {
    font-size: 22px;
    color: #2c3e50;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 32px;
    color: #6c757d;
    cursor: pointer;
    padding: 0 10px;
    line-height: 1;
}

/* 设置面板样式 */
.settings-content {
    max-width: 400px;
}

.setting-group {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    text-align: left;
}

.setting-label {
    font-size: 16px;
    color: #495057;
    margin-bottom: 10px;
    font-weight: 600;
    display: block;
}

.level-select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ced4da;
    background-color: white;
    font-size: 16px;
}

/* 数据分析面板样式 */
.analytics-content {
    width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 25px;
}

.stat-card {
    background: #f8f9fa;
    padding: 15px 10px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #e9ecef;
}

.stat-label {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 18px;
    font-weight: 800;
    color: #2c3e50;
}

.chart-container {
    margin-bottom: 25px;
    text-align: left;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.chart-header h3 {
    font-size: 16px;
    color: #495057;
    margin: 0;
}

.chart-tabs {
    display: flex;
    gap: 5px;
    background: #f1f3f5;
    padding: 3px;
    border-radius: 8px;
}

.chart-tab {
    border: none;
    background: none;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-tab.active {
    background: white;
    color: #a18cd1;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chart-view {
    display: none;
    height: 150px;
    position: relative;
}

.chart-view.active {
    display: flex; /* for trend chart */
}

/* 柱状图特定样式 */
#trend-chart {
    align-items: flex-end;
    gap: 4px;
    padding: 10px 0;
    border-bottom: 1px solid #dee2e6;
}

.chart-bar {
    flex: 1;
    background: #a18cd1;
    border-radius: 4px 4px 0 0;
    transition: height 0.3s ease;
    min-width: 4px;
    position: relative;
}

.chart-bar:hover {
    opacity: 0.8;
}

/* 折线图特定样式 */
#accuracy-chart {
    display: none;
    border-bottom: 1px solid #dee2e6;
    padding: 10px 0;
}

#accuracy-chart.active {
    display: block;
}

.line-chart-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.line-path {
    fill: none;
    stroke: #4cd137;
    stroke-width: 2px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.data-point {
    fill: #4cd137;
    stroke: white;
    stroke-width: 2px;
    r: 4;
}

/* 散点图特定样式 */
#scatter-chart {
    display: none;
    border: 1px solid #dee2e6;
    margin-top: 10px;
    background-image: 
        linear-gradient(rgba(222, 226, 230, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(222, 226, 230, 0.3) 1px, transparent 1px);
    background-size: 20px 20px;
}

#scatter-chart.active {
    display: block;
}

.scatter-point {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transform: translate(-50%, 50%); /* 坐标原点在左下角，但CSS是左上角，需要转换 */
    background: #a18cd1;
    opacity: 0.7;
    border: 1px solid white;
}

.no-data {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #adb5bd;
    font-style: italic;
}

.history-list {
    text-align: left;
}

.history-list h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #495057;
}

.history-items {
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

.history-item:last-child {
    border-bottom: none;
}

.history-date {
    color: #6c757d;
}

.history-detail {
    display: flex;
    gap: 15px;
    font-weight: 500;
}

.acc-high {
    color: #28a745;
}

.acc-low {
    color: #dc3545;
}


/* 游戏区域 */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stave-container {
    background: #fff;
    border-radius: 12px;
    border: 2px solid #a18cd1;
    min-height: 140px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    overflow: hidden;
    position: relative; /* 为播放按钮定位 */
}

.play-audio-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(161, 140, 209, 0.1);
    border: 1px solid #a18cd1;
    color: #a18cd1;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.play-audio-btn:hover {
    background: rgba(161, 140, 209, 0.2);
    transform: scale(1.05);
}

.play-audio-btn:active {
    transform: scale(0.95);
}

.play-audio-btn.playing {
    background: #a18cd1;
    color: white;
    cursor: not-allowed;
    animation: pulse 1s infinite;
}

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

/* 输入状态显示 */
.input-status {
    min-height: 60px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: auto;
}

.input-sequence {
    display: flex;
    gap: 8px;
}

.note-slot {
    width: 36px;
    height: 44px;
    border: 2px dashed #adb5bd;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: 700;
    color: #495057;
    background: white;
    transition: all 0.2s;
}

.note-slot.filled {
    border-style: solid;
    border-color: #6c757d;
    background: #e9ecef;
}

.note-slot.active {
    border-color: #a18cd1;
    box-shadow: 0 0 0 2px rgba(161, 140, 209, 0.2);
    transform: scale(1.1);
}

.note-slot.correct {
    border-color: #28a745;
    color: #28a745;
    background: #d4edda;
}

.note-slot.wrong {
    border-color: #dc3545;
    color: #dc3545;
    background: #f8d7da;
    text-decoration: line-through;
}

/* 键盘输入区域 */
.keyboard-container {
    margin-top: auto;
    padding-bottom: 10px;
}

.piano-keyboard {
    display: flex;
    justify-content: center;
    position: relative;
    height: 180px;
    margin-bottom: 20px;
    padding: 0 10px;
}

.piano-key {
    position: relative;
    cursor: pointer;
    transition: all 0.1s;
    user-select: none;
}

.piano-key.white {
    width: 45px;
    height: 180px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 0 0 5px 5px;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    font-weight: bold;
    color: #888;
    box-shadow: 0 4px 2px rgba(0,0,0,0.1);
}

.piano-key.black {
    width: 30px;
    height: 110px;
    background: #333;
    border-radius: 0 0 3px 3px;
    margin-left: -15px;
    margin-right: -15px;
    z-index: 2;
    box-shadow: 0 4px 2px rgba(0,0,0,0.2);
}

.piano-key.white:active, .piano-key.white.active {
    background: #e9ecef;
    height: 178px;
    margin-top: 2px;
    box-shadow: 0 2px 1px rgba(0,0,0,0.1);
}

.piano-key.black:active, .piano-key.black.active {
    background: #000;
    height: 108px;
    margin-top: 2px;
    box-shadow: 0 2px 1px rgba(0,0,0,0.2);
}

/* 禁用状态 */
.piano-key.disabled {
    cursor: not-allowed;
    opacity: 0.6;
    background: #f8f9fa;
}

.piano-key.black.disabled {
    background: #555;
}

/* 反馈样式 */
.piano-key.correct {
    background-color: #d4edda !important;
    color: #155724;
}

.piano-key.wrong {
    background-color: #f8d7da !important;
    color: #721c24;
}

.controls-row {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.action-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    background: #a18cd1;
    color: white;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(161, 140, 209, 0.4);
    transition: all 0.2s;
    min-width: 140px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(161, 140, 209, 0.5);
}

.action-btn:active {
    transform: translateY(0);
}

.control-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: #e9ecef;
    color: #495057;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.control-btn:hover {
    background: #dee2e6;
}

.hidden {
    display: none !important;
}

/* 结果反馈 Overlay */
.result-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 20px;
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

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

.result-score {
    font-size: 64px;
    font-weight: 800;
    margin: 20px 0;
    color: #2ecc71;
}

.score-label {
    display: block;
    font-size: 18px;
    color: #ddd;
    font-weight: normal;
}

#result-time {
    font-size: 20px;
    margin-bottom: 30px;
    color: #ccc;
    line-height: 1.5;
}

@media (max-width: 480px) {
    .key-btn {
        font-size: 16px;
        border-radius: 8px;
    }
    
    .stave-container {
        min-height: 100px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
