:root {
    --primary-color: #3498db;
    --primary-hover: #2980b9;
    --bg-color: #f5f7fa;
    --panel-bg: #ffffff;
    --text-color: #2c3e50;
    --border-color: #e1e8ed;
    
    /* 標準選択カラー（赤系） */
    --active-color-light: #ff6b6b;
    --active-color-dark: #ee5253;
    --active-shadow: rgba(238, 82, 83, 0.6);

    /* スケールガイド（水色） */
    --guide-color-light: #5dade2;
    --guide-color-dark: #2980b9;
    --guide-shadow: rgba(93, 173, 226, 0.6);

    /* コードホバー（オレンジ） */
    --chord-color-light: #ffbe59;
    --chord-color-dark: #e67e22;
    --chord-shadow: rgba(255, 190, 89, 0.8);
    
    /* 3色比較カラー (ホバー時) */
    --color-match-light: #58d68d;   /* 含まれている（緑・明） */
    --color-match-dark: #2ecc71;    /* 含まれている（緑・暗） */
    --color-match-shadow: rgba(46, 204, 113, 0.6);

    --color-wrong-light: #ec7063;   /* 含まれていない（赤・明） */
    --color-wrong-dark: #e74c3c;    /* 含まれていない（赤・暗） */
    --color-wrong-shadow: rgba(231, 76, 60, 0.6);

    --color-missing-light: #f7dc6f; /* 足りない音（黄・明） */
    --color-missing-dark: #f1c40f;  /* 足りない音（黄・暗） */
    --color-missing-shadow: rgba(241, 196, 15, 0.6);
}

h1 {
    margin-bottom: 5px;
    color: #2c3e50;
}

p.desc {
    color: #7f8c8d;
    margin-top: 0;
    margin-bottom: 25px;
    text-align: center;
}

.container {
    max-width: 900px;
    width: 100%;
    background: var(--panel-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    box-sizing: border-box;
}

/* コントロール・情報パネル */
.info-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 15px;
    background: #eef2f7;
    border-radius: 8px;
}

.selected-notes {
    font-weight: bold;
}

.clear-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}
.clear-btn:hover {
    background-color: #c0392b;
}

