:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #202b27;
  background: #f6f7f6;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button:focus-visible, input:focus-visible + span { outline: 2px solid #276c52; outline-offset: 2px; }

.app-shell { max-width: 1120px; margin: auto; padding: 0 28px 26px; }
.page-header { padding: 30px 0 20px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: 1.8rem; font-weight: 700; letter-spacing: -.035em; line-height: 1.2; }
.panel { margin-bottom: 18px; padding: 24px 28px; border: 1px solid #e0e5e1; border-radius: 10px; background: #fff; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; }
h2 { margin: 0; font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; }
.text-button { padding: 6px 0; border: 0; background: none; color: #496157; font-size: .85rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.text-button:disabled { color: #aaa99f; text-decoration: none; }
.selected-cards { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 11px; margin-top: 23px; }
.selected-card, .empty-card { position: relative; display: grid; place-items: center; min-width: 0; height: 100px; border-radius: 10px; }
.selected-card { border: 1px solid #cbd6ce; background: #fff; }
.selected-card:hover { border-color: #8aa998; }
.selected-card .card-chip { font-size: clamp(1.55rem, 2.7vw, 2.35rem); }
.empty-card { border: 1.5px dashed #cbd3cc; background: #fafbfa; color: #a6b0a8; font-size: .85rem; font-weight: 700; }
.remove-mark { position: absolute; top: 6px; right: 9px; color: #a0aa9e; font-size: 1.15rem; line-height: 1; }
.helper { margin: 16px 0 23px; color: #6d7e74; font-size: .86rem; }
.card-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; padding: 24px; border: 1px solid #e1e7e2; border-radius: 8px; background: #f8faf8; }
.suit-group { min-width: 0; }
.suit-heading { margin: 0 0 10px; font-size: .84rem; font-weight: 800; }
.red { color: #bd5748; }
.black { color: #223c36; }
.rank-grid { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 3px; }
.rank-button { display: grid; place-items: center; min-width: 0; height: 32px; padding: 0; border: 1px solid #dce2dc; border-radius: 4px; background: #fff; font-size: .75rem; font-weight: 750; }
.rank-button:hover:not(:disabled) { border-color: #9cad9d; background: #eef4e9; }
.rank-button.chosen { border-color: #204b3a; background: #204b3a; color: #fff; }
.rank-button:disabled:not(.chosen) { opacity: .44; }
.input-footer { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-top: 24px; }
.dealer-field { margin: 0; padding: 0; border: 0; }
.dealer-field legend { margin-bottom: 9px; color: #667a6f; font-size: .8rem; font-weight: 700; }
.segmented-control { display: inline-flex; padding: 3px; border: 1px solid #dce3d9; border-radius: 8px; background: #f1f3ed; }
.segmented-control label { position: relative; }
.segmented-control input { position: absolute; opacity: 0; }
.segmented-control span { display: block; padding: 10px 15px; border-radius: 5px; color: #65796f; font-size: .83rem; font-weight: 750; white-space: nowrap; cursor: pointer; }
.segmented-control input:checked + span { background: #214d3d; color: #fff; }
.primary-button { min-height: 44px; padding: 11px 22px; border: 1px solid #214d3d; border-radius: 6px; background: #214d3d; color: #fff; font-size: .88rem; font-weight: 700; }
.primary-button:hover:not(:disabled) { background: #173d30; }
.primary-button:disabled { border-color: #e0e4e0; background: #ecefec; color: #9ca89d; }
.results-head { align-items: center; }
.result-count { color: #66796d; font-size: .8rem; font-weight: 600; }
.results-description { max-width: 700px; margin: 12px 0 20px; color: #718076; font-size: .85rem; line-height: 1.55; }
.status { display: grid; place-items: center; min-height: 110px; border: 1px dashed #d9dfd4; border-radius: 8px; background: #fafbf7; color: #728077; font-size: .91rem; text-align: center; }
.progress-wrap { height: 5px; overflow: hidden; margin-top: 10px; border-radius: 100px; background: #e6e9de; }
.progress-bar { height: 100%; width: 0; background: #35735a; transition: width .15s ease; }
.table-wrap { overflow-x: auto; border: 1px solid #e5e9df; border-radius: 9px; }
table { width: 100%; border-collapse: collapse; }
thead { background: #f1f4ed; }
th { padding: 13px 12px; color: #53675a; font-size: .72rem; font-weight: 800; line-height: 1.3; text-align: left; white-space: nowrap; }
th span { display: block; font-weight: 500; }
th.number, td.number { text-align: right; }
td { padding: 12px; border-top: 1px solid #e9eee6; font-size: .84rem; white-space: nowrap; }
tbody tr:hover { background: #f8faf6; }
.best-row { background: #f4f8f0; }
.best-row:hover { background: #eff6e9; }
.keep-content, .card-group { display: inline-flex; align-items: center; gap: 4px; }
.keep-content { gap: 10px; }
.row-rank { min-width: 19px; color: #a5ada2; font-size: .71rem; font-weight: 800; }
.best-row .row-rank { color: #43835f; }
.card-chip { font-family: Georgia, "Times New Roman", serif; font-weight: 700; white-space: nowrap; }
.card-chip.small { display: inline-grid; place-items: center; min-width: 27px; height: 34px; padding: 0 3px; border: 1px solid #dce4d9; border-radius: 4px; background: #fff; font-size: 1.04rem; }
.crib-value { color: #7c6a56; }
.total-heading, .total-value { background: #eaf0e5; color: #28523d; font-weight: 850; }
.best-row .total-value { color: #16653c; }
.result-note { margin: 14px 0 0; color: #748078; font-size: .77rem; line-height: 1.5; }

@media (max-width: 880px) {
  .card-picker { grid-template-columns: 1fr; }
  .rank-button { height: 38px; font-size: .84rem; }
}

@media (max-width: 700px) {
  .app-shell { padding: 0 13px 20px; }
  .page-header { padding: 22px 5px 17px; }
  h1 { font-size: 1.5rem; }
  .panel { padding: 22px 18px; border-radius: 12px; }
  h2 { font-size: 1.15rem; }
  .selected-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 20px; }
  .selected-card, .empty-card { height: 88px; }
  .selected-card .card-chip { font-size: 2rem; }
  .card-picker { gap: 18px; padding: 16px; }
  .rank-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
  .rank-button { height: 34px; }
  .input-footer { align-items: stretch; flex-direction: column; }
  .primary-button { justify-content: center; width: 100%; }
  .results-description { margin-bottom: 17px; }
  .table-wrap { overflow: visible; border: 0; }
  table, tbody { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-bottom: 11px; padding: 12px 13px; border: 1px solid #e4eade; border-radius: 9px; background: #fff; }
  tbody tr.best-row { border-color: #b8d0b5; background: #f4f8f0; }
  td, td.number { display: block; min-width: 0; padding: 8px 3px; border: 0; text-align: left; font-size: .85rem; }
  td::before { display: block; margin-bottom: 5px; color: #7d8c80; content: attr(data-label); font-size: .67rem; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
  .keep-cell { grid-column: span 2; }
  .crib-cell { grid-column: span 1; }
  .keep-cell::before, .crib-cell::before { margin-bottom: 6px; }
  .row-rank { min-width: 17px; }
  .keep-content { gap: 5px; }
  .card-group { gap: 2px; }
  .card-chip.small { min-width: 24px; height: 30px; font-size: .9rem; }
  .total-value { grid-column: span 2; margin: 0 -5px 0 0; padding: 8px 10px !important; border-radius: 6px; }
}

@media (max-width: 360px) {
  .panel { padding: 18px 13px; }
  .card-picker { padding: 12px; }
  .card-chip.small { min-width: 21px; font-size: .82rem; }
  .keep-content { gap: 3px; }
  .row-rank { min-width: 15px; font-size: .64rem; }
}
