/* Card Night design system --------------------------------------------------
   Card-room look: felt-green nav and heroes, card red accent, chip gold highlights,
   Inter for text and Fraunces for display numbers. Same structure as the F1 Pool system.
   Use tokens (var(--...)) everywhere so dark mode just works. */

:root {
  --accent: #c8102e;
  --accent-dark: #a00c24;
  --felt: #0f4d36;
  --felt-2: #13603f;
  --felt-dark: #0a3324;
  --ink: #14211b;
  --carbon: #1d2a24;
  --carbon-2: #1d6b49;
  --chip-gold: #e0b43c;
  --bg: #f3f1ea;
  --surface: #ffffff;
  --surface-2: #f8f7f5;
  --text: #15151e;
  --muted: #67676f;
  --line: #e4e1dc;
  --line-strong: #cfcbc4;
  --hit: #0f9d58;
  --hit-bg: #e3f6ec;
  --miss: #9a9aa2;
  --neg: #d93025;
  --neg-bg: #fde8e7;
  --gold: #d4a017;
  --silver: #9ea3a8;
  --bronze: #b0703c;
  --warn: #b26a00;
  --warn-bg: #fff4e0;
  --info-bg: #e8f0fe;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(21, 21, 30, .06), 0 4px 16px rgba(21, 21, 30, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1411; --surface: #16201b; --surface-2: #1d2a23; --text: #eef2ef; --muted: #9fb0a7;
    --line: #26352d; --line-strong: #35483d; --hit-bg: #0f2e1f; --neg-bg: #3a1513; --warn-bg: #33250d;
    --info-bg: #17223a; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1411; --surface: #16201b; --surface-2: #1d2a23; --text: #eef2ef; --muted: #9fb0a7;
  --line: #26352d; --line-strong: #35483d; --hit-bg: #0f2e1f; --neg-bg: #3a1513; --warn-bg: #33250d;
  --info-bg: #17223a; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column;
}
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
img { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .5em; font-weight: 700; }
h1 { font-family: var(--display); font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.upper { text-transform: uppercase; letter-spacing: .04em; }
.display { font-family: var(--display); font-weight: 800; letter-spacing: -.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* --- Layout -------------------------------------------------------------- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 24px; padding-bottom: 48px; flex: 1; }
.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 28px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } .span-2 { grid-column: auto; } }

