/* Thai lottery board, payout calculator and dashboard.
   Designed for an iPad held in landscape (1024-1194 x ~740 usable): the board
   and its editor sit side by side and the 10x10 grid fits without scrolling.
   Touch first: 44px targets, nothing hover-only. Phones get a stacked fallback. */
.player-main:has(> .lot), .player-main:has(.lot) { max-width: 1240px; padding: 12px 16px 24px; }
.lot { font-size: 15px; font-variant-numeric: tabular-nums; }
.lot [hidden] { display: none !important; }
/* style.css sets a global `table { min-width: 760px }`; these tables live in cards. */
.lot table { min-width: 0; }
.lot th { text-transform: none; letter-spacing: normal; }
.lot h2 { margin: 0 0 6px; font-size: 1rem; }
.lot h3 { margin: 0 0 6px; font-size: .85rem; color: var(--ads-muted); font-weight: 600; }

/* Header + tabs */
.lot-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 10px; }
.lot-title h1 { margin: 0; font-size: 1.3rem; }
.lot-title h1 span { font-size: .9rem; font-weight: 500; color: var(--ads-muted); margin-left: 6px; }
.lot-tabs { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--ads-surface); border: 1px solid var(--ads-line); }
.lot-tabs a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 18px; border-radius: 9px; color: var(--ads-muted); text-decoration: none; font-weight: 600; }
.lot-tabs a[aria-current="page"] { background: var(--ads-surface-2); color: var(--ads-text); box-shadow: inset 0 0 0 1px var(--ads-line); }
.lot-flash { margin: 0 0 0 auto; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--ads-success-line); background: var(--ads-success-soft); }
.lot-flash.is-error { border-color: var(--ads-danger-line); background: var(--ads-danger-soft); }
.lot-denied, .lot-loading, .lot-empty { padding: 14px; border: 1px solid var(--ads-line); border-radius: 10px; background: var(--ads-surface); }

/* Controls */
.lot-btn { min-height: 44px; padding: 0 16px; font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid var(--ads-line); background: var(--ads-surface-2); color: var(--ads-text); cursor: pointer; touch-action: manipulation; }
.lot-btn:disabled { opacity: .45; cursor: default; }
.lot-btn-primary { background: var(--ads-blue-strong); border-color: var(--ads-blue-strong); color: #fff; }
.lot-btn-warn { border-color: var(--ads-warning-line); color: var(--ads-warning); }
.lot-btn-wide { width: 100%; }
.lot-field { display: grid; gap: 4px; font-size: .8rem; color: var(--ads-muted); }
.lot-field input, .lot-field select { min-height: 44px; padding: 0 12px; font: inherit; font-size: 16px; color: var(--ads-text); background: var(--ads-bg); border: 1px solid var(--ads-line); border-radius: 10px; }
.lot-field input:focus, .lot-field select:focus { outline: none; box-shadow: var(--ads-focus); }
.lot-check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.lot-check input { width: 26px; height: 26px; accent-color: var(--ads-success); }
.lot-hint { margin: 4px 0 0; font-size: .8rem; color: var(--ads-muted); }
.lot-card { background: var(--ads-surface); border: 1px solid var(--ads-line); border-radius: 14px; padding: 14px; min-width: 0; }

/* Draw bar */
.lot-drawbar { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-bottom: 10px; }
.lot-drawbar .lot-field select { min-width: 0; max-width: 240px; }
.lot-drawbar .lot-field input { max-width: 170px; }
.lot-spacer { flex: 1; }
.lot-status { align-self: center; padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: .85rem; }
.lot-status.is-open { background: var(--ads-success-soft); color: var(--ads-success); }
.lot-status.is-closed { background: var(--ads-warning-soft); color: var(--ads-warning); }
.lot-status.is-settled { background: var(--ads-status-unknown-soft); color: var(--ads-muted); }
.lot-close { align-self: center; color: var(--ads-muted); font-size: .85rem; }

/* Board */
.lot-board-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 14px; align-items: start; }
.lot-grid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); grid-template-rows: repeat(10, 1fr); gap: 4px; height: clamp(470px, calc(100dvh - 230px), 640px); }
.lot-cell { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; min-width: 0; padding: 2px 3px; border-radius: 8px; border: 1px solid var(--ads-line); background: var(--ads-surface); color: var(--ads-text); font: inherit; cursor: pointer; touch-action: manipulation; overflow: hidden; }
.lot-cell b { font-size: 1.15rem; line-height: 1.1; letter-spacing: .04em; }
.lot-cell small { display: block; max-width: 100%; font-size: .68rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ads-muted); }
.lot-cell.is-unpaid { border: 2px solid var(--ads-danger); }
.lot-cell.is-paid { background: var(--ads-success-soft); border: 2px solid var(--ads-success); }
.lot-cell.is-blocked { background: var(--ads-surface-2); border-color: transparent; color: var(--ads-muted-2); opacity: .45; }
.lot-cell.is-blocked b { text-decoration: line-through; }
.lot-cell.is-win { box-shadow: 0 0 0 3px var(--ads-gold); }
.lot-cell[aria-selected="true"] { box-shadow: 0 0 0 3px var(--ads-accent); z-index: 1; }
.lot-cell.is-paid small.lot-paid-mark { color: var(--ads-success); }

