/* Scale | Note drop-downs (phone and desktop). The row of key buttons is no longer shown. */
#prRoom .p-keybtns{display:none}
.p-sels{display:grid;grid-template-columns:minmax(240px,1fr) 150px;gap:12px;max-width:520px;margin:2px 0 10px}
.p-sel-d{min-width:170px}.p-sel-d:first-child{min-width:240px}
#prRoom .e-ctl .p-sel-d select{width:100%;min-height:40px;padding:8px 34px 8px 14px;appearance:none;-webkit-appearance:none;background:#0c1426 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center}
.p-sel{display:grid;gap:4px;min-width:0}
.p-sel span{font:700 11px system-ui,sans-serif;letter-spacing:.14em;text-transform:uppercase;color:#9fb0d8}
.p-sel select{width:100%;min-height:44px;padding:8px 36px 8px 14px;border-radius:14px;border:1.5px solid #3a4a74;background:#0c1426 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center;color:#fff;font:600 16px system-ui,sans-serif;-webkit-appearance:none;appearance:none;text-overflow:ellipsis}
.p-sel select optgroup{color:#111;font-style:normal}
.p-sel select option{color:#111}
/* Phone layout. Loaded last so it wins. Desktop is untouched: everything is inside phone media queries. */
@media (max-width:700px){
  /* Scale practice: two drop-downs (Scale | Note) instead of twelve key buttons */
  html body #prRoom .p-keybtns{display:none}
  html body #prRoom .p-sels{display:grid;grid-template-columns:1fr 1fr;gap:10px;width:100%}
  /* Class: four compact rows instead of tall cards */
  html body .cl-four{grid-template-columns:1fr;gap:10px}
  html body .cl-box{min-height:0;height:108px;flex-direction:row;border-radius:18px}
  html body .cl-box .ph{flex:0 0 36%;width:36%;height:100%;min-height:0;-webkit-mask-image:none;mask-image:none}
  html body .cl-box .tx{flex:1;min-width:0;margin:0;padding:10px 34px 10px 12px;display:grid;grid-template-columns:44px 1fr;column-gap:12px;row-gap:2px;align-content:center;align-items:center}
  html body .cl-box .ic{grid-row:1/3;width:44px;height:44px;border-radius:13px}
  html body .cl-box .ic svg{width:26px;height:26px}
  html body .cl-box b{font-size:19px;line-height:1.15}
  html body .cl-box span{font-size:13px;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
  html body .cl-box .go{display:none}
  html body .cl-box:after{content:"›";position:absolute;right:12px;top:50%;transform:translateY(-52%);font:700 26px var(--body);color:rgba(255,255,255,.7)}

  /* Nothing may push the page wider than the screen */
  html,body{max-width:100%;overflow-x:hidden}
  html body .chart{max-width:100%;overflow-x:auto}

  /* Menu bar: back, name, room chip and one Menu button (all the menus live inside it) */
  html body .menubar{overflow:visible;gap:6px;height:44px;padding:0 8px}
  html body .menubar .menu-btn:not(.mmore):not(#psChip):not(#psBackBtn){display:none}
  html body .menubar #psChip{min-width:0;max-width:56vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  html body .menubar .menu-btn.mmore{display:block;margin-left:auto;min-height:0;height:34px;line-height:1;padding:0 14px;border:1.5px solid var(--line);border-radius:999px;font-weight:700}
  html body .menubar .menu-status{display:none}
  html body .menu-pop{left:8px!important;right:8px!important;top:48px!important;min-width:0;max-width:none;max-height:calc(100dvh - 64px);overflow:auto;border-radius:16px;padding:6px 6px calc(10px + env(safe-area-inset-bottom))}
  html body .menu-pop .menu-item{min-height:46px;font-size:16px;padding:8px 12px}
  html body .menu-pop .mi-key{display:none}

  /* Install banner: one slim line */
  #psInstBar{left:8px;right:8px;bottom:calc(8px + env(safe-area-inset-bottom));padding:7px 10px;gap:8px;border-radius:14px}
  #psInstBar img{width:30px;height:30px}
  #psInstBar span{font-size:12px;line-height:1.25}
  #psInstBar .go{padding:8px 11px;font-size:12.5px;white-space:nowrap}

  /* Ear training and Practice: segmented mode switch fits the screen */
  html body #earRoom .e-seg:not(.sm){display:grid;grid-template-columns:1fr 1fr;border-radius:22px;width:100%}
  html body #earRoom .e-seg:not(.sm) button{padding:12px 8px;font-size:14px}
  html body #prRoom .e-seg:not(.sm){display:grid;grid-auto-flow:column;grid-auto-columns:1fr;width:100%}
  html body #prRoom .e-seg:not(.sm) button{padding:12px 6px;font-size:14px}

  /* Bigger touch targets */
  html body #earRoom button,html body #prRoom button,html body #prRoom select,html body #earRoom select{min-height:44px}
  html body #earRoom,html body #prRoom{padding:14px 14px calc(24px + env(safe-area-inset-bottom));gap:14px;top:36px}
  html body #earRoom .e-big{font-size:clamp(38px,13vw,64px)}

  /* Studio: Play stays in reach */
  html body .transport{position:sticky;bottom:0;z-index:5;padding:10px 0 calc(10px + env(safe-area-inset-bottom));background:var(--stage,#0f1729);box-shadow:0 -10px 14px -8px rgba(0,0,0,.45)}

  /* Challenge cards a touch tighter */
  html body .pcard{padding:18px}
}

/* Phone held sideways: keyboard rooms use the short, wide screen */
@media (max-height:520px) and (orientation:landscape) and (pointer:coarse){
  html body #earRoom,html body #prRoom{padding:8px 16px 10px;gap:8px;top:36px}
  html body #earRoom .e-top h1,html body #prRoom .e-top h1{font-size:20px}
  html body #earRoom .e-big,html body #prRoom .e-big{font-size:clamp(28px,7vh,44px);min-height:0}
  html body #earRoom .e-lbl,html body #earRoom .e-sub,html body #prRoom .e-lbl{margin:0}
  html body #earRoom button,html body #prRoom button{min-height:38px}
  html body .menubar{position:static}
  html body #psInstBar{display:none}
  html body #earRoom .e-kb,html body #prRoom .e-kb{position:sticky;bottom:0;z-index:4;margin-top:auto;background:var(--stage,#070b14)}
  html body.dest-plus .tx canvas,body[data-dest="plus"] .tx canvas{height:calc(100dvh - 120px)!important;min-height:200px!important}
}

/* Upright phone on a keyboard screen: the whole app is turned sideways (see rotate.js) */
@media (max-width:700px) and (orientation:portrait) and (pointer:coarse){
  html.ps-rot{overflow:hidden;height:100%}
  html.ps-rot body{position:fixed;top:0;left:0;margin:0;max-width:none;max-height:none;width:100vh;width:100dvh;height:100vw;height:100dvw;overflow:auto;transform-origin:0 0;transform:translateX(100vw) rotate(90deg)}
  html.ps-rot body #earRoom,html.ps-rot body #prRoom{padding:8px 16px 10px;gap:8px;top:36px}
  html.ps-rot body #earRoom .e-top h1,html.ps-rot body #prRoom .e-top h1{font-size:20px}
  html.ps-rot body #earRoom .e-big,html.ps-rot body #prRoom .e-big{font-size:clamp(28px,12vw,44px);min-height:0}
  html.ps-rot body #earRoom .e-seg:not(.sm){display:inline-flex;width:auto;border-radius:999px}
  html.ps-rot body #earRoom .e-seg:not(.sm) button{padding:10px 18px}
  html.ps-rot body #prRoom .e-seg:not(.sm){display:inline-flex;width:auto}
  html.ps-rot body #earRoom button,html.ps-rot body #prRoom button{min-height:38px}
  html.ps-rot body #earRoom .e-kb,html.ps-rot body #prRoom .e-kb{position:sticky;bottom:0;z-index:4;margin-top:auto;background:var(--stage,#070b14)}
  html.ps-rot body .menubar{position:sticky}
  html.ps-rot body #psInstBar{display:none}
  html.ps-rot body #txCard{left:8px!important;right:8px!important;top:44px!important;bottom:8px!important;width:auto!important;max-width:none!important;height:auto!important;max-height:none!important}
  html.ps-rot body .tx canvas{height:calc(100vw - 130px)!important;min-height:180px!important}
}

/* Studio on a sideways phone: compact three-column top, hide the extras so the chord, chart and keys fit */
@media (max-width:700px) and (orientation:portrait) and (pointer:coarse){
  html.ps-rot body .stage{padding:10px 14px;gap:8px;border-radius:14px}
  html.ps-rot body .stage-top{grid-template-columns:auto minmax(0,1fr) auto;gap:6px 18px;align-items:center}
  html.ps-rot body .stage-top .top-mid{grid-column:auto;grid-row:auto;max-width:none}
  html.ps-rot body .stage-top .now{font-size:clamp(34px,13vh,56px);line-height:1}
  html.ps-rot body .stage-top .next{font-size:15px;margin:0}
  html.ps-rot body .stage-top .lbl{margin:0;font-size:11px}
  html.ps-rot body .stage-sync,html.ps-rot body .stage-top .pos,html.ps-rot body .stage-top .bpmbig,html.ps-rot body .tip{display:none}
  html.ps-rot body .stage-tempo{flex-wrap:nowrap;gap:8px}
  html.ps-rot body .meter{justify-items:end;text-align:right}
  html.ps-rot body .beats{display:none}
  html.ps-rot body .transport{position:static;gap:8px;flex-wrap:nowrap;overflow-x:auto;padding:0;background:transparent}
  html.ps-rot body .transport .tog,html.ps-rot body .transport .play{min-height:38px;padding-top:6px;padding-bottom:6px;white-space:nowrap;flex:0 0 auto}
  html.ps-rot body .transport .stopbtn{flex:0 0 auto;width:42px;height:42px}
  html.ps-rot body .room-back,html.ps-rot body .stage-top .lbl,html.ps-rot body .stage-kbd .fing-line:empty{display:none}
  html.ps-rot body .stage-top .now{font-size:clamp(30px,10vh,44px)!important}
  html.ps-rot body .stage-top{align-items:start}
  html.ps-rot body #kbdWrap{max-height:84px;overflow:hidden}
  html.ps-rot body #kbdWrap svg,html.ps-rot body #kbdWrap canvas{height:84px!important;width:100%}
  html.ps-rot body .stage-kbd{gap:4px}
  html.ps-rot body .stage-tempo .tapbig{padding:4px 14px;min-height:36px}
  html.ps-rot body .stage-kbd{padding:6px 10px}
  html.ps-rot body .stage-kbd .kbd-bar{margin:0;gap:10px}
  html.ps-rot body .stage-kbd .kbd-bar .seg button{padding:4px 10px;min-height:30px}
  html.ps-rot body .chart{margin:0}
  html.ps-rot body .corner-tools{transform:scale(.8);transform-origin:right top}
}
@media (max-width:700px) and (orientation:portrait) and (pointer:coarse){ html.ps-rot body .tx .txempty{bottom:40%!important} }
@media (max-width:700px) and (orientation:portrait) and (pointer:coarse){ html.ps-rot body .e-kb #prKb svg,html.ps-rot body .e-kb #earKb svg,html.ps-rot body .e-kb svg.kbd{height:78px!important;width:100%} html.ps-rot body .e-kb .e-lbl{margin:0} html.ps-rot body .e-kb{padding-top:2px;padding-bottom:2px} }
@media (max-width:700px) and (orientation:portrait) and (pointer:coarse){ html.ps-rot body #prRoom .p-sels{grid-template-columns:2fr 1fr} }

.p-tip{margin:10px 0;padding:12px 14px;border:1.5px solid #3a4a74;border-radius:14px;background:#0c1426;color:#dfe7ff;font-size:14px;line-height:1.45;display:grid;gap:10px;justify-items:start}.p-tip p{margin:0}.p-tip[hidden]{display:none}

.p-octs{min-width:170px}.p-octs select{min-height:40px}
.p-learn{margin:10px 0;padding:12px 14px;border:2px solid #ffd43b;border-radius:14px;background:#17213d;color:#fff;font-size:15px;line-height:1.45;display:grid;gap:8px;justify-items:start}.p-learn p{margin:0}.p-learn b{color:#ffd43b;letter-spacing:.04em}.p-learn[hidden]{display:none}

/* Scale/Chord room on phones: controls and the whole keyboard first; the note chips (with fingering) sit below the keyboard */
@media (max-width:700px){
  html body #prRoom .e-kb{order:10;position:static;margin-top:0}
  html body #prRoom .p-learn{order:11}
  html body #prRoom .p-tip{order:11}
  html body #prRoom #prMsg{order:12}
  html body #prRoom .p-chips{order:13}
  html body #prRoom #prPick{order:14}
}
@media (max-width:700px) and (orientation:portrait) and (pointer:coarse){
  html.ps-rot body #prRoom{gap:6px;padding:6px 14px 14px}
  html.ps-rot body #prRoom .e-top{gap:8px;flex-wrap:nowrap}
  html.ps-rot body #prRoom .e-now{grid-template-columns:minmax(0,1fr) auto;gap:4px 16px;align-items:center}
  html.ps-rot body #prRoom #prLbl,html.ps-rot body #prRoom #prSub{display:none}
  html.ps-rot body #prRoom .e-big{font-size:clamp(24px,9vh,34px)!important}
  html.ps-rot body #prRoom .p-sels{gap:8px}
  html.ps-rot body #prRoom .p-sel span{display:none}
  html.ps-rot body #prRoom .p-sel select{min-height:38px}
  html.ps-rot body #prRoom .e-ctl{gap:6px 10px}
  html.ps-rot body #prRoom .e-kb .e-lbl{display:none}
  html.ps-rot body #prRoom .e-kb #prKb svg{height:72px!important}
  html.ps-rot body #prRoom .p-tab{height:16px;margin:0 0 2px} html.ps-rot body #prRoom .p-tab span{font-size:9px;border-radius:4px}
}
@media (max-width:700px) and (orientation:portrait) and (pointer:coarse){ html.ps-rot body #prRoom[data-kind=scales] .e-now{grid-template-columns:1fr} html.ps-rot body #prRoom[data-kind=scales] .e-now>div:first-child{display:none} }

#prRoom .p-chips:has(.p-orow){display:grid;gap:10px}
#prRoom .p-orow{display:flex;gap:8px;flex-wrap:nowrap}
#prRoom .p-orow .p-chip{flex:1 1 0;min-width:0;padding:10px 4px 8px}

/* Scale room on a phone: row 1 Scale, Note, Octaves, Loop, Tempo, Ask Dr. Onye; row 2 the toggles and Play scale; keyboard below */
@media (max-width:700px){
  html body #prRoom .p-r1,html body #prRoom .p-r2{display:flex;flex-wrap:wrap;gap:6px 8px;align-items:center;width:100%}
  html body #prRoom .p-r1 .p-sel{flex:1 1 0;min-width:0}
  html body #prRoom .p-r1 .p-sel select{min-height:38px;padding:6px 30px 6px 10px;font-size:14px}
  html body #prRoom .p-r1 .p-rng{flex:0 0 auto;gap:6px;font-size:13px}
  html body #prRoom .p-r1 .p-rng input[type=range]{width:90px}
  html body #prRoom .p-r1 .e-btn{flex:0 0 auto;padding:6px 12px;min-height:38px;font-size:13px}
  html body #prRoom .p-r2 .e-seg{display:inline-flex;width:auto;flex:0 0 auto}
  html body #prRoom .p-r2 .e-seg button{padding:6px 9px;font-size:12px;min-height:36px}
  html body #prRoom .p-r2 #prPlay{margin-left:auto;padding:6px 14px;min-height:38px;font-size:14px}
  html body #prRoom .p-r2 [hidden]{display:none}
  html body #prRoom .e-seg button:disabled{opacity:.35}
}
/* Menu sheet that stands in for the phone's own drop-down while a page is turned sideways, so the list turns with the page */
.ps-menu{position:fixed;inset:0;z-index:99999;display:flex;align-items:center;justify-content:center;background:rgba(5,8,18,.55)}
.ps-menu .ps-sheet{width:min(88%,520px);max-height:88%;display:flex;flex-direction:column;background:#161f38;color:#eef2ff;border:1.5px solid #3a4a74;border-radius:16px;overflow:hidden;font:16px system-ui,sans-serif}
.ps-menu .ps-t{padding:10px 16px;font:700 11px system-ui,sans-serif;letter-spacing:.14em;text-transform:uppercase;color:#9fb0d8;border-bottom:1px solid #2a3858}
.ps-menu .ps-l{overflow-y:auto;-webkit-overflow-scrolling:touch}
.ps-menu .ps-g{padding:10px 16px 4px;font:600 12px system-ui,sans-serif;color:#9fb0d8}
.ps-menu button{display:flex;gap:10px;width:100%;text-align:left;padding:12px 16px;min-height:44px;border:0;border-radius:0;background:none;color:inherit;font:inherit;cursor:pointer}
.ps-menu button[aria-selected=true]{color:#f7d35c;font-weight:700}
.ps-menu button[aria-selected=true]::before{content:"✓"}
.ps-menu button[aria-selected=false]::before{content:"";width:1em}
.ps-menu{padding-top:52px;box-sizing:border-box}
.ps-menu .ps-sheet{max-height:100%}
@media (max-width:700px){
  html body #prRoom .p-r2{gap:4px 6px;flex-wrap:nowrap}
  html body #prRoom .p-r2 .e-seg button{padding:5px 6px;font-size:11px;min-height:34px;white-space:nowrap}
  html body #prRoom .p-r2 #prPlay{padding:6px 10px;font-size:13px;white-space:nowrap}
}
@media (max-width:700px){
  html body #prRoom[data-kind=scales] .e-now>div,html body #prRoom[data-kind=scales] .e-ctl{min-width:0;max-width:100%;width:100%}
  html body #prRoom .p-r1,html body #prRoom .p-r2{max-width:100%}
  html body #prRoom .p-r2 .e-seg{padding:2px}
  html body #prRoom .p-r2 .e-seg button{padding:5px 5px;font-size:10.5px}
  html body #prRoom .p-r1{flex-wrap:nowrap}
  html body #prRoom .p-r1 .p-rng input[type=range]{width:64px}
  html body #prRoom .p-r1 .p-rng{font-size:11px;letter-spacing:.06em}
}
@media (max-width:700px){ html body #prRoom .p-r2{flex-wrap:wrap} }
@media (max-width:700px){
  html body #prRoom .p-r3{display:flex;flex-wrap:nowrap;gap:8px;width:100%;max-width:100%}
  html body #prRoom .p-r3 .e-btn{flex:1 1 0;min-width:0;margin:0;padding:6px 8px;min-height:40px;font-size:13px;white-space:nowrap;justify-content:center}
}

/* Scale room: the note boxes and the line of note letters are not shown (desktop and phone) */
#prRoom[data-kind=scales] #prChips,#prRoom[data-kind=scales] #prSub{display:none !important}
@media (min-width:701px){ #prRoom[data-kind=scales] .e-now{align-items:start;gap:6px 32px} #prRoom[data-kind=scales] .e-now .e-lbl{margin-top:0} #prRoom[data-kind=scales] .e-big{min-height:0;line-height:.95} }
@media (min-width:701px) and (max-height:820px){ #prRoom[data-kind=scales] .e-now{grid-template-columns:minmax(0,.6fr) minmax(0,1.6fr);gap:4px 20px} #prRoom[data-kind=scales]{gap:8px} #prRoom[data-kind=scales] .e-big{font-size:clamp(40px,9vh,72px)} #prRoom[data-kind=scales] .e-ctl{gap:6px 8px} #prRoom[data-kind=scales] #prMsg{font-size:16px;min-height:0;margin:0} #prRoom[data-kind=scales] .e-kb{padding:8px 12px 6px} #prRoom[data-kind=scales] .p-kbw{margin-top:0} #prRoom[data-kind=scales] .e-kb .e-lbl{margin-bottom:2px} #prRoom[data-kind=scales]{padding-bottom:4px} }