/* ピアノ鍵盤の共通スタイル */
.piano-wrapper {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.piano {
    position: relative;
    height: 180px;
    width: 675px; /* 15つの白鍵 * 45px */
    margin: 0 auto;
    border: 1px solid #ccc;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    box-shadow: 0 6px 15px rgba(0,0,0,0.08);
    background: #fff;
}

.key {
    cursor: pointer;
    box-sizing: border-box;
    user-select: none;
}

/* 白鍵のデザイン（立体感向上） */
.white-key {
    position: absolute;
    width: 45px;
    height: 180px;
    background: linear-gradient(to bottom, #ffffff 0%, #f7f9fa 100%);
    border-right: 1px solid #ccc;
    z-index: 1;
    border-radius: 0 0 4px 4px;
    box-shadow: inset 0 -5px 10px rgba(0,0,0,0.05);
    transition: background 0.1s;
}
.white-key:last-child {
    border-right: none;
}

/* 黒鍵のデザイン（立体感向上） */
.black-key {
    position: absolute;
    width: 28px;
    height: 110px;
    background: linear-gradient(to bottom, #333333 0%, #151515 100%);
    z-index: 2;
    border-radius: 0 0 4px 4px;
    border: 1px solid #000;
    box-shadow: inset 0px 2px 2px rgba(255,255,255,0.2), 0px 3px 5px rgba(0,0,0,0.4);
    transition: background-color 0.1s, box-shadow 0.1s, border-color 0.1s;
}

/* --- 白鍵のカラー状態（グラデーション） --- */
.white-key.active { background: linear-gradient(to bottom, var(--active-color-light) 0%, var(--active-color-dark) 100%); }
.white-key.key-match { background: linear-gradient(to bottom, var(--color-match-light) 0%, var(--color-match-dark) 100%) !important; }
.white-key.key-wrong { background: linear-gradient(to bottom, var(--color-wrong-light) 0%, var(--color-wrong-dark) 100%) !important; }
.white-key.key-missing { background: linear-gradient(to bottom, var(--color-missing-light) 0%, var(--color-missing-dark) 100%) !important; }
.white-key.guide { background: linear-gradient(to bottom, #aed6f1 0%, var(--guide-color-dark) 100%) !important; }
.white-key.chord-active { background: linear-gradient(to bottom, #fecb7e 0%, var(--chord-color-dark) 100%) !important; }

/* --- 黒鍵のカラー状態（高コントラスト＋グロー発光効果） --- */
.black-key.active {
    background: linear-gradient(to bottom, var(--active-color-light) 0%, var(--active-color-dark) 100%) !important;
    box-shadow: inset 0px 2px 3px rgba(255,255,255,0.4), 0 0 10px var(--active-shadow);
    border-color: #900;
}
.black-key.key-match {
    background: linear-gradient(to bottom, var(--color-match-light) 0%, var(--color-match-dark) 100%) !important;
    box-shadow: inset 0px 2px 3px rgba(255,255,255,0.4), 0 0 10px var(--color-match-shadow);
    border-color: #1e7e34;
}
.black-key.key-wrong {
    background: linear-gradient(to bottom, var(--color-wrong-light) 0%, var(--color-wrong-dark) 100%) !important;
    box-shadow: inset 0px 2px 3px rgba(255,255,255,0.4), 0 0 10px var(--color-wrong-shadow);
    border-color: #7e1e1e;
}
.black-key.key-missing {
    background: linear-gradient(to bottom, var(--color-missing-light) 0%, var(--color-missing-dark) 100%) !important;
    box-shadow: inset 0px 2px 3px rgba(255,255,255,0.4), 0 0 10px var(--color-missing-shadow);
    border-color: #9a7d0a;
}
.black-key.guide {
    background: linear-gradient(to bottom, var(--guide-color-light) 0%, var(--guide-color-dark) 100%) !important;
    box-shadow: inset 0px 2px 3px rgba(255,255,255,0.4), 0 0 12px var(--guide-shadow);
    border-color: #1a5276;
}
.black-key.chord-active {
    background: linear-gradient(to bottom, var(--chord-color-light) 0%, var(--chord-color-dark) 100%) !important;
    box-shadow: inset 0px 2px 3px rgba(255,255,255,0.4), 0 0 12px var(--chord-shadow);
    border-color: #935116;
}

/* 凡例パネル */
.legend-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 8px;
    background: #fdfefe;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}
.legend-dot.match { background-color: var(--color-match-dark); }
.legend-dot.wrong { background-color: var(--color-wrong-dark); }
.legend-dot.missing { background-color: var(--color-missing-dark); }

/* チェックボックス設定エリア */
.config-panel {
    background: #fafbfc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 25px;
}

.config-panel h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #34495e;
}

.checkbox-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 500;
}

/* 検索結果エリア */
.results-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .results-section {
        grid-template-columns: 1fr;
    }
}

.result-box {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    box-sizing: border-box;
}

.result-box h3 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    color: var(--text-color);
}

.scale-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 250px;
    overflow-y: auto;
}

.scale-item {
    padding: 10px;
    border-bottom: 1px solid #f1f1f1;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 4px;
    transition: background-color 0.15s;
}

.scale-item:hover, .scale-item.selected {
    background-color: #f0f7fc;
}

.scale-item .name {
    font-weight: bold;
    color: var(--text-color);
}

/* リストの音階数バッジ */
.scale-item .note-count-badge {
    color: #475569;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: bold;
}

.scale-item .origin {
    color: #7f8c8d;
    background: #f1f2f6;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

.scale-item .match-rate {
    color: #27ae60;
}

/* 詳細パネル */
.detail-panel {
    background: #fdfefe;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 20px;
    margin-top: 10px;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
}

.detail-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.detail-title {
    margin: 0 0 5px 0;
    color: #2c3e50;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.detail-notes {
    margin: 0;
}

.detail-desc {
    text-align: center;
    margin-bottom: 5px;
}

.chord-grid {
    margin-top: 25px;
}

.chord-grid h4 {
    margin-top: 0;
    margin-bottom: 12px;
    color: #2c3e50;
}

.chord-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.chord-item {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.15s;
}

.chord-item:hover {
    background: var(--chord-color-dark);
    color: white;
    border-color: var(--chord-color-dark);
    transform: translateY(-2px);
}