/* Layout: a harvest table. A chestnut header band with drifting maple
   leaves, warm parchment ground, table "place cards" for each game, and
   tabular figures so scores line up across the room. */
:root {
  --bark: #3b1f12;
  --bark-2: #6b2a12;
  --bark-ink: #fbefdc;
  --bg: #faf3e8;
  --card: #fffaf3;
  --ink: #2a1a10;
  --muted: #75604f;
  --line: #e7d8c3;
  --pumpkin: #c4511a;
  --gold: #b97f16;
  --cranberry: #9b1d32;
  --good: #3f6b32;
  --warn: #8a5300;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --text: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bark: #22110a; --bark-2: #4a1d0c; --bark-ink: #f7e6cf; --bg: #1a110b; --card: #261810; --ink: #f4e7d6;
    --muted: #b89f88; --line: #3d2a1d; --pumpkin: #f08a3e; --gold: #e7b04a; --cranberry: #ec7186; --good: #9bc47f; --warn: #f0c060;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bark: #22110a; --bark-2: #4a1d0c; --bark-ink: #f7e6cf; --bg: #1a110b; --card: #261810; --ink: #f4e7d6;
  --muted: #b89f88; --line: #3d2a1d; --pumpkin: #f08a3e; --gold: #e7b04a; --cranberry: #ec7186; --good: #9bc47f; --warn: #f0c060;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--text);
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
a { color: var(--pumpkin); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding-block: 24px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header band: chestnut with a scatter of maple leaves */
.bar {
  position: relative;
  overflow: hidden;
  color: var(--bark-ink);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='90' viewBox='0 0 160 90'%3E%3Cg fill='%23ffffff' fill-opacity='0.06'%3E%3Cpath d='M20 10l3 7 6-3-2 7 6 2-6 3 2 6-6-2-3 7-3-7-6 2 2-6-6-3 6-2-2-7 6 3z'/%3E%3Cpath d='M110 50l2.4 5.6 4.8-2.4-1.6 5.6 4.8 1.6-4.8 2.4 1.6 4.8-4.8-1.6-2.4 5.6-2.4-5.6-4.8 1.6 1.6-4.8-4.8-2.4 4.8-1.6-1.6-5.6 4.8 2.4z'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(115deg, var(--bark), var(--bark-2));
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 4px solid var(--pumpkin);
}
.bar-inner {
  position: relative;
  z-index: 1;
  max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 10px 24px;
  align-items: center; justify-content: space-between; padding-block: 14px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; font: 800 1.45rem/1.1 var(--display); letter-spacing: -0.01em; }
.brand svg { width: 30px; height: 30px; flex: none; }
nav { display: flex; flex-wrap: wrap; gap: 4px; }
nav a {
  text-decoration: none; padding: 6px 13px; border-radius: 999px; font-weight: 600; font-size: 0.95rem;
  color: color-mix(in srgb, var(--bark-ink) 82%, transparent);
}
nav a[aria-current="page"] { background: var(--bark-ink); color: var(--bark); }

/* A few leaves drifting down the header */
.leaves { position: absolute; inset: 0; pointer-events: none; }
.leaves span {
  position: absolute; top: -24px; width: 16px; height: 16px; opacity: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23e0892f' d='M12 1l2.7 6.3 5.4-2.7-1.8 6.3 5.4 1.8-5.4 2.7 1.8 5.4-5.4-1.8L12 23l-2.7-4.5-5.4 1.8 1.8-5.4-5.4-2.7 5.4-1.8-1.8-6.3 5.4 2.7z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.leaves span:nth-child(2) { left: 22%; animation-delay: 3s; width: 12px; height: 12px; }
.leaves span:nth-child(3) { left: 48%; animation-delay: 7s; }
.leaves span:nth-child(4) { left: 71%; animation-delay: 1.5s; width: 13px; height: 13px; }
.leaves span:nth-child(5) { left: 90%; animation-delay: 5s; }
.leaves span:nth-child(1) { left: 8%; }
@media (prefers-reduced-motion: no-preference) {
  .leaves span { animation: drift 11s linear infinite; }
}
@keyframes drift {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.85; }
  100% { transform: translate(-40px, 130px) rotate(260deg); opacity: 0; }
}

h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.12; text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.7rem, 4.2vw, 2.7rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.09em; font-size: 0.74rem; font-weight: 700; color: var(--pumpkin); }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.stack { display: grid; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; }
.spread { justify-content: space-between; }
.narrow { max-width: 28rem; }

/* Round header */
.round-head { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: end; justify-content: space-between; margin-bottom: 22px; }
.pace { display: flex; gap: 20px; flex-wrap: wrap; color: var(--muted); font-size: 0.95rem; }
.pace b { color: var(--ink); font-weight: 600; }

/* Table place cards */
.tables { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.table {
  background: var(--card); border: 1px solid var(--line); border-top: 5px solid var(--gold); border-radius: 14px; padding: 18px;
  display: grid; gap: 12px; min-width: 0;
}
.table-name { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.table-name h2 { font-size: 1.4rem; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.team { display: grid; gap: 2px; min-width: 0; }
.team span { font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.team.b { text-align: right; }
.vs-mark { font: italic 700 0.95rem var(--display); color: var(--pumpkin); }
.score { font: 800 2rem/1 var(--display); }
.win .score { color: var(--good); }
.status { font-size: 0.82rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.status.playing { color: var(--warn); border-color: currentColor; }
.status.done { color: var(--good); border-color: currentColor; }
.status.flag { color: var(--cranberry); border-color: currentColor; }
.flag-text { color: var(--cranberry); font-weight: 600; }
.me-highlight { outline: 3px solid var(--pumpkin); outline-offset: 2px; }

/* Data tables */
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.97rem; }
.data th, .data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.data td.num, .data th.num { text-align: right; }
.data tr:last-child td { border-bottom: 0; }
.rank { font: 800 1.15rem var(--display); color: var(--pumpkin); width: 3ch; }
.data tr.mine td { background: color-mix(in srgb, var(--gold) 14%, transparent); }

/* My page */
.seat {
  color: var(--bark-ink); border-radius: 16px; padding: 24px; display: grid; gap: 12px;
  background: linear-gradient(135deg, var(--bark-2), var(--bark));
}
.seat .eyebrow { color: var(--gold); }
.seat .big { font: 800 clamp(2rem, 7vw, 3.2rem)/1.05 var(--display); }
.seat dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 1.1rem; }
.seat dt { color: color-mix(in srgb, var(--bark-ink) 70%, transparent); }
.seat dd { margin: 0; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stats > div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; }
.stats b { font: 800 1.7rem/1.1 var(--display); }
.champion h1 { color: var(--pumpkin); }

/* Forms */
label { display: grid; gap: 4px; font-weight: 500; font-size: 0.95rem; }
input, select, textarea, button { font: inherit; }
input[type="text"], input[type="number"], input[type="password"], input[type="tel"], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
textarea { min-height: 14rem; resize: vertical; }
textarea.short { min-height: 8rem; }
.fields input[type="number"] { max-width: 9rem; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
button {
  border: 1px solid var(--pumpkin); background: var(--pumpkin); color: #fff; padding: 10px 16px;
  border-radius: 10px; font-weight: 600; cursor: pointer;
}
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.danger { background: transparent; color: var(--cranberry); border-color: currentColor; }
button.small { padding: 5px 10px; font-size: 0.85rem; }
button.link { background: none; border: 0; padding: 0; color: var(--pumpkin); text-decoration: underline; font-weight: 500; }
button.camera { border-style: dashed; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.small-links { font-size: 0.9rem; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 14px; min-width: 0; }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.team-form { display: grid; gap: 10px; align-content: start; }
.team-form .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: 10px; }
.total-line { font: 800 1.6rem var(--display); }
.msg { padding: 10px 12px; border-radius: 10px; font-size: 0.95rem; }
.msg.error { color: var(--cranberry); border: 1px solid currentColor; }
.msg.warn { color: var(--warn); border: 1px solid currentColor; }
.msg.ok { color: var(--good); border: 1px solid currentColor; }
.code { font: 800 1.5rem var(--display); letter-spacing: 0.12em; }
.cov { font-weight: 600; }
details summary { cursor: pointer; font-weight: 600; padding-block: 6px; }

/* Card review dialog */
dialog.review {
  width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; background: var(--card); color: var(--ink);
}
dialog.review::backdrop { background: rgb(20 10 4 / 0.55); }
.meld { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px;
  font-weight: 700; min-width: 2.8rem;
}
.chip.red { color: var(--cranberry); }
.tag { padding: 4px 10px; font-size: 0.82rem; border-radius: 999px; }
.tag.clean { background: var(--good); border-color: var(--good); }
.tag.dirty { background: var(--warn); border-color: var(--warn); }
.add-card { display: inline-flex; gap: 6px; align-items: center; }
.add-card select { width: auto; padding: 5px 8px; }

/* Banner picture: the turkeys at the card table */
.hero { position: relative; border-radius: 18px; overflow: hidden; background: var(--bark); aspect-ratio: 3 / 1; max-height: 360px; width: 100%; }
.hero.slim { aspect-ratio: 4 / 1; margin-bottom: 22px; }
.hero.small { aspect-ratio: 16 / 9; }
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 42%; }
.hero-text {
  position: absolute; inset: auto 0 0 0; padding: 18px 20px; display: grid; gap: 4px; color: #fff7ea;
  background: linear-gradient(to top, rgb(30 12 4 / 0.85), rgb(30 12 4 / 0));
}
.hero-text h1 { font-size: clamp(1.4rem, 3.6vw, 2.5rem); text-shadow: 0 2px 8px rgb(0 0 0 / 0.45); }
.hero-text p { font-size: 0.98rem; max-width: 60ch; text-shadow: 0 1px 6px rgb(0 0 0 / 0.5); }
@media (max-width: 600px) {
  .hero, .hero.slim { aspect-ratio: 16 / 9; }
}

/* Rules page */
.toc { display: flex; flex-wrap: wrap; gap: 8px; }
.toc a { text-decoration: none; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font-weight: 600; font-size: 0.9rem; }
.rules ul, .rules ol { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; max-width: 70ch; }
.rules section { scroll-margin-top: 16px; }
.formula { font: 600 1.1rem var(--display); padding: 12px 14px; border-left: 4px solid var(--pumpkin); background: var(--bg); border-radius: 0 10px 10px 0; }
.small { font-size: 0.85rem; }

.foot { color: var(--muted); font-size: 0.85rem; padding-block: 8px 28px; }

/* Big-screen display: larger type when shown on a TV. */
@media (min-width: 1500px) {
  body { font-size: 19px; }
  .wrap, .bar-inner { max-width: 1600px; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .stats b { font-size: 1.35rem; }
}