.lot-side { display: grid; gap: 10px; }
.lot-editor { display: grid; gap: 8px; }
.lot-editor-head { display: flex; align-items: center; gap: 12px; }
.lot-editor-num { font-size: 2.4rem; font-weight: 800; letter-spacing: .05em; line-height: 1; }
.lot-editor-state { color: var(--ads-muted); font-weight: 600; }
.lot-editor-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 4px; }
.lot-editor-more { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 10px; border-top: 1px solid var(--ads-line); }
/* Buyer popup, centred over the board; sized for iPad landscape (keyboard pushes it up) */
.lot-dialog { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 18px; color: var(--ads-text); background: var(--ads-surface); border: 1px solid var(--ads-line); border-radius: 16px; box-shadow: var(--ads-shadow); }
.lot-dialog::backdrop { background: rgba(3, 8, 18, .6); }
.lot-dialog .lot-editor-head { margin-bottom: 4px; }
.lot-dialog-x { margin-left: auto; width: 44px; height: 44px; font-size: 1.6rem; line-height: 1; color: var(--ads-muted); background: none; border: 0; border-radius: 10px; cursor: pointer; }
.lot-dialog .lot-check { font-size: 1.05rem; }
.lot-check-quiet { font-weight: 500; color: var(--ads-muted); }
.lot-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lot-kpis div { padding: 8px; border-radius: 10px; background: var(--ads-bg); }
.lot-kpis span { display: block; font-size: .72rem; color: var(--ads-muted); }
.lot-kpis strong { font-size: 1.1rem; }
.lot-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 0; padding: 0; list-style: none; font-size: .78rem; color: var(--ads-muted); }
.lot-legend i { display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; border-radius: 4px; border: 1px solid var(--ads-line); }
.lot-legend .is-free { background: var(--ads-surface); }
.lot-legend .is-unpaid { border: 2px solid var(--ads-danger); }
.lot-legend .is-paid { background: var(--ads-success-soft); border: 2px solid var(--ads-success); }
.lot-legend .is-blocked { background: var(--ads-surface-2); opacity: .45; }

