/* =========================================================
   おんがく：おんがくのへや（#/music）・けんばん（#/keys）
   見た目は さいしょの画面・レベル選択・問題の画面に そろえる
   ========================================================= */

/* ---------- さいしょの画面の「おんがくのへや」ボタン（ほかのボタンと同じ） ---------- */

#homeScreen #homeMusic {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 360 / 110;
    height: auto;
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    box-shadow: none;
    outline: none;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.25s;
    align-items: center;
    justify-content: center;
}

#homeScreen #homeMusic svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    display: block;
}

#homeScreen #homeMusic:hover {
    transform: scale(1.1) translateY(-3px);
    filter: brightness(1.06) drop-shadow(0 6px 10px rgba(0, 0, 0, 0.15));
}

#homeScreen #homeMusic:active {
    transform: scale(0.95);
}


/* ---------- おんがくのへや ---------- */

html[data-mode="music"] body {
    /* さいしょの画面と同じ 宇宙のキラキラ背景 */
    background-image: url('../img/bg_space.svg');
    background-size: cover;
    background-position: center;
    margin: 0;
    overflow: hidden;
    height: 100vh;
    color: #333;
}

#musicScreen {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* 水色の枠と水面ボード（さいしょの画面と同じ） */
#musicScreen .music-board {
    position: absolute;
    top: 14vh;
    left: 1.5vw;
    right: 1.5vw;
    bottom: 2.5vh;
    border: 14px solid #57c1e8;
    background-image: url('../img/board_water.svg');
    background-size: 100% 100%;
    box-sizing: border-box;
    z-index: 0;
}

/* タマとタイトル（レベル選択の画面と同じ置きかた） */
#musicScreen .music-header-logo {
    position: absolute;
    top: calc(14vh - clamp(52px, 8.2vw, 96px));
    left: 48%;
    transform: translateX(-50%);
    width: clamp(540px, 86vw, 1020px);
    z-index: 2;
    pointer-events: none;
}

#musicScreen .music-header-logo svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

/* レッスンのボタン（3列） */
#musicScreen .music-menu {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    width: min(86vw, 1000px);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    column-gap: clamp(12px, 3vw, 40px);
    row-gap: clamp(10px, 3vh, 30px);
    justify-items: center;
    align-items: start;
    z-index: 3;
}

#musicScreen .music-lesson {
    width: 100%;
    max-width: 300px;
    aspect-ratio: 360 / 150;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.25s;
}

#musicScreen .music-lesson svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    display: block;
}

#musicScreen .music-lesson:not(:disabled):hover {
    transform: scale(1.08) translateY(-3px);
    filter: brightness(1.06) drop-shadow(0 6px 10px rgba(0, 0, 0, 0.15));
}

#musicScreen .music-lesson:not(:disabled):active {
    transform: scale(0.95);
}

/* まだ ひらいていない レッスン（くろいけんばん） */
#musicScreen .music-lesson {
    position: relative;
}

.music-lock {
    display: none;
}

#musicScreen .music-lesson.locked svg {
    filter: grayscale(1);
    opacity: 0.45;
}

#musicScreen .music-lesson.locked .music-lock {
    display: block;
    position: absolute;
    left: 50%;
    top: 34%;
    transform: translateX(-50%);
    width: 90%;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: clamp(10px, 1.4vw, 14px);
    color: #57606f;
}

/* じゅんびちゅうのレッスン（おんぷよみ・リズム） */
#musicScreen .music-lesson.coming {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 3px dashed #a9cce3;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.55);
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    color: #8395a7;
    cursor: default;
}

.music-coming-icon {
    font-size: clamp(18px, 3vw, 30px);
}

.music-coming-name {
    font-size: clamp(16px, 2.6vw, 28px);
}

.music-coming-note {
    font-size: clamp(11px, 1.4vw, 14px);
    padding: 1px 10px;
    border-radius: 999px;
    background: #dfe6e9;
    color: #636e72;
}

/* 右上：おと あり／なし・もどる（レベル選択の「もどる」と同じ カプセル） */
#musicScreen .music-nav {
    position: fixed;
    top: 10px;
    right: 14px;
    z-index: 10;
    display: flex;
    gap: 6px;
}

#musicScreen .music-nav button {
    padding: 5px 14px;
    font-size: 14px;
    font-weight: 900;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 999px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.22);
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, filter 0.2s ease;
}

#musicBack {
    background: linear-gradient(135deg, #26c6da, #0097a7);
}

#musicSound {
    background: linear-gradient(135deg, #c56cf0, #6c5ce7);
}

#musicSound.off {
    background: linear-gradient(135deg, #b2bec3, #636e72);
}

#musicScreen .music-nav button:hover {
    transform: scale(1.06);
    filter: brightness(1.08);
}

#musicScreen .music-nav button:active {
    transform: scale(0.95);
}


/* ---------- けんばん：レベル選択 ---------- */

html[data-mode="keys"] #openingScreen .title-keys,
html[data-mode="black"] #openingScreen .title-black,
html[data-mode="notes"] #openingScreen .title-notes,
html[data-mode="notesBass"] #openingScreen .title-notesBass,
html[data-mode="bassTb"] #openingScreen .title-bassTb,
html[data-mode="bassTuba"] #openingScreen .title-bassTuba,
html[data-mode="rhythm"] #openingScreen .title-rhythm {
    display: inline;
}

html[data-mode="keys"] #openingScreen .opening-board {
    border-color: #c39bd3; /* けんばんは ラベンダーの枠 */
}

html[data-mode="black"] #openingScreen .opening-board {
    border-color: #57606f; /* くろいけんばんは グレーの枠 */
}

html[data-mode="keys"] .select-level-buttons button {
    background-color: #ecdcfa;
    border-color: #6c3483;
    color: #4a235a;
}

html[data-mode="rhythm"] .select-level-buttons button {
    background-color: #fff1d6;
    border-color: #c0392b;
    color: #7b241c;
}

html[data-mode="notes"] .select-level-buttons button,
html[data-mode="notesBass"] .select-level-buttons button {
    background-color: #dff3ff;
    border-color: #1e3799;
    color: #0b3c5d;
}

html[data-mode="bassTb"] .select-level-buttons button,
html[data-mode="bassTuba"] .select-level-buttons button {
    background-color: #fff3d1;
    border-color: #9a5b00;
    color: #5a3a00;
}

