/* Phones and tablets: larger touch targets for the coach bar, a compact landscape layout, a rotate hint. */
@media (pointer: coarse) {
  .chips button { height: 46px; padding: 0 12px; font-size: 15px; }
  .coach .hit { height: 46px; padding: 0 18px; font-size: 16px; }
  .coach .to button { width: 40px; height: 40px; }
  .coach .tag { padding: 6px 10px; }
  .tb { min-width: 44px; height: 44px; }
  .shots li { min-height: 52px; }
}

/* Phone held sideways: keep the court big, move the controls to the edges */
@media (orientation: landscape) and (max-height: 540px) {
  .sb { transform: scale(.82); transform-origin: top left; top: 6px; left: 8px; }
  .tools { top: 6px; right: 6px; flex-direction: column; padding: 4px; gap: 2px; }
  .tools .tb { min-width: 38px; height: 38px; }
  .tools .tb.wide span { display: none; }
  .menu { right: 50px; top: 0; bottom: auto; }
  .tl { width: 230px; left: 8px; bottom: 8px; max-height: calc(100vh - 100px); }
  .tl .court, .tl .hint { display: none; }
  .coach { left: 50%; right: auto; transform: translateX(-50%); bottom: 6px; max-width: calc(100vw - 120px); padding: 6px; }
  .coach .khint { display: none; }
  .cbar { flex-wrap: nowrap; }
  .chips button { height: 40px; }
  .speedpop { top: 6px; right: 56px; }
  .speedpop b { font-size: 30px; }
  .toast { bottom: 8px; }
  .replay { top: auto; bottom: 8px; right: 56px; font-size: 18px; }
  .banner { top: 6px; }
  .lower { bottom: 10px; }
}

/* Portrait phone: suggest turning it sideways (shown once by the app) */
.rotate-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 22px; border-radius: 14px; background: rgba(9, 14, 26, .92); border: 1px solid rgba(255,255,255,.12); color: #eef2f8; text-align: center; max-width: 280px; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.rotate-hint svg { width: 46px; height: 46px; color: #ffd21f; animation: rot 1.6s ease-in-out infinite; }
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
.rotate-hint button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 9px; background: #ffd21f; color: #0b1426; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .rotate-hint svg { animation: none; } }

/* Toolbar on phones: keep the essentials, hide what lives in Settings anyway (language) or is automatic (replay) */
.tb.only-mobile { display: none; }
@media (max-width: 760px), (pointer: coarse) and (max-height: 540px) {
  #bReplay, #bFull, #bLang { display: none !important; }
  .tb.only-mobile { display: inline-flex; }
}
/* already sideways: no need for the landscape button */
@media (orientation: landscape) and (max-height: 540px) { .tb.only-mobile { display: none; } }

/* Coach bar on phones: tag on top, shot buttons in an even row, then target stepper + Hit */
@media (max-width: 760px) {
  .coach { left: 8px; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); transform: none; max-width: none; width: auto; padding: 8px; }
  .cbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "tag tag" "chips chips" "to hit"; gap: 8px; align-items: center; }
  .coach .tag { grid-area: tag; justify-self: start; font-size: 13px; padding: 3px 9px; }
  .chips { grid-area: chips; display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
  .chips button { min-width: 0; height: 44px; padding: 0 6px; justify-content: center; gap: 4px; font-size: 13px; }
  .chips button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .chips button kbd { display: none; }
  .chips button[aria-pressed="true"] { transform: none; }
  .coach .to { grid-area: to; min-width: 0; justify-content: space-between; gap: 6px; }
  .coach .to .tz { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
  .coach .to button { width: 40px; height: 40px; flex: none; }
  .coach .hit { grid-area: hit; height: 44px; padding: 0 18px; }
  .coach .hit kbd { display: none; }
  .coach .khint { display: none; }
  .coach .tbar { margin-top: 8px; }
}
/* phone sideways: one compact row */
@media (orientation: landscape) and (max-height: 540px) {
  .coach { left: 50%; right: auto; transform: translateX(-50%); bottom: 6px; max-width: calc(100vw - 110px); width: max-content; }
  .cbar { display: flex; flex-wrap: nowrap; gap: 6px; }
  .chips { display: flex; }
  .chips button { height: 38px; font-size: 12.5px; }
  .chips button kbd, .coach .hit kbd { display: none; }
  .coach .to .tz { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .coach .to button { width: 32px; height: 32px; }
  .coach .hit { height: 38px; }
}
@keyframes coachUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 760px) { .coach.in { animation: coachUp .25s ease-out; } }
@keyframes coachUpC { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translateX(-50%); } }
@media (orientation: landscape) and (max-height: 540px) { .coach.in { animation: coachUpC .25s ease-out; } }

