/* The Meld Table: a card table in the evening. Claret baize, cream card stock, a little gold. */
:root {
  --paper: #F2F1EE;
  --card: #FFFDF7;        /* card stock */
  --ink: #2B1B2E;         /* aubergine ink */
  --muted: #5F5563;
  --claret: #7A1F3D;      /* table baize */
  --claret-deep: #5E1730;
  --red: #C8213F;         /* hearts and diamonds */
  --gold: #B88A2A;
  --blue: #2F5F86;        /* card-back blue */
  --line: #DCD6D0;
  --good: #2F7A4A; --good-bg: #E3F2E8;
  --focus: #2F6FD6;
  --radius: 12px;
  --wrap: 1100px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #18131A; --card: #231C25; --ink: #F1EAE6; --muted: #B8ABB5; --claret: #B2456A; --red: #F0607A;
    --gold: #D9AE52; --blue: #7FB0D8; --line: #3A2F3C; --good: #7CC79A; --good-bg: #1E3327; color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 19px/1.6 Lexend, system-ui, sans-serif; }
[hidden] { display: none !important; }
img, svg, canvas { max-width: 100%; }
a { color: var(--claret); text-underline-offset: 3px; }
a:hover { color: var(--red); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
main { padding: 28px 0 56px; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; font-family: "Zilla Slab", Georgia, serif; font-weight: 700; }
h1 { font-size: clamp(2.1rem, 5vw, 3.2rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.45rem, 3vw, 1.9rem); }
h3 { font-size: 1.2rem; font-family: Lexend, sans-serif; font-weight: 600; }
p { margin: 0 0 1em; }
.lede { font-size: 1.2rem; color: var(--muted); max-width: 40rem; }
.small { font-size: .92rem; color: var(--muted); }
.read { max-width: 46rem; }
.eyebrow { color: var(--claret); font-weight: 600; font-size: .95rem; margin-bottom: .3em; }

/* header: the baize */
.site-head { background: var(--claret-deep); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .site-head { background: #3A1020; } }
.head-row { display: flex; align-items: center; gap: 24px; min-height: 66px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: "Zilla Slab", Georgia, serif; font-weight: 700; font-size: 1.45rem; }
.brand:hover { color: #fff; }
.logo { width: 38px; height: 34px; }
.nav { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav a { color: #F3DDE4; text-decoration: none; padding: 8px 12px; white-space: nowrap; font-weight: 500; font-size: .95rem; border-radius: 6px; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a[aria-current] { color: #fff; box-shadow: inset 0 -3px 0 var(--gold); border-radius: 0; }
@media (max-width: 760px) { .head-row { gap: 0; padding-top: 10px; } .nav { margin: 0 -20px; padding: 4px 14px 8px; width: calc(100% + 40px); } }

.site-foot { border-top: 1px solid var(--line); padding: 28px 0 40px; font-size: .9rem; color: var(--muted); }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 12px; }
.site-foot a { color: var(--ink); }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 10px 20px; border-radius: 10px; border: 2px solid var(--ink);
  background: var(--card); color: var(--ink); font: 600 1rem Lexend, sans-serif; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--paper); color: var(--ink); }
.btn.primary { background: var(--claret); border-color: var(--claret); color: #fff; }
.btn.primary:hover { background: var(--claret-deep); border-color: var(--claret-deep); color: #fff; }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: .9rem; }
.btn.quiet { border-color: var(--line); }
label { font-weight: 500; }
input[type=number], input[type=text], select { font: inherit; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); min-height: 48px; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; accent-color: var(--claret); vertical-align: -5px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stack > * + * { margin-top: 14px; }
section + section { margin-top: 48px; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.table-scroll { overflow-x: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* home hero: a fanned meld is the one loud element */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 36px; align-items: center; padding: 16px 0 30px; }
.hero h1 { font-size: clamp(2.4rem, 5.6vw, 3.8rem); }
.fan { position: relative; height: 300px; }
.fan svg { position: absolute; left: 50%; bottom: 34px; width: 132px; height: 186px; transform-origin: 50% 165%; filter: drop-shadow(0 8px 14px rgba(43,27,46,.25)); }
.table-felt { background: radial-gradient(ellipse at 50% 40%, #8C2A4A, #5E1730 70%); border-radius: 24px; padding: 24px; box-shadow: inset 0 0 0 8px rgba(0,0,0,.12); }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; } .fan { height: 250px; } .fan svg { width: 108px; height: 152px; bottom: 26px; } }
.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.tool { display: block; padding: 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none; border-top: 5px solid var(--claret); }
.tool:nth-child(2) { border-top-color: var(--blue); } .tool:nth-child(3) { border-top-color: var(--gold); } .tool:nth-child(4) { border-top-color: var(--good); }
.tool:hover { border-color: var(--ink); color: var(--ink); }
.tool h3 { margin: 0 0 4px; }
.tool p { margin: 0; color: var(--muted); font-size: .95rem; }
.guide-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-width: 900px; }
@media (max-width: 700px) { .guide-list { grid-template-columns: 1fr; } }
.guide-list a { display: flex; gap: 12px; align-items: center; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--gc, var(--claret)); border-radius: 10px; color: var(--ink); text-decoration: none; }
.guide-list a:hover { border-color: var(--gc, var(--claret)); }
.guide-list .suit { font-size: 1.6rem; line-height: 1; width: 1.4em; text-align: center; color: var(--gc, var(--claret)); }
.guide-list b { display: block; font-weight: 600; }
.guide-list span.d { display: block; color: var(--muted); font-size: .85rem; line-height: 1.35; }

/* scorekeeper */
.sk-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { font: 600 1rem Lexend, sans-serif; padding: 10px 16px; min-height: 48px; border: 0; background: var(--card); color: var(--ink); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--claret); color: #fff; }
.board { display: grid; grid-template-columns: repeat(var(--teams, 2), minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .board.three { grid-template-columns: 1fr; } }
.team { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; border-top: 6px solid var(--tc, var(--claret)); }
.team input.tname { width: 100%; text-align: center; font-weight: 600; border-color: transparent; background: transparent; min-height: 40px; }
.team input.tname:hover, .team input.tname:focus { border-color: var(--line); }
.team .total { font-family: "Zilla Slab", Georgia, serif; font-size: clamp(2.6rem, 9vw, 4rem); font-weight: 700; line-height: 1; margin: 4px 0; font-variant-numeric: tabular-nums; }
.team .need { font-size: .9rem; color: var(--muted); }
.team.lead .total { color: var(--good); }
.entry { margin-top: 18px; }
.entry-grid { display: grid; grid-template-columns: repeat(var(--teams, 2), minmax(0, 1fr)); gap: 12px; }
@media (max-width: 700px) { .entry-grid { grid-template-columns: 1fr; } }
.tcol { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; border-left: 6px solid var(--tc, var(--claret)); }
.tcol h3 { margin: 0 0 8px; }
.row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.row:last-of-type { border-bottom: 0; }
.row .lab { font-size: .95rem; }
.row .lab small { display: block; color: var(--muted); font-size: .78rem; }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); font: 600 1.3rem Lexend, sans-serif; cursor: pointer; }
.stepper output, .stepper input { min-width: 2.2ch; text-align: center; font-weight: 600; font-size: 1.1rem; }
.stepper input { width: 4.6em; min-height: 44px; padding: 4px 6px; }
.pts input { width: 6.2em; text-align: right; font-weight: 600; }
.hand-total { margin-top: 10px; padding-top: 8px; border-top: 2px solid var(--ink); display: flex; justify-content: space-between; font-weight: 700; font-size: 1.1rem; }
.hand-total .neg { color: var(--red); }
.counter-btn { font: 500 .8rem Lexend, sans-serif; color: var(--claret); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }
.history td, .history th { text-align: center; font-variant-numeric: tabular-nums; }
.history td:first-child, .history th:first-child { text-align: left; }
.banner { padding: 14px 16px; border-radius: 10px; background: var(--good-bg); color: var(--good); font-weight: 600; margin-bottom: 14px; }
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; max-width: 460px; width: calc(100% - 24px); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(20,10,20,.45); }
dialog .dlg { padding: 18px; }
.settings-grid { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.settings-grid input { width: 7em; }

/* prose */
.prose h2 { margin-top: 1.6em; }
.prose h3 { margin-top: 1.3em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .35em; }
.prose table { margin: 1em 0 1.4em; }
.prose .card { margin-top: 2em; }

/* printable sheets */
.sheet { background: #fff; color: #000; border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.sheet table { font-size: .95rem; }
.sheet th, .sheet td { border: 1px solid #999; height: 30px; text-align: center; color: #000; }
.sheet th { background: #f3f3f3; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  .site-head, .site-foot, .no-print { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  main { padding: 0; }
  .sheet { border: 0; padding: 0; }
  .sheet + .sheet { break-before: page; }
}
.table-felt { overflow: hidden; }
.sheet { overflow-x: auto; }

@media (max-width: 520px) { .fan { transform: scale(.8); transform-origin: 50% 100%; } }