html[data-mode="bassTb"] #openingScreen .opening-board,
html[data-mode="bassTuba"] #openingScreen .opening-board {
    border-color: #f0a500; /* ヘおんよみは 金管の 金色の枠 */
}

html[data-mode="black"] .select-level-buttons button {
    background-color: #2f3640;
    border-color: #a29bfe;
    color: #ffffff;
}


/* ---------- けんばん：問題の画面 ---------- */

#keysScreen {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #fff;
}

/* カード・メッセージ（けんばんの上の あいたところの まんなか） */
#keysScreen .keys-stage {
    position: absolute;
    top: 6vh;
    left: 0;
    right: 0;
    bottom: calc(var(--keys-height) * var(--keys-zoom) + 12px); /* けんばんの 上の はしに あわせて 上下する */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1vh;
    pointer-events: none;
}

#keysScreen {
    --keys-height: clamp(120px, 33vh, 270px); /* けんばんは 画面の 下に ひくめに（まんなかを ひろく） */
    --keys-zoom: 1;                            /* けんばんの おおきさ（スライダー。0.6〜1.8） */
}

.keys-cards {
    display: flex;
    gap: clamp(6px, 1.6vw, 18px);
    align-items: center;
    justify-content: center;
}

/* 音の名前のカード（計算の「？」カードと同じ 白いカード） */
.keys-card {
    width: min(26vh, 30vw);
    aspect-ratio: 160 / 130;
    background: #fff;
    border: 1px solid grey;
    border-radius: 10px;
    padding: 4px;
    box-sizing: border-box;
    transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.keys-cards.phrase .keys-card {
    width: min(17vh, 21vw);
    opacity: 0.55;
}

.keys-cards.phrase .keys-card.current {
    opacity: 1;
    transform: scale(1.08);
    border: 3px solid #c56cf0;
    box-shadow: 0 0 14px rgba(197, 108, 240, 0.45);
}

.keys-cards.phrase .keys-card.done {
    opacity: 1;
    background: #eafaf1;
    border-color: #27ae60;
}

.keys-name {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

/* 正解：カードが ぽんと はねる */
.keys-cards.solved .keys-card {
    animation: keys-card-pop 0.6s ease;
}

@keyframes keys-card-pop {
    0% { transform: scale(1); }
    35% { transform: scale(1.18) rotate(-3deg); }
    100% { transform: scale(1); }
}

.keys-message {
    margin: 0;
    min-height: 1.4em;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: clamp(16px, 2.6vh, 24px);
    color: #6c5ce7;
    text-align: center;
}

/* メッセージ・ヒント・こたえの ボタンは ちぢめない（場所が たりない ときは カードの ほうが ちぢむ。文字が かさならないように） */
#keysScreen .keys-message,
#keysScreen .keys-hint,
#keysScreen .keys-answers {
    flex-shrink: 0;
}

#keysScreen .keys-cards {
    min-height: 0;
    max-height: 100%;
}

/* けんばんを 大きく して 上が せまく なったら、カード（五線）が ちぢむ */
#keysScreen .keys-card.staff-card {
    max-height: 100%;
}

.keys-hint {
    margin: 0;
    min-height: 1.2em;
    padding: 0 12px;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 700;
    font-size: clamp(12px, 1.9vh, 16px);
    color: #636e72;
    text-align: center;
}

/* けんばんの よみかた（おんぷよみ Lv5）：右上の スイッチ（右上の ドロップより 上に） */
/* 右上の どうぐ（けんばんの おおきさ・けんばんの よみかた） */
.keys-tools {
    position: absolute;
    z-index: 20;
    top: 5px;
    right: 10px;
    display: flex;
    flex-wrap: wrap-reverse;
    justify-content: flex-end;
    align-items: center;
    gap: 4px 14px;
    max-width: calc(100vw - 20px);
}

.keys-tools .keys-help {
    position: static;
}

.keys-zoom {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 15px;
    color: #4a235a;
    cursor: pointer;
}

.keys-zoom-mark {
    font-size: 13px;
    color: #6c5ce7;
}

.keys-zoom input[type="range"] {
    width: clamp(80px, 12vw, 140px);
    margin: 0;
    accent-color: #6c5ce7;
    cursor: pointer;
}

/* せまい 画面：スイッチの 下の だんに（左上の タイトルと かさならない）。ことばは かくして ー・＋ だけ */
@media (max-width: 600px) {
    .keys-tools {
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
    }

    .keys-tools .keys-help {
        order: -1;
    }

    .keys-zoom {
        padding: 2px 6px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.85);
    }

    .keys-zoom-label {
        display: none;
    }
}

.keys-help {
    z-index: 20;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 15px;
    color: #4a235a;
}

/* おんぷよみ：五線の 音符（js/staff.js） */
.keys-card.staff-card {
    width: auto;
    height: min(36vh, 300px);
    aspect-ratio: auto;
    padding: 6px 10px;
}

.keys-cards.staff.phrase .keys-card {
    width: auto;
    opacity: 1;
}

/* 五線は カードの 中に おさめる（せまい 画面で 4/4 の 1小節が はみださないように） */
.keys-card.staff-card .staff {
    max-width: min(92vw, calc(100vw - 60px));
}

.staff {
    height: 100%;
    max-width: 92vw;
    display: block;
    overflow: visible;
}

.staff-lines line,
.staff-ledger {
    stroke: #2d3436;
    stroke-width: 2.5;
}

.staff-head {
    fill: #2d3436;
}

.staff-stem {
    stroke: #2d3436;
    stroke-width: 3;
}

.staff-glow {
    fill: none;
}

