/* Mobile portrait adaptations for WeChat mini-program web-view.
   DESKTOP DEFAULTS UNTOUCHED — everything is inside max-width:768px.
   Linked after style.css / mtt.css / poker-table.css / home.css / audio.css. */

@media (max-width: 768px) {
  /* —— Shared chrome —— */
  body.play-page {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  body.play-page > header {
    gap: 6px;
    padding: 4px 8px;
    align-items: flex-start;
  }

  body.play-page .title {
    font-size: 14px;
    line-height: 1.25;
  }

  body.play-page .title span {
    display: inline;
    margin-left: 4px;
    font-size: 11px;
  }

  /* Session stats: keep one line compact or hide if cramped */
  body.play-page .session {
    display: none;
  }

  body.play-page .hbtns {
    width: 100%;
    gap: 6px;
    justify-content: flex-start;
  }

  body.play-page .hbtns > a.nav-pill[href="mtt.html"],
  body.play-page .hbtns > a.nav-pill[href="regular.html"],
  body.play-page .hbtns > a.nav-pill[href*="review.html"],
  body.play-page .hbtns > label,
  body.play-page #btnExportState {
    display: none !important;
  }

  /* Keep 暂停/继续 reachable on phone (restore starts paused) */
  body.play-page #btnPause {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 6px 14px !important;
    font-size: 14px;
    font-weight: 700;
    border-radius: 999px;
    background: #1f6feb;
    color: #fff;
    border: none;
  }
  body.play-page #btnPause.is-resume {
    background: #2ea043;
    box-shadow: 0 0 0 2px rgba(46, 160, 67, 0.4);
  }

  body.play-page .hbtns > a.nav-pill,
  body.play-page .hbtns > button,
  body.play-page .audio-mute-btn {
    min-height: 36px;
    padding: 4px 10px !important;
    font-size: 13px;
  }

  /* Audio bar: collapsed summary only */
  body.play-page > .audio-panel {
    display: none !important;
  }

  /* Main column: table + controls only; hide desktop aside log */
  body.play-page > main {
    flex-direction: column;
    padding: 2px 4px 4px;
    gap: 2px;
  }

  body.play-page > main > aside {
    display: none !important;
  }

  body.play-page .tablewrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  /* WPK-style: tall felt dominates the phone; action bar stays thin at bottom */
  body.play-page .tablewrap > .table,
  body.play-page .poker-surface > .table {
    aspect-ratio: 0.88;
    width: min(98%, calc(min(68dvh, 100%) * 0.88));
    max-width: 98%;
    height: auto;
    max-height: min(68dvh, 100%);
    margin: 0 auto;
    overflow: visible;
  }

  /* Compact seats — only under 768; desktop seat sizes unchanged */
  body.play-page .seat,
  body.play-page .poker-surface .seat {
    width: 78px;
  }

  body.play-page .seat .plate,
  body.play-page .poker-surface .seat .plate {
    padding: 2px 3px;
    border-radius: 8px;
    gap: 3px;
  }

  body.play-page .seat .avatar,
  body.play-page .seat .avatar > svg:first-child,
  body.play-page .poker-surface .seat .avatar,
  body.play-page .poker-surface .seat .avatar > svg:first-child {
    display: block !important;
    width: 26px !important;
    height: 26px !important;
  }

  body.play-page .seat .ring,
  body.play-page .poker-surface .seat .ring {
    width: 34px;
    height: 34px;
    inset: -4px;
  }

  body.play-page .seat .nm,
  body.play-page .poker-surface .seat .nm {
    font-size: 10px;
  }

  body.play-page .seat .stk,
  body.play-page .poker-surface .seat .stk {
    font-size: 11px;
  }

  body.play-page .seat .tag,
  body.play-page .seat .sty,
  body.play-page .imit,
  body.play-page .poker-surface .seat .tag,
  body.play-page .poker-surface .seat .sty {
    display: none !important;
  }

  body.play-page .seat .card,
  body.play-page .poker-surface .seat .card {
    width: 30px;
    height: 42px;
  }

  body.play-page .seat .cards,
  body.play-page .poker-surface .seat .cards {
    height: 44px;
  }

  body.play-page .seat.hero .card,
  body.play-page .poker-surface .seat.hero .card {
    width: 48px;
    height: 68px;
  }

  body.play-page .seat.hero .cards,
  body.play-page .poker-surface .seat.hero .cards {
    height: 70px;
  }

  body.play-page .seat .card .r,
  body.play-page .poker-surface .seat .card .r { font-size: 11px; }
  body.play-page .seat .card .s,
  body.play-page .poker-surface .seat .card .s { font-size: 10px; }
  body.play-page .seat .card .pip,
  body.play-page .poker-surface .seat .card .pip { font-size: 18px; }
  body.play-page .seat .card .corner.br,
  body.play-page .poker-surface .seat .card .corner.br { display: none; }

  body.play-page .seat.hero .card .r,
  body.play-page .poker-surface .seat.hero .card .r { font-size: 15px; }
  body.play-page .seat.hero .card .s,
  body.play-page .poker-surface .seat.hero .card .s { font-size: 13px; }
  body.play-page .seat.hero .card .pip,
  body.play-page .poker-surface .seat.hero .card .pip { font-size: 28px; }

  body.play-page .center .card {
    width: 42px;
    height: 58px;
  }

  body.play-page .center .card .r { font-size: 13px; }
  body.play-page .center .card .s { font-size: 11px; }
  body.play-page .center .card .pip { font-size: 22px; }
  body.play-page .center .card .corner.br { display: none; }

  body.play-page .board {
    gap: 4px;
    min-height: 60px;
  }

  body.play-page .pot { font-size: 12px; }
  body.play-page .msg { font-size: 12px; max-width: 200px; }

  /* Hero plate clear of action bar on tall phone */
  body.play-page .poker-surface .seat.hero {
    transform: translate(-50%, calc(-50% - 8px));
  }

  /* WPK action bar: presets + thin slider + 3 fat thumbs */
  body.play-page .controls,
  body.play-page .mtt-controls {
    position: relative;
    bottom: auto;
    z-index: 2;
    margin: 0;
    padding: 4px 6px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    border-radius: 12px;
    max-width: 100%;
    width: 100%;
    gap: 3px;
    flex: 0 0 auto;
  }

  body.play-page .controls .raiserow,
  body.play-page .mtt-controls .amount-row {
    margin-bottom: 2px;
    gap: 6px;
    align-items: center;
  }

  body.play-page .controls .raise-meta,
  body.play-page .shortcut-hint,
  body.play-page .act kbd,
  body.play-page .mtt-controls .act kbd {
    display: none !important;
  }

  body.play-page .controls #slider,
  body.play-page .mtt-controls #amountSlider {
    flex: 1 1 auto;
    height: 22px;
    margin: 0;
  }

  body.play-page .controls .raise-amt,
  body.play-page .mtt-controls #amount {
    min-height: 28px;
    width: 56px;
    font-size: 16px; /* avoid iOS zoom */
    padding: 2px 4px;
  }

  body.play-page .controls .quick button,
  body.play-page .mtt-controls .quick button {
    min-height: 28px;
    min-width: 0;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 2px;
    border-radius: 999px;
  }

  body.play-page .act,
  body.play-page .mtt-controls .act,
  body.play-page .mtt-controls .table-round-controls button {
    min-height: 48px;
    min-width: 0;
    font-size: 15px;
    font-weight: 800;
    padding: 8px 4px;
    border-radius: 10px;
  }

  /* WPK: three primary actions; all-in lives in presets */
  body.play-page #bAllin,
  body.play-page #allin {
    display: none !important;
  }

  body.play-page .mainbtns,
  body.play-page .mtt-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  body.play-page .nexthand {
    margin-top: 2px;
  }

  /* Street confirm is auto-skipped on phone; never show the banner */
  body.play-page .decision-ack {
    display: none !important;
  }

  /* Hand result overlay */
  body.play-page .hand-result-card {
    min-width: min(92vw, 320px);
    padding: 14px 14px 12px;
  }

  body.play-page .hand-result-net {
    font-size: 28px;
  }

  body.play-page .modal .box {
    width: calc(100vw - 16px);
    max-height: min(82dvh, 640px);
    padding: 12px;
  }

  body.play-page .seatpick {
    grid-template-columns: 1fr;
  }
}