/* Payout */
.lot-payout-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr) minmax(0, 1.1fr); gap: 14px; align-items: start; }
.lot-calc { display: grid; gap: 12px; }
.lot-calc form { display: grid; gap: 10px; }
.lot-result-input { font-size: 2.6rem !important; font-weight: 800; text-align: center; letter-spacing: .2em; min-height: 76px !important; }
.lot-settle { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--ads-line); }
.lot-settled-note { margin: 0; font-weight: 600; }
.lot-result-empty { margin: 30px 0; text-align: center; color: var(--ads-muted); }
.lot-result-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.lot-result-num { flex: none; display: grid; place-items: center; min-width: 84px; padding: 0 14px; height: 84px; border-radius: 16px; background: var(--ads-surface-2); border: 2px solid var(--ads-gold); font-size: 2rem; font-weight: 800; white-space: nowrap; }
.lot-result-who { margin: 0; font-size: 1.25rem; font-weight: 700; }
.lot-result-why { margin: 4px 0 0; color: var(--ads-muted); }
.lot-sum { width: 100%; border-collapse: collapse; margin-top: 8px; }
.lot-sum th { text-align: left; font-weight: 500; color: var(--ads-muted); padding: 7px 0; }
.lot-sum td { text-align: right; padding: 7px 0; font-weight: 600; }
.lot-sum tr + tr th, .lot-sum tr + tr td { border-top: 1px solid var(--ads-line); }
.lot-sum-total th, .lot-sum-total td { color: var(--ads-text); font-size: 1.15rem; font-weight: 800; }
.lot-sum-draw { margin-top: 18px; }
.is-loss { color: var(--ads-danger) !important; }
.is-gain { color: var(--ads-success) !important; }

/* Tables */
.lot-table-wrap { overflow-x: auto; max-height: 560px; overflow-y: auto; }
.lot-table { width: 100%; border-collapse: collapse; }
.lot-table th, .lot-table td { padding: 8px 6px; border-bottom: 1px solid var(--ads-line); text-align: left; white-space: nowrap; }
.lot-table thead th { position: sticky; top: 0; background: var(--ads-surface); font-size: .75rem; color: var(--ads-muted); font-weight: 600; }
.lot-table td.num, .lot-table th.num { text-align: right; }
.lot-table tr.is-win td { background: rgba(251, 191, 36, .12); }

/* Dashboard */
.lot-dash { display: grid; gap: 14px; }
.lot-tiles { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 12px; }
.lot-tile { padding: 14px; border-radius: 14px; background: var(--ads-surface); border: 1px solid var(--ads-line); }
.lot-tile span { display: block; font-size: .75rem; color: var(--ads-muted); }
.lot-tile strong { display: block; margin-top: 4px; font-size: 1.5rem; }
.lot-tile-hero strong { font-size: 2rem; }
.lot-tile em { display: block; font-style: normal; font-size: .75rem; color: var(--ads-muted); }
.lot-dash-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 14px; align-items: stretch; }
.lot-settings { display: grid; gap: 10px; align-content: start; }
.lot-settings-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.lot-switch { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 600; cursor: pointer; }
.lot-switch small { display: block; font-weight: 400; font-size: .75rem; color: var(--ads-muted); }
.lot-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.lot-switch-track { flex: none; position: relative; width: 52px; height: 30px; border-radius: 999px; background: var(--ads-surface-2); border: 1px solid var(--ads-line); transition: background .15s; }
.lot-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ads-muted); transition: transform .15s, background .15s; }
.lot-switch input:checked + .lot-switch-track { background: var(--ads-success-soft); border-color: var(--ads-success-line); }
.lot-switch input:checked + .lot-switch-track::after { transform: translateX(22px); background: var(--ads-success); }
.lot-switch input:focus-visible + .lot-switch-track { box-shadow: var(--ads-focus); }
.lot-winners { width: 100%; margin-top: 4px; }
.lot-winners td small { display: block; color: var(--ads-muted); font-size: .75rem; }
.lot-owed-list { list-style: none; margin: 0; padding: 0; max-height: 230px; overflow-y: auto; }
.lot-owed-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--ads-line); }
.lot-owed-list li small { display: block; color: var(--ads-muted); font-size: .75rem; }

