/* V3.4 mobile display patch. Original game CSS and audio/game logic stay intact. */
@font-face {
  font-family: "NoteQuest Music";
  src: url("../fonts/NotoMusic-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: block;
}

/* Use an explicitly shipped music font on narrow/touch screens. */
@media (max-width: 1100px), (pointer: coarse) {
  #staff text[font-family*="Noto Music"] { font-family: "NoteQuest Music", serif; }
  /* Noto's F-clef dots are 220 font units apart. Match the 24-unit staff
     spacing and centre the dots around F3 (SVG y=103). */
  #staff text[font-family*="Noto Music"][font-size="104"] {
    font-size: 109.0909px;
    transform: translateY(22.3091px);
  }
}

/* Short landscape viewports: keep the staff and all 25 keys together.
   The atlas and statistics remain reachable below the playing area. */
@media (orientation: landscape) and (max-width: 1100px) and (max-height: 600px) {
  .sheetwrap { --compact-staff-height: clamp(72px, 24vh, 142px); }
  @supports (height: 1svh) {
    .sheetwrap { --compact-staff-height: clamp(72px, 24svh, 142px); }
  }
  .page { padding: 8px max(10px, env(safe-area-inset-right)) 20px max(10px, env(safe-area-inset-left)); }
  .layout { display: flex; flex-direction: column; gap: 10px; }
  .layout > .play { width: 100%; min-width: 0; display: flex; flex-direction: column; }
  .layout > .side { order: 2; width: 100%; }
  .play > .melody-options { order: 0; }
  .play > .scorecard { order: 1; }
  .play > .piano-panel { order: 2; }
  .play > .stats { order: 3; margin-top: 8px; }
  .scorecard { padding: 6px 9px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 3px 10px; }
  .scoretop { grid-column: 1; align-items: center; }
  .scoretop h2 { font-size: 14px; margin: 0; }
  .scoretop p, .scoretop .eyebrow, .journey-labels { display: none; }
  .small-tag { font-size: 10px; padding: 4px 7px; }
  .timing-box { grid-column: 2; grid-row: 1; padding: 3px 6px; margin: 0; }
  .timing-row { flex-wrap: nowrap; gap: 6px; }
  .timing-row strong { font-size: 10px; }
  .speed-actions { flex-wrap: nowrap; gap: 4px; }
  .speed-actions .small-btn { font-size: 10px; padding: 5px 7px; }
  .timer-rail { height: 3px; margin-top: 3px; }
  .journey { grid-column: 1 / -1; margin: 1px 3px; }
  .journey .step { height: 12px; max-width: 36px; font-size: 10px; border-width: 1px; border-radius: 4px; }
  .journey::before { top: 6px; border-top-width: 1px; }
  .sheetwrap { grid-column: 1 / -1; min-height: 0; margin-top: 1px; padding: 0; }
  .sheet-corner { display: none; }
  .staff-svg { min-height: 0; height: var(--compact-staff-height); max-width: none; }
  /* Extend only the five staff lines across the panel. The SVG glyphs,
     note positions and ledger lines retain their original uniform scale. */
  .sheetwrap::before {
    content: "";
    position: absolute;
    pointer-events: none;
    left: 12px;
    right: 12px;
    top: calc(var(--compact-staff-height) * 79 / 252);
    height: calc(var(--compact-staff-height) * 96 / 252 + .7px);
    background: repeating-linear-gradient(to bottom,
      #72847a 0, #72847a .7px,
      transparent .7px, transparent calc(var(--compact-staff-height) * 24 / 252));
  }
  #staff > g > line[stroke="#72847a"] { opacity: 0; }
  .sheet-caption { font-size: 10px; margin: 0 0 2px; }
  .piano-panel { margin-top: 5px; padding: 5px 9px 9px; }
  .piano-title { margin-bottom: 4px; flex-wrap: nowrap; }
  .piano-title h3 { font-size: 13px; }
  .piano-title p { display: none; }
  .toggle { font-size: 10px; }
  .piano-frame { padding: 6px; border-radius: 10px; }
  .piano-inner { height: clamp(84px, 30vh, 150px); height: clamp(84px, 30svh, 150px); }
  .piano-foot { display: none; }
  .key { padding-bottom: 6px; }
  .key-name, .key.black .key-name { font-size: 10px; writing-mode: horizontal-tb; }
  .key.black { padding-bottom: 5px; }
  .feedback { margin-top: 8px; }
  .overlay { overflow-y: auto; justify-content: flex-start; }
  .overlay .big-winner { display: none; }
  .overlay h3 { font-size: 17px; }
  .overlay p { margin: 0; }
  .overlay .actionbar { margin-top: 4px; }
}
