:root {
  --forest-950: #102c28;
  --forest-900: #183c35;
  --forest-800: #235047;
  --forest-700: #32665a;
  --sage-500: #739789;
  --sage-200: #cadbd3;
  --sage-100: #e8f0eb;
  --cream-50: #fcfaf5;
  --cream-100: #f6f1e7;
  --cream-200: #eae1d1;
  --ink: #192822;
  --muted: #68756f;
  --line: rgba(24, 60, 53, .14);
  --gold: #c99532;
  --gold-soft: #f3e4bb;
  --red: #a3443f;
  --red-soft: #f7e8e4;
  --white: #fffefb;
  --shadow-sm: 0 2px 10px rgba(18, 45, 39, .07);
  --shadow-lg: 0 24px 70px rgba(18, 45, 39, .16);
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 26px;
  --content: 760px;
  color: var(--ink);
  background: var(--cream-100);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--cream-100); }
body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 82% -5%, rgba(201, 149, 50, .13), transparent 31rem),
    linear-gradient(180deg, #fbf8f1 0, var(--cream-100) 55%, #efe8dc 100%);
}

button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: .42; }
input, select { color: var(--ink); }
input::placeholder { color: #9ba49f; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid rgba(201, 149, 50, .42);
  outline-offset: 2px;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, .display-number { font-family: Georgia, "Times New Roman", serif; }
.hidden { display: none !important; }

.setup-view { width: min(100%, 680px); margin: 0 auto; padding: max(38px, env(safe-area-inset-top)) 18px 44px; }
.setup-hero { text-align: center; margin-bottom: 28px; }
.hero-card {
  width: 76px;
  height: 96px;
  margin: 0 auto 22px;
  display: grid;
  place-content: center;
  grid-template-columns: auto auto auto;
  gap: 3px;
  border: 5px double rgba(246, 241, 231, .8);
  border-radius: 12px;
  color: white;
  background:
    repeating-linear-gradient(45deg, transparent 0 8px, rgba(255,255,255,.04) 8px 16px),
    var(--forest-900);
  box-shadow: 0 14px 32px rgba(16, 44, 40, .2);
  font-family: Georgia, serif;
  font-size: 1.3rem;
  transform: rotate(-2deg);
}
.hero-card i { color: #e5c671; font-weight: 400; }
.eyebrow, .step-label {
  margin-bottom: 7px;
  color: var(--forest-700);
  font-size: .7rem;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.setup-hero h1 { margin-bottom: 14px; color: var(--forest-950); font-size: clamp(2.55rem, 12vw, 4rem); font-weight: 500; letter-spacing: -.055em; line-height: .98; }
.setup-hero h1 em { color: var(--forest-700); font-weight: 400; }
.lede { max-width: 490px; margin-inline: auto; color: var(--muted); font-size: .98rem; line-height: 1.6; }
.setup-rule-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 999px;
  color: var(--forest-700);
  font-size: .75rem;
  font-weight: 800;
  text-decoration: none;
}
.setup-rule-link span { margin-right: 4px; color: var(--muted); font-weight: 650; }
.setup-rule-link b { margin-left: 6px; font-size: .9rem; }
.setup-rule-link:hover { background: rgba(255,254,251,.68); }

.surface {
  border: 1px solid rgba(255,255,255,.95);
  border-radius: var(--radius-lg);
  background: rgba(255, 254, 251, .88);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
}
.setup-card { padding: 21px; }
.section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 21px; }
.section-title h2, .page-heading h1 { margin: 0; color: var(--forest-950); font-size: 1.75rem; font-weight: 500; letter-spacing: -.025em; }
.quiet-pill, .status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--sage-100);
  color: var(--forest-800);
  font-size: .7rem;
  font-weight: 800;
  white-space: nowrap;
}
.status-pill.ready { background: #e2f0e7; color: #37694d; }
.status-pill.attention { background: var(--gold-soft); color: #74581c; }

.field-label { display: block; margin: 0 0 7px; color: var(--forest-800); font-size: .78rem; font-weight: 800; }
.field-label span, .field-hint { color: var(--muted); font-size: .7rem; font-weight: 600; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 20px; }
.label-row .field-label { margin-bottom: 7px; }
input, select {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  background: var(--white);
  font-size: 1rem;
  box-shadow: inset 0 1px 1px rgba(16, 44, 40, .025);
}
.setup-players { display: grid; gap: 8px; }
.player-input-row { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 8px; align-items: center; }
.seat-number { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--cream-100); color: var(--forest-700); font-size: .72rem; font-weight: 850; }
.row-actions { display: flex; gap: 3px; }
.icon-button {
  width: 44px;
  min-height: 46px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
}
.icon-button:hover { background: var(--cream-100); }
.add-player {
  width: 100%;
  min-height: 48px;
  margin-top: 9px;
  border: 1px dashed rgba(24,60,53,.28);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--forest-700);
  font-weight: 800;
}
.mode-fieldset { margin: 22px 0 0; padding: 0; border: 0; }
.mode-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mode-option {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  text-align: left;
}
.mode-option strong, .mode-option small { display: block; }
.mode-option strong { color: var(--forest-900); font-size: .82rem; }
.mode-option small { margin-top: 4px; color: var(--muted); font-size: .68rem; line-height: 1.3; }
.mode-option.selected { border-color: var(--forest-700); background: var(--sage-100); box-shadow: inset 0 0 0 1px var(--forest-700); }
.formation-preview { margin-top: 12px; padding: 13px 14px; border-left: 3px solid var(--gold); border-radius: 0 12px 12px 0; background: #fbf5e5; color: #625536; font-size: .76rem; line-height: 1.5; }
.formation-preview strong { color: #4e432c; }
.custom-assignments { display: grid; gap: 9px; margin-top: 13px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--cream-50); }
.custom-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(115px,.75fr); gap: 9px; align-items: center; }
.custom-row strong { font-size: .82rem; }
.custom-row select { min-height: 44px; }
.primary-button, .secondary-button, .danger-button, .soft-button {
  min-height: 50px;
  border-radius: 13px;
  padding: 11px 16px;
  font-weight: 850;
  border: 1px solid transparent;
}
.primary-button { background: var(--forest-900); color: white; border-color: var(--forest-900); }
.primary-button:hover { background: var(--forest-800); }
.secondary-button { background: var(--white); color: var(--forest-800); border-color: var(--line); }
.soft-button { background: var(--sage-100); color: var(--forest-800); border-color: var(--sage-200); }
.danger-button { background: var(--red); color: white; border-color: var(--red); }
.full-button { width: 100%; }
.start-button { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-top: 20px; }
.setup-import-button { width: 100%; margin-top: 8px; }
.autosave-note { display: flex; justify-content: center; align-items: center; gap: 7px; margin: 13px 0 0; color: var(--muted); font-size: .68rem; }
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: #6c9d78; }
.inline-error, .storage-warning, .validation-box { padding: 11px 13px; border-radius: 12px; background: var(--red-soft); color: #7c3733; font-size: .76rem; line-height: 1.45; }
.inline-error { margin-top: 12px; }

.app-header {
  position: sticky;
  z-index: 30;
  top: 0;
  min-height: calc(70px + env(safe-area-inset-top));
  padding: max(10px, env(safe-area-inset-top)) 15px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: white;
  background: rgba(24,60,53,.96);
  box-shadow: 0 7px 24px rgba(16,44,40,.15);
  backdrop-filter: blur(16px);
}
.brand-button, .round-chip { border: 0; background: transparent; color: inherit; }
.brand-button { display: flex; align-items: center; min-width: 0; min-height: 44px; gap: 10px; padding: 0; text-align: left; }
.brand-button > span:last-child { min-width: 0; }
.brand-button strong, .brand-button small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-button strong { max-width: 48vw; font-size: .88rem; }
.brand-button small { margin-top: 2px; color: #bad0c7; font-size: .61rem; font-weight: 650; }
.mini-card { display: grid; place-items: center; flex: 0 0 auto; width: 35px; height: 43px; border: 2px double #d9c17d; border-radius: 6px; font: 700 .72rem Georgia,serif; background: #214c44; }
.mini-card span { color: #e1be61; margin-inline: 1px; }
.round-chip { min-height: 44px; padding: 4px 11px; border: 1px solid rgba(255,255,255,.18); border-radius: 12px; text-align: right; }
.round-chip span, .round-chip small { display: block; }
.round-chip span { font-size: .74rem; font-weight: 850; }
.round-chip small { margin-top: 2px; color: #bad0c7; font-size: .6rem; }

.game-view { width: min(100%, var(--content)); margin: 0 auto; padding: 19px 14px calc(94px + env(safe-area-inset-bottom)); }
.storage-warning { margin-bottom: 13px; }
.app-view { animation: settle .18s ease-out; }
@keyframes settle { from { opacity: .25; transform: translateY(4px); } }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; margin: 4px 3px 16px; }
.page-heading h1 { font-size: 2rem; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.text-button { min-height: 44px; padding: 8px; border: 0; background: transparent; color: var(--forest-700); font-size: .73rem; font-weight: 850; }

.score-strip { display: flex; gap: 8px; overflow-x: auto; margin: 0 -14px 17px; padding: 0 14px 2px; scrollbar-width: none; scroll-snap-type: x proximity; }
.score-strip::-webkit-scrollbar { display: none; }
.score-chip { flex: 0 0 auto; min-width: 126px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,254,251,.85); scroll-snap-align: start; box-shadow: var(--shadow-sm); }
.score-chip.leader { color: white; border-color: var(--forest-800); background: var(--forest-800); }
.score-chip small, .score-chip strong { display: block; }
.score-chip small { max-width: 120px; overflow: hidden; color: inherit; opacity: .72; font-size: .65rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.score-chip strong { margin-top: 2px; font-size: 1.1rem; }
.score-chip .delta { display: inline; margin-left: 4px; color: #dce8e2; font-size: .62rem; }

.round-context {
  position: relative;
  overflow: hidden;
  margin-bottom: 13px;
  padding: 18px;
  border-radius: var(--radius);
  color: white;
  background: var(--forest-900);
  box-shadow: 0 15px 36px rgba(16,44,40,.17);
}
.round-context::after { content: ""; position: absolute; right: -30px; top: -34px; width: 120px; height: 120px; border: 22px solid rgba(255,255,255,.045); border-radius: 50%; }
.round-context .step-label { color: #b7cec5; }
.round-context h1, .round-context h2 { position: relative; margin-bottom: 7px; font-family: Georgia, "Times New Roman", serif; font-size: 1.65rem; font-weight: 500; }
.round-context p { position: relative; max-width: 520px; margin: 0; color: #d1e0da; font-size: .76rem; line-height: 1.5; }
.round-context .edit-label { color: #f0d58c; }

.surface-card { border: 1px solid rgba(255,255,255,.9); border-radius: var(--radius); background: rgba(255,254,251,.9); box-shadow: var(--shadow-sm); }
.winner-card { margin-bottom: 13px; padding: 17px; }
.card-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 13px; }
.card-heading h2, .card-heading h3 { margin: 0; color: var(--forest-950); font-size: 1.05rem; }
.card-heading p { margin: 4px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.4; }
.winner-options { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.winner-option { min-height: 52px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--cream-50); color: var(--forest-800); font-size: .77rem; font-weight: 850; }
.winner-option.selected { border-color: var(--gold); background: var(--gold-soft); color: #5b451b; box-shadow: inset 0 0 0 1px var(--gold); }

.progress-row { display: flex; align-items: center; gap: 7px; overflow-x: auto; margin: 0 -3px 10px; padding: 3px; scrollbar-width: none; }
.progress-button { flex: 0 0 auto; min-height: 44px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,254,251,.72); color: var(--muted); font-size: .67rem; font-weight: 800; }
.progress-button.active { border-color: var(--forest-700); color: white; background: var(--forest-700); }
.progress-button.done:not(.active) { border-color: #a9c6b5; color: #3c6a51; background: #e4f0e8; }

.entry-card { overflow: hidden; margin-bottom: 13px; }
.entry-top { position: sticky; z-index: 4; top: calc(70px + env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 17px; border-bottom: 1px solid var(--line); background: rgba(255,254,251,.96); backdrop-filter: blur(12px); }
.entry-top .step-label { margin-bottom: 4px; }
.entry-top h2 { max-width: 52vw; overflow: hidden; margin: 0; color: var(--forest-950); font-size: 1.35rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.subtotal { text-align: right; }
.subtotal small { display: block; color: var(--muted); font-size: .58rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.subtotal strong { color: var(--forest-900); font-size: 1.45rem; letter-spacing: -.03em; }
.input-section { padding: 17px; }
.input-section + .input-section { border-top: 1px solid var(--line); }
.input-section-heading { margin-bottom: 12px; }
.input-section-heading h3 { margin: 0; color: var(--forest-900); font-size: .9rem; }
.input-section-heading p { margin: 4px 0 0; color: var(--muted); font-size: .69rem; line-height: 1.45; }
.count-list { display: grid; gap: 8px; }
.count-row { min-height: 60px; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 10px; }
.count-row + .count-row { border-top: 1px solid rgba(24,60,53,.075); padding-top: 8px; }
.count-label strong, .count-label small { display: block; }
.count-label strong { color: var(--ink); font-size: .79rem; }
.count-label small { margin-top: 2px; color: var(--muted); font-size: .65rem; }
.stepper { display: grid; grid-template-columns: 44px 52px 44px; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--cream-50); }
.stepper button { min-height: 48px; border: 0; background: transparent; color: var(--forest-700); font-size: 1.25rem; font-weight: 500; }
.stepper input { min-height: 46px; padding: 5px 2px; border: 0; border-inline: 1px solid var(--line); border-radius: 0; background: white; font-size: 1rem; font-weight: 850; text-align: center; appearance: textfield; box-shadow: none; }
.stepper input::-webkit-inner-spin-button { appearance: none; }
.formula-panel { margin: 0 17px 17px; padding: 14px; border-radius: 14px; background: var(--sage-100); color: var(--forest-900); }
.formula-line { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: .7rem; }
.formula-line.total { margin-top: 6px; padding-top: 8px; border-top: 1px solid rgba(24,60,53,.13); font-size: .82rem; font-weight: 900; }
.formula-line.negative span:last-child { color: var(--red); }
.entry-actions { display: grid; grid-template-columns: .8fr 1.2fr; gap: 8px; margin-top: 12px; }
.entry-actions .primary-button, .entry-actions .secondary-button { width: 100%; }
.validation-box { margin: 0 17px 15px; }
.validation-box ul { margin: 0; padding-left: 18px; }

.review-card { padding: 18px; }
.review-card .page-heading { margin-inline: 0; }
.review-list { display: grid; gap: 8px; margin: 15px 0; }
.review-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 9px; align-items: center; padding: 12px; border-radius: 13px; background: var(--cream-100); }
.review-row strong, .review-row small { display: block; }
.review-row small { margin-top: 3px; color: var(--muted); font-size: .65rem; }
.review-row .round-delta { color: var(--forest-900); font-size: 1.05rem; font-weight: 900; }
.review-row button { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--forest-700); font-size: .7rem; font-weight: 850; }
.review-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 2px; border-top: 1px solid var(--line); color: var(--muted); font-size: .7rem; }
.review-total strong { color: var(--forest-950); font-size: 1.1rem; }
.review-card > .primary-button { width: 100%; margin-top: 9px; }

.result-banner { margin-bottom: 14px; padding: 18px; border: 1px solid rgba(201,149,50,.3); border-radius: var(--radius); background: linear-gradient(135deg, #fff8e6, #f1e4bd); color: #57451e; }
.result-banner.target { border-color: var(--forest-700); background: linear-gradient(135deg, var(--forest-900), var(--forest-700)); color: white; }
.result-banner .step-label { color: inherit; opacity: .72; }
.result-banner h2 { margin: 0 0 5px; font-size: 1.45rem; font-weight: 500; }
.result-banner p { margin: 0; font-size: .74rem; line-height: 1.5; opacity: .82; }
.standings-list { display: grid; gap: 9px; margin-bottom: 14px; }
.standing-row { display: grid; grid-template-columns: 36px minmax(0,1fr) auto; gap: 11px; align-items: center; padding: 14px; border: 1px solid rgba(255,255,255,.9); border-radius: 15px; background: rgba(255,254,251,.88); box-shadow: var(--shadow-sm); }
.standing-row:first-child { border-color: rgba(201,149,50,.4); background: #fff9e9; }
.rank-number { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--cream-200); color: var(--forest-800); font-size: .76rem; font-weight: 900; }
.standing-row:first-child .rank-number { background: var(--gold); color: white; }
.standing-name strong, .standing-name small { display: block; }
.standing-name strong { overflow: hidden; font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }
.standing-name small { margin-top: 3px; color: var(--muted); font-size: .65rem; }
.standing-score { text-align: right; }
.standing-score strong, .standing-score small { display: block; }
.standing-score strong { color: var(--forest-950); font-size: 1.25rem; }
.standing-score small { margin-top: 2px; color: var(--forest-700); font-size: .62rem; font-weight: 800; }
.standings-cta { width: 100%; }
.score-table-wrap { overflow-x: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.score-table { width: 100%; min-width: 440px; border-collapse: collapse; font-size: .7rem; }
.score-table th, .score-table td { padding: 10px 11px; border-bottom: 1px solid var(--line); text-align: right; }
.score-table th:first-child, .score-table td:first-child { position: sticky; left: 0; text-align: left; background: var(--white); }
.score-table thead th { color: var(--muted); font-size: .61rem; text-transform: uppercase; letter-spacing: .06em; }
.score-table tbody tr:last-child td { border-bottom: 0; }

.history-list { display: grid; gap: 10px; }
.history-round { overflow: hidden; border: 1px solid rgba(255,255,255,.9); border-radius: 16px; background: rgba(255,254,251,.9); box-shadow: var(--shadow-sm); }
.history-round summary { min-height: 66px; display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 11px; align-items: center; padding: 13px 15px; cursor: pointer; list-style: none; }
.history-round summary::-webkit-details-marker { display: none; }
.round-number { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 12px; background: var(--forest-900); color: white; font-size: .7rem; font-weight: 900; }
.history-summary strong, .history-summary small { display: block; }
.history-summary strong { font-size: .82rem; }
.history-summary small { margin-top: 3px; color: var(--muted); font-size: .65rem; }
.history-best { text-align: right; }
.history-best strong, .history-best small { display: block; }
.history-best strong { color: var(--forest-900); font-size: .95rem; }
.history-best small { color: var(--muted); font-size: .6rem; }
.history-details { padding: 0 15px 15px; border-top: 1px solid var(--line); }
.history-side { padding: 13px 0; }
.history-side + .history-side { border-top: 1px solid var(--line); }
.history-side-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.history-side-heading strong { font-size: .78rem; }
.history-side-heading span { color: var(--forest-900); font-size: .85rem; font-weight: 900; }
.mini-breakdown { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px 12px; color: var(--muted); font-size: .64rem; }
.mini-breakdown div { display: flex; justify-content: space-between; gap: 7px; }
.history-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.undo-button { width: 100%; margin-top: 13px; }
.empty-state { padding: 32px 20px; text-align: center; }
.empty-state h2 { margin-bottom: 8px; font-size: 1.35rem; font-weight: 500; }
.empty-state p { margin-bottom: 18px; color: var(--muted); font-size: .76rem; line-height: 1.5; }

.rules-stack { display: grid; gap: 11px; }
.rules-card { padding: 17px; }
.rules-card h2 { margin: 0 0 8px; color: var(--forest-950); font-size: 1rem; }
.rules-card p, .rules-card li { color: var(--muted); font-size: .72rem; line-height: 1.55; }
.rules-card p:last-child { margin-bottom: 0; }
.rules-card ul { margin: 8px 0 0; padding-left: 18px; }
.value-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; margin-top: 10px; }
.value-chip { padding: 10px; border-radius: 11px; background: var(--cream-100); }
.value-chip strong, .value-chip small { display: block; }
.value-chip strong { color: var(--forest-900); font-size: .78rem; }
.value-chip small { margin-top: 2px; color: var(--muted); font-size: .64rem; }
.data-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 13px; }
.data-actions button { width: 100%; }
.data-actions .danger-button { grid-column: 1 / -1; }
.uncertainty { border-left: 3px solid var(--gold); background: #fff9e9; }
.standalone-rule-link {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 11px;
  padding: 13px 16px;
  border: 1px solid rgba(201,149,50,.3);
  border-radius: var(--radius);
  color: var(--forest-900);
  background: linear-gradient(135deg, #fff9e9, #f4ead0);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.standalone-rule-link strong, .standalone-rule-link small { display: block; }
.standalone-rule-link strong { font-size: .82rem; }
.standalone-rule-link small { margin-top: 3px; color: #756640; font-size: .66rem; line-height: 1.4; }
.standalone-rule-link > b { font-size: 1.1rem; }

/* Standalone beginner rule card */
.beginner-rules-body { background: linear-gradient(180deg, #f7f1e4 0, #fbf9f4 18rem, #eee6d9 100%); }
.skip-link { position: fixed; z-index: 100; left: 12px; top: 8px; padding: 10px 13px; border-radius: 10px; color: white; background: var(--forest-950); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.beginner-topbar { position: sticky; z-index: 20; top: 0; color: white; background: rgba(24,60,53,.96); box-shadow: 0 8px 24px rgba(16,44,40,.12); backdrop-filter: blur(14px); }
.beginner-topbar-inner { width: min(100%, 940px); min-height: calc(60px + env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 auto; padding: max(8px, env(safe-area-inset-top)) 16px 8px; }
.beginner-topbar-inner > span { color: #c5d7d0; font-size: .66rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.beginner-back-link { min-height: 44px; display: inline-flex; align-items: center; gap: 7px; color: white; font-size: .76rem; font-weight: 800; text-decoration: none; }
.beginner-rules-page { width: min(100%, 940px); margin: 0 auto; padding: 32px 14px max(52px, env(safe-area-inset-bottom)); }
.beginner-hero { max-width: 690px; margin: 0 auto 28px; text-align: center; }
.beginner-card-mark { width: 58px; height: 72px; display: grid; place-items: center; margin: 0 auto 17px; border: 4px double rgba(246,241,231,.82); border-radius: 10px; color: white; background: repeating-linear-gradient(45deg, transparent 0 7px, rgba(255,255,255,.04) 7px 14px), var(--forest-900); box-shadow: 0 12px 28px rgba(16,44,40,.18); font: 700 .95rem Georgia,serif; transform: rotate(-2deg); }
.beginner-card-mark span { color: #e5c671; }
.beginner-hero h1 { margin-bottom: 13px; color: var(--forest-950); font-size: clamp(2.5rem, 11vw, 4.3rem); font-weight: 500; letter-spacing: -.055em; line-height: .95; }
.beginner-hero h1 em { color: var(--forest-700); font-weight: 400; }
.beginner-hero > p:not(.eyebrow) { max-width: 570px; margin: 0 auto; color: var(--muted); font-size: .9rem; line-height: 1.6; }
.beginner-jump-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 18px; }
.beginner-jump-nav a { min-height: 44px; display: inline-flex; align-items: center; padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--forest-800); background: rgba(255,254,251,.75); font-size: .7rem; font-weight: 800; text-decoration: none; }
.beginner-quick-card, .beginner-rule-card, .beginner-score-card { border: 1px solid rgba(255,255,255,.92); background: rgba(255,254,251,.9); box-shadow: var(--shadow-sm); }
.beginner-quick-card { padding: 20px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.beginner-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.beginner-section-heading h2, .beginner-rule-card h2, .beginner-score-card h2, .beginner-house-call h2 { margin: 0; color: var(--forest-950); font-size: 1.5rem; font-weight: 500; letter-spacing: -.025em; }
.beginner-turn-flow { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.beginner-turn-flow li { min-height: 92px; display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.beginner-turn-flow li:first-child { border-top: 0; }
.beginner-turn-number { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 12px; color: white; background: var(--forest-900); font-size: .75rem; font-weight: 900; }
.beginner-turn-flow strong { display: block; margin-bottom: 4px; color: var(--forest-950); font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; font-weight: 600; }
.beginner-turn-flow p, .beginner-goal, .beginner-rule-card li, .beginner-rule-card p, .beginner-score-card p, .beginner-house-call p, .beginner-definition-list dd { color: var(--muted); font-size: .76rem; line-height: 1.58; }
.beginner-turn-flow p { margin: 0; }
.beginner-goal { margin: 5px 0 0; padding: 14px; border-radius: 14px; color: #5e512f; background: var(--gold-soft); }
.beginner-goal strong { color: #4f431f; }
.beginner-stock-note { margin: 10px 2px 0; color: var(--muted); font-size: .68rem; line-height: 1.5; }
.beginner-stock-note strong { color: var(--forest-800); }
.beginner-rule-grid { display: grid; gap: 12px; margin-top: 12px; }
.beginner-rule-grid.compact { margin-top: 12px; }
.beginner-rule-card { padding: 19px; border-radius: var(--radius); }
.beginner-card-kicker { margin: 0 0 6px !important; color: var(--forest-700) !important; font-size: .63rem !important; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.beginner-rule-card h2 { margin-bottom: 11px; font-size: 1.28rem; }
.beginner-rule-card ul { margin: 0; padding-left: 19px; }
.beginner-rule-card li + li { margin-top: 6px; }
.beginner-note, .beginner-checklist { margin-top: 14px; padding: 13px 14px; border-radius: 13px; background: var(--sage-100); }
.beginner-note > strong, .beginner-checklist > p strong { color: var(--forest-900); font-size: .74rem; }
.beginner-note p, .beginner-checklist p { margin: 4px 0 0; }
.beginner-checklist ul { margin-top: 7px; }
.beginner-book-list { display: grid; gap: 8px; margin-top: 14px; }
.beginner-book-list > div { min-height: 54px; display: grid; grid-template-columns: 13px minmax(0,1fr); gap: 11px; align-items: stretch; padding: 9px 11px; border-radius: 12px; background: var(--cream-100); }
.beginner-book-list p { align-self: center; margin: 0; }
.beginner-book-list strong, .beginner-book-list small { display: block; }
.beginner-book-list strong { color: var(--forest-900); font-size: .76rem; }
.beginner-book-list small { margin-top: 2px; color: var(--muted); font-size: .65rem; }
.beginner-book-swatch { width: 7px; border-radius: 999px; background: var(--sage-500); }
.beginner-book-swatch.dirty { background: var(--gold); }
.beginner-book-swatch.wild { background: var(--forest-950); }
.beginner-fine-print { margin: 12px 0 0 !important; font-size: .68rem !important; }
.beginner-thresholds { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; margin: 13px 0 15px; }
.beginner-thresholds div { padding: 11px 5px; border-radius: 12px; background: var(--cream-100); text-align: center; }
.beginner-thresholds small, .beginner-thresholds strong { display: block; }
.beginner-thresholds small { color: var(--muted); font-size: .57rem; font-weight: 750; }
.beginner-thresholds strong { margin-top: 3px; color: var(--forest-900); font-size: 1.15rem; }
.beginner-score-card { margin-top: 12px; padding: 20px; border-radius: var(--radius-lg); }
.beginner-formula { margin: 0 0 15px; padding: 14px; border-left: 3px solid var(--gold); border-radius: 0 13px 13px 0; color: #625536 !important; background: #fbf5e5; }
.beginner-value-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.beginner-value-grid div { min-height: 74px; display: grid; align-content: center; padding: 11px; border-radius: 12px; background: var(--cream-100); }
.beginner-value-grid strong, .beginner-value-grid span { display: block; }
.beginner-value-grid strong { color: var(--forest-900); font: 600 1.25rem Georgia,"Times New Roman",serif; }
.beginner-value-grid span { margin-top: 3px; color: var(--muted); font-size: .64rem; }
.beginner-value-grid .positive { background: #e5f0e8; }
.beginner-value-grid .positive strong { color: #3d6d52; }
.beginner-value-grid .negative { background: var(--red-soft); }
.beginner-value-grid .negative strong { color: var(--red); }
.beginner-definition-list { margin: 0; }
.beginner-definition-list > div { padding: 11px 0; border-top: 1px solid var(--line); }
.beginner-definition-list > div:first-child { padding-top: 0; border-top: 0; }
.beginner-definition-list dt { color: var(--forest-900); font-size: .76rem; font-weight: 900; }
.beginner-definition-list dd { margin: 3px 0 0; }
.beginner-house-call { margin-top: 12px; padding: 19px; border: 1px solid rgba(201,149,50,.35); border-radius: var(--radius); background: linear-gradient(135deg,#fff9e9,#f4e8c7); }
.beginner-house-call h2 { margin-bottom: 7px; font-size: 1.25rem; }
.beginner-house-call p:last-child { margin-bottom: 0; color: #6f603b; }
.beginner-footer { max-width: 600px; margin: 29px auto 0; text-align: center; }
.beginner-footer p { margin-bottom: 14px; color: var(--muted); font-size: .68rem; line-height: 1.5; }
.beginner-open-scorekeeper { display: inline-flex; align-items: center; justify-content: center; gap: 12px; text-decoration: none; }
.beginner-rules-page section[id] { scroll-margin-top: 78px; }

.bottom-nav {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: calc(69px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4,1fr);
  padding: 7px 7px max(7px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(252,250,245,.95);
  box-shadow: 0 -8px 28px rgba(16,44,40,.08);
  backdrop-filter: blur(18px);
}
.bottom-nav button { min-height: 52px; display: grid; place-content: center; gap: 2px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); }
.bottom-nav button > span { font-size: 1rem; font-weight: 600; line-height: 1; }
.bottom-nav button small { font-size: .58rem; font-weight: 750; }
.bottom-nav button.active { color: var(--forest-900); background: var(--sage-100); }

.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(83px + env(safe-area-inset-bottom)); width: min(calc(100% - 30px), 460px); padding: 12px 15px; border-radius: 13px; color: white; background: #263d37; box-shadow: var(--shadow-lg); font-size: .78rem; line-height: 1.4; opacity: 0; pointer-events: none; transform: translate(-50%, 18px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #713b37; }

.modal { width: min(calc(100% - 28px), 460px); padding: 0; border: 0; border-radius: 22px; color: var(--ink); background: var(--cream-50); box-shadow: 0 32px 90px rgba(10,30,26,.28); }
.modal::backdrop { background: rgba(11,30,27,.56); backdrop-filter: blur(3px); }
.modal form { padding: 22px; }
.modal h2 { margin: 0 0 9px; color: var(--forest-950); font-size: 1.55rem; font-weight: 500; }
.modal-copy { color: var(--muted); font-size: .76rem; line-height: 1.5; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 17px; }
.reset-label { margin-top: 16px; }
.danger-text { color: var(--red); }
.import-preview { margin: 12px 0; padding: 13px; border-radius: 13px; background: var(--sage-100); }
.import-preview strong, .import-preview small { display: block; }
.import-preview strong { color: var(--forest-900); }
.import-preview small { margin-top: 4px; color: var(--muted); font-size: .7rem; }
.inline-error p { margin: 0; }
.recovery-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.recovery-actions button { min-height: 44px; }

@media (min-width: 680px) {
  .setup-card { padding: 28px; }
  .game-view { padding-top: 25px; }
  .winner-options { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .entry-card { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .entry-top, .formula-panel, .validation-box, .entry-actions { grid-column: 1 / -1; }
  .table-section { border-top: 0 !important; border-left: 1px solid var(--line); }
  .held-section { grid-column: 1 / -1; }
  .entry-actions { margin: 0 17px 17px; }
  .bottom-nav { left: 50%; right: auto; width: min(100%, var(--content)); transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; }
  .beginner-rules-page { padding-top: 44px; }
  .beginner-quick-card, .beginner-score-card { padding: 28px; }
  .beginner-rule-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .beginner-rule-card { padding: 23px; }
  .beginner-value-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width: 410px) {
  .setup-view { padding-inline: 12px; }
  .setup-card { padding: 17px; }
  .mode-options { grid-template-columns: 1fr; }
  .player-input-row { grid-template-columns: 32px minmax(0,1fr) auto; }
  .winner-options { grid-template-columns: 1fr; }
  .entry-actions { grid-template-columns: 1fr; }
  .count-row { grid-template-columns: minmax(0,1fr) 140px; }
  .data-actions { grid-template-columns: 1fr; }
  .data-actions .danger-button { grid-column: auto; }
  .recovery-actions { grid-template-columns: 1fr; }
}

@media (max-width: 350px) {
  .player-input-row { grid-template-columns: 32px minmax(0, 1fr); }
  .row-actions { grid-column: 2; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  @page { margin: 12mm; }
  .beginner-rules-body { background: white; }
  .beginner-topbar, .beginner-jump-nav, .skip-link, .beginner-open-scorekeeper { display: none !important; }
  .beginner-rules-page { width: 100%; padding: 0; }
  .beginner-hero { margin-bottom: 14px; }
  .beginner-card-mark { box-shadow: none; }
  .beginner-quick-card, .beginner-rule-card, .beginner-score-card, .beginner-house-call { break-inside: avoid; box-shadow: none; }
  .beginner-rule-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .beginner-footer { margin-top: 14px; }
}