/* --- Top nav -------------------------------------------------------------- */
.topbar { background: var(--felt-dark); color: #fff; border-top: 3px solid var(--chip-gold); position: sticky; top: 0; z-index: 50; }
.topbar .container { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; font-family: var(--display);
  font-weight: 800; font-size: 1.35rem; letter-spacing: -.01em; white-space: nowrap; }
.brand:hover { color: #fff; }
.brand-mark { display: inline-flex; gap: 1px; font-size: 1rem; line-height: 1; }
.brand-mark i { font-style: normal; color: #fff; }
.brand-mark i.r { color: #ff6b7d; }
.nav { display: flex; gap: 2px; flex: 1; }
.nav a { color: #d6d6dd; text-decoration: none; font-weight: 600; padding: 8px 12px; border-radius: var(--radius-sm);
  text-transform: uppercase; font-size: .85rem; letter-spacing: .05em; }
.nav a:hover { color: #fff; background: var(--carbon-2); }
.nav a.active { color: #fff; box-shadow: inset 0 -3px 0 var(--chip-gold); border-radius: 0; }
.nav-user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--player, var(--accent)); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex: none; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; padding: 8px; cursor: pointer; }
.nav-toggle svg { width: 26px; height: 26px; }
@media (max-width: 860px) {
  .nav-toggle { display: block; margin-left: auto; }
  .nav { display: none; position: absolute; top: 63px; left: 0; right: 0; background: var(--felt-dark); flex-direction: column;
    padding: 8px 16px 16px; border-bottom: 3px solid var(--chip-gold); }
  .nav.open { display: flex; }
  .nav a { padding: 12px; }
  .nav a.active { box-shadow: inset 3px 0 0 var(--chip-gold); }
  .nav-user .user-name { display: none; }
}
.dropdown { position: relative; }
.dropdown > button { background: none; border: 0; padding: 0; cursor: pointer; display: flex; align-items: center; gap: 8px; color: #fff; font: inherit; }
.dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 10px); background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 190px; padding: 6px; z-index: 60; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: var(--radius-sm);
  text-decoration: none; background: none; border: 0; font: inherit; color: inherit; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); color: var(--text); }

/* --- Footer ----------------------------------------------------------------- */
.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 20px 0; }

/* --- Cards -------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; position: relative; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; text-transform: uppercase; font-size: 1rem; letter-spacing: .05em; }
.card.flush .card-head { padding: 14px 18px 0; }
.card.accent { border-top: 3px solid var(--accent); }
.card.corner::after { content: ""; position: absolute; top: -1px; right: -1px; width: 28px; height: 28px;
  border-top: 3px solid var(--accent); border-right: 3px solid var(--accent); border-top-right-radius: var(--radius); }

/* Hero: felt table banner with a faint card-suit pattern */
.hero { background: radial-gradient(120% 140% at 20% 0%, var(--felt-2) 0%, var(--felt) 45%, var(--felt-dark) 100%); color: #fff;
  border-radius: var(--radius); padding: 22px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.hero::before { content: "♠♥♦♣"; position: absolute; right: 16px; top: 50%; transform: translateY(-50%) rotate(-12deg);
  font-size: 7rem; letter-spacing: -.1em; color: rgba(255, 255, 255, .06); pointer-events: none; white-space: nowrap; }
.hero > * { position: relative; }
.hero .eyebrow { color: var(--chip-gold); }
.hero h1, .hero h2 { color: #fff; }
.hero .muted { color: #b9cfc3; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 700; color: var(--accent); }

/* --- Stat tiles ------------------------------------------------------------------ */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; color: var(--muted); font-weight: 700; }
.stat .value { font-family: var(--display); font-size: 2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .85rem; color: var(--muted); }
.hero .stat { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); }
.hero .stat .label, .hero .stat .sub { color: #b9cfc3; }

/* --- Buttons & forms ------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 2px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 18px; font: inherit; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: .85rem;
  cursor: pointer; text-decoration: none; background: var(--accent); color: #fff; transition: background .15s, transform .05s; }
.btn:hover { background: var(--accent-dark); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--felt); color: #fff; }
.btn.secondary:hover { background: var(--felt-2); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn.ghost:hover { border-color: var(--text); }
.btn.danger { background: transparent; border-color: var(--neg); color: var(--neg); }
.btn.danger:hover { background: var(--neg); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: .75rem; }
.btn.block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.hero .btn.ghost { color: #fff; border-color: rgba(255,255,255,.4); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 9px 11px; min-height: 42px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200, 16, 46, .15); }
textarea { min-height: 100px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.help { font-size: .82rem; color: var(--muted); }

/* --- Flash / alerts ------------------------------------------------------------- */
.flash { border-radius: var(--radius-sm); padding: 12px 14px; border-left: 4px solid var(--hit); background: var(--hit-bg); margin-bottom: 16px; }
.flash.error { border-color: var(--neg); background: var(--neg-bg); }
.flash.info { border-color: #4a7dff; background: var(--info-bg); }
.flash.warn { border-color: var(--warn); background: var(--warn-bg); }

/* --- Tables ------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  font-weight: 700; padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.me { background: rgba(200, 16, 46, .06); }
.table tr.me td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.table .num { text-align: right; }
.table.compact td, .table.compact th { padding: 6px 8px; }
.table td.sticky, .table th.sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; }

/* --- Pills, badges, positions -------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.red { background: var(--accent); color: #fff; border-color: var(--accent); }
.pill.green { background: var(--hit-bg); color: var(--hit); border-color: transparent; }
.pill.amber { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.pill.gold { background: var(--chip-gold); color: #2a1f00; border-color: var(--chip-gold); }
.pill.felt { background: var(--felt); color: #fff; border-color: var(--felt); }
.pos { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 28px; padding: 0 6px;
  font-weight: 800; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); }
.pos.p1 { background: var(--gold); color: #1a1300; border-color: var(--gold); }
.pos.p2 { background: var(--silver); color: #111; border-color: var(--silver); }
.pos.p3 { background: var(--bronze); color: #fff; border-color: var(--bronze); }
.move { font-size: .78rem; font-weight: 700; }
.move.up { color: var(--hit); } .move.down { color: var(--neg); } .move.same { color: var(--muted); }
.pts { font-weight: 800; font-variant-numeric: tabular-nums; }
.pts.big { font-size: 1.4rem; }
.pts.neg { color: var(--neg); }
.hit { background: var(--hit-bg); color: var(--hit); font-weight: 700; }
.miss { color: var(--miss); }
.neg { color: var(--neg); }


/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; font-weight: 700; text-transform: uppercase; font-size: .8rem; letter-spacing: .06em;
  color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a.active, .tabs a:hover { color: var(--text); border-bottom-color: var(--accent); }

/* Charts */
.chart-box { position: relative; height: 320px; }
.chart-box.sm { height: 200px; }
.chart-box.lg { height: 420px; }
.spark { display: block; }

/* Heatmap cells */
.heat { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; border-radius: 4px; min-width: 34px; }

/* Empty states */
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

/* Auth pages */
.auth-wrap { max-width: 420px; margin: 6vh auto; }
.auth-wrap .card { padding: 28px; }

/* Utility spacing */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.gap-sm { gap: 6px; }
.w-100 { width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* --- Card Night additions --------------------------------------------------- */
/* Player chip: coloured initials disc + name. style="--player: #hex" */
.pchip { display: inline-flex; align-items: center; gap: 8px; min-width: 0; text-decoration: none; }
.pchip .disc { width: 28px; height: 28px; border-radius: 50%; background: var(--player, var(--muted)); color: #fff; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .72rem;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35), 0 0 0 1.5px var(--player, var(--muted)); }
.pchip .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pchip.sm .disc { width: 22px; height: 22px; font-size: .62rem; }
.pchip.lg .disc { width: 48px; height: 48px; font-size: 1rem; }
.pchip .guest { font-size: .68rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

/* Money colouring */
.money-pos { color: var(--hit); font-weight: 700; font-variant-numeric: tabular-nums; }
.money-neg { color: var(--neg); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Game tiles on the home page */
.game-tile { display: block; text-decoration: none; border-radius: var(--radius); padding: 18px; color: #fff; position: relative; overflow: hidden;
  min-height: 120px; box-shadow: var(--shadow); }
.game-tile:hover { color: #fff; transform: translateY(-1px); }
.game-tile h3 { font-family: var(--display); font-size: 1.4rem; margin: 0 0 4px; }
.game-tile .suit { position: absolute; right: 12px; bottom: -14px; font-size: 5.5rem; opacity: .16; line-height: 1; }
.game-tile.wizard { background: linear-gradient(135deg, #3b2a7a, #1e1446); }
.game-tile.cribbage { background: linear-gradient(135deg, #8a4b14, #4a2608); }
.game-tile.poker { background: linear-gradient(135deg, var(--felt-2), var(--felt-dark)); }

/* Choice chips (multi-select players etc.) built from checkboxes/radios */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1.5px solid var(--line-strong);
  background: var(--surface); cursor: pointer; font-weight: 600; user-select: none; }
.choice input:checked + span { background: var(--felt); color: #fff; border-color: var(--felt); }
.choice input:focus-visible + span { box-shadow: 0 0 0 3px rgba(200, 16, 46, .25); }

/* Number stepper for fast score entry on phones */
.stepper { display: inline-flex; align-items: stretch; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.stepper button { background: var(--surface-2); border: 0; width: 40px; font-size: 1.2rem; font-weight: 700; cursor: pointer; color: var(--text); }
.stepper input { width: 56px; border: 0; text-align: center; border-radius: 0; min-height: 40px; padding: 0; }
/* Picker chips inside a .field must not inherit the uppercase field-label style */
.field label.choice { text-transform: none; letter-spacing: normal; font-size: inherit; font-weight: inherit; color: inherit; }