/* Extra-narrow phones (iPhone SE / 375) */
@media (max-width: 400px) {
  body.play-page .tablewrap > .table,
  body.play-page .poker-surface > .table {
    aspect-ratio: 0.86;
    width: min(98%, calc(min(64dvh, 100%) * 0.86));
    max-width: 98%;
    max-height: min(64dvh, 100%);
  }

  body.play-page .seat,
  body.play-page .poker-surface .seat {
    width: 70px;
  }

  body.play-page .seat.hero .card,
  body.play-page .poker-surface .seat.hero .card {
    width: 44px;
    height: 62px;
  }

  body.play-page .seat.hero .cards,
  body.play-page .poker-surface .seat.hero .cards {
    height: 64px;
  }

  body.play-page .center .card {
    width: 38px;
    height: 52px;
  }

  body.play-page .act,
  body.play-page .mtt-controls .act {
    font-size: 14px;
    padding: 8px 2px;
  }
}

/* —— Home —— */
@media (max-width: 768px) {
  body.home-page {
    padding: 12px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  body.home-page header {
    margin-bottom: 8px;
  }

  body.home-page .intro h1 {
    font-size: 26px;
  }

  body.home-page .modes {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  body.home-page .mode {
    min-height: 0;
    padding: 16px 16px;
  }

  body.home-page .mode h2 {
    font-size: 18px;
  }

  body.home-page .mode p {
    font-size: 13px;
    margin: 6px 0 10px;
  }
}

/* —— MTT phone —— */
@media (max-width: 768px) {
  body.mtt-page > header h1 {
    font-size: 16px;
    margin: 0;
  }

  body.mtt-page > header p {
    display: none;
  }

  body.mtt-page .table-topbar {
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 4px 8px;
    font-size: 12px;
  }

  body.mtt-page .rules-banner,
  body.mtt-page #notice:empty {
    display: none;
  }

  body.mtt-page .rules-banner {
    font-size: 11px;
    margin: 0;
    padding: 4px 8px;
    max-height: 2.6em;
    overflow: hidden;
  }

  body.mtt-page .mtt-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
    gap: 4px;
    padding: 4px 6px;
  }

  body.mtt-page .mtt-main > .play {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 6px;
    margin: 0;
    overflow: hidden;
  }

  body.mtt-page .mtt-main > .play > h2,
  body.mtt-page .mtt-main > .play > #turn,
  body.mtt-page .mtt-main > .play > #moveNotice:empty {
    display: none;
  }

  body.mtt-page .mtt-main > .play > #turn,
  body.mtt-page .mtt-main > .play > #moveNotice {
    font-size: 11px;
    margin: 0 0 4px;
    max-height: 2.4em;
    overflow: hidden;
  }

  body.mtt-page .tablewrap {
    flex: 1 1 auto;
    min-height: 0;
  }

  body.mtt-page .poker-surface > .table {
    aspect-ratio: 0.88;
    width: min(98%, calc(min(62dvh, 100%) * 0.88));
    max-width: 98%;
    max-height: min(62dvh, 100%);
  }

  /* Sidebar: collapse to tab strip height; default panels already use details */
  body.mtt-page .event-sidebar {
    flex: 0 0 auto;
    max-height: 18vh;
    width: 100%;
    margin: 0;
    padding: 6px;
    overflow: auto;
    order: 2;
  }

  body.mtt-page .mobile-event-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
  }

  body.mtt-page .mobile-event-tabs button {
    flex: 1;
    min-height: 36px;
    font-size: 12px;
    padding: 6px 4px;
  }

  body.mtt-page .play .hand-log,
  body.mtt-page .play > details:not(.hand-log) {
    display: none;
  }

  body.mtt-page .cold-start {
    padding: 12px;
  }

  body.mtt-page .cold-card {
    max-width: 100%;
    padding: 16px;
  }

  body.mtt-page .cold-blinds {
    overflow: auto;
  }
}