/* Coach bar on phones, compact: no label, tighter padding, two short rows (portrait) or one row (landscape) */
@media (max-width: 760px) {
  .coach { left: 6px; right: 6px; padding: 6px; border-radius: 10px; border-top-width: 2px; bottom: calc(60px + env(safe-area-inset-bottom)); }
  .cbar { grid-template-areas: "chips chips" "to hit"; gap: 6px; }
  .coach .tag, .chips b, .coach .to b { display: none; }
  .chips { gap: 4px; }
  .chips button { height: 38px; padding: 0 4px; font-size: 12.5px; border-radius: 8px; }
  .coach .to { gap: 4px; }
  .coach .to button { width: 34px; height: 34px; }
  .coach .to .tz { font-size: 12.5px; text-align: center; }
  .coach .hit { height: 38px; padding: 0 16px; border-radius: 8px; }
  .coach .tbar { margin: 5px 1px 0; height: 2px; }
}
@media (orientation: landscape) and (max-height: 540px) {
  .coach { left: 50%; right: auto; width: max-content; max-width: calc(100vw - 112px); padding: 5px; bottom: 6px; }
  .cbar { display: flex; flex-wrap: nowrap; gap: 5px; }
  .coach .tag, .chips b, .coach .to b, .coach .khint { display: none; }
  .chips { display: flex; gap: 4px; }
  .chips button { height: 34px; padding: 0 9px; font-size: 12px; }
  .coach .to button { width: 30px; height: 30px; }
  .coach .to .tz { max-width: 104px; font-size: 12px; }
  .coach .hit { height: 34px; padding: 0 14px; }
  .coach .tbar { margin-top: 4px; height: 2px; }
}
@media (max-width: 760px) { .coach { bottom: calc(68px + env(safe-area-inset-bottom)); background: rgb(9, 14, 26); } }
@media (orientation: landscape) and (max-height: 540px) { .coach { background: rgb(9, 14, 26); } }
/* portrait: slimmer still */
@media (max-width: 760px) {
  .coach { padding: 5px; border-top-width: 2px; }
  .cbar { gap: 5px; }
  .coach .tag { display: none !important; }
  .chips { gap: 4px; }
  .chips button { height: 30px; padding: 0 4px; font-size: 12px; font-weight: 600; border-radius: 7px; }
  .chips button[aria-pressed="true"] { box-shadow: 0 0 0 1.5px var(--accent); }
  .coach .to button { width: 28px; height: 28px; border-radius: 6px; }
  .coach .to .tz { font-size: 12px; }
  .coach .hit { height: 30px; padding: 0 12px; font-size: 13px; border-radius: 7px; }
  .coach .tbar { margin-top: 4px; }
}
@media (max-width: 760px) { .coach { bottom: calc(72px + env(safe-area-inset-bottom)); } }

/* portrait: same width as the toolbar, bigger Hit button for an easy tap */
@media (max-width: 760px) {
  .coach { left: 50%; right: auto; width: var(--toolbar-w, calc(100vw - 12px)); max-width: calc(100vw - 12px); transform: translateX(-50%); box-sizing: border-box; }
  .coach.in { animation: coachUpC .25s ease-out; }
  .cbar { grid-template-columns: minmax(0, 1fr) auto; }
  .coach .hit { height: 42px; min-width: 92px; padding: 0 22px; font-size: 16px; font-weight: 700; border-radius: 9px; justify-content: center; }
  .coach .to button { width: 34px; height: 34px; }
}
@media (max-width: 760px) { .coach { bottom: calc(80px + env(safe-area-inset-bottom)); } }

/* portrait: replay badge at the top right, level with the scoreboard, compact */
@media (max-width: 760px) {
  .replay { top: max(14px, env(safe-area-inset-top)); bottom: auto; right: 16px; left: auto; padding: 6px 12px 7px; font-size: 16px; letter-spacing: .12em; gap: 6px; border-radius: 8px; }
  .replay small { font-size: 11px; }
  .replay .dot { width: 8px; height: 8px; }
  .replay .prog { height: 3px; margin-top: 3px; }
}
