/* 手机端只调整展示和触控，不改变账号、方案或订单行为。 */
.mobile-getting-started { display: none; }

@media (max-width: 800px) {
  body { overflow-wrap: break-word; }
  .topbar, .navigation, .workspace {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .workspace { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .workspace > section, .workspace .panel { min-width: 0; }
  .navigation { gap: 8px; }
  #main-nav { align-items: flex-start; }
  #main-nav .more-navigation[open] { flex-basis: 100%; }
  #main-nav .more-navigation > div button { min-height: 44px; }
  #main-nav > button, #main-nav .more-navigation summary {
    min-height: 44px;
    font-size: 14px;
  }
  #main-nav .more-navigation summary { display: flex; align-items: center; justify-content: center; }
  button, summary { touch-action: manipulation; }
  .workspace button, dialog button, .login-card button { min-height: 44px; }
  .workspace input:not([type="checkbox"]):not([type="radio"]),
  .workspace select, dialog input:not([type="checkbox"]):not([type="radio"]),
  dialog select, .login-card input:not([type="checkbox"]) {
    min-height: 44px;
    max-width: 100%;
    font-size: 16px;
  }
  .workspace :focus-visible, dialog :focus-visible, .login-card :focus-visible {
    outline: 3px solid #1c66d4;
    outline-offset: 2px;
  }
  .mobile-getting-started {
    display: block;
    padding: 12px 14px;
    border: 1px solid #b4cae5;
    border-radius: 8px;
    background: #f2f7ff;
    color: #254765;
    line-height: 1.6;
  }
  .mobile-getting-started summary { cursor: pointer; font-weight: 700; min-height: 32px; }
  .mobile-getting-started ol { padding-left: 22px; margin: 8px 0; }
  .mobile-getting-started li { margin: 6px 0; }
  .account-console .account-table { overflow: visible; }
  #external-account-body tr { background: #fff; }
  #external-account-body td { font-size: 14px; line-height: 1.5; }
  #external-account-body td::before { color: #435a73; }
  #external-account-body .binding-actions { min-width: 0; }
  #external-account-body .binding-actions button { min-height: 44px; }
  #external-account-body .binding-switch { min-height: 44px; }
  #external-account-body select { min-width: 0; flex-basis: 160px; }
  #binding-count, #binding-totals { line-height: 1.6; overflow-wrap: anywhere; }
  #player-plans { max-height: none; overflow: visible; }
  .account-activity #ui-log { height: auto; min-height: 120px; max-height: 260px; }
  dialog[open] {
    max-width: calc(100% - 24px);
    max-height: min(90vh, 90dvh);
    overflow: auto;
    overscroll-behavior: contain;
  }
  .dialog-heading { flex-wrap: wrap; }
  .table-scroll, .backtest-table { max-width: 100%; overflow-x: auto; }
  /* 保留表头与全部数据，允许表格局部横向滚动，避免压缩到难以阅读。 */
  .history-page .history-table { min-width: 600px; }
  .history-page .history-table th, .history-page .history-table td { font-size: 13px; }
  .history-page .history-date, .history-page .history-table td:last-child { font-size: 12px; }
  .history-page .history-balls span { width: 22px; height: 22px; font-size: 12px; }
  .history-page .history-toolbar, .history-page .history-source,
  .schedule-page, .schedule-page .schedule-description,
  .schedule-page .time-window, .schedule-page .schedule-rules { font-size: 14px; }
  .login-page { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}

@media (max-width: 650px) {
  /* 交易记录每期一张卡片，仍保留订单明细及原有数据顺序。 */
  #transactions-body { display: grid; gap: 12px; }
  #transactions-body tr { display: block; border: 1px solid #bdcce0; border-radius: 8px; background: #fff; }
  #transactions-body td { display: flex; gap: 10px; padding: 9px 12px; border: 0; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
  #transactions-body td::before { content: attr(data-label); flex: 0 0 100px; color: #435a73; font-weight: 600; }
  #transactions-body td > * { min-width: 0; }
  #transactions-body td:first-child { background: #edf4ff; font-weight: 700; }
  #transactions-body td:first-child::before { font-weight: 600; }
  #transactions-body .transaction-summary { min-width: 0; }
  #transactions-body details { min-width: 0; overflow-wrap: anywhere; }
  [data-view="transactions"] .table-scroll > table,
  [data-view="transactions"] .table-scroll > table > tbody { display: block; min-width: 0; width: 100%; }
  [data-view="transactions"] .table-scroll > table > thead { display: none; }
}
