@import url('https://fonts.googleapis.com/css2?family=Lato:wght@700&family=Noto+Sans+JP:wght@600&display=swap');
.lato-bold {
    font-family: "Lato", sans-serif;
    font-weight: 700;
    font-style: normal;
    unicode-range: U+0030-0039;
}

:root {
    --primary-color: #007bff;
    --bg-color: #f4f7f9;
    --card-bg: #ffffff;
    --text-color: #333;
    --border-color: #e0e0e0;
    --pitch-color: #28a745;
    --stability-color: #ffc107;
    --longtone-color: #17a2b8;
    --rhythm-color: #dc3545;
    --tech-color: #6f42c1;
    --highlight-bg: #e7f1ff;
}

body {
    font-family: '游ゴシック', 'Lato', sans-serif;
    font-weight: Bold;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

header h1 { margin: 0; }

.file-loader { text-align: center; padding: 20px 0; }
.file-loader label {
    cursor: pointer;
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
    transition: background-color 0.2s;
}
.file-loader label:hover { background-color: #0056b3; }
.file-loader input[type="file"] { display: none; }

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.hidden { display: none; }

/* ★★★ データマージ機能のスタイルを追加/修正 ★★★ */
#merge-box {
    padding: 15px;
    border: 1px dashed var(--primary-color);
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.file-input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.file-input-group label {
    font-weight: bold;
    font-size: 0.9em;
}
/* テキストエリア用のスタイルを追加 */
#json-input-b {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: monospace; /* 等幅フォントで見やすく */
    font-size: 0.9em;
    box-sizing: border-box;
}
#merge-btn {
    padding: 10px 15px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}
#merge-btn:hover {
    background-color: #218838;
}
/* ★★★ 追加ここまで ★★★ */

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    margin-bottom: 10px;
}
.list-header h2 {
    margin: 0;
    padding: 0;
    border: none;
}
/* ★★★ 記録数表示用のスタイルを追加 ★★★ */
.record-count {
    font-size: 0.7em;
    font-weight: normal;
    color: #6c757d;
    margin-left: 10px;
    vertical-align: middle;
}
/* ★★★ 追加ここまで ★★★ */

#toggle-scores-btn {
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    background-color: #f8f9fa;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
}
#toggle-scores-btn:hover { background-color: #e9ecef; }

/* ★★★ フィルター操作パネルのスタイル更新 ★★★ */
#filter-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end; /* ラベルと入力欄の下端を揃える */
    gap: 15px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
    margin-bottom: 20px;
}
.filter-group {
    display: flex;
    flex-direction: column; /* ラベルを入力欄の上に配置 */
    gap: 5px;
    min-width: 150px; /* グループの最小幅を確保 */
    flex-grow: 1; /* 空きスペースに応じて幅を広げる */
}
.filter-group label {
    font-size: 0.8em;
    font-weight: bold;
    color: #555;
}
.multi-input-group {
    display: flex;
    gap: 5px;
    width: 100%;
}
#filter-controls select, #filter-controls input, #filter-controls button {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1em;
    box-sizing: border-box; /* paddingを含めて幅を計算 */
}
.multi-input-group > * {
    flex-grow: 1; /* グループ内の要素幅を均等に */
}
.multi-input-group > input[type="number"] {
    flex-grow: 0.5; /* 点数入力欄は少し狭く */
}
.button-group {
    flex-direction: row; /* ボタンは横並び */
    align-self: flex-end; /* ボタンを一番下に配置 */
}
#filter-controls button {
    border: none;
    cursor: pointer;
    font-weight: bold;
}
#apply-filter-btn {
    background-color: var(--primary-color);
    color: white;
}
#reset-filter-btn {
    background-color: #6c757d;
    color: white;
}
/* ===== フッター ===== */
.footer {
    padding: 30px 0;
    text-align: center;
    font-size: 0.9rem;
    color: #333;
}
#detail-view h2 {
    margin-top: 0;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

#song-list { list-style: none; padding: 0; margin: 0; }
#song-list li {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#song-list li:last-child { border-bottom: none; }
#song-list li:hover { background-color: #f8f9fa; }
#song-list .list-song-name { font-weight: bold; }
#song-list .list-score { font-size: 1.1em; color: var(--primary-color); }

.scores-hidden .list-score { display: none; }

#back-to-list-btn {
    background: none; border: 1px solid var(--primary-color); color: var(--primary-color);
    padding: 8px 15px; border-radius: 5px; cursor: pointer; font-size: 1em;
    margin-bottom: 15px; transition: background-color 0.2s, color 0.2s;
}
#back-to-list-btn:hover { background-color: var(--primary-color); color: white; }