.lot-verdict { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--ads-bg); border-left: 3px solid var(--ads-accent); }
.lot-stats-layout { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 18px; }
.lot-heat { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.lot-heat button { aspect-ratio: 1; display: grid; place-items: center; padding: 0; font: inherit; font-size: .78rem; font-weight: 600; border: 0; border-radius: 4px; cursor: pointer; touch-action: manipulation; }
.lot-heat button[aria-pressed="true"] { outline: 2px solid var(--ads-text); outline-offset: 1px; }
.lot-heat-caption { min-height: 2.4em; }
.lot-stats-lists { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.lot-rank { margin: 0; padding: 0; list-style: none; font-size: .9rem; }
.lot-rank li { display: flex; justify-content: space-between; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--ads-line); }
.lot-rank b { letter-spacing: .05em; }
.lot-rank span { color: var(--ads-muted); font-size: .8rem; }
.lot-digits { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 18px; margin-top: 16px; }
.lot-bars { display: grid; gap: 3px; }
.lot-bar { display: grid; grid-template-columns: 16px minmax(0, 1fr) 44px; align-items: center; gap: 8px; font-size: .8rem; }
.lot-bar i { display: block; height: 14px; border-radius: 0 4px 4px 0; background: var(--ads-accent-2); }
.lot-bar span { color: var(--ads-muted); text-align: right; }
.lot-recent { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0; padding: 0; list-style: none; }
.lot-recent li { padding: 6px; border-radius: 8px; background: var(--ads-bg); text-align: center; }
.lot-recent b { display: block; font-size: 1.1rem; }
.lot-recent small { color: var(--ads-muted); font-size: .7rem; }

/* Three-digit board: hundreds strip above the 10x10 grid */
.lot-board-main { min-width: 0; }
.lot-board-main.has-hundreds .lot-grid { height: clamp(420px, calc(100dvh - 290px), 580px); }
.lot-board-main.has-hundreds .lot-cell b { font-size: 1rem; }
.lot-hundreds-bar { display: flex; gap: 8px; margin-bottom: 6px; }
.lot-hundreds { flex: 1; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.lot-hundreds button { min-height: 48px; padding: 2px; font: inherit; font-weight: 700; color: var(--ads-muted); background: var(--ads-surface); border: 1px solid var(--ads-line); border-radius: 8px; cursor: pointer; touch-action: manipulation; line-height: 1.1; }
.lot-hundreds button small { display: block; font-size: .65rem; font-weight: 500; }
.lot-hundreds button[aria-selected="true"] { color: var(--ads-text); background: var(--ads-surface-2); box-shadow: inset 0 0 0 2px var(--ads-accent); }
.lot-goto input { width: 104px; min-height: 48px; padding: 0 10px; font: inherit; font-size: 16px; color: var(--ads-text); background: var(--ads-bg); border: 1px solid var(--ads-line); border-radius: 8px; }
.lot-result-pair { display: grid; grid-template-columns: 1fr 1.25fr; gap: 8px; }
.lot-result-pair .lot-result-input { font-size: 2rem !important; letter-spacing: .12em; min-height: 64px !important; padding: 0 6px; }
.lot-stats3 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1.2fr; gap: 16px; }
.lot-recent-2col { grid-template-columns: repeat(2, 1fr); }

/* Standing rules */
.lot-checks { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.lot-kept-mark { color: var(--ads-accent); margin-right: 6px; }
.lot-cell .lot-kept-mark { position: absolute; top: 2px; right: 4px; margin: 0; font-size: .75rem; }
.lot-cell.is-permanent b { text-decoration: line-through; }
.lot-standing-row { grid-template-columns: 1fr 1fr; }
.lot-add-block { display: flex; gap: 8px; margin: 8px 0; }
.lot-add-block input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; font: inherit; font-size: 16px; color: var(--ads-text); background: var(--ads-bg); border: 1px solid var(--ads-line); border-radius: 10px; }
.lot-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.lot-chips li { display: inline-flex; align-items: center; gap: 4px; padding-left: 12px; border-radius: 999px; background: var(--ads-surface-2); border: 1px solid var(--ads-line); font-weight: 700; letter-spacing: .05em; }
.lot-chips button, .lot-owed-list button.lot-x { min-width: 40px; min-height: 40px; font: inherit; font-size: 1.1rem; color: var(--ads-muted); background: none; border: 0; border-radius: 999px; cursor: pointer; }

/* Automatic results + authorisation */
.lot-auto { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; padding: 10px; border-radius: 10px; background: var(--ads-bg); border: 1px solid var(--ads-line); }
.lot-auto-badge { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ads-muted); }
.lot-auto-text { grid-column: 1 / -1; font-size: .85rem; }
.lot-auto[data-state="agreed"] { border-color: var(--ads-success-line); }
.lot-auto[data-state="agreed"] .lot-auto-badge { color: var(--ads-success); }
.lot-auto[data-state="disagree"], .lot-auto[data-state="partial"] { border-color: var(--ads-warning-line); }
.lot-btn-small { min-height: 36px; padding: 0 10px; font-size: .8rem; }
.lot-auth-state { margin: 0 0 10px; padding: 6px 10px; border-radius: 8px; font-weight: 700; font-size: .85rem; background: var(--ads-warning-soft); color: var(--ads-warning); }
.lot-auth-state.is-authorised { background: var(--ads-success-soft); color: var(--ads-success); }
/* Recommendations */
.lot-recs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lot-rec-list { list-style: none; margin: 0; padding: 0; }
.lot-rec-list li { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--ads-line); }
.lot-rec-list b { font-size: 1.15rem; letter-spacing: .05em; }
.lot-rec-list small { color: var(--ads-muted); font-size: .78rem; }
.lot-heat button.is-rec-block { box-shadow: inset 0 0 0 2px var(--ads-warning); }
.lot-heat button.is-perm-block { text-decoration: line-through; opacity: .55; }

