/* Phone and tablet layout: readable score, prominent controls, compact scenery. */
@media(max-width:900px){
 .stage{width:100%;min-height:0;height:auto;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:108px 260px 52px auto 100px;gap:8px;padding:0 10px 12px;background-position:center;background-size:cover}
 .stage header{grid-row:1;width:100%;height:108px}
 .stage .brand{top:8px;left:0;font-size:18px;padding:5px 9px}
 .stage .back{top:8px;left:auto;right:0;font-size:12px;min-height:34px;padding:8px 12px}
 .stage .stars{display:none}
 .stage .sign{top:51px;left:50%;width:100%;max-width:100%;padding:7px;border-width:3px;transform:translateX(-50%)}
 .stage h1{font-size:clamp(21px,5.4vw,30px);letter-spacing:-.6px}
 .stage .sign p{font-size:12px;padding:3px 0;left:7%;width:86%}
 .stage .score-panel{grid-row:2;grid-column:1;width:100%;height:260px;padding:10px 8px 8px;border-radius:24px;border-width:3px;background:#fffefbf7}
 .stage .score-heading{padding:0 4px;font-size:12px}
 .stage .score-panel #score{flex:1 1 0;min-height:0;width:100%;height:100%;overflow:hidden}
 .stage .score-message{margin-top:4px;min-height:34px;gap:4px}
 .stage .score-panel .cue{font-size:14px;line-height:1.2;padding:5px 12px}
 #voice-live{font-size:12px}
 .stage .pulse-panel,.stage .pulse-panel:has(.beats b:nth-child(5)){grid-row:3;grid-column:1;display:flex;align-items:center;justify-content:center;gap:12px;position:relative;inset:auto;transform:none;width:100%;max-width:none;min-width:0;height:52px;margin:0;padding:6px 10px;border-radius:22px;font-size:13px;white-space:nowrap}
 .stage .beats,.stage .pulse-panel:has(.beats b:nth-child(5)) .beats{display:flex;gap:6px;margin:0;flex-wrap:nowrap}
 .stage .beats b,.stage .pulse-panel:has(.beats b:nth-child(5)) .beats b{width:32px;height:32px;flex:0 0 32px;font-size:21px}
 .stage .pulse-panel:has(.beats b:nth-child(5))>span{display:none}
 .stage .pulse-panel:has(.beats b:nth-child(7)) .beats{gap:3px;flex-wrap:wrap}
 .stage .pulse-panel:has(.beats b:nth-child(7)){height:auto;min-height:52px}
 .stage .pulse-panel:has(.beats b:nth-child(7)) .beats b{width:24px;height:24px;flex-basis:24px;font-size:16px}
 .stage .controls{grid-row:4;grid-column:1;position:relative;inset:auto;display:grid;grid-template-columns:1fr 1fr;grid-template-rows:48px 42px auto;gap:8px;width:100%;height:auto;padding:10px;border-radius:24px;background:#fffdf8f5;box-shadow:0 4px 12px #3e276022}
 .stage .play-controls{display:contents}
 .stage .controls #listen{grid-row:1;grid-column:1;align-self:stretch}
 .stage .controls #play{grid-row:1;grid-column:2}
 .stage .controls button,.stage .controls .primary{font-size:19px;min-height:48px;width:100%;padding:8px;border-radius:18px}
 .stage .mic-toggle{grid-row:2;grid-column:1/-1;position:static;inset:auto;transform:none;min-height:42px;width:100%;font-size:15px;padding:8px;border-radius:14px;box-shadow:none;background:#f2eaff;white-space:nowrap}
 .stage .tempo{grid-row:3;grid-column:1;width:100%;font-size:16px;padding:7px 10px;border-radius:14px;gap:3px}
 .stage .tempo input{min-height:24px;width:100%;max-width:none}
 .stage .level{grid-row:3;grid-column:2;max-width:none;width:100%;min-width:0;padding:7px 10px;border-radius:14px;font-size:12px}
 .stage .level select{width:100%;max-width:100%;font-size:14px;min-height:32px;padding:4px 0}
 .stage .landscape{grid-row:5;grid-column:1;position:relative;inset:auto;height:100px;width:100%;background:url('landscape-v11.webp') center 86% / 100% auto no-repeat;border-radius:18px}
 .stage #train{left:8%;width:84%;bottom:25px}
 .stage #train:after{font-size:48px;bottom:4px}
 .stage .journey{left:3%;width:94%;bottom:0;font-size:11px;padding:4px 8px}
 .options{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:14px 12px;font-size:13px}
 .options label{display:flex;align-items:center;gap:6px;min-height:40px}
 .options input{width:18px;height:18px;flex-shrink:0}
 .options button{min-height:44px;padding:8px;font-size:13px}
 .voice-controls{font-size:13px;padding:12px;margin:10px 12px}
}
@media(max-width:1000px) and (max-height:550px) and (orientation:landscape){
 .stage{width:100%;height:auto;min-height:100svh;display:grid;grid-template-columns:minmax(0,1fr) 238px;grid-template-rows:50px minmax(236px,1fr) 56px;gap:8px;padding:0 max(10px,env(safe-area-inset-right)) 8px max(10px,env(safe-area-inset-left));background-size:cover}
 .stage header{grid-row:1;grid-column:1/-1;position:relative;inset:auto;width:100%;height:50px;margin:0}
 .stage .brand{top:8px;left:0;font-size:18px;padding:5px 8px}
 .stage .back{left:auto;right:0;top:8px;min-height:34px;font-size:12px;padding:8px 12px}
 .stage .stars{display:none}
 .stage .sign{top:5px;left:50%;width:46%;max-width:46%;padding:7px;border-width:3px;transform:translateX(-50%)}
 .stage h1{font-size:clamp(16px,2.5vw,24px)}
 .stage .sign p{display:none}
 .stage .score-panel{grid-row:2;grid-column:1;position:relative;inset:auto;width:100%;height:100%;min-height:236px;padding:10px;border-radius:22px;border-width:3px}
 .stage .score-heading{font-size:12px;padding:0 4px}
 .stage .score-panel #score{flex:1 1 0;min-height:0;height:100%;width:100%}
 .stage .score-message{min-height:32px;margin-top:4px}
 .stage .score-panel .cue{font-size:14px;padding:4px 10px}
 .stage .controls{grid-row:2;grid-column:2;position:relative;inset:auto;display:grid;grid-template-columns:1fr 1fr;grid-template-rows:48px 42px 52px 52px;align-content:center;gap:8px;width:100%;height:100%;padding:10px;border-radius:22px;background:#fffdf8f5}
 .stage .play-controls{display:contents}
 .stage .controls #listen{grid-row:1;grid-column:1;align-self:stretch}
 .stage .controls #play{grid-row:1;grid-column:2}
 .stage .controls button,.stage .controls .primary{font-size:17px;min-height:48px;width:100%;padding:6px}
 .stage .mic-toggle{grid-row:2;grid-column:1/-1;position:static;inset:auto;transform:none;width:100%;min-height:42px;font-size:14px;padding:6px;border-radius:14px;white-space:nowrap}
 .stage .tempo{grid-row:3;grid-column:1/-1;display:grid;grid-template-columns:18px 1fr;min-width:0;width:100%;padding:4px 10px;font-size:15px}
 .stage .tempo input{grid-column:1/-1;min-height:20px;width:100%;max-width:none}
 .stage .level{grid-row:4;grid-column:1/-1;width:100%;max-width:none;min-width:0;padding:4px 10px;font-size:11px}
 .stage .level select{min-height:30px;font-size:14px;padding:2px;width:100%;max-width:100%}
 .stage .pulse-panel,.stage .pulse-panel:has(.beats b:nth-child(5)){grid-row:3;grid-column:1;position:relative;inset:auto;transform:none;display:flex;align-items:center;justify-content:center;gap:12px;width:100%;height:56px;max-width:none;min-width:0;margin:0;padding:5px 10px;font-size:13px}
 .stage .beats{display:flex;gap:6px;margin:0}
 .stage .beats b,.stage .pulse-panel:has(.beats b:nth-child(5)) .beats b{width:32px;height:32px;flex:0 0 32px;font-size:21px}
 .stage .landscape{grid-row:3;grid-column:2;position:relative;inset:auto;width:100%;height:56px;background:none}
 .stage #train{left:8%;width:84%;bottom:20px}
 .stage #train:after{font-size:38px;bottom:4px}
 .stage .journey{left:0;width:100%;bottom:0;font-size:9px;padding:3px}
}
@media(max-width:650px) and (max-height:550px) and (orientation:landscape){.stage{grid-template-columns:minmax(0,1fr) 200px}.stage .brand{font-size:14px}.stage .back{font-size:10px;padding:8px}.stage .sign{width:43%;max-width:43%}.stage h1{font-size:14px}.stage .pulse-panel>span{display:none}}

/* An uncluttered journey card gives the moving train its own visual space. */
.stage .landscape{background:#fff9eefa;border:3px solid #e7c98a;box-shadow:0 5px 15px #3d2c4522;border-radius:22px;overflow:hidden}
.stage .trip-title{position:absolute;top:8px;left:14px;right:14px;font-size:15px;font-weight:800;color:#51346f;display:flex;justify-content:space-between;gap:10px}
.stage .trip-title span{font-size:12px;font-weight:normal}
.stage #train{background:repeating-linear-gradient(90deg,#9b7962 0 8px,#f5dbaf 8px 19px);height:10px;border:2px solid #6b596a;box-shadow:none}
.stage #train:after{filter:drop-shadow(0 3px 2px #77542440);font-size:64px;bottom:5px}
.stage .journey{background:none;font-size:12px;padding:4px 8px}
@media(min-width:1001px), (min-width:901px) and (min-height:551px){
 .stage .landscape{left:41%;top:67%;width:55%;height:17%}
 .stage #train{left:7%;width:86%;bottom:27px}
 .stage #train:after{font-size:64px}
 .stage .journey{left:3%;width:94%;bottom:1px}
}
@media(max-width:900px){
 .stage .landscape{background:#fff9eefa;height:112px}
 .stage{grid-template-rows:108px 260px 52px auto 112px}
 .stage .trip-title{font-size:13px;top:6px;left:10px;right:10px}
 .stage .trip-title span{font-size:11px}
 .stage #train:after{font-size:58px}
 .stage .journey{font-size:11px}
}
@media(max-width:1000px) and (max-height:550px) and (orientation:landscape){
 .stage{grid-template-rows:50px minmax(260px,1fr) 74px}
 .stage .score-panel{min-height:260px}
 .stage .landscape{height:74px;background:#fff9eefa;border-width:2px}
 .stage .trip-title{display:none}
 .stage #train{bottom:20px}
 .stage #train:after{font-size:46px;bottom:2px}
 .stage .journey{font-size:9px;padding:2px}
 .stage .pulse-panel,.stage .pulse-panel:has(.beats b:nth-child(5)){height:74px}
}

/* Version 11: larger score and a single moving train on a quiet backdrop. */
.stage #train:after{left:var(--journey,42px)}
@media(min-width:1001px), (min-width:901px) and (min-height:551px){
 .stage .score-panel{height:42%}
 .stage .pulse-panel,.stage .pulse-panel:has(.beats b:nth-child(5)){left:18%;top:65%;width:27%;padding:1% 1.2%}
 .stage .landscape{left:35%;top:63%;width:61%;height:21%}
 .stage #train:after{font-size:80px}
 .stage .trip-title{font-size:17px}
}
@media(max-width:900px){
 .stage{grid-template-rows:108px 310px 52px auto 128px}
 .stage .score-panel{height:310px}
 .stage .landscape{height:128px}
 .stage #train:after{font-size:70px}
}
@media(max-width:1000px) and (max-height:550px) and (orientation:landscape){
 .stage{grid-template-rows:50px minmax(300px,1fr) 84px}
 .stage .score-panel{height:100%;min-height:300px}
 .stage .landscape,.stage .pulse-panel,.stage .pulse-panel:has(.beats b:nth-child(5)){height:84px}
 .stage #train:after{font-size:56px}
}
@media(min-width:1001px), (min-width:901px) and (min-height:551px){
 .stage .controls{bottom:1%;height:13%}
 .stage .play-controls{display:flex;flex-direction:column;gap:4px}
 .stage .play-controls #play{min-height:44px;padding:5px 12px;font-size:clamp(20px,2cqw,30px)}
 .stage .mic-toggle{position:static;inset:auto;transform:none;width:100%;min-height:32px;padding:4px 8px;font-size:12px;box-shadow:none}
}
/* Version 12: the illustration's railway is the actual train route. */
.stage .landscape{background:none;border:0;box-shadow:none;border-radius:0;overflow:visible;pointer-events:none}
.stage .trip-title,.stage .journey>span{display:none}
.stage .journey{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip-path:inset(50%)}
.stage #train{left:4%;width:89%;top:var(--rail-y,80.5%);bottom:auto;height:0;border:0;border-radius:0;background:none;box-shadow:none;z-index:4}
.stage #train:after{bottom:-.07em;filter:drop-shadow(0 3px 2px #52382650)}
@media(min-width:1001px), (min-width:901px) and (min-height:551px){
 .stage .landscape{left:0;top:0;width:100%;height:100%;z-index:3}
 .stage .pulse-panel,.stage .pulse-panel:has(.beats b:nth-child(5)){top:61%;left:50%;width:max-content;max-width:80%;min-height:54px;height:auto;padding:6px 16px;display:flex;align-items:center;gap:16px;font-size:14px}
 .stage .beats{display:flex;margin:0;gap:8px}
 .stage .beats b,.stage .pulse-panel:has(.beats b:nth-child(5)) .beats b{width:38px;height:38px;font-size:24px}
}
@media(max-width:900px){
 .stage{background:linear-gradient(#b9e0ff,#e9f5e0)}
 .stage .landscape{background:url('landscape-v11.webp') center bottom / cover no-repeat;width:calc(100% + 20px);margin-left:-10px;height:128px}
 .stage #train{left:4%;width:89%;bottom:auto;top:var(--rail-y,80.5%)}
}
@media(max-width:1000px) and (max-height:550px) and (orientation:landscape){
 .stage{background:linear-gradient(#b9e0ff,#e9f5e0)}
 .stage .landscape{background:url('landscape-v11.webp') center bottom / cover no-repeat;width:100%;height:84px;margin:0}
 .stage #train{left:4%;width:89%;bottom:auto;top:var(--rail-y,80.5%)}
 .stage #train:after{font-size:48px}
}

/* Version 13: double-size locomotive with an animal carriage, on the same rails. */
.stage #train:after{content:none}
.stage #train .train-convoy{--engine-size:160px;position:absolute;display:flex;align-items:flex-end;gap:0;left:var(--journey,0px);bottom:0;transform:translateX(-50%);width:max-content;filter:drop-shadow(0 3px 2px #52382650)}
.train-convoy .locomotive{display:block;font-size:var(--engine-size);line-height:1;transform:scaleX(-1);margin-bottom:-.07em}
.animal-wagon{position:relative;width:calc(var(--engine-size)*.8);height:calc(var(--engine-size)*.36);margin-bottom:calc(var(--engine-size)*.03);border:4px solid #efbd59;border-radius:8px;background:linear-gradient(#36bfd1,#078394);box-shadow:inset 0 0 0 2px #086676}
.animal-wagon .passengers{position:absolute;bottom:calc(100% - 5px);left:0;width:100%;text-align:center;white-space:nowrap;font-size:calc(var(--engine-size)*.3);letter-spacing:-.08em}
.wagon-music{display:block;text-align:center;color:#fff2ad;font-size:calc(var(--engine-size)*.27);line-height:1}
.animal-wagon i{position:absolute;bottom:calc(var(--engine-size)*-.08);width:calc(var(--engine-size)*.16);height:calc(var(--engine-size)*.16);border:5px solid #f0b841;border-radius:50%;background:#66432f;left:8%}
.animal-wagon i:last-child{left:auto;right:8%}
@media(min-width:1001px), (min-width:901px) and (min-height:551px){
 .stage .pulse-panel,.stage .pulse-panel:has(.beats b:nth-child(5)){top:11%;left:85%;max-width:27%;padding:5px 9px;min-height:38px;gap:6px;font-size:11px}
 .stage .beats{gap:4px}
 .stage .beats b,.stage .pulse-panel:has(.beats b:nth-child(5)) .beats b{width:25px;height:25px;font-size:17px}
}
@media(max-width:900px){
 .stage #train .train-convoy{--engine-size:140px}
 .stage{grid-template-rows:108px 310px 52px auto 200px}
 .stage .landscape{height:200px}
}
@media(max-width:1000px) and (max-height:550px) and (orientation:landscape){
 .stage #train .train-convoy{--engine-size:96px}
 .stage{grid-template-rows:50px minmax(300px,1fr) 140px}
 .stage .landscape{height:140px}
}

/* Spoken feedback is independent from the optional score labels and grading. */
.heard-popup{position:absolute;left:18px;right:auto;top:38px;z-index:8;min-width:120px;max-width:210px;padding:8px 18px;border:3px solid #fff;border-radius:24px;background:linear-gradient(145deg,#c8ff94,#69d780);color:#124b29;box-shadow:0 5px 20px #165d3540;text-align:center;pointer-events:none}
.heard-popup[hidden]{display:none}
.heard-popup span{display:block;font-size:13px;font-weight:700}
.heard-popup strong{display:block;font-size:clamp(38px,4vw,64px);line-height:1.08;overflow-wrap:anywhere}
.heard-popup.pop{animation:heard-pop .18s ease-out}
@keyframes heard-pop{from{transform:scale(.75);opacity:.3}to{transform:scale(1);opacity:1}}
@media(max-width:900px){.heard-popup{left:12px;right:auto;top:32px;min-width:90px;max-width:160px;padding:6px 12px}.heard-popup strong{font-size:42px}}
@media(prefers-reduced-motion:reduce){.heard-popup.pop{animation:none}}

/* The completed microphone result stays visible until the next exercise. */
.voice-result{position:absolute;z-index:9;left:50%;top:48%;transform:translate(-50%,-50%);width:min(420px,90%);padding:16px 20px;border:3px solid #fff;border-radius:28px;background:linear-gradient(145deg,#e6ffc7,#a8edb4);box-shadow:0 6px 24px #225a3640;color:#164b2b;text-align:center;pointer-events:none}
.voice-result[hidden]{display:none}
.voice-result>span,.voice-result>b,.voice-result>strong{display:block}
.voice-result>span{font-size:20px;font-weight:bold}
.voice-result>strong{font-size:clamp(42px,5vw,72px);line-height:1.15;margin:5px 0}
.voice-result>b{font-size:21px}
.voice-result p{font-size:14px;margin:9px 0}
.voice-result small{font-size:11px}
@media(max-width:900px){.voice-result{padding:12px}.voice-result>span{font-size:17px}.voice-result>b{font-size:18px}}

/* Grouped speech results show all new notes immediately, without a playback queue. */
.heard-popup{max-width:min(480px,85%)}
.heard-popup strong{overflow-wrap:normal;white-space:normal}
@media(max-width:900px){.heard-popup{max-width:85%}.heard-popup strong{font-size:36px}}

.voice-transcript{padding:9px 12px;background:#f0ebff;border-radius:12px;overflow-wrap:anywhere;color:#35216c;font-size:15px}

/* Learning mode: hide suspended microphone controls, reclaim their grid row. */
.stage .mic-toggle[hidden],.voice-controls[hidden]{display:none!important}
@media(max-width:900px){
 .stage .controls{grid-template-rows:48px auto}
 .stage .tempo,.stage .level{grid-row:2}
}
@media(max-width:1000px) and (max-height:550px) and (orientation:landscape){
 .stage .controls{grid-template-rows:48px 52px 52px}
 .stage .tempo{grid-row:2}
 .stage .level{grid-row:3}
}

/* Keep the loaded file visible beside the measure count throughout playback. */
.stage .score-heading{gap:10px;align-items:center}
#score-source{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#score-source.imported-source{color:#175f35;background:#def5df;border:1px solid #9ed7ac;border-radius:10px;padding:4px 8px}
.stage .score-heading #measure{flex-shrink:0}

/* Small translucent note name just below the reading line. */
.stage .heard-popup{position:absolute;right:auto;bottom:auto;display:flex;align-items:center;justify-content:center;transform:translateX(-50%);width:max-content;min-width:0;max-width:90%;padding:0;border:0;border-radius:0;background:none;box-shadow:none;color:rgba(26,142,65,.72);pointer-events:none}
.stage .heard-popup[hidden]{display:none}
.stage .heard-popup strong{font-size:clamp(22px,2.2vw,32px);line-height:1;font-weight:900;text-shadow:0 1px 6px #ffffffa0}
.stage .heard-popup.pop{animation:learning-note-in .16s ease-out}
@keyframes learning-note-in{from{opacity:0}to{opacity:1}}
@media(max-width:900px){.stage .heard-popup strong{font-size:24px}}
@media(prefers-reduced-motion:reduce){.stage .heard-popup.pop{animation:none}}

/* Ten interchangeable scenes share the same rail height and proportions. */
.stage{background-image:var(--scene,url('landscape-v11.webp'))}
.theme-picker{display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:9px 13px;background:#fff9ed;border:2px solid #daceef;border-radius:20px;font-weight:bold;max-width:100%;min-width:0}
.theme-picker select{border:0;background:transparent;max-width:220px;min-width:0;font:inherit;padding:5px;color:#35216c}
.train-convoy img.locomotive{width:calc(var(--engine-size)*1.2);height:var(--engine-size);font-size:initial;transform:none;margin-bottom:0;object-fit:contain;display:block}
@media(max-width:900px),(max-width:1000px) and (max-height:550px){
 .stage{background-image:linear-gradient(#b9e0ff,#e9f5e0)}
 .stage .landscape{background-image:var(--scene,url('landscape-v11.webp'))}
 .theme-picker{grid-column:1/-1;width:100%;font-size:14px}
 .theme-picker select{flex:1;max-width:none}
}

/* Panoramic trial: fixed train, endlessly joined landscape, separate arrival station. */
.panorama-window{display:none}
.stage.panoramic{background-image:linear-gradient(#86c9ff,#eaf5c6)}
.stage.panoramic .landscape{background-image:none;z-index:1}
.stage.panoramic header,.stage.panoramic .controls,.stage.panoramic .pulse-panel{z-index:5}
.stage.panoramic .panorama-window{display:block;position:absolute;inset:0;overflow:hidden;pointer-events:none}
.panorama-strip{position:absolute;left:0;bottom:0;display:flex;height:var(--pano-height);width:max-content;transform:translateX(var(--pano-offset,0px));will-change:transform}
.panorama-strip i{display:block;flex:0 0 var(--pano-tile);width:var(--pano-tile);height:100%;background:var(--panorama-scene,url('themes/panorama-v26.webp')) center/100% 100% no-repeat}
.panorama-strip i:nth-child(even){transform:scaleX(-1)}
.panorama-station{position:absolute;width:clamp(180px,16vw,260px);height:auto;left:0;top:var(--rail-y);transform:translate(var(--station-x,200vw),-96%);max-width:none;pointer-events:none}
@media(max-width:900px){.panorama-station{width:180px}}
@media(max-width:1000px) and (max-height:550px){.panorama-station{width:150px}}

/* Clear the smoke above the engine, keeping the wheels on the rails. */
@media(min-width:1001px), (min-width:901px) and (min-height:551px){
 .stage.panoramic .score-panel{height:39%}
}
.distance-sign{display:none}
.stage.panoramic .distance-sign{display:flex;position:absolute;right:5%;top:62%;z-index:5;flex-direction:column;gap:4px;text-align:center;padding:10px 18px;background:linear-gradient(#fff1c9,#f8dca2);border:3px solid #b7834e;border-radius:15px;box-shadow:0 3px 7px #65442c33;color:#533769;pointer-events:none}
.distance-sign span{font-size:13px;font-weight:bold}
.distance-sign strong{font-size:23px;font-variant-numeric:tabular-nums;white-space:nowrap}
@media(max-width:900px),(max-width:1000px) and (max-height:550px){
 .stage.panoramic .distance-sign{top:8px;right:8px;padding:6px 9px;border-width:2px;border-radius:12px;gap:2px}
 .distance-sign span{font-size:10px}
 .distance-sign strong{font-size:17px}
}

.panorama-toggle{display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:12px 15px;border:2px solid #daceef;border-radius:20px;background:#fff9ed;font-weight:bold;cursor:pointer}
.panorama-toggle input{width:19px;height:19px;accent-color:#8441c6}
.panorama-toggle:has(input:checked){background:#e5f5e3;border-color:#99c9a0}
.stage.panoramic[data-theme="nuit"] .panorama-station,.stage.panoramic[data-theme="espace"] .panorama-station{filter:brightness(.85)}
@media(max-width:900px){.panorama-toggle{grid-column:1/-1}}

/* Fine alignment of the train wheels with the illustrated rails. */
.stage #train .train-convoy{bottom:5px}
/* Learning controls and end-of-journey actions. */
.score-tools{position:relative;z-index:14;display:flex;align-items:center;gap:9px;flex-shrink:0}
.stage #fullscreen{padding:5px 9px;border-radius:12px;box-shadow:none;font-size:12px;white-space:nowrap;background:#f4eeff}
.aid-picker{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:center;font-weight:bold}
.aid-picker select{font:inherit;background:#fffdf8;border:2px solid #daceef;border-radius:12px;padding:8px;max-width:100%}
.practice-settings{max-width:920px;margin:14px auto;padding:15px 20px;background:#fffdf4;border:2px solid #daceef;border-radius:22px;color:#35216c}
.practice-settings summary{cursor:pointer;font-weight:bold;font-size:18px}
.practice-settings p{line-height:1.5}
.practice-settings fieldset{display:flex;flex-wrap:wrap;gap:10px 16px;border:1px solid #daceef;border-radius:14px;padding:12px;margin:14px 0}
.practice-settings legend{font-weight:bold;padding:0 7px}
.practice-settings label{display:inline-flex;align-items:center;gap:6px;min-height:32px}
.practice-settings input{width:18px;height:18px;accent-color:#8441c6}
.practice-extras{display:flex;gap:18px;flex-wrap:wrap}
#practice-error{color:#a72b48;font-weight:bold}
.journey-end{position:absolute;z-index:12;inset:12% 6%;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:10px;text-align:center;border:3px solid #c6dfad;border-radius:26px;padding:18px;background:#f6ffeef5;box-shadow:0 6px 25px #315a3c30;color:#285836}
.journey-end[hidden]{display:none}
.journey-end h2{font-size:clamp(20px,2.6vw,32px);margin:0}
.journey-end p{margin:0;max-width:440px;font-size:15px}
.journey-end>div{display:flex;gap:10px;flex-wrap:wrap;justify-content:center}
.journey-end button{font-size:16px;padding:10px 15px}
.journey-end small{font-size:12px}
body.immersive{position:fixed;inset:0;z-index:9999;overflow:auto;padding:0;background:#edf4df}
body.immersive>.help,body.immersive>footer{display:none}
:fullscreen{overflow:auto;background:#edf4df}
@media(max-width:900px){
 .stage #fullscreen{font-size:10px;padding:5px}
 .score-tools{gap:5px}
 .aid-picker{grid-column:1/-1;font-size:14px}
 .practice-settings{margin:14px 12px;padding:14px;font-size:14px}
 .practice-settings summary{font-size:16px}
 .journey-end{inset:8px;padding:12px;gap:8px;border-radius:18px}
 .journey-end h2{font-size:21px}
 .journey-end p{font-size:13px}
 .journey-end button{font-size:14px;padding:8px 10px}
}

.practice-shortcut{display:flex;justify-content:center;margin:16px 12px 0}
#open-practice{min-height:44px;padding:10px 22px;font-size:17px;font-weight:bold;border:2px solid #b999ed;background:#eee4ff;color:#35216c;border-radius:24px;cursor:pointer}
#practice-settings{scroll-margin-top:16px}

.practice-shortcut{flex-wrap:wrap;align-items:center;gap:12px}
.journey-length{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px;color:#35216c;font-weight:bold}
.journey-length select{font:inherit;min-height:44px;max-width:100%;padding:8px 12px;border:2px solid #b999ed;border-radius:18px;background:#fffdf4;color:#35216c}
.journey-length-help{max-width:920px;margin:8px auto 0;padding:0 14px;text-align:center;color:#51465c;font-size:14px}

.score-library{max-width:920px;margin:18px auto;padding:18px 20px;border:2px solid #daceef;border-radius:22px;background:#fffdf4;color:#35216c}
.score-library h2{font-size:21px;margin:0 0 8px}
.score-library p{line-height:1.5;margin:8px 0}
.library-actions{display:flex;align-items:center;flex-wrap:wrap;gap:12px}
.library-actions select{font:inherit;min-height:44px;max-width:100%;padding:8px;border:2px solid #daceef;border-radius:12px;background:white;color:#35216c}
.library-actions button{min-height:44px;padding:10px 16px}
.library-actions a{color:#63329d;min-height:44px;display:inline-flex;align-items:center}
@media(max-width:600px){.score-library{margin:16px 12px;padding:14px}.library-actions select{width:100%}}

/* Mobile layout: one game area, readable musical preview and optional settings. */
.game-settings{border:0}
.game-settings>summary{display:none}
@media(max-width:900px),(max-width:1000px) and (max-height:550px){
 .stage{aspect-ratio:auto;min-height:0;height:auto;grid-template-columns:minmax(0,1fr);grid-template-rows:100px 240px 44px 150px auto;gap:6px;padding:0 max(8px,env(safe-area-inset-right)) 10px max(8px,env(safe-area-inset-left))}
 .stage header{position:relative;inset:auto;grid-row:1;grid-column:1;height:100px}
 .stage .brand{font-size:17px;padding:6px 8px}
 .stage .back{font-size:11px;padding:8px;min-height:34px}
 .stage .sign{top:48px;width:100%;max-width:100%;padding:5px}
 .stage h1{font-size:clamp(18px,5vw,25px);letter-spacing:-.5px}
 .stage .sign p{font-size:11px;padding:2px 0}
 .stage .score-panel,.stage.panoramic .score-panel{position:relative;inset:auto;grid-row:2;grid-column:1;width:100%;height:240px;min-height:0;padding:8px 6px;border-radius:22px}
 .stage .score-heading{padding:0;gap:5px;font-size:11px;min-height:32px}
 .stage #fullscreen{font-size:11px;min-height:32px;padding:5px 7px}
 .stage .score-panel #score{min-height:0;flex:1;width:100%;height:100%}
 .stage .score-message{min-height:30px;margin:0}
 .stage .score-panel .cue{font-size:12px;padding:4px 8px;max-width:96%;white-space:normal}
 .stage .pulse-panel,.stage .pulse-panel:has(.beats b:nth-child(5)){grid-row:3;grid-column:1;inset:auto;transform:none;height:44px;min-height:44px;width:100%;max-width:100%;padding:4px 8px;margin:0;gap:9px;font-size:12px;border-width:2px}
 .stage .beats,.stage .pulse-panel:has(.beats b:nth-child(5)) .beats{display:flex;gap:5px;margin:0;flex-wrap:nowrap}
 .stage .beats b,.stage .pulse-panel:has(.beats b:nth-child(5)) .beats b{width:28px;height:28px;flex:0 0 28px;font-size:18px}
 .stage .pulse-panel:has(.beats b:nth-child(7)) .beats{gap:2px}
 .stage .pulse-panel:has(.beats b:nth-child(7)) .beats b{width:21px;height:26px;flex-basis:21px;font-size:15px}
 .stage .landscape{position:relative;inset:auto;grid-row:4;grid-column:1;height:150px;width:100%;margin:0;border-radius:16px;background-size:cover;background-position:center bottom;overflow:hidden}
 .stage .controls{position:relative;inset:auto;grid-row:5;grid-column:1;grid-template-columns:minmax(0,1fr) minmax(0,1fr);grid-template-rows:46px 48px auto;gap:6px;height:auto;width:100%;padding:8px;border-radius:20px}
 .stage .controls #listen,.stage .controls #play{grid-row:1;min-width:0;min-height:44px;font-size:18px;padding:6px}
 .stage .tempo{grid-row:2;grid-column:1/-1;display:flex;align-items:center;gap:8px;width:100%;min-width:0;padding:5px 10px;font-size:16px;white-space:nowrap}
 .stage .tempo input{flex:1;min-width:0;max-width:none;width:auto;min-height:30px}
 .stage .level{grid-row:3;grid-column:1/-1;display:flex;align-items:center;gap:10px;width:100%;max-width:none;padding:5px 10px;font-size:12px}
 .stage .level select{flex:1;min-width:0;min-height:34px;font-size:16px;padding:3px 0}
 .stage.panoramic .distance-sign{top:6px;right:6px;padding:4px 7px;border-width:1px}
 .distance-sign span{font-size:9px}.distance-sign strong{font-size:14px}
 .game-settings{margin:10px 8px;border:2px solid #daceef;border-radius:18px;background:#fffdf4;min-width:0}
 .game-settings>summary{display:list-item;cursor:pointer;margin:0 14px;padding:15px 0;font-size:16px;font-weight:bold;min-height:48px}
 .game-settings .practice-shortcut{margin:8px;gap:8px}
 .game-settings .journey-length{font-size:14px;width:100%}
 .game-settings .journey-length select,.game-settings select{font-size:16px}
 .game-settings .options{grid-template-columns:minmax(0,1fr);gap:8px;margin:14px 10px}
 .game-settings .options label{justify-content:flex-start;min-height:44px;grid-column:1}
 .game-settings .options button{font-size:15px}
 .game-settings .options input{width:21px;height:21px}
 .game-settings .theme-picker select{width:0;min-width:0}
 .game-settings .aid-picker{justify-content:space-between}
 .game-settings .score-library,.game-settings .practice-settings{margin:12px 8px;padding:12px}
 .help{font-size:12px;margin:10px auto}
 .journey-end{inset:40px 5px 5px;padding:7px;gap:5px}
 .journey-end h2{font-size:18px}.journey-end p{font-size:12px}.journey-end button{padding:8px;font-size:12px;min-height:40px}
}
@media(max-width:1000px) and (max-height:550px) and (orientation:landscape){
 .stage{height:max(360px,100svh);grid-template-columns:minmax(0,1fr) 210px;grid-template-rows:36px minmax(190px,1fr) 102px;gap:5px;padding-bottom:5px}
 .stage header{grid-column:1/-1;grid-row:1;height:36px}
 .stage .brand{top:3px;font-size:15px;padding:4px 8px}
 .stage .back{top:2px;font-size:10px;padding:6px 8px;min-height:30px}
 .stage .sign{top:2px;width:44%;max-width:44%;padding:4px;border-width:2px}
 .stage h1{font-size:17px}.stage .sign p{display:none}
 .stage .score-panel,.stage.panoramic .score-panel{grid-row:2;grid-column:1;height:100%;min-height:0;padding:5px 8px}
 .stage .controls{grid-row:2;grid-column:2;grid-template-rows:44px 52px auto;align-content:center;height:100%;padding:6px;gap:5px}
 .stage .controls #listen,.stage .controls #play{font-size:15px}
 .stage .tempo{flex-wrap:wrap;justify-content:center;gap:2px;font-size:14px;padding:3px 6px}
 .stage .tempo input{flex-basis:100%;height:20px;min-height:24px}
 .stage .level{display:block;padding:3px 6px;font-size:11px}
 .stage .level select{width:100%;font-size:16px;min-height:36px}
 .stage .landscape{grid-row:3;grid-column:1;height:102px}
 .stage .pulse-panel,.stage .pulse-panel:has(.beats b:nth-child(5)){grid-row:3;grid-column:2;height:102px;flex-direction:column;justify-content:center;gap:8px;border-radius:20px;font-size:12px}
 .stage .pulse-panel:has(.beats b:nth-child(7)) .beats{flex-wrap:wrap}
 .stage .journey-end h2{font-size:16px}.stage .journey-end p{display:none}.stage .journey-end button{font-size:12px;padding:6px}
}

@media(max-width:900px),(max-width:1000px) and (max-height:550px){
 .stage .landscape{background-position:center var(--scene-offset,0px)}
}
@media(max-width:900px) and (orientation:portrait){
 .stage{grid-template-rows:100px clamp(190px,29svh,240px) 44px clamp(115px,18svh,150px) auto}
 .stage .score-panel,.stage.panoramic .score-panel{height:100%}
 .stage .landscape{height:100%}
}