.song-header { display: flex; justify-content: space-between; align-items: flex-end; }
.song-title-artist h2 { margin: 0; font-size: 1.8em; font-weight: bold; }
.song-title-artist p { margin: 5px 0 0 0; font-size: 1.1em; color: #555; }
.song-meta p { margin: 0; font-size: 0.9em; color: #777; white-space: nowrap; }
hr { border: none; height: 1px; background-color: var(--border-color); margin: 15px 0; }

.total-score-container { text-align: center; font-size: 2.5em; font-weight: bold; margin: 25px 0; }
.total-score-container .score-value { font-size: 1.5em; color: var(--primary-color); }

.score-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 768px) { .score-grid { grid-template-columns: repeat(2, 1fr); } }

.score-item .item-header { display: flex; justify-content: space-between; margin-bottom: 5px; font-weight: bold; }
.progress-bar-bg { height: 20px; background-color: #e9ecef; border-radius: 10px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: 10px; transition: width 0.5s ease-in-out; }
.pitch-bg { background-color: var(--pitch-color); }
.stability-bg { background-color: var(--stability-color); }
.longtone-bg { background-color: var(--longtone-color); }
.rhythm-bg { background-color: var(--rhythm-color); }
.tech-bg { background-color: var(--tech-color); }

.technique-counts { display: flex; flex-wrap: wrap; justify-content: space-around; text-align: center; margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--border-color); }
.tech-item { margin: 10px; }
.tech-item p:first-child { font-weight: bold; margin: 0; }
.tech-item p:last-child { font-size: 1.5em; margin: 5px 0 0 0; }

.table-container { overflow-x: auto; }
#history-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
#history-table th, #history-table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
#history-table thead { background-color: var(--primary-color); color: white; }

.current-row { background-color: var(--highlight-bg); }
.best-score { font-weight: bold; color: var(--rhythm-color); }

@media (min-width: 768px) { .score-grid { grid-template-columns: repeat(2, 1fr); } }

.score-item .item-header { display: flex; justify-content: space-between; margin-bottom: 5px; font-weight: bold; }
.progress-bar-bg { height: 20px; background-color: #e9ecef; border-radius: 10px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: 10px; transition: width 0.5s ease-in-out; }
.pitch-bg { background-color: var(--pitch-color); }
.stability-bg { background-color: var(--stability-color); }
.longtone-bg { background-color: var(--longtone-color); }
.rhythm-bg { background-color: var(--rhythm-color); }
.tech-bg { background-color: var(--tech-color); }

.technique-counts { display: flex; flex-wrap: wrap; justify-content: space-around; text-align: center; margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--border-color); }
.tech-item { margin: 10px; }
.tech-item p:first-child { font-weight: bold; margin: 0; }
.tech-item p:last-child { font-size: 1.5em; margin: 5px 0 0 0; }

.table-container { overflow-x: auto; }
#history-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
#history-table th, #history-table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
#history-table thead { background-color: var(--primary-color); color: white; }

.current-row { background-color: var(--highlight-bg); }
.best-score { font-weight: bold; color: var(--rhythm-color); }

@media (max-width: 768px) {
    body { padding: 10px; }
    .card { padding: 15px; }
    header h1 { font-size: 1.5em; }
    .file-loader label { padding: 10px 15px; }
    
    /* ★★★ フィルターのレスポンシブスタイルを更新 ★★★ */
    #filter-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
    }
    .filter-group {
        min-width: unset;
        width: 100%;
    }
    .multi-input-group {
        flex-wrap: wrap; /* 折り返しを許可 */
    }
    /* 点数/回数フィルターの各項目を均等な幅にする */
    .multi-input-group select, .multi-input-group input {
        flex-grow: 1;
        flex-basis: 100px; /* ある程度の幅を確保し、狭い場合は折り返す */
    }
    .button-group {
        flex-direction: row;
        gap: 10px;
    }
    .button-group button {
        flex-grow: 1;
    }
    /* ★★★ 変更ここまで ★★★ */
    
    .song-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .song-title-artist h2 { font-size: 1.4em; }
    .song-meta p { font-size: 0.9em; }
    .list-header { flex-wrap: wrap; gap: 10px; }
    .list-header h2 { font-size: 1.4em; }
    #song-list li { flex-direction: column; align-items: flex-start; gap: 5px; }
    .list-score { width: 100%; text-align: right; font-size: 1.3em; margin-top: 5px; }
    .total-score-container { font-size: 1.8em; }
    .total-score-container .score-value { font-size: 1.5em; }
}