.music-game { margin:1rem 0; padding:clamp(.85rem,3vw,1.45rem); background:#faf9ff; color:#201e37; border:1px solid #c6bedc; border-radius:16px; }
.game-controls,.game-keys,.game-beats { display:flex; gap:.4rem; margin-block:.8rem; }
.music-game button { color:inherit; cursor:pointer; font:inherit; font-weight:750; min-height:46px; border:1px solid #d0c7b7; border-bottom:3px solid #bead91; border-radius:9px; background:#fffdf7; }
.game-controls button { padding:.4rem .85rem; }
.game-controls button:disabled { opacity:.55; cursor:default; }
.game-keys { width:min(100%,15rem); padding:.3rem; background:#262341; border-radius:12px; }
.game-keys button,.game-beats button { flex:1; min-width:0; min-height:60px; }
.game-beats { max-width:22rem; }
.game-beats small { display:block; }
.game-beats [aria-pressed=true] { background:#d8e7cb; }
.game-beats [aria-pressed=false] { border-style:dashed; }
.music-game .sounding,.game-keys button:active { background:#ffda72; box-shadow:inset 0 0 0 2px #805316; }
.game-staff { position:relative; height:158px; touch-action:none; cursor:ns-resize; user-select:none; border-radius:12px; background:repeating-linear-gradient(to bottom,#827684 0 1px,transparent 1px 20px) center 32px / calc(100% - 28px) 81px no-repeat,#fffbec; }
.staff-note { position:absolute; left:49%; top:calc(132px - var(--rise,0px)); transform:translateY(-50%) rotate(-14deg); width:23px; height:16px; border-radius:55%; background:#282355; }
.staff-note::after { content:''; position:absolute; right:0; bottom:45%; width:2px; height:26px; background:inherit; transform:rotate(14deg); transform-origin:bottom; }
.game-staff:not([data-raised])::before { content:''; position:absolute; top:132px; left:calc(49% - 7px); width:37px; height:1px; background:#726983; }
.game-staff::after { content:attr(data-sign); position:absolute; top:calc(132px - var(--rise,0px)); left:calc(49% - 20px); transform:translateY(-50%); font:1.6rem Georgia,serif; }
.game-staff[data-down] .staff-note::after { right:auto; left:0; top:45%; bottom:auto; transform-origin:top; }
.staff-caption,.staff-tools { display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; margin:.75rem 0 .4rem; }
.staff-caption { justify-content:space-between; color:#403855; font-weight:750; }
.staff-tools button { min-width:46px; }
.staff-tools label { display:flex; align-items:center; gap:.4rem; flex-wrap:wrap; font-size:.9rem; font-weight:700; }
.staff-tools select { color:inherit; font:inherit; min-height:44px; border-radius:8px; background:#fffdf7; }
.game-controls { flex-wrap:wrap; }
.music-game h3 { margin-bottom:.5rem; }
.music-game [data-prompt] { margin:1rem 0 .5rem; font-weight:750; }
.music-game .staff-check { padding:.35rem .85rem; }
.rhythm-dots { display:flex; gap:.5rem; margin:1rem 0 .6rem; }
.rhythm-dots i { flex:1; height:.48rem; border-radius:1rem; background:#ded8e9; }
.rhythm-dots .lit { background:#7056ab; }
.music-game .rhythm-pad { width:100%; min-height:78px; color:#fff; background:#345242; border-color:#243d30; font-size:1.15rem; touch-action:manipulation; }
.music-game .rhythm-pad.listening,.music-game .rhythm-pad:active { color:#282339; background:#ffda72; }
.music-game .rhythm-pad:disabled:not(.listening) { background:#ded8e9; color:#514c61; border-color:#bcb4ca; }
.composer { margin-top:1rem; border-top:1px solid #d8d0df; }
.composer summary { padding:.7rem 0; min-height:44px; font-weight:700; cursor:pointer; }
.music-game [data-feedback]:empty { display:none; }
.music-game .game-feedback { min-height:1.5em; margin:.6rem 0 0; }
.memory-level { display:flex; flex-wrap:wrap; gap:.4rem .7rem; align-items:center; margin-top:.8rem; }
.memory-level select { min-height:44px; font:inherit; color:inherit; background:#fffdf7; border:1px solid #bcb4a4; border-radius:8px; padding:.25rem .5rem; }
.memory-keys { display:grid; grid-template-columns:repeat(auto-fit,minmax(44px,1fr)); gap:4px; padding:5px; border-radius:12px; background:#262341; max-width:28rem; }
.memory-keys button { height:64px; }
.music-game[data-game="memory"] .game-controls { flex-wrap:wrap; }
.music-game[data-game="memory"] h3 { margin-bottom:.55rem; }

.memory-keys {grid-template-columns:repeat(3,minmax(0,1fr));gap:3px;padding:4px;}
.memory-keys:has(button:nth-child(7):not([hidden])) {grid-template-columns:repeat(7,minmax(0,1fr));}
.memory-keys button {position:relative;padding:.45rem .12rem;min-width:0;background:linear-gradient(#fffef9,#f3e8ce);box-shadow:inset 0 -4px #d9c6a6;align-content:end;}
.memory-keys button:is(.sounding,:active) {color:#1d2c21;background:#cde5bc;box-shadow:inset 0 -2px #8bab82;transform:translateY(2px);}
.memory-keys button:not([hidden]):is(:nth-child(1),:nth-child(2),:nth-child(4),:nth-child(5),:nth-child(6))::after {content:'';position:absolute;z-index:1;top:-1px;left:87%;width:30%;height:42%;border-radius:0 0 3px 3px;background:#26302b;pointer-events:none;}

.music-game {background:linear-gradient(148deg,#fffcf5,#f3edf5);border-color:#d8c9b8;}
.music-game h3 {margin:0 0 .48rem;line-height:1.18;}
.music-game :is(.game-controls,[data-tap]) {margin-block:.78rem;}
.music-game .game-controls {flex-wrap:wrap;}
.music-game :is([data-demo],[data-hear],[data-echo-start],[data-staff-check]) {border-color:#3d6250;background:#365745;color:#fff;box-shadow:inset 0 -2px #274335;}
.music-game button:focus-visible {outline:2px solid #5446a4;outline-offset:2px;}
.music-game button:active:not(:disabled) {transform:translateY(1px);}
.music-game .game-feedback:empty {display:none;}
.music-game .game-feedback:not(:empty) {position:relative;margin:.85rem 0 0;padding:.68rem .82rem;border-radius:9px;background:#ece6f2;color:#352f40;line-height:1.5;overflow-wrap:break-word;}
.music-game .game-feedback[data-kind="success"] {border-inline-start:4px solid #4e795c;background:#e0efdc;color:#233e30;}
.music-game .game-feedback[data-kind="hint"] {border-inline-start:4px solid #ad7533;background:#fff0cf;color:#473621;}
.music-game[data-game] .game-feedback[data-kind="success"]::before {content:'✓ ' / '';font-weight:bold;}
.music-game[data-game] .game-feedback[data-kind="success"]::after {content:'♪ ♫ ♪' / '';position:absolute;right:.8rem;top:-.9rem;color:#684983;font:bold 1.15rem Georgia;pointer-events:none;opacity:0;}
@media(prefers-reduced-motion:no-preference) {
  .music-game[data-game] .game-feedback[data-kind="success"]::after {animation:response-notes 1.3s ease-out both;}
  @keyframes response-notes {0%{transform:translateY(14px) scale(.45);opacity:0;}28%,68%{opacity:1;}100%{transform:translateY(-27px) scale(1.18);opacity:0;}}
}
.music-game .staff-clef {position:absolute;left:5%;top:29px;font:3.4rem/1 "Segoe UI Symbol",serif;color:#53476d;pointer-events:none;}
.music-game [data-prompt]:not([hidden]) {margin:.6rem 0;padding:.6rem .72rem;border-radius:8px;background:#ebe5f5;font-weight:700;}
.music-game .rhythm-pad:not(:disabled) {background:#f2deaa;color:#392b23;}
@media(max-width:450px) {.article-practice:has(.music-game) {padding:clamp(12px,4vw,18px);}.music-game {padding:.72rem;}}
