/* F26: players on a phone. The board fills the screen; the interface shrinks
   around it: a compact action bar that scrolls sideways, the windows over the
   whole screen, small party frames and turn order, no minimap. Fingers on the
   board: client/js/input/touch.js. */

@media (max-width: 760px), (max-height: 520px) {
  .hud-tl { top: 6px; left: 6px; max-width: calc(100vw - 12px); }
  .topbar { flex-wrap: wrap; row-gap: 2px; font-size: 0.8rem; }
  .hud-top { top: 116px; left: 56px; right: 56px; transform: none; max-width: none; }
  .turn-bar { padding: 4px 6px; }
  .init, .init .face { width: 28px; }
  .init .face { height: 28px; }
  .init.current, .init.current .face { width: 36px; }
  .init.current .face { height: 36px; }
  .target-frame, .target-hp { min-width: 0; width: 160px; }
  .hud-tr { display: none; }

  .hud-left { top: 124px; left: 6px; bottom: 150px; }
  .party-frame { width: 52px; padding: 3px; }
  .party-frame .face-lg { width: 38px; height: 38px; font-size: 0.8rem; }
  .party-hp small { font-size: 0.65rem; }

  /* The dock: a column of buttons at the right; a window covers the screen. */
  .hud-right { top: 124px; right: 6px; bottom: auto; flex-direction: column; }
  .dock-btn { width: 38px; height: 38px; padding: 7px; }
  .window {
    position: fixed; inset: 0; width: auto; max-height: none; height: 100dvh; border-radius: 0; z-index: 50; background: var(--panel);
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .window-close { font-size: 1.8rem; padding: 4px 10px; }

  .bottom-stack { bottom: 4px; width: calc(100% - 8px); padding-bottom: env(safe-area-inset-bottom); }
  .action-bar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; padding: 6px; border-radius: 10px; }
  .hb-portrait { width: 56px; }
  .face-xl { width: 46px; height: 46px; font-size: 0.95rem; border-width: 2px; }
  .hb-name { max-width: 56px; font-size: 0.7rem; }
  .hb-portrait small { font-size: 0.68rem; }
  .hb-res { gap: 4px 8px; font-size: 0.72rem; }
  .pip { padding: 1px 6px; font-size: 0.7rem; }
  .move-meter { width: 44px; }
  .hb-grid { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; padding: 6px 2px 2px; }
  .act-group { flex-wrap: nowrap; }
  .act { width: 42px; height: 42px; flex: none; }
  .act kbd { display: none; }
  .end-turn { width: 60px; height: 60px; font-size: 0.56rem; line-height: 1.15; padding: 4px; border-width: 2px; overflow: hidden; }
  /* F11c: on a phone the windows have the dock; next to the end of turn, only stealth and the highlight. */
  .hud-buttons { grid-template-columns: 32px; }
  .hud-buttons .hud-btn:nth-child(n + 3) { display: none; }
  .hb-tabs { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .hb-tab { padding: 3px 9px; font-size: 0.7rem; flex: none; }
  .hb-float { width: calc(100vw - 16px); }
  .act-tip { font-size: 0.75rem; max-height: 28vh; overflow-y: auto; }

  .dialogue-box { bottom: 140px; width: calc(100vw - 16px); padding: 10px 12px; }
  .dialogue-text { font-size: 1rem; }
  .dialogue-option { padding: 10px; }
  .check-card { width: calc(100vw - 24px); }
  .narration-box { max-width: calc(100vw - 24px); }
  .travel-banner { flex-wrap: wrap; max-width: calc(100vw - 16px); }
  .object-menu { max-width: calc(100vw - 16px); }
  .object-menu-item { padding: 10px 8px; }
  #toasts { top: 124px; }

  /* F11: the inventory screen takes the whole phone, one part under the other: the character folds away (it starts
     folded), the doll is compact (no figure), the bag scrolls inside, and the loot windows go over it, at the bottom. */
  .inv-screen {
    position: fixed; inset: 0; width: auto; height: 100dvh; margin: 0; border: 0; border-radius: 0; z-index: 50;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .inv-head { padding: 8px 10px; }
  .inv-title h2 { font-size: 1.1rem; }
  .inv-numbers { gap: 12px; font-size: 0.82rem; }
  .inv-close { width: 40px; height: 40px; }
  .inv-body { display: flex; flex-direction: column; overflow-y: auto; gap: 8px; padding: 8px; }
  .inv-body > * { flex: none; }
  .inv-char { max-height: none; }
  .inv-char.open .inv-char-body { max-height: 40dvh; overflow-y: auto; }
  .inv-doll { overflow: visible; padding: 8px; }
  .inv-doll-body { gap: 10px; }
  .inv-doll-slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
  .inv-slots { display: contents; }
  .inv-figure, .is-creature .inv-doll-slots { display: none; }
  .inv-screen .inv-cell { width: 44px; height: 44px; padding: 6px; }
  .inv-screen .inv-slot .inv-cell, .inv-screen .inv-hands .inv-slot .inv-cell { width: 46px; height: 46px; }
  .inv-screen .inv-cell .icon { width: 26px; height: 26px; }
  .inv-pair { gap: 6px; }
  .inv-ac { width: 56px; height: 66px; }
  .inv-ac strong { font-size: 1.35rem; }
  .inv-bag { flex: 1 0 auto; min-height: 420px; }
  .inv-screen .inv-grid { grid-template-columns: repeat(auto-fill, 44px); gap: 5px; min-height: 120px; }
  .inv-detail-host { max-height: 32dvh; }
  .inv-tip { display: none; }
  .board.inv-open .loot-stack {
    top: auto; bottom: 0; left: 0; right: 0; z-index: 55; flex-direction: row; max-height: 46dvh; overflow: auto; padding: 8px;
    background: rgba(8, 8, 10, 0.88);
  }
  .board.inv-open .loot-window { width: min(300px, 86vw); }
}

/* F3: the character creator on a phone or a tablet standing up (up to 900 px, a little more than the board's 760):
   one column (the list, then its details), the steps bar slides sideways, the summary of the character comes over
   the step with the "Ficha" button, and the footer stays in sight. */
@media (max-width: 900px), (max-height: 520px) {
  .creator-head { flex-wrap: wrap; gap: 4px 8px; padding: 8px 10px 2px; }
  .creator-head h1 { display: none; }
  .creator-head .btn { padding: 4px 10px; font-size: 0.82rem; }
  .creator-intro { font-size: 0.82rem; }
  .creator-steps { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 4px 8px 6px; }
  .step { flex: none; white-space: nowrap; padding: 3px 10px; font-size: 0.82rem; }
  .creator-body { grid-template-columns: minmax(0, 1fr); position: relative; }
  .creator-main { padding: 8px 10px 0; }
  .creator-main > h2 { font-size: 1.15rem; margin-bottom: 4px; }
  .creator-side { display: none; border-left: 0; }
  .creator.show-sheet .creator-side { display: block; position: absolute; inset: 0; z-index: 3; }
  .creator-foot { flex-wrap: wrap; gap: 6px 8px; padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); }
  .creator-status { order: -1; flex: 1 0 100%; text-align: left; font-size: 0.8rem; }
  .creator-status:empty { display: none; }
  .creator-sheet-btn { display: inline-flex; align-items: center; margin-right: auto; }
  .creator-scroll.is-split { overflow-y: auto; display: grid; padding-bottom: 14px; }
  .split { display: block; }
  .opt-list { max-height: 38dvh; margin-bottom: 10px; }
  .opt-detail { overflow: visible; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dt { margin-top: 6px; font-size: 0.8rem; }
  .spell-grid { grid-template-columns: 1fr; }
  .ability-table th, .ability-table td { padding: 5px 3px; }
  .ability-table .full, .ab-hint { display: none; }
  .ability-table .short { display: inline; }
  .ability-table .badge { display: none; }
  .step-btn, .bonus-toggle { width: 30px; height: 30px; }
  .stepper { gap: 5px; }
  .score { font-size: 1.1rem; }
  .points { padding: 8px 12px; }
  .points-left strong { font-size: 2rem; }
  .gear-list { grid-template-columns: 1fr; }
}
@media (max-height: 520px) {
  /* A phone on its side: the step bar says where you are, so the title and the intro go. */
  .creator-intro, .creator-main > h2 { display: none; }
  .creator-head { padding-top: 4px; }
  .creator-steps { padding-top: 2px; padding-bottom: 4px; }
  .creator-foot { padding-top: 4px; padding-bottom: 4px; }
  .creator-foot .btn { padding-top: 3px; padding-bottom: 3px; }
}

/* Fingers: bigger targets; the touch help instead of the keyboard's. */
.touch-only { display: none; }
@media (pointer: coarse) {
  .touch-only { display: block; }
  .btn, .chip, .tool { min-height: 38px; }
}
