:root {
  --canvas: #f2efe4;
  --warm-highlight: #e8d6a8;
  --orange: #b98735;
  --red: #9e451f;
  --teal: #287249;
  --sage: #8db4ad;
  --gold: #e3bd61;
  --sage-tint: #e2eeeb;
  --paper: #fffdf8;
  --ink: #174f35;
  --muted: #47616b;
  --line: #b9ccc6;
  font-family: Verdana, Geneva, sans-serif;
  font-size: 18px;
  font-synthesis: none;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.45; }
button, input, select { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .35; }
button:focus-visible, a:focus-visible, summary:focus-visible, .table-wrap:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}
input:focus, select:focus { outline: 3px solid var(--red); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-weight: 700; letter-spacing: -.6px; }
h1 { font-size: clamp(36px, 3.8vw, 50px); line-height: 1.2; }
h2 { font-size: 28px; line-height: 1.3; }
p { line-height: 1.6; }
.muted { color: var(--muted); font-size: 17px; }
.masthead {
  max-width: 1440px;
  min-height: 72px;
  margin: auto;
  padding: 10px 16px;
  border-bottom: 2px solid var(--orange);
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 700; letter-spacing: -1px; line-height: 1.2; }
.brand-mark { width: 36px; height: 42px; border-radius: 8px; display: grid; place-items: center; background: var(--red); color: white; font-size: 30px; flex-shrink: 0; }
.masthead :focus-visible { outline-color: var(--gold); }
main { max-width: 1440px; margin: auto; padding: 20px 16px 0; }
.playing main { padding-top: 16px; }
footer { max-width: 1440px; margin: 24px auto 0; padding: 18px 24px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; color: var(--muted); font-size: 14px; }
.playing footer > span:first-child { display: none; }
.playing footer { margin-top: 16px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; }
.button { min-height: 50px; padding: 11px 16px; border-radius: 9px; border: 1px solid transparent; font-size: 18px; line-height: 1.35; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 12px; }
.primary { background: var(--ink); color: white; }
.primary:hover { background: var(--teal); }
.secondary { background: var(--gold); color: var(--ink); }
.secondary:hover { background: #ffca54; }
.ghost, .subtle { background: var(--paper); color: var(--ink); border-color: var(--line); }
.ghost:hover, .subtle:hover { background: var(--warm-highlight); }
.full { width: 100%; }
.button.full { justify-content: space-between; }
.text-button { min-height: 48px; padding: 10px 4px; border: 0; background: transparent; color: var(--ink); font-size: 16px; line-height: 1.5; text-decoration: underline; text-underline-offset: 4px; }
.text-button:hover { color: var(--teal); }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; letter-spacing: 1px; line-height: 1.5; }
.little-line { width: 28px; height: 3px; background: var(--orange); }
.panel-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.field-label { display: block; font-size: 14px; letter-spacing: .8px; font-weight: 700; margin: 24px 0 12px; }
.error { color: #a12727; font-size: 16px; line-height: 1.5; margin: 12px 0; }
.error:empty { margin: 10px 0; }
.save-note { margin: 16px 0 0; font-size: 14px; color: var(--muted); text-align: center; }
.game-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; margin-bottom: 16px; }
.round-column { min-width: 0; }
.round-banner { height: 150px; border-radius: 16px; padding: 12px 12px 12px 16px; background: var(--teal); color: white; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wild-copy { min-width: 0; }
.round-banner h2 { font-size: 24px; margin: 0 0 8px; white-space: nowrap; letter-spacing: -.5px; }
.round-progress { font-size: 14px; font-weight: 500; line-height: 1.5; margin: 0; }
.wild-card { position: relative; width: 90px; height: 126px; flex-shrink: 0; display: grid; place-items: center; border: 1px solid #d1ddd8; border-radius: 9px; background: var(--paper); color: var(--ink); box-shadow: 0 5px 10px #00334040; }
.wild-card-value { font-size: 54px; line-height: 1; font-weight: 700; letter-spacing: -2px; }
.wild-card.is-double .wild-card-value { font-size: 46px; letter-spacing: -3px; }
.wild-card-corner { position: absolute; top: 6px; left: 7px; font-size: 16px; font-weight: 700; line-height: 1; text-align: center; }
.wild-card-corner small { display: block; font-size: 13px; margin-top: 2px; }
.wild-card-corner.bottom { top: auto; left: auto; right: 7px; bottom: 6px; transform: rotate(180deg); }
.score-entry { padding: 16px; margin-top: 12px; }
.score-entry h2 { font-size: 24px; margin: 0 0 14px; line-height: 1.3; overflow-wrap: anywhere; }
.score-entry .muted { margin: 0 0 14px; }
.score-fields { display: grid; gap: 3px; }
.score-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 66px; padding: 7px 8px; border-bottom: 1px solid var(--line); border-left: 4px solid transparent; border-radius: 8px; }
.score-row label { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; font-size: 21px; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
.score-row input { width: 86px; height: 52px; min-width: 0; flex-shrink: 0; padding: 5px; border: 1px solid var(--sage); border-radius: 8px; background: var(--paper); color: var(--ink); text-align: center; font-size: 30px; font-weight: 700; }
.score-row input[aria-invalid] { border: 2px solid var(--red); }
.score-row.is-dealer { border-left-color: var(--red); background: var(--warm-highlight); border-bottom-color: var(--warm-highlight); }
.is-dealer .player-name { font-weight: 700; }
.dealer-badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 4px; background: var(--ink); color: white; font-size: 13px; font-weight: 700; line-height: 1.4; letter-spacing: .3px; }
.scorecard { overflow: hidden; min-width: 0; }
.table-wrap { max-height: clamp(420px, calc(100dvh - 132px), 760px); overflow: auto; overscroll-behavior: contain; scroll-padding-top: 110px; scroll-padding-bottom: 90px; isolation: isolate; }
table { border-collapse: collapse; width: 100%; table-layout: auto; font-variant-numeric: tabular-nums; line-height: 1.35; }
th, td { text-align: center; padding: 9px 5px; font-size: 22px; overflow-wrap: anywhere; }
thead th { position: sticky; top: 0; z-index: 3; background: var(--sage-tint); font-size: 28px; font-weight: 700; padding: 14px 4px; border-top: 1px solid var(--sage); box-shadow: 0 1px var(--sage); vertical-align: middle; }
thead th:first-child { left: 0; z-index: 4; width: 60px; text-align: left; padding-left: 12px; font-size: 14px; }
.table-name { display: block; font-size: 28px; line-height: 1.25; font-weight: 700; overflow-wrap: normal; word-break: normal; }
tbody tr { border-bottom: 1px solid #e0e6e1; }
tbody th { position: sticky; left: 0; z-index: 1; padding-left: 12px; font-weight: 600; text-align: left; background: var(--paper); }
.rank-symbol { display: inline-block; width: 48px; font-size: 22px; font-weight: 700; white-space: nowrap; }
.row-status { display: block; font-size: 11px; font-weight: 600; line-height: 1.2; }
.current-round { background: var(--sage-tint); }
.current-round th { background: var(--gold); box-shadow: inset 3px 0 var(--orange); }
.latest-round:not(.current-round), .latest-round:not(.current-round) th { background: #f7f2eb; }
.latest-round td { font-weight: 700; }
.unplayed { color: #778174; font-size: 20px; }
tfoot { border-top: 2px solid var(--line); }
tfoot th, tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--sage-tint); box-shadow: 0 -2px var(--sage); }
tfoot th { left: 0; z-index: 4; padding-left: 10px; text-align: left; font-size: 14px; }
tfoot td { font-size: 30px; font-weight: 700; padding: 16px 4px; }
tfoot .leading-total { background: var(--gold); }
.crown { display: block; font-size: 18px; line-height: 17px; margin-bottom: 4px; color: var(--ink); }
.scorecard-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 5px 16px; padding: 12px 16px; color: var(--muted); font-size: 13px; }
.guide { border: 1px solid var(--line); border-radius: 12px; padding: 0 20px; background: var(--canvas); }
.guide summary { list-style: none; cursor: pointer; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 17px; font-weight: 700; }
.guide summary::-webkit-details-marker { display: none; }
.guide-toggle { transition: transform .15s; }
.guide[open] .guide-toggle { transform: rotate(180deg); }
.guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 30px; padding: 20px 0 10px; border-top: 1px solid var(--line); }
.guide-grid > div { display: grid; grid-template-columns: 80px 1fr; column-gap: 12px; align-items: center; }
.guide-grid strong { grid-row: span 2; font-size: 26px; font-weight: 700; }
.guide-grid span { font-size: 16px; color: var(--muted); }
.guide-grid b { font-size: 18px; font-weight: 700; margin-top: 3px; }
.guide > p { font-size: 15px; color: var(--muted); margin: 10px 0 18px; }
.setup-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: start; max-width: 1190px; margin: 12px auto 35px; }
.welcome { padding-top: 16px; }
.welcome h1 { margin: 22px 0 20px; }
.welcome h1 em { font-style: normal; color: var(--red); }
.welcome > p { max-width: 440px; font-size: 20px; color: var(--muted); }
.welcome-tags { display: flex; flex-wrap: wrap; gap: 10px; font-size: 14px; color: var(--muted); }
.welcome-tags span + span:before { content: '•'; margin-right: 10px; }
.setup-panel { padding: 28px; }
.setup-panel .panel-top { flex-wrap: wrap; }
.setup-panel h2 { font-size: 32px; margin: 24px 0 8px; }
.step-label { font-size: 12px; letter-spacing: .8px; color: var(--muted); white-space: nowrap; }
.player-count { display: flex; gap: 10px; margin: 16px 0 24px; }
.count-button { flex: 1; min-height: 52px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--paper); font-size: 26px; font-weight: 700; }
.count-button:hover { background: var(--sage-tint); }
.count-button.selected { color: white; background: var(--ink); border-color: var(--ink); }
.name-list { display: grid; gap: 10px; }
.name-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; background: var(--sage-tint); color: var(--ink); font-size: 16px; font-weight: 700; }
.color-1, .color-4 { background: var(--warm-highlight); }
.color-2, .color-5 { background: var(--gold); }
.color-3 { background: var(--canvas); border: 1px solid var(--line); }
.name-row .avatar { width: 30px; height: 30px; }
.name-row input { width: auto; flex: 1; min-width: 0; height: 54px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font-size: 20px; }
.dealer-tag { flex-basis: 100%; padding-left: 38px; font-size: 12px; font-weight: 700; color: #72401c; letter-spacing: .8px; }
.reorder { display: flex; }
.reorder button { width: 48px; height: 48px; border: 0; background: transparent; color: var(--ink); font-size: 24px; }
select { width: 100%; min-height: 54px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font-size: 20px; }
.setup-intro { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 24px 0; border-top: 1px dashed var(--line); }
.setup-intro > span { font-size: 26px; color: var(--red); letter-spacing: 3px; }
.setup-intro p { font-size: 17px; color: var(--muted); margin: 0; }
.card-art { position: relative; height: 285px; max-width: 430px; margin: 5px 0 20px; }
.playing-card { position: absolute; width: 140px; height: 199px; background: var(--paper); border-radius: 12px; border: 1px solid var(--line); box-shadow: 0 14px 28px #26323820; padding: 12px; }
.playing-card > span { font-size: 26px; display: block; line-height: 1; }
.playing-card small { display: block; font-size: 22px; margin-top: 4px; }
.playing-card > b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 76px; font-weight: 400; }
.playing-card .card-bottom { position: absolute; right: 12px; bottom: 12px; transform: rotate(180deg); }
.art-ace { left: 75px; top: 38px; transform: rotate(-14deg); color: var(--ink); }
.art-king { left: 183px; top: 45px; transform: rotate(12deg); color: var(--red); }
.art-star { position: absolute; color: var(--orange); }
.star-one { left: 25px; top: 65px; font-size: 45px; }
.star-two { right: 15px; top: 178px; font-size: 36px; }
.art-caption { position: absolute; bottom: 0; left: 95px; transform: rotate(-5deg); font-size: 16px; color: var(--muted); }
.standings { list-style: none; padding: 0; margin: 18px 0 22px; }
.standings li { display: flex; align-items: center; gap: 9px; font-size: 20px; border-top: 1px solid var(--line); padding: 12px 0; }
.standings li > span:nth-child(3) { min-width: 0; overflow-wrap: anywhere; }
.standings .placing { width: 20px; font-size: 15px; color: var(--muted); }
.standings strong { margin-left: auto; white-space: nowrap; }
.standings small { font-size: 14px; font-weight: 400; color: var(--muted); }
.finish-icon { font-size: 42px; color: var(--red); margin: 0 0 12px; }
#notice { max-width: 1392px; margin: 12px auto 0; padding: 14px 20px; border: 1px solid var(--orange); border-radius: 8px; background: var(--warm-highlight); font-size: 16px; }
dialog { max-width: 620px; width: calc(100% - 32px); padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); color: var(--ink); box-shadow: 0 20px 80px #0003; }
dialog::backdrop { background: #26323880; backdrop-filter: blur(3px); }
dialog h2 { margin: 18px 0 10px; }
dialog p { font-size: 17px; color: var(--muted); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
@media (min-width: 1200px) {
  .game-layout { grid-template-columns: 340px minmax(0, 1fr); gap: 22px; }
  .score-row input { width: 96px; }
  .round-banner h2 { font-size: 28px; }
  .wild-card { width: 98px; }
  .wild-card-value { font-size: 60px; }
}
@media (max-width: 1000px) {
  .game-layout, .setup-layout { grid-template-columns: minmax(0, 1fr); }
  .setup-layout { max-width: 560px; margin-left: auto; margin-right: auto; }
  .welcome h1 { font-size: 38px; }
  .card-art { display: none; }
  .table-wrap { max-height: 65dvh; min-height: 360px; }
  .scorecard .table-wrap table { min-width: 380px; }
  .scorecard:has(thead th:nth-child(5)) table { min-width: 610px; }
  .scorecard:has(thead th:nth-child(6)) table { min-width: 730px; }
  .scorecard:has(thead th:nth-child(7)) table { min-width: 850px; }
  .round-banner { max-width: none; }
}
@media (max-width: 600px) {
  .masthead { min-height: 72px; padding: 10px 16px; gap: 10px; }
  .brand { font-size: 21px; gap: 7px; letter-spacing: -.7px; }
  .brand-mark { width: 28px; height: 34px; font-size: 25px; }
  #new-game { font-size: 15px; min-height: 48px; padding: 10px; }
  main, .playing main { padding: 16px 14px 0; }
  .game-layout { gap: 16px; }
  .round-banner { height: 150px; }
  .round-banner h2 { font-size: 28px; }
  .guide { padding: 0 16px; }
  .guide summary { font-size: 16px; }
  .guide-grid { grid-template-columns: minmax(0, 1fr); }
  .setup-panel { padding: 22px; }
  .setup-panel h2 { font-size: 30px; }
  .welcome { padding-top: 0; }
  .welcome > p { font-size: 18px; }
  .reorder button { width: 34px; }
  .name-row input { font-size: 19px; }
  footer { padding: 18px 16px; }
  #notice { margin-left: 14px; margin-right: 14px; }
}
@media (prefers-reduced-motion: no-preference) {
  .panel, .round-banner { animation: arrive .2s ease-out; }
  @keyframes arrive { from { opacity: .5; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
}

/* Preserve table-night readability at tablet widths. */
.game-layout { grid-template-columns: 380px minmax(0, 1fr); }
.round-banner { height: auto; min-height: 120px; }
.round-banner h2 { white-space: normal; font-size: 30px; }
.round-progress { font-size: 20px; overflow-wrap: anywhere; }
.golf-mark { font-size: 64px; line-height: 1; }
.leader-summary { margin-top: 12px; padding: 14px 16px; background: var(--sage-tint); border: 1px solid var(--sage); border-radius: 12px; font-size: 22px; font-weight: 700; overflow-wrap: anywhere; }
.score-row { flex-wrap: wrap; gap: 8px; padding: 10px 8px; }
.score-row label { font-size: 28px; flex: 1 1 130px; }
.score-control { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.score-row input { font-size: 32px; width: 100px; height: 56px; }
.sign-button { width: 48px; height: 56px; border: 1px solid var(--sage); background: var(--sage-tint); border-radius: 8px; color: var(--ink); font-size: 30px; font-weight: 700; }
.dealer-badge { font-size: 16px; }
.player-count { flex-wrap: wrap; gap: 8px; }
.count-button { flex: 1 0 48px; min-width: 48px; }
.reorder button { width: 48px; min-height: 48px; }
.table-wrap { max-height: min(760px, calc(100dvh - 140px)); }
th, td { font-size: 26px; padding: 12px 10px; }
thead th { min-width: 130px; }
thead th:first-child { min-width: 76px; }
.table-name { font-size: 28px; overflow-wrap: normal; word-break: normal; min-width: 130px; }
.rank-symbol { font-size: 26px; }
tfoot td { font-size: 36px; padding: 16px 10px; white-space: nowrap; }
.row-status { font-size: 14px; }
.standings li { flex-wrap: wrap; font-size: 24px; }
.standings strong { font-size: 30px; }
.scorecard-foot { font-size: 16px; }
.text-button { font-size: 18px; }
@media (max-width: 1100px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .score-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
  .table-wrap { max-height: 65dvh; }
}
@media (max-width: 650px) {
  .score-fields { grid-template-columns: minmax(0, 1fr); }
  .score-row label { flex-basis: 100px; }
  .masthead { flex-wrap: wrap; }
  .brand { font-size: 24px; }
  .setup-panel { padding: 18px; }
  .name-row .avatar { display: none; }
  .dealer-tag { padding-left: 0; }
}
@media (min-width: 651px) and (max-width: 850px) {
  .score-row label { flex-basis: 100%; overflow-wrap: anywhere; }
}
