/* Handy als App (Stufe 5). Unter 700 px: schmale Kopfzeile mit Seitenname, Reiter fest unten, kein
   Titelband, Brett randlos; direkt unter dem Brett das, was gerade zählt. Klapphandy aufgeklappt:
   ohne Titelband, damit Brett und Leiste höher beginnen. */

.phone-nav, .sheet-wrap, header.top .where { display: none; }

@media (max-width: 699px) {
  :root { --phone-nav: calc(58px + env(safe-area-inset-bottom)); }
  html, body { overscroll-behavior-y: none; }
  header.top nav.bar, header.top .util, .band, footer.foot { display: none; }
  header.top .bar:first-child { height: 46px; border-bottom: 0; padding-top: env(safe-area-inset-top); box-sizing: content-box; }
  header.top .wordmark { font-size: 16px; }
  header.top .where { display: block; margin-left: auto; color: #aaa; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
  #app { padding-bottom: var(--phone-nav); }

  .phone-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    height: var(--phone-nav); padding-bottom: env(safe-area-inset-bottom); box-sizing: border-box; background: var(--black);
  }
  .ptab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: 0; color: #9a9a9a; font: 500 11px/1 var(--sans); text-decoration: none;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  }
  .ptab svg { width: 22px; height: 22px; }
  .ptab.on { color: #fff; }
  .ptab.on svg { color: #19e28f; }

  .sheet-wrap { display: block; position: fixed; z-index: 40; inset: 0 0 var(--phone-nav) 0; background: rgba(0, 0, 0, .35); }
  .sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--card); padding: 4px 0 12px; box-shadow: 0 -10px 30px rgba(0, 0, 0, .18); }
  .sheet a { display: block; padding: 13px 18px; color: var(--text); border-bottom: 1px solid var(--line); font-size: 15px; text-decoration: none; }
  .sheet .langs { justify-content: flex-start; gap: 14px; padding: 12px 18px 4px; font-size: 14px; }
  .sheet .lang { color: var(--text2); }
  .sheet .lang.active { color: var(--accent); }
  .sheet .chk, .sheet p, .sheet .btn { margin: 10px 18px 0; }

  /* Brett randlos über die volle Breite, Spielerleisten mit kleinem Rand */
  main.tight { padding: 0 0 16px; }
  main.tight .board-col .pbar { padding: 0 12px; }
  main.tight .side { padding: 0 12px; }
  /* chessground versetzt die Buchstaben a–h um 24 px nach rechts; ohne Seitenrand ragte das über den Bildschirm */
  main.tight .board-col { overflow-x: clip; }
  .play-body, .analyse-body { gap: 10px; }

  /* während der Partie zuerst, was gerade zählt: Lernhilfen, dann Zugliste und Knöpfe, zuletzt „Neue Partie“;
     vor der Partie bleibt die Gegnerwahl oben. Im Rätsel steht der Stand vor Wertung und Thema. */
  .play.running .side > .coach, .puzzle .side > .coach { order: -2; }
  .play.running .side > .setup:last-child { order: -1; }

  /* kein versehentliches Doppeltipp-Zoomen auf Knöpfen */
  .btn, .lang, .seg-btn, button.link { touch-action: manipulation; }
}

@media (min-width: 700px) and (max-width: 900px) and (min-aspect-ratio: 4/5) {
  /* Kopf bleibt zweizeilig (Reiter, Sprache und Setup passen nicht in eine Zeile); das Titelband entfällt */
  .band { display: none; }
}

/* Handy quer (z. B. 915 × 412): nur die Reiterzeile bleibt, das Brett nimmt die volle Höhe, die Leiste steht daneben */
@media (max-height: 500px) and (orientation: landscape) {
  header.top .bar:first-child, .band, footer.foot { display: none; }
  header.top nav.bar { height: 36px; }
  .tab { padding: 10px 0 8px; }
  main.tight { padding-top: 4px; padding-bottom: 4px; }
  .pbar { height: 28px; }
  .analyse-body, .play-body { --board: max(220px, calc(100 * var(--vh) - 36px - 56px - 10px)); }
}
