/* OHANA V96 · Mobile play surface. Keeps all E/J/K/L/U controls usable. */
/* Loaded AFTER base styles. The rules change layout only, never input bindings. */
@media (hover: none) and (pointer: coarse), (max-width: 640px) {
  body.playing #touch {
    position: fixed;
    inset: auto max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none; /* Only the actual controls intercept game input. */
    gap: 8px;
  }
  body.playing #touch .col {
    pointer-events: none;
  }
  body.playing #touch button {
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
  }
  body.playing #touch .col.move,
  body.playing #touch .col.act {
    padding: clamp(3px, 1vw, 7px);
    gap: clamp(3px, 1vw, 7px);
  }
  body.playing #touch .act-row {
    gap: clamp(3px, .9vw, 7px);
  }
  body.playing #touch button:focus-visible {
    outline: 3px solid #fff2ae;
    outline-offset: 2px;
  }
}
/* Small portrait screens: two non-overlapping rows on the action side. */
@media (max-width: 420px) and (orientation: portrait) {
  body.playing #touch {
    min-height: 116px;
    align-items: flex-end;
  }
  body.playing #touch .col.move {
    flex: 0 0 auto;
    align-self: flex-end;
    flex-direction: row;
    padding: 4px;
  }
  body.playing #touch .col.act {
    position: absolute;
    bottom: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    padding: 4px;
  }
  body.playing #touch .col.act .powers {
    order: 0;
    margin: 0 0 3px;
  }
  body.playing #touch .col.act .main {order: 1;}
  body.playing #touch .col.move .touch-btn {
    width: clamp(36px, 11.5vw, 46px);
    height: clamp(42px, 12vw, 50px);
  }
  body.playing #touch .col.act .powers .touch-btn,
  body.playing #touch .col.act .powers .touch-btn.pw {
    width: clamp(31px, 9vw, 39px);
    height: clamp(39px, 11vw, 44px);
    min-width: 31px;
    border-radius: 12px;
    font-size: 11px;
  }
  body.playing #touch .col.act .main .touch-btn {
    width: clamp(41px, 12vw, 52px);
    height: clamp(43px, 13vw, 54px);
    border-radius: 14px;
  }
  body.playing #touch .col.act .main .touch-btn.jump {
    width: clamp(50px, 15vw, 60px);
    height: clamp(50px, 15vw, 60px);
  }
  body.playing #prompt {
    bottom: calc(134px + env(safe-area-inset-bottom));
  }
}
/* Short landscape phones: keep ability row and movement accessible without
   enlarging the controls into the playable area. */
@media (max-height: 450px) and (orientation: landscape) and (pointer: coarse) {
  body.playing #touch {
    bottom: max(4px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
  }
  body.playing #touch .col.move,
  body.playing #touch .col.act {padding: 3px;gap: 3px}
  body.playing #touch .act-row {gap: 3px}
  body.playing #touch .touch-btn,
  body.playing #touch .touch-btn.pw,
  body.playing #touch .touch-btn.jump {
    width: clamp(36px, 9vh, 48px);
    height: clamp(38px, 11vh, 49px);
    border-radius: 11px;
  }
  body.playing #touch .touch-btn.jump {
    width: clamp(43px, 13vh, 56px);
    height: clamp(43px, 13vh, 56px);
  }
  body.playing #prompt { bottom: 98px; }
}
@media (prefers-reduced-motion: reduce) {
  body.playing #touch button {transition: none !important;}
}

/* Compact play HUD: fixed desktop card widths must never widen a phone. */
@media (max-width: 640px), (max-height: 450px) and (pointer: coarse) {
  body.playing #hud {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    top: max(54px, calc(env(safe-area-inset-top) + 44px));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    gap: 6px;
    padding: 0;
  }
  body.playing #hud .hud-block {
    min-width: 0;
    max-width: none;
    padding: 8px;
    border-radius: 12px;
    background: rgba(7, 16, 29, .92);
    backdrop-filter: none;
    box-shadow: 0 3px 12px rgba(0,0,0,.22);
  }
  body.playing #hud .hud-ident { gap: 6px; margin-bottom: 4px; }
  body.playing #hud .hud-ident > div { min-width: 0; }
  body.playing #hud .hud-avatar { width: 28px; height: 28px; flex-basis: 28px; border-radius: 8px; }
  body.playing #hud .hud-name,
  body.playing #hud #hud-world { font-size: 14px; line-height: 1.2; }
  body.playing #hud .hud-trait { font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.playing #hud .hud-kicker,
  body.playing #hud .hud-meta,
  body.playing #hud #u-exp-hud,
  body.playing #hud .u-exp-track,
  body.playing #hud .form-pips,
  body.playing #hud #hud-combo { display: none; }
  body.playing #hud .bar-row { margin-top: 4px; gap: 4px; }
  body.playing #hud .bar { height: 8px; }
  body.playing #hud .bar-lab { width: 16px; font-size: 8px; }
  body.playing #hud .world-name,
  body.playing #hud .journey,
  body.playing #hud .evo-text,
  body.playing #hud #festival-room-meter { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body.playing #hud .journey,
  body.playing #hud .evo-text,
  body.playing #hud #festival-room-meter { font-size: 9px; line-height: 1.3; }
  body.playing #hud .evo-display { margin-top: 4px; }
  body.playing #top-actions { max-width: calc(100vw - 16px); gap: 4px; }
  body.playing #top-actions button { padding: 7px 8px; font-size: 8px; letter-spacing: .02em; }
  body.playing #notification-container { top: 156px; width: calc(100vw - 24px); max-width: 360px; }
  body.playing #notification-container .game-notification { padding: 8px 10px; backdrop-filter: none; }
  body.playing #boss-wrap { top: 150px; left: 12px; right: 12px; width: auto; transform: none; }
}
@media (hover: none) and (pointer: coarse) {
  body.playing #controls-hint { display: none; }
}
