:root {
  color-scheme: light;
  --felt: #123c32; --felt-dark: #0c2c25; --green: #225b47; --gold: #d8b673;
  --paper: #fcf9f1; --paper-soft: #f2f0e5; --ink: #203b31; --muted: #647067; --line: #dbdfd2;
  font-family: "Segoe UI", Inter, Arial, sans-serif; color: var(--ink); background: var(--felt-dark);
}
* { box-sizing: border-box; }
html, body, button, input, select, label, summary, .table-wrap { touch-action: manipulation; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 50% 0, #245545 0, var(--felt) 45%, var(--felt-dark) 100%); }
button, input, select { font: inherit; }
button, summary { cursor: pointer; }
button { transition: background 140ms ease, transform 140ms ease; }
button:focus-visible, summary:focus-visible, .history-toggle:focus-visible { outline: 3px solid #b08a42; outline-offset: 3px; }
p { margin: 0; }
.page-shell { width: min(1180px, calc(100% - 24px)); margin: 0 auto; padding: 28px 0 24px; }
#app, .heading-block, .hero-title { min-width: 0; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 4px 28px; }
.hero h1, .game-bar h1 { margin: 0; color: var(--paper); font: 500 clamp(2.6rem, 5vw, 4rem)/1.12 Georgia, serif; letter-spacing: -0.04em; }
.hero h1 span, .game-bar h1 span { color: var(--gold); font-style: italic; }
.hero-copy { color: #c0d1c5; margin: 12px 0 0; line-height: 1.5; font-size: 0.95rem; }
.eyebrow, .section-label, .round-label, .summary-rank { margin: 0 0 8px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; color: var(--green); }
.eyebrow { color: var(--gold); }
.hero-cards { position: relative; width: 150px; height: 112px; margin-right: 20px; flex-shrink: 0; }
.playing-card { position: absolute; display: flex; flex-direction: column; justify-content: space-between; width: 68px; height: 94px; padding: 8px 10px; border: 1px solid #e7dcc5; border-radius: 7px; background: var(--paper); font: 700 18px Georgia, serif; box-shadow: 0 8px 20px #071e2440; }
.playing-card > span { align-self: center; font-size: 42px; line-height: 1; }
.card-back { top: 5px; left: 20px; transform: rotate(-17deg); color: #a8543a; }
.card-front { top: 10px; left: 65px; transform: rotate(12deg); color: var(--green); }
.page-footer { display: flex; justify-content: space-between; gap: 16px; padding: 20px 4px 0; color: #b7c9bc; font-size: 0.75rem; }
.page-footer > span { color: var(--gold); letter-spacing: 0.12em; }
h2 { margin: 0; font: 500 clamp(1.6rem, 2.4vw, 2rem)/1.15 Georgia, serif; letter-spacing: -0.025em; }
h3 { margin: 0; font-size: 1.15rem; }
.muted { color: var(--muted); line-height: 1.55; }
.panel { min-width: 0; border: 1px solid #ffffff26; border-radius: 18px; background: var(--paper); box-shadow: 0 12px 32px #061e1a20; }
.setup-panel, .summary-panel, .round-entry-panel, .standings-panel { padding: 16px 18px; }
.rules-panel { background: var(--paper-soft); }
body[data-screen="game"] .hero { display: none; }
body[data-screen="game"] .page-shell { padding-top: 12px; }
.game-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; }
.game-bar h1 { font-size: 28px; line-height: 1; }
.game-bar p { margin-top: 4px; color: #c0d1c5; font-size: 16px; }
.game-bar .ghost-button { color: var(--paper); border-color: #ffffff55; background: transparent; }
.table-layout { display: grid; gap: 12px; }
.setup-layout { display: flex; flex-direction: column; align-items: stretch; gap: 16px; }
.setup-layout > * { min-width: 0; width: 100%; }
.standings-panel { position: sticky; top: 8px; z-index: 3; }
.standings-board { display: grid; gap: 8px; margin-top: 8px; }
.standings-board[data-side-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.standings-board[data-side-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.standings-board[data-side-count="4"],
.standings-board[data-side-count="5"],
.standings-board[data-side-count="6"],
.standings-board[data-side-count="7"],
.standings-board[data-side-count="8"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.seat { min-width: 0; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fffdf7; }
.seat.leader { border-color: #c4a366; background: #f6eedb; }
.seat-status { min-height: 1.15em; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.seat.leader .seat-status { color: #8a6a32; }
.seat h3 { margin-top: 2px; font-size: 22px; line-height: 1.15; overflow-wrap: anywhere; }
.seat .total { margin: 2px 0 0; color: var(--green); font-size: 56px; line-height: 0.95; font-weight: 750; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.standings-board[data-side-count="2"] .total { font-size: 72px; }
.standings-board[data-side-count="2"] h3 { font-size: 28px; }
.standings-board[data-side-count="5"] .total,
.standings-board[data-side-count="6"] .total,
.standings-board[data-side-count="7"] .total,
.standings-board[data-side-count="8"] .total { font-size: 40px; }
.round-trail { margin-top: 6px; color: var(--muted); font-size: 15px; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.round-entry-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.round-entry-heading h2 { font-size: 28px; }
.meld-chip { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 16px; border: 1px solid #c4a366; border-radius: 12px; background: #f6eedb; }
.meld-chip span { color: #8a6a32; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; line-height: 1.2; }
.meld-chip strong { color: var(--ink); font-size: 36px; line-height: 1; font-variant-numeric: tabular-nums; }
.heading-copy { margin: 10px 0 0; font-size: 0.88rem; }
.setup-copy { margin-bottom: 24px; }
.setup-form, .round-form, .rules-shell { display: grid; gap: 16px; }
.setup-form { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.name-grid, .setup-form > .primary-button { grid-column: 1 / -1; }
.name-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 20px 0 4px; border-top: 1px solid var(--line); }
.field, .toggle-field { display: grid; gap: 6px; min-width: 0; }
.field > span, .toggle-field > span, .mode-fieldset > span { font-size: 0.8rem; font-weight: 650; line-height: 1.3; color: var(--ink); }
.field input, .field select { width: 100%; min-width: 0; min-height: 48px; padding: 10px 12px; border: 1px solid #ccd4c7; border-radius: 9px; background: #fffef9; color: var(--ink); font-size: 1rem; }
.field input::placeholder { color: #7c847c; }
.field input:focus, .field select:focus { outline: 2px solid var(--green); outline-offset: 2px; }
.select-wrap { position: relative; }
.select-wrap::after { content: ""; position: absolute; right: 16px; top: 18px; width: 8px; height: 8px; border-right: 2px solid var(--green); border-bottom: 2px solid var(--green); transform: rotate(45deg); pointer-events: none; }
.field select { appearance: none; padding-right: 38px; }
.mode-fieldset { margin: 0; padding: 0; border: 0; }
.mode-toggle { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; background: #e7eade; border-radius: 10px; padding: 4px; min-height: 56px; }
.mode-option { position: relative; display: flex; min-height: 48px; }
.mode-option input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.mode-option span { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 7px; text-align: center; font-size: 0.9rem; font-weight: 650; color: var(--muted); }
.mode-option.selected span, .mode-option input:checked + span { color: #fff; background: var(--green); }
.mode-option input:focus-visible + span { outline: 3px solid #b08a42; outline-offset: 2px; }
.primary-button, .secondary-button, .ghost-button, .icon-button { border-radius: 9px; min-height: 48px; min-width: 48px; padding: 12px 18px; border: 1px solid transparent; font-size: 0.95rem; font-weight: 650; }
.primary-button { background: var(--green); color: #fff; }
.setup-form > .primary-button, .editor-actions .primary-button { min-height: 56px; font-size: 1.05rem; }
.editor-actions .primary-button { min-width: 200px; }
.secondary-button { background: #e9eddf; color: var(--green); border-color: #d0dac8; }
.ghost-button, .icon-button { background: transparent; color: var(--green); border-color: #ccd4c7; flex-shrink: 0; }
.icon-button { width: 48px; padding: 0; font-size: 1.5rem; }
@media (hover: hover) {
  .primary-button:hover { background: #174232; }
  .secondary-button:hover, .ghost-button:hover, .icon-button:hover, .stepper-button:hover { background: #e0e8d7; }
}
button:active { transform: translateY(1px); }
.rules-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 16px; font-size: 16px; font-weight: 700; list-style: none; }
.rules-summary::-webkit-details-marker { display: none; }
.rules-summary-hint { color: var(--muted); font-weight: 500; font-size: 15px; }
.rules-shell { padding: 4px 16px 16px; }
.rules-reference-panel, .minimum-meld-panel { display: grid; gap: 12px; }
.rules-reference-panel .section-label, .minimum-meld-panel .section-label { margin: 0; }
.card-values-list { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.card-value-item { display: grid; gap: 6px; padding: 12px 4px; text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.card-value-item dt { font: 600 1.05rem Georgia, serif; color: var(--ink); }
.card-value-item dd { margin: 0; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.deck-guidance, .rules-formula, .going-out-requirement { margin: 0; font-size: 0.95rem; line-height: 1.55; }
.going-out-list { display: grid; gap: 8px; }
.going-out-item { display: grid; gap: 4px; min-height: 48px; padding: 10px 12px; background: #e6ebde; border-radius: 8px; }
.going-out-item span { color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.going-out-item strong { font-size: 0.95rem; font-weight: 650; line-height: 1.4; }
.minimum-meld-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.minimum-meld-item { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; min-height: 48px; padding: 10px 12px; background: #e6ebde; border-radius: 8px; font-size: 0.9rem; }
.minimum-meld-item.current { background: #f6eedb; outline: 2px solid #c4a366; }
.minimum-meld-item span { color: var(--muted); }
.minimum-meld-item strong { font-variant-numeric: tabular-nums; }
.scoring-details { padding-top: 8px; border-top: 1px solid #cfd6c7; font-size: 0.95rem; }
.scoring-details summary { display: flex; align-items: center; min-height: 48px; font-weight: 650; }
.rules-list { display: grid; gap: 8px; padding-left: 18px; margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.summary-panel > .primary-button { margin-top: 16px; }
.highlight-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.highlight-card, .side-editor { border: 1px solid var(--line); border-radius: 12px; background: #fffdf7; min-width: 0; }
.highlight-card { padding: 14px 16px; }
.highlight-card p { color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.highlight-card .section-label { margin-bottom: 6px; }
.round-form { margin-top: 12px; }
.side-editor { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 10px 12px; }
.side-editor-header { grid-column: 1; grid-row: 1; }
.side-editor-header h3 { overflow-wrap: anywhere; font-size: 20px; }
.entry-total { grid-column: 2; grid-row: 1; margin: 0; text-align: right; }
.editor-grid { grid-column: 1 / -1; grid-row: 2; }
.entry-total span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.entry-total strong { color: var(--green); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.editor-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; align-items: end; }
.editor-grid .toggle-field { display: grid; align-self: end; align-items: stretch; gap: 6px; min-height: 0; padding: 0; border: 0; background: transparent; }
.editor-grid .toggle-control { display: flex; align-items: center; justify-content: flex-end; box-sizing: border-box; height: 48px; min-height: 48px; min-width: 48px; padding: 0 12px; border: 1px solid #ccd4c7; border-radius: 9px; background: #fffef9; }
.editor-grid .toggle-control input { width: 28px; height: 28px; min-width: 28px; min-height: 28px; margin: 0; accent-color: var(--green); }
.field-error:empty { display: none; }
.number-field { display: grid; grid-template-columns: 48px minmax(36px, 1fr) 48px; min-height: 48px; border: 1px solid #ccd4c7; border-radius: 9px; overflow: hidden; background: #fffef9; }
.number-field input { min-width: 0; min-height: 48px; padding: 0 2px; border: 0; border-radius: 0; background: transparent; text-align: center; font-size: 20px; font-variant-numeric: tabular-nums; }
.number-field input:focus { outline: 2px solid var(--green); outline-offset: -2px; }
.stepper-button { width: 48px; min-width: 48px; height: 48px; min-height: 48px; padding: 0; border: 0; border-radius: 0; background: #edf0e6; color: var(--green); font-size: 1.35rem; line-height: 1; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.field-error { color: #a0382c; font-size: 0.75rem; line-height: 1.3; min-height: 1em; }
.editor-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.history-panel { padding: 4px; }
.history-item + .history-item { border-top: 1px solid var(--line); }
.history-row { display: flex; align-items: center; gap: 8px; }
.history-toggle { flex: 1; display: flex; align-items: center; gap: 8px; min-height: 48px; min-width: 48px; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); text-align: left; font-size: 16px; line-height: 1.35; }
.history-caret { color: var(--green); font-size: 14px; }
.history-lock { flex-shrink: 0; padding-right: 8px; color: var(--muted); font-size: 14px; font-weight: 650; }
.history-detail { padding: 0 12px 12px 34px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.history-detail ul { display: grid; gap: 4px; margin: 6px 0 0; padding-left: 18px; }
.history-detail strong { color: var(--ink); }
.callout { margin: 12px 0 0; padding: 12px 16px; border-radius: 8px; background: #e7eade; color: var(--ink); font-size: 0.95rem; line-height: 1.5; }
.callout.error { background: #f8dfd8; color: #853d2c; }
.callout.warning { background: #f4e8c9; color: #6e5426; }
@media (max-width: 1100px) {
  .seat .total { font-size: 48px; }
  .standings-board[data-side-count="2"] .total { font-size: 64px; }
  .seat h3 { font-size: 20px; }
  .round-entry-heading h2 { font-size: 24px; }
  .meld-chip strong { font-size: 32px; }
  .round-trail { font-size: 14px; }
}
@media (max-width: 800px) {
  .page-shell { width: calc(100% - 24px); }
  .hero-cards { margin-right: 0; transform: scale(0.85); transform-origin: right center; width: 130px; }
  .setup-form, .name-grid { grid-template-columns: 1fr; }
  .standings-board[data-side-count="3"],
  .standings-board[data-side-count="4"],
  .standings-board[data-side-count="5"],
  .standings-board[data-side-count="6"],
  .standings-board[data-side-count="7"],
  .standings-board[data-side-count="8"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .minimum-meld-list, .highlight-grid, .card-values-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rules-summary { align-items: flex-start; flex-direction: column; }
  .game-bar h1 { font-size: 24px; }
}
@media (max-width: 520px) {
  .page-shell { padding-top: 20px; }
  .hero { gap: 8px; padding-bottom: 20px; }
  .hero h1 { font-size: clamp(2rem, 9vw, 2.7rem); }
  .hero-copy { font-size: 0.82rem; }
  .hero-cards { width: 70px; margin-left: -15px; transform: scale(0.56); transform-origin: right center; }
  .playing-card.card-back { left: -50px; }
  .playing-card.card-front { left: -5px; }
  .standings-board { grid-template-columns: 1fr 1fr; }
  .editor-actions { flex-direction: column-reverse; align-items: stretch; }
  .editor-actions .primary-button, .editor-actions .ghost-button { width: 100%; }
  .page-footer { font-size: 0.68rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