/* —— Review —— */
@media (max-width: 768px) {
  body:has(.filters) header,
  body > header {
    flex-wrap: wrap;
  }
}

/* Short landscape phones: keep playable, still max-width gated via orientation helper */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  body.play-page .session,
  body.play-page > main > aside,
  body.play-page > .audio-panel .dealer-subtitle {
    display: none !important;
  }

  body.play-page .tablewrap > .table,
  body.play-page .poker-surface > .table {
    aspect-ratio: 1.6;
  }

  body.play-page .controls .act,
  body.play-page .mtt-controls .act {
    min-height: 40px;
    font-size: 14px;
  }
}


/* Phone: drop "下一手" keyboard hint spacing when present; keep ≥44px */
@media (max-width: 768px) {
  body.play-page .controls .nexthand .act.next,
  body.play-page .mtt-controls .table-round-controls button {
    min-height: 36px;
  }
  body.play-page .quick {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    margin-bottom: 2px;
  }
  body.play-page .quick button {
    width: 100%;
  }
  /* Prefer settings reachable; home + mute + settings is enough chrome */
  body.mtt-page > header .hbtns > a.nav-pill[href="/"] {
    display: inline-flex !important;
  }

  body.play-page .mtt-controls .table-round-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  body.play-page #tableEnd,
  body.play-page #endTournament {
    min-height: 36px;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 10px;
  }
}