/* This draw: six headline figures per board + combined */
.lot-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.lot-draw-kpis { display: grid; gap: 8px; }
.lot-draw-kpis-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.lot-draw-kpis-head h2 { margin: 0; font-size: 1.15rem; }
.lot-field-inline select { min-width: 220px; }
.lot-kpi-panels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.lot-kpi-panel { padding: 12px 14px; border-radius: 14px; background: var(--ads-surface); border: 1px solid var(--ads-line); }
.lot-kpi-panel.is-combined { border: 2px solid var(--ads-accent); background: var(--ads-surface-2); }
.lot-kpi-panel h3 { margin: 0 0 8px; font-size: .95rem; color: var(--ads-text); }
.lot-kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.lot-kpi-grid > div { padding: 8px 10px; border-radius: 10px; background: var(--ads-bg); min-width: 0; }
.lot-kpi-grid dt { font-size: .72rem; color: var(--ads-muted); }
.lot-kpi-grid dd { margin: 2px 0 0; font-size: 1.45rem; font-weight: 800; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lot-kpi-grid dd small { font-size: .7rem; font-weight: 600; color: var(--ads-muted); margin-right: 3px; }
.lot-kpi-grid-side dd { font-size: 1.1rem; }
.lot-tile span [data-ccy] { display: inline; }
.lot-panel-note { margin: 6px 0 0; font-size: .75rem; color: var(--ads-muted); }
.lot-dash-row-2 { grid-template-columns: 1.2fr 1fr; }

/* Smaller iPads in landscape (1024 wide) */
@media (max-width: 1100px) {
  .lot-board-layout { grid-template-columns: minmax(0, 1fr) 240px; }
  .lot-payout-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .lot-exposure { grid-column: 1 / -1; }
  .lot-stats-layout { grid-template-columns: 360px minmax(0, 1fr); }
  .lot-stats-lists { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lot-stats3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lot-kpi-grid dd { font-size: 1.25rem; }
  .lot-kpi-grid-side { gap: 6px; }
  .lot-kpi-grid-side > div { padding: 6px 8px; }
  .lot-kpi-grid-side dd { font-size: .95rem; }
  .lot-kpi-grid-side dd small { font-size: .6rem; margin-right: 2px; }
}
/* Portrait tablets and phones: stack. */
@media (max-width: 860px) {
  .lot-board-layout, .lot-payout-layout, .lot-dash-row, .lot-stats-layout, .lot-digits, .lot-stats3, .lot-recs, .lot-kpi-panels { grid-template-columns: 1fr; }
  .lot-hundreds { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .lot-grid { height: auto; grid-template-rows: none; grid-auto-rows: 56px; }
  .lot-tiles { grid-template-columns: repeat(2, 1fr); }
  .lot-tile-hero { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  .lot-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .lot-tabs a { padding: 0 12px; }
}
.lot-sum th small { margin-left: 8px; font-weight: 500; }