/* いま 読む 音符（メロディのとき） */
.keys-cards.phrase .staff-note.current .staff-head { fill: #e84393; }
.keys-cards.phrase .staff-note.current .staff-stem { stroke: #e84393; }
.keys-cards.phrase .staff-note.current .staff-glow { fill: rgba(232, 67, 147, 0.15); }

/* 読みおわった 音符 */
.staff-note.done .staff-head { fill: #27ae60; }
.staff-note.done .staff-stem { stroke: #27ae60; }

/* おんぷの しくみ（おんぷよみの さいしょ）：1つでも いま 読む 音符は ピンク */
.keys-cards.tour .staff-note.current .staff-head { fill: #e84393; }
.keys-cards.tour .staff-note.current .staff-stem { stroke: #e84393; }
.keys-cards.tour .staff-note.current .staff-glow { fill: rgba(232, 67, 147, 0.15); }

/* おだんご（おんぷよみ）：1本の くしに おだんご。色は 音の 色（js/staff.js が style で つける） */
.staff-skewer {
    stroke: #c68e52;
    stroke-width: 5;
    stroke-linecap: round;
}

.keys-cards .staff-note.dango .staff-head {
    stroke: #7a5c3e;
    stroke-width: 2;
}


/* いま おす おだんご：ピンクの わっかが ポワンポワン */
.keys-cards .staff-note.dango.current .staff-glow {
    fill: rgba(232, 67, 147, 0.12);
    stroke: #e84393;
    stroke-width: 3;
    animation: staff-dango-now 0.9s ease-in-out infinite alternate;
}

@keyframes staff-dango-now {
    from { stroke-opacity: 1; }
    to { stroke-opacity: 0.25; }
}

.staff-dango-name {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 18px;
    stroke: #ffffff;
    stroke-width: 4px;
    paint-order: stroke;
}

/* 正解の キラリン：音符が ふくらんで 光り、★ が はじける */
.staff-star {
    font-size: 16px;
    fill: #fdcb6e;
    stroke: #e17055;
    stroke-width: 0.6;
    text-anchor: middle;
    opacity: 0;
    pointer-events: none;
}

.staff-note.sparkle .staff-head {
    animation: staff-sparkle-head 0.5s ease-out; /* transform は つかわない（音符の かたむき rotate が ずれる） */
}

.staff-note.sparkle .staff-glow {
    animation: staff-sparkle-glow 0.55s ease-out;
}

.staff-note.sparkle .staff-star {
    animation: staff-sparkle-star 0.6s ease-out;
}

.staff-note.sparkle .staff-star.b { animation-delay: 0.06s; }
.staff-note.sparkle .staff-star.c { animation-delay: 0.12s; }

@keyframes staff-sparkle-head {
    0% { filter: none; }
    35% { filter: drop-shadow(0 0 6px #ffd700) brightness(1.3); }
    100% { filter: none; }
}

@keyframes staff-sparkle-glow {
    0% { fill: rgba(255, 215, 0, 0); }
    30% { fill: rgba(255, 215, 0, 0.55); }
    100% { fill: rgba(255, 215, 0, 0); }
}

@keyframes staff-sparkle-star {
    0% { opacity: 0; }
    25% { opacity: 1; }
    100% { opacity: 0; }
}

/* きょくふう メロディ（おんぷよみ マスタークラス）：コード名・小節線・ぜんぶの がくふ */
.staff-chord {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 22px;
    fill: #6c5ce7;
}

.staff-bar {
    stroke: #2d3436;
    stroke-width: 2.5;
}

.staff-bar.end {
    stroke-width: 6;
}

/* 4/4拍子の しるし */
.staff-time text {
    font-family: 'Times New Roman', 'Noto Serif', serif;
    font-weight: 900;
    font-size: 54px;
    text-anchor: middle;
    fill: #2d3436;
}

/* 2ぶ音符・全音符の 白い 玉（まわりは 音符の 色、なかは 白） */
.staff-hole {
    fill: #ffffff;
}

/* 2ぶきゅうふ・全きゅうふ（四角） */
.staff-rest-block {
    fill: #2d3436;
}

.staff-rest.on .staff-rest-block {
    fill: #27ae60;
}

/* 4ぶきゅうふ（おやすみ）。その 拍に なると、すこし 光って みどりに（おさなくて いい） */
.staff-rest-mark {
    fill: none;
    stroke: #2d3436;
    stroke-width: 5.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.staff-rest .staff-glow {
    fill: none;
}

.staff-rest.on .staff-rest-mark {
    stroke: #27ae60;
}

.staff-rest.on .staff-glow {
    animation: staff-sparkle-glow 0.55s ease-out;
}

.keys-cards.score .keys-card.score-card {
    height: auto;
    max-height: 100%;
    width: auto;
    max-width: 96vw;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: auto; /* だんが おおいときは スクロール */
}

.keys-cards.score {
    max-height: 100%;
    min-height: 0;
}

.score-row {
    height: min(17vh, 150px);
    width: auto;
    max-width: 92vw;
    flex: none;
}

/* ひきおわったあとの ボタン（もういちど きく・この 曲を もういちど・べつの 曲・えんそうを おわる） */
.keys-perform-button {
    padding: 8px 18px;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: clamp(15px, 2.4vh, 20px);
    color: #fff;
    border: 2px solid #fff;
    border-radius: 999px;
    background: linear-gradient(135deg, #a29bfe, #6c5ce7);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.22);
    cursor: pointer;
}

.keys-perform-button.finish {
    background: linear-gradient(135deg, #ff9ff3, #f368e0);
}

.keys-perform-button.again {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
}

.keys-perform-button.listen {
    background: linear-gradient(135deg, #55efc4, #00b894);
}

.keys-perform-button.melody {
    background: linear-gradient(135deg, #a29bfe, #6c5ce7);
}

/* ヘおん マスタークラス：ぜんぶの がくふ。上の だん（アプリの 右手）は うすく、下の だん（子どもの 左手）を 読む */
.keys-cards.left-score .lh-melody .staff-note .staff-head,
.keys-cards.left-score .lh-melody .staff-note.current .staff-head,
.keys-cards.left-score .lh-melody .staff-note.done .staff-head {
    fill: #a4adbd;
}

.keys-cards.left-score .lh-melody .staff-note .staff-stem,
.keys-cards.left-score .lh-melody .staff-note.current .staff-stem,
.keys-cards.left-score .lh-melody .staff-rest-mark {
    stroke: #a4adbd;
}

.keys-cards.left-score .lh-melody .staff-glow {
    fill: none !important;
}

.keys-cards.left-score .lh-bass .staff-chord {
    display: none; /* コード名は 上の だんに だけ */
}

/* 大譜表（上 右手・下 左手を 1つの 絵に）：2だん ぜんぶが 見える 高さ */
.grand-row {
    height: min(25vh, 216px);
    width: auto;
    max-width: 92vw;
    flex: none;
}

/* 行頭の 大括弧（ブレース） */
.staff-brace {
    fill: none;
    stroke: #2d3436;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* どこを えんそうしているかの たての せん（よこに うごく） */
.lh-playhead {
    stroke: #e84393;
    stroke-width: 4;
    stroke-linecap: round;
    opacity: 0;
    pointer-events: none;
}

.lh-playhead.on {
    opacity: 0.7;
}

.keys-perform-button.save {
    background: linear-gradient(135deg, #fdcb6e, #e17055);
}

/* せまい 画面：4つの ボタンを 2つずつ 2だんに */
@media (max-width: 560px) {
    .keys-perform-button {
        flex: 1 1 calc(50% - 10px);
        max-width: 240px;
        padding: 8px 8px;
        font-size: 15px;
        white-space: nowrap;
    }
}

/* メッセージの 2だんめ（えんそうの とくちょう など） */
.keys-message-sub {
    display: block;
    margin-top: 2px;
    font-size: 0.82em;
    color: #e17055;
}

.keys-perform-button:disabled {
    opacity: 0.55;
    cursor: default;
}

/* まだ 読まない 音符は かくしておく（1つずつ あらわれる） */
.staff-note {
    transition: opacity 0.25s ease;
}

.staff-note.hidden {
    opacity: 0;
}

/* 音符の 下の「せん」「あいだ」の ふだ */
.staff-tag {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 19px;
    text-anchor: middle;
}

.staff-tag.line { fill: #0984e3; }

/* 拍の かず（おんぷよみ Lv8 メロディ：1・2・3・4。きゅうふの 拍は うすく） */
.staff-count {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 20px;
    text-anchor: middle;
    fill: #6c5ce7;
}

.staff-count.rest {
    fill: #b2bec3;
}

.staff-count.rest.on {
    fill: #27ae60;
}
.staff-tag.space { fill: #e17055; }

/* ドの みじかい せん（加線）を 光らせる */
.staff-ledger.focus {
    stroke: #e84393;
    stroke-width: 5;
    animation: staff-ledger-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes staff-ledger-pulse {
    from { opacity: 1; }
    to { opacity: 0.35; }
}

/* せんを かぞえる：タッチする ところ・かぞえた せん・番号 */
.staff-line-hit {
    fill: transparent;
    cursor: pointer;
    pointer-events: all; /* うしろの .keys-stage は さわれないので、ここだけ さわれるように */
}

.staff-lines line.counted {
    stroke: #0984e3;
    stroke-width: 5;
}

/* 1ぽんめ：やさしく 点滅して「おしてね」 */
.staff-lines line.beckon {
    stroke: #e84393;
    stroke-width: 5;
    animation: staff-beckon 1.1s ease-in-out infinite alternate;
}

@keyframes staff-beckon {
    from { opacity: 1; }
    to { opacity: 0.3; }
}

.staff-line-push {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 16px;
    fill: #e84393;
    text-anchor: end;
    animation: staff-beckon 1.1s ease-in-out infinite alternate;
}

.staff-line-number {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 15px;
    fill: #0984e3;
    stroke: #ffffff;
    stroke-width: 3px;
    paint-order: stroke; /* せんに かさなっても 読めるように 白い ふち */
    text-anchor: end;
}

/* くろいけんばん Lv4：「ド♯ ＝ ？♭」 */
.keys-equal {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: clamp(28px, 6vh, 56px);
    color: #636e72;
}

.keys-cards.enharmonic .keys-card {
    width: min(20vh, 26vw);
}

/* こたえの ボタン（ド♭〜シ♭ など） */
.keys-answers {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(4px, 1vw, 10px);
    pointer-events: auto;
}

.keys-answers:empty {
    display: none;
}

.keys-answer {
    min-width: clamp(52px, 9vw, 84px);
    padding: 6px 10px;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: clamp(18px, 3vh, 28px);
    background: #fff;
    border: 3px solid #d9d2fb;
    border-radius: 16px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.keys-answer:active {
    transform: scale(0.92);
}

.keys-answer.ok {
    background: #a3e4b8;
    border-color: #27ae60;
}

.keys-answer.ng {
    animation: tk-ng 0.45s ease;
    border-color: #ff7675;
}

/* おとあそび：10この ♪ が ひとつずつ ともる */
.keys-free-notes {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(2px, 1vw, 10px);
    font-size: clamp(28px, 7vh, 60px);
    color: #dfe6e9;
}

.keys-free-note.on {
    color: #c56cf0;
    animation: keys-card-pop 0.4s ease;
}

/* けんばんの場所（画面の いちばん下。「はじめにもどる」は まん丸の ボタンで けんばんの 上に かさなる） */
#keysScreen .keys-keyboard {
    position: absolute;
    z-index: 2; /* 投げたドロップ（.coin、z-index 1）は けんばんの うしろに おちる（けんばんを ふさがない） */
    left: 50%;
    bottom: 4px;
    transform: translateX(-50%);
    /* おおきさは はばも たかさも 同じ わりあいで（大きく すると はしは 見きれる。まんなかが 見える） */
    width: calc(min(96vw, 1100px) * var(--keys-zoom));
    height: calc(var(--keys-height) * var(--keys-zoom));
}


/* クリア・ざんねんの画面は けんばん・つもった ドロップより手前に。もらったドロップは さらに手前（計算と同じ見え方）
   カードは 上のほうに（けんばんの上に つもった ドロップと かさならないように） */
html[data-mode="keys"] #completionModal,
html[data-mode="keys"] #mistakeModal,
html[data-mode="black"] #completionModal,
html[data-mode="black"] #mistakeModal,
html[data-mode="notes"] #completionModal,
html[data-mode="notes"] #mistakeModal,
html[data-mode="notesBass"] #completionModal,
html[data-mode="notesBass"] #mistakeModal,
html[data-mode="bassTb"] #completionModal,
html[data-mode="bassTb"] #mistakeModal,
html[data-mode="bassTuba"] #completionModal,
html[data-mode="bassTuba"] #mistakeModal,
html[data-mode="rhythm"] #completionModal,
html[data-mode="rhythm"] #mistakeModal {
    z-index: 5;
    align-items: flex-start !important;
    padding-top: max(12px, 4vh);
    box-sizing: border-box;
    overflow-y: auto;
}

html[data-mode="keys"] .reward-coin,
html[data-mode="black"] .reward-coin,
html[data-mode="notes"] .reward-coin,
html[data-mode="notesBass"] .reward-coin,
html[data-mode="bassTb"] .reward-coin,
html[data-mode="bassTuba"] .reward-coin,
html[data-mode="rhythm"] .reward-coin {
    z-index: 6;
}

/* けんばんの上に つもる ドロップ（指で けんばんの上に うごかしても 見えるように、けんばんより手前） */
.coin.keys-pile {
    z-index: 3;
    touch-action: none;
}


/* ---------- けんばんの部品（js/keyboard.js） ---------- */

.tk {
    position: relative;
    touch-action: none;             /* 指で おしても、スクロール・ズームしない */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.tk-key {
    position: absolute;
    top: 0;
    box-sizing: border-box;
    cursor: pointer;
}

/* 白いけんばん：つやのある ぷっくり */
.tk-white-key {
    height: 100%;
    border: 2px solid #4a235a;
    border-top: none;
    border-radius: 0 0 12px 12px;
    background: linear-gradient(180deg, #ffffff 0%, #ffffff 75%, #eef2f7 100%);
    box-shadow: inset 0 -6px 0 rgba(74, 35, 90, 0.12), 0 3px 4px rgba(0, 0, 0, 0.15);
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 10%;
}

.tk-white-key + .tk-white-key {
    border-left-width: 1px;
}

/* 黒いけんばん */
.tk-black-key {
    height: 60%;
    border-radius: 0 0 8px 8px;
    background: linear-gradient(180deg, #2d3436 0%, #1e272e 80%, #485460 100%);
    box-shadow: inset 0 -5px 0 rgba(255, 255, 255, 0.12), 0 3px 4px rgba(0, 0, 0, 0.35);
    z-index: 2;
}

/* おしているあいだ */
.tk-white-key.tk-down {
    background: linear-gradient(180deg, #f1f2f6 0%, #e4e8ef 100%);
    box-shadow: inset 0 -2px 0 rgba(74, 35, 90, 0.12);
}

.tk-black-key.tk-down {
    background: linear-gradient(180deg, #1e272e 0%, #2d3436 100%);
    box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.1);
}

/* そのレベルで使わない けんばん（おせば鳴るけれど、こたえには ならない） */
.tk-white-key.tk-dim {
    background: linear-gradient(180deg, #d5dbe3 0%, #c8cfd9 100%);
}

.tk-black-key.tk-dim {
    background: linear-gradient(180deg, #57606f 0%, #485460 100%);
}

/* 正解・まちがい */
.tk-white-key.tk-ok {
    animation: tk-ok-white 0.45s ease;
}

.tk-black-key.tk-ok {
    animation: tk-ok-black 0.45s ease;
}

.tk-key.tk-ng {
    animation: tk-ng 0.45s ease;
}

@keyframes tk-ok-white {
    0%, 60% { background: #a3e4b8; }
    100% { background: #fff; }
}

@keyframes tk-ok-black {
    0%, 60% { background: #27ae60; }
    100% { background: #2d3436; }
}

@keyframes tk-ng {
    0%, 60% { background: #ffb3b3; }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    100% { transform: translateX(0); }
}

/* けんばんの 名前（ド・レ・ミ …） */
.tk-label {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: clamp(13px, 2.4vw, 26px);
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}

/* けんばんの しるし（ヘおんよみ：まんなかの ド に ★） */
.tk-mark {
    font-size: clamp(12px, 2vw, 20px);
    line-height: 1;
    color: #f39c12;
    text-shadow: 0 0 3px #fff;
    margin-bottom: 4px;
    pointer-events: none;
}

/* ♯・♭ の ガイド：もとの音は ふちどりだけ（ぬりつぶすと「ここを おす」に 見えるので）。矢印は おす けんばんの ほうへ */
.tk-white-key.tk-guide {
    box-shadow: inset 0 0 0 4px #ffb300, 0 3px 4px rgba(0, 0, 0, 0.15);
}

.tk-arrow {
    position: absolute;
    top: 64%;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: clamp(22px, 3.6vw, 40px);
    line-height: 1;
    color: #e67e22;
    text-shadow: 0 0 4px #fff, 0 0 4px #fff;
    pointer-events: none;
    --tk-arrow-x: 4px;
    --tk-arrow-y: 0px;
    animation: tk-arrow 0.9s ease-in-out infinite alternate;
}

.tk-arrow.left {
    --tk-arrow-x: -4px;
}

/* 黒いけんばんへ：黒いけんばんの すぐ下から、ななめ上を さす */
.tk-arrow.up {
    top: 62%;
    font-size: clamp(28px, 4.6vw, 50px);
    --tk-arrow-y: -4px;
}

.tk-arrow.up.right {
    right: 2%;
}

.tk-arrow.up.left {
    left: 2%;
}

/* 「ここを おしてね」：ポワンポワン 光る わっか（おんぷよみ しくみの さいしょの ド） */
.tk-white-key.tk-beckon {
    background: linear-gradient(180deg, #fff0f6 0%, #ffd6e8 100%);
}

.tk-ring {
    position: absolute;
    left: 50%;
    bottom: 3%;
    width: 78%;
    aspect-ratio: 1;
    border: 4px solid #e84393;
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(232, 67, 147, 0.6);
    pointer-events: none;
    animation: tk-ring 1s ease-in-out infinite;
}

@keyframes tk-ring {
    0% { transform: translateX(-50%) scale(0.75); opacity: 1; }
    100% { transform: translateX(-50%) scale(1.25); opacity: 0.15; }
}

@keyframes tk-arrow {
    from { transform: translate(calc(var(--tk-arrow-x) * -1), calc(var(--tk-arrow-y) * -1)); }
    to { transform: translate(var(--tk-arrow-x), var(--tk-arrow-y)); }
}

/* まほうで 名前が きえる */
.tk-label.tk-vanish {
    animation: tk-vanish 0.9s ease forwards;
}

@keyframes tk-vanish {
    0% { transform: scale(1); opacity: 1; filter: blur(0); }
    40% { transform: scale(1.5) rotate(-10deg); opacity: 1; }
    100% { transform: scale(0.2) translateY(-40px); opacity: 0; filter: blur(4px); }
}

.tk-sparkle {
    position: absolute;
    bottom: 12%;
    font-size: clamp(16px, 3vw, 30px);
    pointer-events: none;
    animation: tk-sparkle 1s ease forwards;
}

@keyframes tk-sparkle {
    0% { transform: scale(0.3); opacity: 0; }
    30% { transform: scale(1.4) rotate(20deg); opacity: 1; }
    100% { transform: scale(0.8) translateY(-50px) rotate(60deg); opacity: 0; }
}

/* けんばんの上の ふきだし（おした音の名前） */
.tk-balloon {
    position: absolute;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    padding: 0.35em 0.9em;
    background: #fffcd2;
    border: 3px solid #d9d2fb;
    border-radius: 1.2em;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: clamp(14px, 2.6vh, 24px);
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
    filter: drop-shadow(3px 3px 4px rgba(0, 0, 0, 0.25));
    animation: tk-balloon 1.1s ease forwards;
}

@keyframes tk-balloon {
    0% { opacity: 0; transform: translate(-50%, 10px) scale(0.7); }
    15% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -12px); }
}

/* スマホのたて画面：けんばんを すこし ひくく */
@media (max-width: 600px) {
    #keysScreen {
        --keys-height: clamp(110px, 26vh, 200px);
    }
}

/* はじめにもどる（まん丸。くるりん やじるし）：けんばんの 左下に かさなる（左下は たいてい くらい けんばん）。
   マウスを のせると 横に のびて「はじめにもどる」が 出る */
#keysScreen .round-return {
    z-index: 3;
    left: 8px;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 0;
    height: 46px;
    min-width: 46px;
    max-width: 46px;
    padding: 0 9px;
    overflow: hidden;
    white-space: nowrap;
    border: 2px solid #fff;
    border-radius: 999px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
    transition: max-width 0.3s ease, gap 0.3s ease, transform 0.2s, box-shadow 0.3s;
}

#keysScreen .round-return-icon {
    flex: none;
    width: 24px;
    height: 24px;
}

#keysScreen .round-return-label {
    opacity: 0;
    font-size: 18px;
    transition: opacity 0.2s ease;
}

#keysScreen .round-return:hover {
    max-width: 260px;
    gap: 6px;
    transform: none;
}

#keysScreen .round-return:hover .round-return-label {
    opacity: 1;
}


/* ---------- じゆうにひこう（#/piano） ---------- */

#pianoScreen {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #fff;
    --piano-height: clamp(150px, 52vh, 420px);
}

/* 右上：音名かくにん・もどる（おんがくのへやと同じ カプセル） */
#pianoScreen .piano-nav {
    position: fixed;
    top: 10px;
    right: 14px;
    z-index: 10;
    display: flex;
    gap: 6px;
}

#pianoScreen .piano-nav button {
    padding: 6px 14px;
    font-size: 15px;
    font-weight: 900;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 999px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.22);
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, filter 0.2s ease;
}

#pianoBack {
    background: linear-gradient(135deg, #26c6da, #0097a7);
}

/* けんばんの はばの スライダー */
#pianoScreen .piano-width {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px;
    font-size: 13px;
    font-weight: 900;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    color: #4a235a;
    background: #f3e8fd;
    border: 2px solid #fff;
    border-radius: 999px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.22);
    white-space: nowrap;
}

#pianoWidth {
    width: clamp(80px, 14vw, 160px);
    accent-color: #c56cf0;
}

#pianoNames {
    background: linear-gradient(135deg, #b2bec3, #636e72);
}

#pianoNames.on {
    background: linear-gradient(135deg, #c56cf0, #6c5ce7);
}

/* おと：ピアノ（みずいろ）⇄ ニャー（オレンジ） */
#pianoSound {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
}

#pianoSound.cat {
    background: linear-gradient(135deg, #ffc371, #ff8c42);
}

#pianoScreen .piano-nav button:hover {
    transform: scale(1.06);
    filter: brightness(1.08);
}

#pianoScreen .piano-nav button:active {
    transform: scale(0.95);
}

/* さわった音の 名前（音名かくにん ON のとき） */
#pianoScreen .piano-stage {
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    bottom: calc(var(--piano-height) + 44px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.piano-name {
    height: min(28vh, 100%);
    max-width: 90vw;
}

.piano-name-svg {
    height: 100%;
    max-width: 90vw;
    display: block;
    overflow: visible;
    animation: keys-card-pop 0.35s ease;
}

/* けんばん：画面の 左はしから 右はしまで */
#pianoScreen .piano-keyboard {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 12px;
    height: var(--piano-height);
}

@media (max-width: 600px) {
    #pianoScreen {
        --piano-height: clamp(140px, 40vh, 300px);
    }

    /* せまい画面では、ボタンを タイトルの下へ（かさならないように）。スライダーは その下の だん */
    #pianoScreen .piano-nav {
        top: 40px;
        left: 10px;
        right: 10px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    /* ボタン 3つが 1だんに ならぶように、すこし 小さく */
    #pianoScreen .piano-nav button {
        padding: 5px 10px;
        font-size: 13px;
    }

    #pianoScreen .piano-width {
        order: 1;
        flex-basis: 100%;
        justify-content: center;
    }

    #pianoWidth {
        width: 160px;
    }

    #pianoScreen .piano-stage {
        top: 120px;
    }
}


/* ---------- リズム（#/rhythm。js/engines/rhythm.js） ---------- */

#rhythmScreen {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #fff;
    touch-action: manipulation;
}

/* 流れる がくふの 帯 */
#rhythmScreen .rhythm-stage {
    position: absolute;
    top: 12vh;
    left: 0;
    right: 0;
    height: 190px;
    background: linear-gradient(180deg, #fff8e7 0%, #fff1d6 100%);
    border-top: 4px solid #ffcf8a;
    border-bottom: 4px solid #ffcf8a;
    overflow: hidden;
}

.rhythm-lane {
    position: absolute;
    inset: 15px 0 15px 0;
    overflow: hidden;
}

.rh-score {
    position: absolute;
    left: 0;
    top: 0;
    will-change: transform;
}

.rh-line { stroke: #7b241c; stroke-width: 3; }
.rh-tick { fill: #e0b07a; }
.rh-barline { stroke: #b9770e; stroke-width: 3; }
.rh-barline.end { stroke-width: 6; }
.rh-count {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 40px;
    fill: #e0b07a;
}
.rh-head { fill: #2d3436; }
.rh-note.hollow .rh-head { fill: #fff; stroke: #2d3436; stroke-width: 3.5; }
.rh-stem { stroke: #2d3436; stroke-width: 3; }
.rh-beam { fill: #2d3436; }
.rh-rest { fill: none; stroke: #2d3436; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.rh-syllable {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 22px;
    fill: #c0392b;
}
.rh-syllable.rest { fill: #95a5a6; }

/* はんてい */
.rh-note.perfect .rh-head { fill: #27ae60; }
.rh-note.perfect .rh-stem { stroke: #27ae60; }
.rh-note.good .rh-head { fill: #2e86de; }
.rh-note.good .rh-stem { stroke: #2e86de; }
.rh-note.hollow.perfect .rh-head,
.rh-note.hollow.good .rh-head { fill: #fff; stroke: currentColor; }
.rh-note.hollow.perfect { color: #27ae60; }
.rh-note.hollow.good { color: #2e86de; }
.rh-note.miss .rh-head { fill: #ff7675; }
.rh-note.miss .rh-stem { stroke: #ff7675; }

/* たたく せん（ここに 来たら たたく） */
#rhythmScreen .rhythm-hitline {
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(25% - 4px);
    width: 8px;
    background: rgba(232, 67, 147, 0.75);
    border-radius: 4px;
    box-shadow: 0 0 12px rgba(232, 67, 147, 0.6);
    pointer-events: none;
}

/* はじめの 1・2・3・4 */
#rhythmScreen .rhythm-count {
    position: absolute;
    top: 50%;
    left: 60%;
    transform: translate(-50%, -50%);
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 110px;
    color: rgba(231, 76, 60, 0.85);
    pointer-events: none;
}

/* ぴったり！・いいね・ミス */
.rhythm-popup {
    position: absolute;
    top: 6px;
    left: 25%;
    transform: translateX(-50%);
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 24px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
}

.rhythm-popup.perfect { color: #27ae60; }
.rhythm-popup.good { color: #2e86de; }
.rhythm-popup.miss { color: #e74c3c; }

.rhythm-popup.show {
    animation: rhythm-popup 0.6s ease forwards;
}

@keyframes rhythm-popup {
    0% { opacity: 0; transform: translate(-50%, 8px) scale(0.8); }
    20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -10px) scale(1); }
}

#rhythmScreen .rhythm-message {
    position: absolute;
    top: calc(12vh + 200px);
    left: 0;
    right: 0;
}

#rhythmScreen .rhythm-hint {
    position: absolute;
    top: calc(12vh + 236px);
    left: 0;
    right: 0;
}

/* おてほん・スタート */
#rhythmScreen .rhythm-start-buttons {
    position: absolute;
    top: calc(12vh + 270px);
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 16px;
    z-index: 4;
}

.rhythm-button {
    padding: 10px 26px;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: clamp(18px, 3vh, 26px);
    color: #fff;
    border: 3px solid #fff;
    border-radius: 999px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.rhythm-button { white-space: nowrap; }

@media (max-width: 600px) {
    .rhythm-button { padding: 8px 16px; font-size: 18px; }
    #rhythmScreen .rhythm-start-buttons { gap: 10px; }
}

.rhythm-button.demo { background: linear-gradient(135deg, #26c6da, #0097a7); }
.rhythm-button.start { background: linear-gradient(135deg, #ff9f43, #e74c3c); }
.rhythm-button:active { transform: scale(0.94); }

/* たいこ（画面の どこを たたいても いい。これは めじるし） */
#rhythmScreen .rhythm-pad {
    position: absolute;
    left: 50%;
    bottom: 64px;
    transform: translateX(-50%);
    width: min(44vw, 30vh, 240px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #fff8e7 0%, #ffe0a3 55%, #ff9f43 100%);
    border: 6px solid #7b241c;
    box-shadow: 0 8px 0 #b9770e, 0 12px 18px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: clamp(20px, 4vh, 34px);
    color: #7b241c;
    pointer-events: none;
}

#rhythmScreen .rhythm-pad.hit {
    animation: rhythm-pad 0.15s ease;
}

@keyframes rhythm-pad {
    0% { transform: translateX(-50%) translateY(6px) scale(0.96); box-shadow: 0 2px 0 #b9770e, 0 4px 8px rgba(0, 0, 0, 0.25); }
    100% { transform: translateX(-50%); }
}

@media (max-height: 640px) {
    #rhythmScreen .rhythm-pad { display: none; }
}

/* きょくふうを えらぶ（/song⏎。js/song-picker.js） */
.song-picker-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.song-picker {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    padding: 14px 16px;
    width: min(760px, 100%);
    max-height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
    font-family: 'M PLUS Rounded 1c', sans-serif;
}

.song-picker h2 {
    margin: 0 0 4px;
    font-size: 20px;
    color: #6c5ce7;
}

.song-picker h3 {
    margin: 12px 0 6px;
    font-size: 16px;
    color: #2d3436;
}

.song-picker-note {
    margin: 0;
    font-size: 13px;
    color: #636e72;
}

.song-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.song-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 10px;
    border: 2px solid #dcd6ff;
    border-radius: 10px;
    background: #f7f5ff;
    font-family: inherit;
    font-weight: 800;
    font-size: 14px;
    color: #2d3436;
    cursor: pointer;
    text-align: left;
}

.song-chip small {
    font-weight: 400;
    font-size: 11px;
    color: #636e72;
}

.song-chip.on {
    border-color: #6c5ce7;
    background: #6c5ce7;
    color: #fff;
}

.song-chip.on small {
    color: #eee;
}

.song-chip.mini {
    display: inline-block;
    padding: 1px 8px;
    margin-left: 6px;
    font-size: 12px;
}

.song-family {
    margin-top: 8px;
}

.song-family-name {
    margin-bottom: 4px;
    font-weight: 900;
    font-size: 14px;
    color: #6c5ce7;
}

.song-sound {
    margin-left: 8px;
    font-weight: 400;
    font-size: 12px;
    color: #636e72;
}

.song-picker-buttons {
    margin-top: 12px;
    text-align: center;
}

.song-picker-buttons button {
    padding: 6px 24px;
    font-family: inherit;
    font-size: 15px;
    border-radius: 999px;
    border: 2px solid #6c5ce7;
    background: #fff;
    color: #6c5ce7;
    cursor: pointer;
}


/* ---------- ステージ（マスタークラスの とおし えんそう。js/engines/keys.js の keysStage） ----------
   まわりが ゆっくり 暗く なって、がくふに スポットライト（がくふの カードの 影を 画面いっぱいに ひろげる）。
   けんばん・ボタン・ことばは 明るい まま。タマが 観客として 曲に あわせて ゆれて、おわったら 拍手 */
#keysScreen .keys-cards.score .score-card {
    transition: box-shadow 1.2s ease;
    box-shadow: 0 0 0 0 rgba(255, 236, 170, 0), 0 0 0 200vmax rgba(14, 10, 36, 0);
}

#keysScreen.on-stage .keys-cards.score .score-card {
    box-shadow: 0 0 46px 14px rgba(255, 236, 170, 0.6), 0 0 0 200vmax rgba(14, 10, 36, 0.84);
}

/* うえから さす 光の すじ */
#keysScreen .keys-spot {
    position: absolute;
    top: -6vh;
    left: 50%;
    width: min(110vw, 1300px);
    height: 100%;
    transform: translateX(-50%);
    clip-path: polygon(44% 0, 56% 0, 88% 100%, 12% 100%);
    background: linear-gradient(to bottom, rgba(255, 246, 210, 0.32), rgba(255, 246, 210, 0.04) 85%, rgba(255, 246, 210, 0));
    opacity: 0;
    transition: opacity 1.2s ease;
    pointer-events: none;
}

#keysScreen.on-stage .keys-spot {
    opacity: 1;
}

#keysScreen.on-stage .keys-message { color: #ffeaa7; }
#keysScreen.on-stage .keys-message-sub { color: #fab1a0; }
#keysScreen.on-stage .keys-hint { color: #b2bec3; }
#keysScreen.on-stage .keys-tools { opacity: 0.45; }

/* 観客の タマ：けんばんの 左うえに すわる */
#keysScreen .keys-audience {
    position: absolute;
    z-index: 4; /* つもった ドロップ（.coin.keys-pile、3）より 手前。とんでくる ごほうびの ドロップ（6）より うしろ。クリックは とおす */
    left: max(8px, calc(50vw - min(96vw, 1100px) * var(--keys-zoom) / 2 + 6px));
    bottom: calc(var(--keys-height) * var(--keys-zoom) + 6px);
    width: clamp(64px, 11vw, 140px);
    opacity: 0;
    transform: translateY(30%);
    transition: opacity 1s ease, transform 1s ease;
    pointer-events: none;
}

#keysScreen.on-stage .keys-audience {
    opacity: 1;
    transform: translateY(0);
}

.keys-audience svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

/* 目が 光って 見える ように（暗い ところでも タマと わかる） */
#keysScreen.on-stage .keys-audience svg {
    filter: drop-shadow(0 0 6px rgba(255, 236, 170, 0.55));
}

/* ゆれる：1拍で 右、つぎの 1拍で 左（--beat は 曲の 1拍の 秒） */
#keysScreen.on-stage .keys-audience.sway svg {
    animation: tama-sway calc(var(--beat, 0.6s) * 2) ease-in-out infinite;
    transform-origin: 50% 100%;
}

@keyframes tama-sway {
    0%, 100% { transform: rotate(-6deg); }
    50% { transform: rotate(6deg); }
}

/* 拍手：手を 上で パチパチ（ゆれは とまる） */
.keys-audience .tama-paw {
    transform-box: fill-box;
    transform-origin: 50% 50%;
}

.keys-audience.clap .tama-paw {
    stroke: #ffeaa7; /* 黒い 顔の 前でも 手が 見える ように */
    stroke-width: 2;
}

.keys-audience.clap .tama-paw.left { animation: tama-clap-left 0.32s ease-in-out infinite; }
.keys-audience.clap .tama-paw.right { animation: tama-clap-right 0.32s ease-in-out infinite; }

@keyframes tama-clap-left {
    0%, 100% { transform: translate(16px, -10px); }
    50% { transform: translate(38px, -16px); }
}

@keyframes tama-clap-right {
    0%, 100% { transform: translate(-16px, -10px); }
    50% { transform: translate(-38px, -16px); }
}

.keys-audience .tama-clap-mark {
    position: absolute;
    top: -10%;
    font-size: clamp(14px, 2vw, 24px);
    color: #ffeaa7;
    opacity: 0;
}

.keys-audience .tama-clap-mark.left { left: 4%; }
.keys-audience .tama-clap-mark.right { right: 4%; }

.keys-audience.clap .tama-clap-mark { animation: tama-clap-mark 0.64s ease-out infinite; }
.keys-audience.clap .tama-clap-mark.right { animation-delay: 0.32s; }

@keyframes tama-clap-mark {
    0% { opacity: 0; transform: translateY(6px) scale(0.7); }
    40% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-16px) scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
    #keysScreen.on-stage .keys-audience.sway svg,
    .keys-audience.clap .tama-paw,
    .keys-audience.clap .tama-clap-mark { animation: none; }
}


/* ---------- きょくノート（js/song-note.js）：きょくふう ずかん と のこした 曲 ---------- */
.zukan {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 6px;
}

.zukan-card {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 4px;
    border: 2px dashed #dcd6ff;
    border-radius: 10px;
    background: #f7f5ff;
    font-weight: 800;
    font-size: 13px;
    color: #b2bec3;
    text-align: center;
}

.zukan-card.on {
    border: 2px solid #fdcb6e;
    background: linear-gradient(135deg, #fff6d5, #ffeaa7);
    color: #6c5ce7;
}

.note-songs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.note-song {
    padding: 8px 12px;
    border: 2px solid #dcd6ff;
    border-radius: 12px;
    background: #fbfaff;
}

.note-song.playing {
    border-color: #00b894;
    background: #effcf8;
}

.note-song-name {
    font-weight: 900;
    font-size: 17px;
    color: #6c5ce7;
}

.note-song-info,
.note-song-words {
    font-size: 12px;
    color: #636e72;
}

.note-song-words {
    color: #e17055;
}

.note-song-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.note-song-buttons button {
    padding: 4px 14px;
    font-family: inherit;
    font-weight: 800;
    font-size: 14px;
    border-radius: 999px;
    border: 2px solid #6c5ce7;
    background: #fff;
    color: #6c5ce7;
    cursor: pointer;
}

.note-song-buttons .note-play {
    border-color: #00b894;
    background: #00b894;
    color: #fff;
}

.note-song-buttons .note-remove {
    border-color: #b2bec3;
    color: #636e72;
}

.note-song-buttons .note-remove.sure {
    border-color: #d63031;
    background: #d63031;
    color: #fff;
}
