/* List cards and append controls only. Analysis matrices remain charts, not records. */
@media (max-width: 768px) {
    #analysisContent .analysis-table-scroll:has(.trend-matrix) { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: auto; }
    #analysisContent .analysis-table-scroll:has(.trend-matrix)::before { content: '左右滑动查看完整表格 →'; display: block; position: sticky; left: 0; width: max-content; padding: 5px 8px; color: #6683a6; font-size: 11px; background: #f5f8fc; }
    #analysisContent .trend-matrix .trend-draw-numbers { white-space: nowrap; }
    #main-content .mobile-card-table { display: block !important; width: 100% !important; min-width: 0 !important; max-width: 100% !important; border: 0 !important; background: transparent; table-layout: auto; }
    #main-content .mobile-card-table > colgroup { display: none; }
    #main-content .mobile-card-table thead, #main-content .mobile-card-table thead tr { display: flex; flex-wrap: wrap; width: 100%; height: auto; min-height: 0; border: 0; background: transparent; }
    #main-content .mobile-card-table thead th { display: none !important; }
    #main-content .mobile-card-table thead th.mobile-card-control { display: flex !important; align-items: center; width: auto !important; min-width: 0 !important; height: auto; padding: 4px 0 12px; border: 0; background: transparent; }
    #main-content .mobile-card-table .record-header-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
    #main-content .mobile-card-table thead button { min-height: 36px; height: auto; padding: 6px 10px; white-space: nowrap; border-radius: 6px; }
    #main-content .mobile-card-table tbody { display: grid; width: 100%; gap: 8px; }
    #main-content .mobile-card-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 8px; width: 100%; height: auto !important; min-height: 0; padding: 6px; box-sizing: border-box; border: 1px solid #e4ebf5; border-radius: 12px; background: #fff; box-shadow: 0 2px 8px #173e6b05; }
    #main-content .mobile-card-table tbody tr > td { display: flex !important; align-items: baseline; flex-wrap: wrap; gap: 0 5px; position: static !important; width: auto !important; min-width: 0 !important; max-width: 100% !important; height: auto !important; padding: 4px !important; border: 0 !important; box-sizing: border-box; font-size: 13px; line-height: 18px; text-align: left; white-space: normal !important; overflow-wrap: anywhere; }
    #main-content .mobile-card-table tbody td::before { content: attr(data-mobile-label); display: block; margin: 0; font-size: 10px; font-weight: 400; line-height: 18px; color: #8794a7; }
    #main-content .mobile-card-table tbody td.numbers-cell { grid-column: 1 / -1; padding-top: 7px !important; padding-bottom: 7px !important; border-top: 1px solid #f0f3f8 !important; border-bottom: 1px solid #f0f3f8 !important; }
    #main-content .mobile-card-table tbody .ball-row { display: flex !important; width: 100% !important; max-width: 100% !important; flex-wrap: wrap !important; justify-content: flex-start !important; gap: 5px !important; }
    #main-content .mobile-card-table:is([data-family=pk10],[data-family=ssc],[data-family=bingo]) tbody .ball-row { display: grid !important; width: auto !important; grid-template-columns: repeat(5, 25px); justify-items: center; gap: 4px !important; }
    #main-content .mobile-card-table[data-family=pk10] tbody td.numbers-cell { flex-wrap: nowrap; gap: 4px; }
    #main-content .mobile-card-table[data-family=pk10] tbody td.numbers-cell::before { flex: none; font-size: 9px; }
    #main-content .mobile-card-table[data-family=pk10] tbody .ball-row { flex: 1; min-width: 0; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 2px !important; }
    #main-content .mobile-card-table[data-family=pk10] tbody .numbers-cell .ball { width: 100%; max-width: 24px; min-width: 0; height: auto; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 10px; line-height: 1; }
    #main-content .mobile-card-table[data-family=bingo] tbody td.numbers-cell { flex-wrap: nowrap; gap: 4px; }
    #main-content .mobile-card-table[data-family=bingo] tbody td.numbers-cell::before { flex: none; font-size: 9px; }
    #main-content .mobile-card-table[data-family=bingo] tbody .ball-row { flex: 1; min-width: 0; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px 2px !important; }
    #main-content .mobile-card-table[data-family=bingo] tbody .numbers-cell .record-bingo-ball { width: 100% !important; max-width: 25px; min-width: 0 !important; height: auto !important; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 10px; line-height: 1; }
    #main-content .mobile-card-table:not(.lhc-history-table) tbody td.numbers-cell { align-items: center; gap: 4px 8px; padding: 5px 4px !important; }
    #main-content .mobile-card-table:not(.lhc-history-table) tbody td.numbers-cell .ball-row { width: auto !important; max-width: 100% !important; }
    #main-content .history-table:not(.lhc-history-table) tbody tr { grid-template-columns: repeat(6, minmax(0, 1fr)); column-gap: 0; }
    #main-content .history-table:not(.lhc-history-table) tbody tr > td { grid-column: span 2; }
    #main-content .history-table:not(.lhc-history-table) tbody td:first-child { grid-column: span 4; font-size: 12px; }
    #main-content .history-table:not(.lhc-history-table) tbody td:nth-child(2) { font-size: 11px !important; line-height: 18px; }
    #main-content .history-table:not(.lhc-history-table) tbody td.numbers-cell, #main-content .history-table:not(.lhc-history-table) tbody td.record-block { grid-column: 1 / -1; }
    #main-content .history-table[data-family=pk10] tbody td:nth-last-child(-n+2) { grid-column: span 3; }
    #main-content .history-table[data-family=bingo] tbody td:last-child { grid-column: 1 / -1; }
    #main-content .history-table[data-family=bingo] tbody tr { grid-template-columns: repeat(12, minmax(0, 1fr)); padding: 4px; }
    #main-content .history-table[data-family=bingo] tbody tr > td { grid-column: span 3; padding: 2px 3px !important; font-size: 12px; line-height: 17px; gap: 0 3px; }
    #main-content .history-table[data-family=bingo] tbody td:first-child { grid-column: span 8; }
    #main-content .history-table[data-family=bingo] tbody td:nth-child(2) { grid-column: span 4; }
    #main-content .history-table[data-family=bingo] tbody td.numbers-cell { grid-column: 1 / -1; padding: 3px !important; }
    #main-content .history-table[data-family=bingo] tbody td:last-child { grid-column: span 6; }
    #main-content .history-table[data-family=bingo] tbody td::before { font-size: 9px; line-height: 17px; }
    #main-content .history-table[data-family=ssc] tbody tr { grid-template-columns: repeat(12, minmax(0, 1fr)); padding: 4px; }
    #main-content .history-table[data-family=ssc] tbody tr > td { grid-column: span 3; padding: 2px 3px !important; font-size: 12px; line-height: 17px; gap: 0 3px; }
    #main-content .history-table[data-family=ssc] tbody td:first-child { grid-column: span 8; }
    #main-content .history-table[data-family=ssc] tbody td:nth-child(2) { grid-column: span 4; }
    #main-content .history-table[data-family=ssc] tbody td.numbers-cell { grid-column: 1 / -1; padding: 3px !important; }
    #main-content .history-table[data-family=ssc] tbody td::before { font-size: 9px; line-height: 17px; }
    #main-content .history-table[data-family=ssc] tbody .numbers-cell .ball { width: 22px; height: 22px; min-width: 22px; line-height: 22px; }
    #main-content .dividends-table tbody tr > td:first-child { order: 1; }
    #main-content .dividends-table tbody tr > td:nth-child(2) { order: 3; grid-column: 1 / -1; }
    #main-content .dividends-table tbody tr > td:nth-child(3) { order: 2; }
    #main-content .mobile-card-table tbody .numbers-cell .ball { width: 24px; height: 24px; min-width: 24px; font-size: 11px; line-height: 24px; }
    #main-content .mobile-card-table .numbers-cell .ball-wrapper { display: flex; flex: none; flex-direction: column; align-items: center; width: 24px; gap: 2px; }
    #main-content .mobile-card-table tbody .record-inline-values { justify-content: flex-start; flex-wrap: wrap; }
    #main-content .mobile-card-table .heat-ball-list { flex-wrap: wrap; gap: 8px; }
    #main-content .mobile-card-table .record-bingo-ball { width: 25px !important; height: 25px !important; min-width: 25px !important; }
    #main-content .history-table.mobile-card-table tbody td.numbers-cell:has(.cell-num .ball-other) { flex-wrap: nowrap; align-items: center; gap: 5px; }
    #main-content .history-table.mobile-card-table tbody td.numbers-cell:has(.cell-num .ball-other)::before { flex: none; }
    #main-content .history-table.mobile-card-table tbody .cell-num:has(.ball-other) { display: block; flex: 1; min-width: 0; padding: 2px 0; }
    #main-content .history-table.mobile-card-table tbody .cell-num:has(.ball-other) .ball-row { display: grid !important; width: 100% !important; max-width: 100% !important; grid-template-columns: repeat(10, minmax(0, 1fr)); justify-items: center; gap: 3px 2px !important; }
    #main-content .history-table.mobile-card-table tbody .cell-num .ball-other { width: 100%; max-width: 24px; min-width: 0; height: auto; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 10px; line-height: 1; }
    #main-content .lhc-history-table.mobile-card-table tbody tr { grid-template-columns: repeat(6, minmax(0, 1fr)); column-gap: 0; }
    #main-content .lhc-history-table.mobile-card-table tbody tr > td { grid-column: span 2; padding: 4px !important; }
    #main-content .lhc-history-table.mobile-card-table tbody td:first-child { grid-column: span 4; }
    #main-content .lhc-history-table.mobile-card-table tbody td:nth-child(-n+2) { display: flex !important; align-items: baseline; flex-wrap: wrap; gap: 0 5px; padding-top: 2px !important; padding-bottom: 4px !important; font-size: 12px; line-height: 18px; }
    #main-content .lhc-history-table.mobile-card-table tbody td:nth-child(-n+2)::before { margin: 0; line-height: 18px; }
    #main-content .lhc-history-table.mobile-card-table tbody td:first-child br { display: none; }
    #main-content .lhc-history-table.mobile-card-table tbody td.numbers-cell { grid-column: 1 / -1; grid-row: 2; display: flex !important; align-items: flex-start; gap: 4px; padding: 4px !important; }
    #main-content .lhc-history-table.mobile-card-table tbody td.numbers-cell::before, #main-content .lhc-history-table.mobile-card-table tbody td:nth-child(4)::before { flex: none; margin: 0; line-height: 24px; }
    #main-content .lhc-history-table.mobile-card-table tbody .numbers-cell .ball-row { flex: none; width: auto !important; gap: 3px !important; }
    #main-content .lhc-history-table.mobile-card-table tbody td:nth-child(4) { grid-column: 1 / -1; grid-row: 2; justify-self: start; margin-left: 190px; display: flex !important; align-items: flex-start; gap: 4px; padding: 4px !important; border: 0 !important; }
    #main-content .lhc-history-table.mobile-card-table tbody td:nth-child(4) .ball-wrapper { display: flex; flex-direction: column; align-items: center; width: 24px; gap: 2px; }
    #main-content .lhc-history-table.mobile-card-table tbody td:nth-child(4) .ball { width: 24px; height: 24px; min-width: 24px; font-size: 11px; line-height: 24px; }
    #main-content .lhc-history-table.mobile-card-table tbody .zodiac { height: 16px; line-height: 16px; font-size: 11px; margin: 0; }
    #main-content .lhc-history-table.mobile-card-table tbody td:nth-child(n+5) { display: flex !important; align-items: baseline; flex-wrap: wrap; gap: 0 5px; }
    #main-content .lhc-history-table.mobile-card-table tbody td:nth-child(n+5)::before { margin: 0; font-size: 10px; line-height: 18px; }
    #main-content .mobile-card-table tbody tr > td.mobile-card-state { grid-column: 1 / -1 !important; justify-content: center; text-align: center; color: #8794a7; padding: 24px 12px !important; }
    #main-content .mobile-card-table .mobile-card-state::before { content: none; }
    #main-content .mobile-card-table tr.mobile-card-later { display: none !important; }
    #main-content .dragon-table-scroll { overflow: visible; }
    #main-content .dragon-table.mobile-card-table { box-shadow: none; }
    #main-content .dragon-table.mobile-card-table tbody { gap: 6px; }
    #main-content .dragon-table.mobile-card-table tbody tr { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0 4px; padding: 4px; }
    #main-content .dragon-table.mobile-card-table tbody tr > td { padding: 2px 3px !important; align-items: center; font-size: 12px; line-height: 18px; }
    #main-content .dragon-table.mobile-card-table tbody td:first-child { order: 1; grid-column: span 3; font-weight: 600; }
    #main-content .dragon-table.mobile-card-table tbody td:nth-child(2) { order: 2; grid-column: span 2; }
    #main-content .dragon-table.mobile-card-table tbody td:nth-child(3) { order: 3; grid-column: span 1; justify-content: flex-end; }
    #main-content .dragon-table.mobile-card-table tbody td:nth-child(3)::before { content: none; }
    #main-content .dragon-table.mobile-card-table tbody td:nth-child(n+4) { order: 4; grid-column: span 3; flex-wrap: nowrap; }
    #main-content .dragon-table.mobile-card-table tbody td a { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 0 7px; border-radius: 5px; color: #347de0; background: #edf5ff; }
    #main-content .dragon-table.mobile-card-table .dragon-streak { padding: 2px 6px; font-size: 12px; line-height: 18px; white-space: nowrap; }
    #main-content .prediction-shell-results:has(.mobile-card-table), #main-content .prediction-plan-panel:has(.mobile-card-table) { padding: 12px; overflow: visible; }
    #main-content #predictionShellRows > tr { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0 4px; padding: 4px; }
    #main-content #predictionShellRows > tr > td { grid-column: span 2; padding: 2px 4px !important; font-size: 12px; line-height: 18px; }
    #main-content #predictionShellRows > tr > td:first-child { grid-column: span 4; grid-row: 1; align-items: center; font-weight: 600; font-size: 14px; }
    #main-content #predictionShellRows > tr > td:first-child img { display: inline-block; width: 22px; height: 22px; vertical-align: middle; border-radius: 50%; margin-right: 2px; }
    #main-content #predictionShellRows > tr > td:nth-child(5) { grid-column: 1 / -1; align-items: baseline; gap: 0 5px; }
    #main-content #predictionShellRows .prediction-last-code { font-size: 11px; line-height: 18px; }
    #main-content #predictionShellRows > tr > td:last-child { grid-column: 5 / -1; grid-row: 1; flex-wrap: nowrap; align-items: center; justify-self: end; min-width: 60px !important; }
    #main-content #predictionShellRows > tr > td:last-child::before { content: none; }
    #main-content #predictionShellRows > tr > td:last-child a { display: flex; width: 100%; min-height: 32px; padding: 0 12px; box-sizing: border-box; justify-content: center; align-items: center; background: #edf5ff; color: #347de0; border-radius: 6px; }
    #detailHistory .history-table-wrapper { overflow: visible; border: 0; box-shadow: none; background: transparent; }
    #detailHistory .history-scroll-hint { display: none !important; }
    #lhcSpecialPanel, .prediction-plan-statistics { overflow: visible !important; }
    body.reference-embedded:has(.embed-history) #main-content { height: 100dvh; overflow-y: auto; }
    .mobile-list-more, .mobile-card-more, .mobile-history-loader, .prediction-load-more, .articles-load-more { display: block; width: 100%; min-height: 44px; margin: 12px 0; padding: 12px; box-sizing: border-box; border: 1px solid #dce8f8; border-radius: 10px; color: #347de0; background: #edf5ff; font: inherit; font-size: 14px; cursor: pointer; }
    .mobile-list-more:disabled, .mobile-card-more:disabled { color: #99a5b5; background: #f5f7fa; border-color: #edf1f5; cursor: default; }
    #main-content .mobile-history-loader { width: calc(100% - 24px); margin: 12px; }
    .record-live-pagination { display: none !important; }
    .record-live-more { margin: 12px; }
    .record-live-more .mobile-list-more { color: #fff; background: #1d84d8; border-color: #1d84d8; }
    .record-live-more .mobile-list-more:disabled { color: #94a3b8; background: #f3f6fa; border-color: #dce3ed; }
    .forum-card, .mine-card, .articles-card { background: transparent; }
    .forum-list, #forumList, #mineBody, #articlesBody, .fc-list { display: grid; gap: 8px; }
    #forumList .fp-item, #mineBody .mine-item, .fc-list .fc-item, #articlesBody .article-card-item, .ranking-entry { margin: 0; padding: 10px; border: 1px solid #e4ebf5; border-radius: 10px; background: #fff; box-sizing: border-box; }
    #articlesBody .article-card-item { display: flex; gap: 8px; }
    #forumList .fp-title, #mineBody .mine-title, #articlesBody .article-card-title { font-size: 14px; line-height: 20px; }
    #forumList .fp-head { margin-bottom: 4px; gap: 4px; }
    #forumList .fp-summary, #articlesBody .article-card-summary { margin: 4px 0; font-size: 12px; line-height: 18px; }
    #forumList .fp-meta, #mineBody .mine-meta, #articlesBody .article-card-meta { margin-top: 4px; font-size: 11px; line-height: 18px; gap: 4px 8px; }
    #articlesBody .article-list-thumb, #articlesBody .article-list-placeholder { width: 64px; height: 56px; flex: 0 0 64px; }
    #forumPager, #minePager { display: block; padding: 0 12px; }
    .ranking-entry { margin-bottom: 10px; }
    .simple-row { margin: 10px; border: 1px solid #e4ebf5; border-radius: 12px; }
    .simplicity-layout .simple-row { grid-template-columns: repeat(6, minmax(0, 1fr)); min-height: 0; padding: 8px; gap: 4px; margin: 6px 10px; }
    .simplicity-layout .simple-row > * { grid-column: 1 / -1; }
    .simplicity-layout .simple-lottery { gap: 6px; }
    .simplicity-layout .simple-lottery img, .simplicity-layout .simple-logo-fallback { width: 28px; height: 28px; }
    .simplicity-layout .simple-lottery p { display: inline; margin: 0 6px 0 0; font-size: 10px; line-height: 15px; }
    .simplicity-layout .simple-lottery strong { display: block; font-size: 13px; line-height: 18px; }
    .simplicity-layout .simple-codes .ball { width: 22px; height: 22px; min-width: 22px; font-size: 11px; line-height: 22px; }
    .simplicity-layout .simple-summary { display: flex; flex-wrap: wrap; gap: 3px; font-size: 11px; line-height: 18px; }
    .simplicity-layout .simple-row[data-family=ssc] .simple-codes { grid-column: span 4; }
    .simplicity-layout .simple-row[data-family=ssc] .simple-summary { grid-column: span 2; align-self: center; }
    .simplicity-layout .simple-time { gap: 3px 6px; }
    .simplicity-layout .simple-time > span { font-size: 10px; line-height: 18px; }
    .simplicity-layout .simple-time > strong { font-size: 16px; line-height: 20px; }
    .simplicity-layout .simple-time .simple-analysis { width: auto; gap: 4px; }
    .simplicity-layout .simple-row .simple-analysis a { min-height: 28px; padding: 3px 6px; font-size: 11px; }
    .reference-trend-hub .trend-hub-entries { gap: 8px; margin-top: 8px; }
    .reference-trend-hub .trend-lottery-entry { grid-template-columns: minmax(0, 1fr); min-height: 0; gap: 6px; padding: 10px; border-left-width: 3px; border-radius: 10px; }
    .reference-trend-hub .trend-lottery-entry header { flex-direction: row; justify-content: flex-start; gap: 6px; padding: 0; font-size: 13px; }
    .reference-trend-hub #trendHubEntries .trend-lottery-entry header .trend-entry-brand { display: inline-flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 6px; margin: 0; font-size: 13px; color: #444; }
    .reference-trend-hub .trend-lottery-entry header img { width: 28px; height: 28px; }
    .reference-trend-hub #trendHubEntries .trend-lottery-entry > .trend-entry-links { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 4px 8px; padding: 0; }
    .reference-trend-hub .trend-entry-links > div { display: contents; }
    .reference-trend-hub .trend-lottery-entry > .trend-entry-links a { display: inline-flex; align-items: center; min-height: 28px; font-size: 12px; line-height: 18px; padding: 0 4px; border-radius: 4px; background: #f5f8fd; }
}

/* Keep embedded history cards inside the mobile viewport. */
@media(max-width:768px){body.reference-embedded .embed-history{box-sizing:border-box;width:100%;min-width:0;max-width:100%}body.reference-embedded .embed-history header{height:auto;min-height:20px;gap:8px;flex-wrap:wrap}body.reference-embedded .embed-history header>span{padding-right:0}body.reference-embedded .embed-history header button{position:static;flex:none}body.reference-embedded .embed-history .mobile-card-table tbody td:nth-child(3){grid-column:1/-1}}
@media(max-width:768px){
    .reference-home #homeLotteryGrid .lottery-card:is([data-code=bingo],[data-code=canada_keno]) .ball-row { display:grid; grid-template-columns:repeat(10,minmax(0,1fr)); width:100%; max-width:340px; gap:5px 3px; justify-items:center; }
    .reference-home #homeLotteryGrid .lottery-card:is([data-code=bingo],[data-code=canada_keno]) .ball { width:100%; max-width:28px; min-width:0; height:auto; aspect-ratio:1; display:flex; align-items:center; justify-content:center; font-size:11px; line-height:1; }
}
@media(max-width:768px){
    .lhc-analysis-body #lhcSelectionPanel #lhcSelectionInput { height:160px; min-height:160px; line-height:24px; resize:vertical; }
}
