/* 2026-10-18 UI/UX fixes: responsive shelves, focus/ARIA, short-landscape HUD. */

.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* Visible focus for text links (buttons already have a 4px ring). */
.brand:focus-visible,.song-credits a:focus-visible,#result-recommend:focus-visible{outline:4px solid var(--left);outline-offset:4px;border-radius:8px}
h1[tabindex="-1"]:focus,h2[tabindex="-1"]:focus{outline:none}

/* The header must cover content once a paper page scrolls. */
@media(min-width:801px){
  body:not([data-page="title"]):not([data-page="playing"]):not([data-page="countdown"]) header{
    background:#FFF9F3F2;backdrop-filter:blur(12px);box-shadow:0 8px 22px #FFF9F3
  }
}

/* Home: one primary action; the demo entry is a quiet secondary. */
.home-actions .demo-entry .demo-first-hint{display:none}
.home-actions .demo-entry .demo-recommended{border:0;box-shadow:none;background:#ffffffdd}
.home-actions .demo-entry button{padding-bottom:var(--space-16)}

/* Song picker: keep the CTA in reach on every desktop height; let difficulty wrap. */
@media(min-width:801px){
  body[data-page="songs"] #songs{padding-bottom:240px}
  body[data-page="songs"] .song-bottom{
    position:fixed;left:5%;right:5%;bottom:16px;z-index:6;margin:0;padding:14px 18px;
    display:grid;grid-template-columns:minmax(0,1fr) minmax(300px,.8fr);gap:14px;align-items:center;
    border:1px solid #fff;border-radius:22px;background:#FFFAF5F2;backdrop-filter:blur(14px);
    box-shadow:0 16px 40px #1c24401f
  }
  body[data-page="songs"] .song-bottom .difficulty{flex-wrap:wrap;gap:8px;justify-content:flex-start}
  body[data-page="songs"] .song-bottom .speed-row{grid-column:1/-1;margin:0 0 2px}
  body[data-page="songs"] .song-bottom .difficulty>span{flex:0 0 auto;margin-right:4px;white-space:nowrap}
  body[data-page="songs"] .song-bottom .difficulty button{min-width:0;flex:1 1 86px;padding:12px 10px;font-size:clamp(14px,1.05vw,19px)}
  body[data-page="songs"] .song-bottom #song-start{min-width:0;width:100%;min-height:64px!important;font-size:clamp(17px,1.3vw,22px);padding:10px 18px;white-space:nowrap}
  body[data-page="songs"] .song-bottom .difficulty button{min-height:48px!important;height:48px;padding:6px 10px;font-size:15px}
}
@media(max-width:800px){
  body[data-page="songs"] #songs{padding-bottom:118px}
  body[data-page="songs"] #song-start{position:fixed;left:20px;right:20px;bottom:14px;z-index:7;box-shadow:0 14px 34px #1c244033}
}
.song-credits{margin-top:14px;font-size:14px;color:#565D75}
.song-credits summary{cursor:pointer;font-weight:700;color:#73404E;min-height:32px;display:flex;align-items:center}
.song-credits p{margin-top:8px;font-size:13px;line-height:1.7}
.song-credits a{color:#73404E;text-decoration:underline;text-underline-offset:3px}

/* Settings: two columns on wide screens, opaque sticky heading, normal button scale. */
@media(min-width:1000px){
  body.handsfree .settings-grid{grid-template-columns:repeat(2,minmax(0,1fr));align-items:start}
}
@media(min-width:801px){
  body.handsfree #settings .page-heading{
    top:108px;
    background:linear-gradient(135deg,#FFFAF5,#F4F7FB 60%,#FFF0F6);
    box-shadow:0 10px 24px #F4F7FB;border:1px solid #fff
  }
  body.handsfree #settings .page-heading .primary{min-width:180px;min-height:56px;font-size:20px;padding:12px 22px}
}
@media(max-width:800px){
  .occasion-options button{padding:12px;font-size:15px}
  .occasion-options small{display:block;margin-top:4px;font-size:12px;line-height:1.4}
}

/* Results: the recommendation is a real action, not decoration. */
#result-recommend{
  display:block;margin:6px auto 0;min-height:44px;padding:6px 10px;font-size:16px;line-height:1.5;
  color:#73404E;background:transparent;box-shadow:none;text-decoration:underline;text-underline-offset:4px
}
#result-recommend[hidden]{display:none}

/* Calibration: one status source, camera boot state, earlier direct start. */
body[data-page="calibration"] #tracking{display:none!important}
#camera-starting{display:none;margin-left:8px;font-style:normal;font-size:12px;color:#D9537A}
body[data-page="calibration"] #preview:not(.has-pose) #camera-starting{display:inline-flex;align-items:center;gap:6px}
#camera-starting:before{content:'';width:10px;height:10px;border:2px solid #ffd0dd;border-top-color:#D9537A;border-radius:50%;animation:ux-spin .8s linear infinite}
@keyframes ux-spin{to{transform:rotate(360deg)}}

/* Keep the shortcut utility compact even in handsfree layouts. */
#display-quick{min-width:0!important;width:auto;min-height:40px!important;height:40px;padding:8px 14px;right:2.4%;top:17%;font-size:14px}

/* Demo badge while a simulated run is playing. */
.demo-badge{position:fixed;left:50%;bottom:2.2%;transform:translateX(-50%);z-index:12;min-height:34px;padding:6px 14px;font-size:13px;background:#FFF3D8;color:#7A4B00;border:1px solid #E8C98A;box-shadow:0 6px 18px #1c24401a}
.demo-badge[hidden]{display:none}

/* Quick-start skeleton while the camera/model boot. */
.quick-skeleton{pointer-events:none;background:#fffdf8;border-color:#e7eee9}
.quick-skeleton .quick-cover{height:120px;border-radius:18px;background:linear-gradient(90deg,#eef3ef 25%,#f9fbf9 37%,#eef3ef 63%);background-size:400% 100%;animation:ux-shimmer 1.4s ease infinite}
.quick-skeleton .quick-copy{display:flex;flex-direction:column;gap:10px}
.quick-skeleton .quick-copy h2,.quick-skeleton .quick-copy p,.quick-skeleton .quick-copy small,.quick-skeleton .quick-copy strong{display:block;height:14px;border-radius:8px;background:linear-gradient(90deg,#eef3ef 25%,#f9fbf9 37%,#eef3ef 63%);background-size:400% 100%;animation:ux-shimmer 1.4s ease infinite;margin:0}
.quick-skeleton .quick-copy h2{width:46%;height:22px}
.quick-skeleton .quick-copy p{width:92%}
.quick-skeleton .quick-copy p+p{width:70%}
.quick-skeleton .quick-copy small{width:54%}
.quick-skeleton .quick-copy strong{width:36%;height:18px;margin-top:auto}
@keyframes ux-shimmer{0%{background-position:100% 0}100%{background-position:0 0}}

/* Loading tips are decorative: don't let them be clipped on short desktops. */
@media(max-height:950px){#load-tip{display:none}}

/* Portrait phones must not show HUD under the rotate overlay. */
@media(max-width:800px) and (orientation:portrait){
  body[data-page="playing"] .session-bottom,body[data-page="playing"] #display-quick,
  body[data-page="playing"] #preview,body[data-page="playing"] #tracking,body[data-page="playing"] #next-note,body[data-page="playing"] #skeleton-window,
  body[data-page="playing"] #input-status,body[data-page="playing"] #debug,body[data-page="playing"] .demo-badge,body[data-page="playing"] .gesture-pointer{display:none!important}
}

/* Small screens: readable labels, without turning the layout into a poster. */
@media(max-width:800px){
  #results .result-grid span{font-size:13px}
  .credits{font-size:14px}
  .session-bottom>span{font-size:12px}
}

/* Short landscape (phones held sideways): a compact HUD that never overlaps. */
@media(max-height:500px) and (orientation:landscape){
  body[data-page="playing"] .hud-card{padding:8px 14px;min-width:118px;border-radius:16px}
  body[data-page="playing"] .hud-card>span{font-size:12px}
  body[data-page="playing"] .hud-card strong{font-size:28px}
  body[data-page="playing"] .time-card{left:1.5%;top:2%}
  body[data-page="playing"] .score-card{right:1.5%;top:2%}
  body[data-page="playing"] #display-quick{top:24%;right:1.5%;bottom:auto;min-height:44px!important;height:44px!important;padding:8px 12px;font-size:12px}
  body[data-page="playing"] .call{left:23%;right:23%;top:2%}
  body[data-page="playing"] #coach-speech{font-size:18px;padding:7px 14px;white-space:normal}
  body[data-page="playing"] .progress{height:8px;margin:8px auto}
  body[data-page="playing"] #section{display:none}
  body[data-page="playing"] .combo{right:auto;left:50%;top:auto;bottom:13%;transform:translateX(-50%);font-size:20px;padding:3px 12px}
  body[data-page="playing"] .combo strong{font-size:26px}
  body[data-page="playing"] #next-note{display:none}
  body[data-page="playing"] .session-bottom{bottom:1%;left:2%;gap:8px}
  body[data-page="playing"] .session-bottom>span{font-size:12px;padding:6px 9px;height:32px;line-height:18px}
  body[data-page="playing"] .session-bottom{height:44px}
  body[data-page="playing"] #pause{min-height:44px!important;height:44px!important;padding:6px 14px;font-size:13px}
  body[data-page="playing"] .lane{top:13%;bottom:10%}
  body[data-page="playing"] .lane>span{bottom:12px;font-size:16px}
  body[data-page="playing"] .target{width:56px;height:56px;border-width:4px}
  body[data-page="playing"] #preview{width:auto;height:20vh;aspect-ratio:4/3;right:1.5%;bottom:18%}
  body[data-page="playing"] .demo-badge{bottom:1.5%;min-height:40px;padding:8px 12px;font-size:12px}

  body[data-page="results"] #stage{visibility:hidden!important}
  body[data-page="results"] header{display:none!important}
  #results{overflow:auto;padding:8px 3% 12px;background:linear-gradient(135deg,#FFFAF5,#F4F7FB 60%,#FFF0F6)}
  #results .result-layout{grid-template-columns:minmax(0,.95fr) minmax(0,1.05fr);grid-template-rows:auto;gap:18px;min-height:0;height:auto;align-items:start;margin:0}
  #results .result-heading h1{font-size:24px;line-height:1.2}
  #results .result-heading>p{font-size:12px;line-height:1.5;margin:4px auto;max-width:none}
  #results #rating{width:58px;height:58px;font-size:40px;border-width:4px;margin:4px}
  #results .result-score{font-size:34px}
  #results .result-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
  #results .result-grid div{padding:7px 4px}
  #results .result-grid strong{font-size:22px}
  #results .result-grid span{font-size:12px}
  #results .achievement{margin:6px 0;padding:7px;font-size:12px}
  #results .result-details .actions{display:flex;gap:6px;margin-top:6px}
  #results .result-details button{min-height:44px!important;font-size:13px;padding:8px;flex:1;min-width:0}
  #results .result-details .primary{flex-basis:auto}
  #results #result-recommend{font-size:13px;min-height:44px;margin-top:2px}
}

/* Tap targets: brand links stay at least 44px high. */
.brand{display:inline-flex;align-items:center;min-height:44px}
@media(max-width:800px){header .brand{min-height:44px}}

@media (min-width: 1000px) {
  body.handsfree .occasion-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  body.handsfree .occasion-options button { padding: 14px; }
}

/* Wide-screen settings: use the right column and keep gesture targets sane. */
@media (min-width: 1000px) {
  #settings .settings-grid { grid-auto-flow: dense; }
  #settings .settings-grid .input-settings { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #settings .settings-grid .latency-settings { grid-column: auto; }
  body.handsfree #settings .settings-grid button[data-gesture] { min-width: 0; min-height: 56px; }
  body.handsfree .settings-grid .home-card > button[data-gesture] { width: 100%; font-size: 16px; padding: 10px 16px; }
  body.handsfree .occasion-options button { min-height: 56px; padding: 12px; }
  body.handsfree .occasion-details button { min-height: 48px; font-size: 15px; }
  body.handsfree #settings .display-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; align-content: start; }
  body.handsfree #settings .display-settings h2 { grid-column: 1 / -1; margin-bottom: 4px; }
  body.handsfree #settings .display-settings .display-slider { grid-column: 1 / -1; margin: 2px 0; }
}

@media (min-width: 1000px) {
  body.handsfree #settings .home-card:has(#quality-toggle) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; align-content: start; }
  body.handsfree #settings .home-card:has(#quality-toggle) h2,
  body.handsfree #settings .home-card:has(#quality-toggle) p,
  body.handsfree #settings .home-card:has(#quality-toggle) #enable-gestures { grid-column: 1 / -1; }
  body.handsfree #settings .home-card:has(#quality-toggle) p { margin: 4px 0; }
}

@media (min-width: 801px) and (max-height: 920px) {
  body[data-page="songs"] .song-cover { height: 27vh; }
}

@media (max-width: 800px) {
  .occasion-details { gap: 8px; }
  .occasion-details button { padding: 10px 8px; font-size: 14px; white-space: nowrap; }
}
@media (min-width: 801px) {
  body.handsfree #settings .page-heading .secondary { min-width: 0; min-height: 56px; font-size: 16px; padding: 10px 18px; }
}

@media (max-width: 800px) {
  .goal-card .text-button { min-height: 44px !important; padding: 8px 0; }
}


@media (max-width: 800px) {
  body:not([data-page="title"]):not([data-page="playing"]):not([data-page="countdown"]) header {
    background: #FFF9F3; box-shadow: 0 6px 16px #FFF9F3;
  }
  body[data-page="results"] .result-heading .eyebrow { display: none; }
}

@media (min-width: 801px) and (max-height: 850px) {
  body.handsfree #settings .page-heading { top: 84px; }
}

/* Global navigation stays available on phones, without competing with the start CTA. */
header #menu-open { pointer-events:auto; min-width:72px!important; min-height:44px!important; height:44px; padding:8px 16px; flex-shrink:0; font:650 14px system-ui; background:#fff9f1; border:1px solid #d8cfc9; box-shadow:none; }
header #mode { margin-left:auto; margin-right:14px; }header .header-note { margin-left:auto; }
.home-actions .team-entry { display:flex; align-items:center; justify-content:center; gap:8px; border-color:#86b8ad; background:#edf6ef; color:#265e55; }
.team-entry small { font:700 12px/1.5 system-ui; background:#d7eade; padding:3px 6px; border-radius:7px; white-space:nowrap; }
.global-menu { color:var(--ink); background:var(--paper); width:min(440px,calc(100vw - 24px)); max-height:calc(100dvh - 24px); overflow:auto; border:1px solid #fff; border-radius:24px; padding:24px; box-shadow:0 20px 90px #3630483b; }
.global-menu::backdrop { background:#36304788; backdrop-filter:blur(5px); }
.global-menu-heading { display:flex; justify-content:space-between; gap:12px; align-items:center; margin-bottom:14px; }.global-menu h2 { font-size:24px; }
.global-menu button,.global-menu a { min-width:0!important; min-height:48px!important; padding:10px 14px; font:650 15px/1.5 system-ui; border:1px solid #e1d9d1; border-radius:12px; background:#fffaf5; box-shadow:none; text-align:left; transition:none; }
.global-menu button:hover { transform:none; }.global-menu a:focus-visible { outline:4px solid var(--left); outline-offset:3px; }
#global-menu-actions { display:grid; gap:8px; }#global-menu-actions a { display:flex; align-items:center; justify-content:space-between; }
#global-menu-actions .menu-team { background:#e8f3eb; border-color:#9dbdb0; }#global-menu-actions small,#global-menu-actions button span { font:500 12px/1.5 system-ui; margin-left:10px; }
.global-menu p { font-size:14px; margin:14px 0; }.global-menu > button { width:100%; margin-top:8px; }
@media(min-width:801px){ .home-actions,.handsfree .home-actions { grid-template-columns:repeat(6,minmax(0,1fr)); } }
@media(max-width:800px){
  /* Bring the six actions before goal/calendar cards, so the team entry is on the first screen. */
  .home-page { gap:14px; }.home-heading { order:-3; }#move-now { order:-2; }.home-actions { order:-1; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .home-actions button,.home-actions .secondary { width:100%; min-width:0!important; min-height:54px!important; font-size:15px; padding:10px 6px; }
  .home-actions .demo-entry { width:auto; margin:0; display:flex; }.home-actions .demo-entry button { width:100%; padding:10px 6px; }
  .home-actions .primary { grid-column:1/-1; }.home-actions #settings-open { grid-column:1/-1; min-height:44px!important; }
  .home-actions .team-entry { gap:4px; }.team-entry small { padding:2px 4px; }
  .home-heading .eyebrow { margin-bottom:6px; }.home-heading p:last-child { display:none; }
  #move-now { min-height:78px!important; padding-block:12px; }#move-now strong { font-size:22px; }
}
/* Full-screen pages retain the same global menu, with a separate band below the score. */
body:is([data-page="playing"],[data-page="countdown"],[data-page="layout"]) > header { display:block!important; height:0; padding:0; background:transparent!important; box-shadow:none; backdrop-filter:none; z-index:70; }
body:is([data-page="playing"],[data-page="countdown"],[data-page="layout"]) > header > :not(#menu-open) { display:none; }
body:is([data-page="playing"],[data-page="countdown"],[data-page="layout"]) header #menu-open { position:fixed; right:2.4%; top:calc(3.2vh + 112px); }
body[data-page="playing"] #display-quick { top:calc(3.2vh + 164px); }
@media(max-height:500px) and (orientation:landscape){
  body[data-page="results"] > header { display:block!important; height:0; padding:0; background:transparent; }
  body[data-page="results"] > header > :not(#menu-open) { display:none; }
  body[data-page="results"] header #menu-open { position:fixed; right:12px; bottom:8px; top:auto; }
  body:is([data-page="playing"],[data-page="countdown"],[data-page="layout"]) header #menu-open { top:calc(2vh + 76px); right:1.5%; }
  body[data-page="playing"] #display-quick { top:calc(2vh + 128px); }
}

/* Short landscape phones: home becomes an action-first scrollable screen. */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 1000px) {
  body[data-page="title"] #stage { visibility: hidden; }
  body[data-page="title"] header { height: 60px; padding: 0 16px; background: #FFF9F3; box-shadow: 0 4px 12px #FFF9F3; }
  body[data-page="title"] .brand { font-size: 28px; }
  body[data-page="title"] .header-note, body[data-page="title"] #mode { display: none; }
  #title.home-page {
    display: flex; flex-direction: column; gap: 10px; height: 100dvh; min-height: 0;
    padding: 70px 16px 18px; overflow: auto;
    background: linear-gradient(145deg, #FFF6EE, #F4F7FB 65%, #FFF0F6);
  }
  #title .home-heading { position: relative; inset: auto; width: 100%; text-align: left; }
  #title .home-heading h1 { font-size: 30px; }
  #title .home-heading .eyebrow { font-size: 14px; margin-bottom: 4px; }
  #title .home-heading p:last-child { font-size: 14px; margin-top: 4px; }
  #title #move-now, #title .coach-caption { display: none; }
  #title .goal-card, #title .calendar-card { position: relative; inset: auto; width: 100%; }
  #title .goal-card { order: 4; display: grid; grid-template-columns: 86px 1fr; gap: 8px 14px; padding: 16px; text-align: left; }
  #title .goal-card .card-icon { display: none; }
  #title .goal-card h2 { grid-column: 1 / -1; font-size: 18px; margin: 0; }
  #title #goal-ring { grid-row: 2 / 5; width: 86px; height: 86px; margin: 0; }
  #title #goal-ring strong { width: 68px; height: 68px; font-size: 24px; }
  #title #goal-detail { font-size: 20px; align-self: end; }
  #title .goal-card p { font-size: 13px; margin: 0; }
  #title .goal-card button { min-height: 40px; padding: 0; text-align: left; font-size: 14px; }
  #title .calendar-card { order: 5; padding: 16px; }
  #title .calendar-card p { font-size: 14px; }
  #title .home-actions {
    position: relative; inset: auto; width: 100%; order: 1;
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  }
  #title .home-actions .primary { grid-column: 1 / -1; width: 100%; min-height: 56px; font-size: 20px; }
  #title .home-actions .secondary { width: 100%; min-height: 56px; font-size: 16px; }
  #title .home-actions .demo-entry { grid-column: auto; width: 100%; margin: 0; }
  #title .home-actions .demo-entry button { width: 100%; min-height: 56px; font-size: 16px; }
  #title .home-actions #team-open { background: #e5f5eb; border-color: #8ac9a8; color: #1d5b46; font-weight: 750; }
  #title .home-actions #settings-open { display: none; }
  body[data-page="title"] #privacy { display: none; }
}
