/* =============================================================================
 * CHESSWOOD — responsive.css
 * Where things sit on each screen shape. The 3D camera reads these positions
 * (interface.js -> boardInsets) and fits the board into the space left over.
 *
 *  WIDE  (landscape, 760px+): top bar, player plaques on the left, moves panel
 *                             docked on the right, view tools in a left column.
 *  NARROW (portrait / small): compact top bar, opponent above the board, you
 *                             below, view tools along the bottom, moves panel
 *                             as a pull-up drawer.
 * ===========================================================================*/

/* ============================== WIDE ====================================== */
@media (min-width: 760px) and (orientation: landscape) {
  .menu-card {
    left: calc(28px + var(--safe-l)); top: 50%; transform: translateY(-50%);
    width: min(400px, 40vw); max-height: calc(100% - 40px); overflow-y: auto;
  }
  .topbar { top: calc(14px + var(--safe-t)); left: calc(16px + var(--safe-l)); right: calc(16px + var(--safe-r)); height: 56px; }
  .timer { margin-left: auto; }
  .topbar-actions { margin-left: auto; }
  #bar-top { top: calc(84px + var(--safe-t)); left: calc(78px + var(--safe-l)); width: min(380px, calc(100vw - 480px)); }
  #bar-bottom { bottom: calc(16px + var(--safe-b)); left: calc(78px + var(--safe-l)); width: min(380px, calc(100vw - 480px)); }
  .panel {
    top: calc(84px + var(--safe-t)); right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b));
    width: clamp(250px, 25vw, 330px);
  }
  .panel-close, .tool-moves { display: none; }
  .board-tools { left: calc(16px + var(--safe-l)); top: 50%; transform: translateY(-50%); flex-direction: column; }
  .thinking { top: calc(150px + var(--safe-t)); }
  .banner { top: calc(150px + var(--safe-t)); }
  .show-results { bottom: calc(86px + var(--safe-b)); }
  .toasts { bottom: calc(90px + var(--safe-b)); }
}

/* Short landscape screens (phones turned sideways) */
@media (min-width: 760px) and (orientation: landscape) and (max-height: 540px) {
  .menu-card { gap: 10px; padding: 16px; width: min(360px, 44vw); }
  .menu-title { max-height: 74px; object-fit: contain; }
  .menu-actions { gap: 8px; }
  .btn-lg { min-height: 46px; font-size: 1rem; }
  .menu-footer { padding-top: 10px; }
  .topbar { top: calc(8px + var(--safe-t)); height: 46px; }
  .topbar-match { display: none; }
  .icon-btn { width: 42px; height: 42px; }
  .timer { height: 42px; }
  #bar-top { top: calc(60px + var(--safe-t)); }
  #bar-top, #bar-bottom { min-height: 46px; padding: 4px 10px 4px 6px; }
  #bar-bottom { bottom: calc(8px + var(--safe-b)); }
  .pb-piece { width: 34px; height: 34px; font-size: 1.35rem; }
  .panel { top: calc(60px + var(--safe-t)); bottom: calc(8px + var(--safe-b)); padding: 12px; gap: 8px; }
  .thinking, .banner { top: calc(112px + var(--safe-t)); }
  .splash-title { width: min(60vw, 620px); }
}

/* ============================== NARROW ==================================== */
@media not all and (min-width: 760px) and (orientation: landscape) {
  .menu-card {
    left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); bottom: calc(12px + var(--safe-b));
    padding: 18px; gap: 14px; max-height: 70vh; overflow-y: auto;
    max-width: 520px; margin: 0 auto;
  }
  .menu-title { max-height: 18vh; object-fit: contain; }
  .topbar { top: calc(8px + var(--safe-t)); left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r)); height: 48px; gap: 8px; }
  .topbar-title { display: none; }
  .timer { margin: 0 auto; height: 44px; font-size: 1.05rem; }
  .topbar-actions { margin-left: 0; }
  .icon-btn { width: 44px; height: 44px; }
  #bar-top { top: calc(64px + var(--safe-t)); left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r)); }
  #bar-bottom { bottom: calc(68px + var(--safe-b)); left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r)); }
  .board-tools { bottom: calc(10px + var(--safe-b)); left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r)); justify-content: center; gap: 16px; }
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    max-height: 64vh; min-height: 40vh;
    border-radius: 24px 24px 0 0;
    padding: 18px calc(18px + var(--safe-r)) calc(18px + var(--safe-b)) calc(18px + var(--safe-l));
    background: var(--surface-strong);
    transform: translateY(105%); visibility: hidden;
    transition: transform 0.3s cubic-bezier(.2, .9, .3, 1), visibility 0s linear 0.3s;
  }
  .panel.is-open { transform: none; visibility: visible; transition: transform 0.3s cubic-bezier(.2, .9, .3, 1), visibility 0s; }
  .panel::before {
    content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 44px; height: 5px; border-radius: 99px; background: var(--line-strong);
  }
  .thinking, .banner { top: calc(126px + var(--safe-t)); }
  .show-results { bottom: calc(132px + var(--safe-b)); }
  .toasts { bottom: calc(136px + var(--safe-b)); }
  .modal { padding: 20px; border-radius: 22px; }
  .modal h2 { font-size: 1.4rem; }
  .results-title { font-size: 2.1rem !important; }
  .room-code { font-size: 1.8rem; }
  .splash-title { width: min(88vw, 560px); }
}

@media (max-width: 380px) {
  .pb-captured { display: none; }
  .seg span { font-size: 0.92rem; }
  .menu-row { grid-template-columns: 1fr; }
}
