/* DRPL premium theme. Tokens first; light and dark palettes follow the device
   (prefers-color-scheme). Header + hero stay dark in both themes so the black
   logo JPG blends seamlessly. */
:root {
  /* Brand constants (from the logo art) */
  --gold: #f0b43c;
  --gold-bright: #ffd76e;
  --gold-deep: #b07d1a;
  --river: #0a665b;
  --river-bright: #159080;
  --night: #0b0d12;          /* header ground, matches logo black */
  --night-panel: #141824;
  --night-line: #262d3d;
  --felt: #175c40;           /* poker felt green: the brand anchor */
  --felt-deep: #0f4530;
  --felt-bright: #1d6f4e;

  /* Light palette (default): felt-green anchor on warm light neutrals */
  --paper: #ecf1ea;
  --card: #ffffff;
  --ink: #1f2a24;
  --ink-soft: #5a655e;
  --line: #cfdccf;
  --accent-text: #8a6114;    /* gold dark enough for light backgrounds */
  --heading-ink: var(--felt-deep);
  --heading-accent: var(--gold);
  --brand: var(--river);
  --brand-strong: #084f47;
  --danger: #a4232a;
  --row-alt: #f2f7f0;
  --shadow: 0 1px 2px rgba(18, 32, 24, .06), 0 8px 24px rgba(18, 32, 24, .07);
  /* Table header: felt + gold in BOTH themes (the brand band) */
  --thead-bg: var(--felt);
  --thead-ink: var(--gold-bright);
  /* Hero: the poker table - felt gradient in both themes */
  --hero-bg: radial-gradient(130% 180% at 85% -30%, rgba(255, 215, 110, .12) 0%, transparent 50%),
             linear-gradient(160deg, var(--felt-bright) 0%, var(--felt) 55%, var(--felt-deep) 100%);
  --hero-border: var(--felt-deep);
  --hero-ink: #eef3ec;
  --hero-sub: #c4d6c6;
  --hero-h1-top: var(--gold-bright);
  --hero-h1-bottom: var(--gold);
  --hero-tile-bg: rgba(255, 255, 255, .09);
  --hero-tile-line: rgba(255, 255, 255, .14);
  --hero-tile-accent: var(--gold-bright);
  --hero-link: #ffffff;

  --radius: 12px;
  --radius-sm: 8px;
  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

/* Dark tokens apply two ways: device preference (unless the user explicitly
   chose light) or an explicit user choice via the theme toggle. The two
   blocks below must stay identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d1411;
    --card: #131e18;
    --ink: #e4e8e1;
    --ink-soft: #97a49b;
    --line: #24352b;
    --accent-text: var(--gold);
    --heading-ink: var(--gold-bright);
    --heading-accent: var(--felt-bright);
    /* Links/interactive teal must clear AA on the dark cards. */
    --brand: #3ec9a7;
    --brand-strong: #63dcc0;
    --danger: #e8707a;
    --row-alt: #172420;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
    --hero-bg: radial-gradient(130% 180% at 85% -30%, rgba(255, 215, 110, .08) 0%, transparent 50%),
               linear-gradient(160deg, var(--felt) 0%, var(--felt-deep) 60%, #0a3323 100%);
    --hero-border: #0a3323;
    --hero-ink: #e9efe6;
    --hero-sub: #b2c4b4;
    --hero-h1-top: var(--gold-bright);
    --hero-h1-bottom: var(--gold);
    --hero-tile-bg: rgba(255, 255, 255, .07);
    --hero-tile-line: rgba(255, 255, 255, .11);
    --hero-tile-accent: var(--gold-bright);
    --hero-link: #fff;
    --thead-bg: var(--felt-deep);
    --thead-ink: var(--gold-bright);
  }
}
:root[data-theme="dark"] {
  --paper: #0d1411;
  --card: #131e18;
  --ink: #e4e8e1;
  --ink-soft: #97a49b;
  --line: #24352b;
  --accent-text: var(--gold);
    /* Links/interactive teal must clear AA on the dark cards. */
  --brand: #3ec9a7;
  --brand-strong: #63dcc0;
  --danger: #e8707a;
  --row-alt: #172420;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  --hero-bg: radial-gradient(130% 180% at 85% -30%, rgba(255, 215, 110, .08) 0%, transparent 50%),
             linear-gradient(160deg, var(--felt) 0%, var(--felt-deep) 60%, #0a3323 100%);
  --hero-border: #0a3323;
  --hero-ink: #e9efe6;
  --hero-sub: #b2c4b4;
  --hero-h1-top: var(--gold-bright);
  --hero-h1-bottom: var(--gold);
  --hero-tile-bg: rgba(255, 255, 255, .07);
  --hero-tile-line: rgba(255, 255, 255, .11);
  --hero-tile-accent: var(--gold-bright);
  --hero-link: #fff;
  --thead-bg: var(--felt-deep);
  --thead-ink: var(--gold-bright);
}


/* ---------- Theme variants (admin-selected in Settings; C25) ----------
   Light variants override the default ("felt") light tokens; specificity
   (0,1,1) beats :root but loses to the dark blocks, so dark mode is
   unaffected by the light variant and vice versa. */
html[data-light="crisp"] {
  --paper: #f4f5f6; --card: #ffffff; --ink: #1e242c; --ink-soft: #5b6470;
  --line: #dfe3e8; --row-alt: #f8f9fa;
  --shadow: 0 1px 2px rgba(20, 26, 34, .05), 0 8px 24px rgba(20, 26, 34, .06);
}
html[data-light="sage"] {
  --paper: #e4ece2; --card: #fbfdfa; --ink: #1d2822; --ink-soft: #54615a;
  --line: #c3d4c3; --row-alt: #eef4ec;
}
/* Dark variants: repeated for both dark activation paths (device preference
   and explicit toggle), mirroring the base dark blocks. */
@media (prefers-color-scheme: dark) {
  html[data-dark="navy"]:not([data-theme="light"]) {
    --paper: #0e1119; --card: var(--night-panel); --ink: #e8e4d8;
    --ink-soft: #9aa2b1; --line: var(--night-line); --row-alt: #191e2c;
  }
  html[data-dark="black"]:not([data-theme="light"]) {
    --paper: #050607; --card: #101214; --ink: #e6e6e2;
    --ink-soft: #9aa1a8; --line: #23262b; --row-alt: #131619;
  }
}
html[data-dark="navy"][data-theme="dark"] {
  --paper: #0e1119; --card: var(--night-panel); --ink: #e8e4d8;
  --ink-soft: #9aa2b1; --line: var(--night-line); --row-alt: #191e2c;
}
html[data-dark="black"][data-theme="dark"] {
  --paper: #050607; --card: #101214; --ink: #e6e6e2;
  --ink-soft: #9aa1a8; --line: #23262b; --row-alt: #131619;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 1rem; }
@media (min-width: 1440px) { .wrap { max-width: 1200px; } }

.uat-banner {
  background: repeating-linear-gradient(45deg, #b7791f, #b7791f 12px, #92400e 12px, #92400e 24px);
  color: #fff; text-align: center; font-weight: 700; padding: .35rem;
  letter-spacing: .08em; font-size: .85rem;
}

/* ---------- Header (always night, carries the logo) ---------- */
.site-header {
  background: linear-gradient(180deg, #000 0%, var(--night) 100%);
  border-bottom: 3px solid var(--gold);
  position: relative; /* anchors the corner-pinned theme toggle */
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; padding-top: .45rem; padding-bottom: .45rem; gap: .5rem;
}
.brand { text-decoration: none; display: flex; align-items: center; gap: .8rem; }
.brand-logo { height: 54px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; }
.brand-name {
  color: var(--gold-bright); font-family: var(--font-display); font-weight: 700;
  font-size: 1.25rem; letter-spacing: .02em;
  text-shadow: 0 1px 0 #000, 0 2px 6px rgba(0, 0, 0, .6);
}
.brand-tagline { color: #8f97a8; font-size: .78rem; }
.site-nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.site-nav a {
  color: #d7dae2; text-decoration: none; padding: .38rem .7rem;
  border-radius: 999px; font-size: .92rem; border: 1px solid transparent;
  font-weight: 600; /* constant weight: active state must not change link width */
}
.site-nav a:hover { background: rgba(255, 255, 255, .08); }
.site-nav a.active {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #231a05;
  box-shadow: 0 2px 8px rgba(240, 180, 60, .35);
}
.whoami { color: #8f97a8; font-size: .85rem; padding: 0 .5rem; }
button.linklike {
  background: none; border: 0; cursor: pointer; font: inherit;
  color: #d7dae2; padding: .45rem .8rem; border-radius: 999px;
}
button.linklike:hover { background: rgba(255, 255, 255, .08); }

/* ---------- Main / cards ---------- */
main.wrap { padding-top: 1rem; padding-bottom: 1.1rem; overflow-x: auto; flex: 1 0 auto; width: 100%; }
h1 {
  font-family: var(--font-display); color: var(--heading-ink);
  margin: .2rem 0 1.1rem; letter-spacing: -.01em; font-size: 1.9rem; font-weight: 700;
}
h1::after {
  content: ''; display: block; width: 3.2rem; height: 3px; margin-top: .3rem;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--heading-accent), transparent);
}
/* The hero carries its own gold identity; no brand bar inside it. */
.hero h1::after { display: none; }
h2 { font-family: var(--font-display); color: var(--heading-ink); margin: 1rem 0 .5rem; font-size: 1.14rem; letter-spacing: .01em; }
a { color: var(--brand); }
a:hover { color: var(--brand-strong); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1.15rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.card > h2:first-child { margin-top: .1rem; }

/* Equal-ending columns (grid children stretch; card stacks fill their column). */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: stretch; }
.grid-2 > .card { margin-bottom: 0; height: 100%; }
.grid-2 > div { display: flex; flex-direction: column; gap: 1rem; }
.grid-2 > div > .card { margin-bottom: 0; }
.grid-2 > div > .card:last-child { flex: 1; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
table.data {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow);
}
table.data th {
  background: var(--thead-bg); color: var(--thead-ink); text-align: left;
  padding: .48rem .75rem; font-size: .76rem; text-transform: uppercase;
  letter-spacing: .08em; font-weight: 600;
}
table.data td { padding: .42rem .75rem; border-top: 1px solid var(--line); }
table.data tr:nth-child(even) td { background: var(--row-alt); }
table.data tr:hover td { background: color-mix(in srgb, var(--gold) 10%, var(--card)); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.rank-1 td {
  background: color-mix(in srgb, var(--gold) 16%, var(--card)) !important;
  font-weight: 600;
}
td.move { white-space: nowrap; font-size: .8rem; font-weight: 700; }
.move-up { color: var(--brand-strong); }
.move-down { color: var(--danger); }
.move-flat { color: var(--ink-soft); }
.move-new { color: var(--gold-bright); background: var(--felt); padding: .08rem .35rem; border-radius: 4px; font-size: .7rem; letter-spacing: .05em; }

/* ---------- Pills / buttons ---------- */
.pill {
  display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .78rem;
  background: var(--river); color: #fff; letter-spacing: .02em; /* fixed deep teal: AA in both themes */
}
/* Fixed neutral, not --ink-soft: that token is light in dark mode and would
   sink white text below AA contrast. */
.pill.muted { background: #5a646c; color: #fff; }
.pill.gold {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #231a05; font-weight: 600;
}

.btn {
  display: inline-block; border: 0; cursor: pointer; text-decoration: none;
  padding: .5rem 1.1rem; border-radius: 999px; font-size: .95rem; font-weight: 600;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #231a05; box-shadow: 0 2px 8px rgba(240, 180, 60, .3);
}
.btn:hover { filter: brightness(1.05); }
.btn.secondary {
  background: transparent; color: var(--brand); border: 1px solid var(--brand);
  box-shadow: none;
}
.btn.secondary:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.btn.danger { background: #a4232a; color: #fff; box-shadow: none; } /* fixed deep red: AA in both themes */
.btn.small { padding: .28rem .7rem; font-size: .85rem; }

/* ---------- Forms ---------- */
form.stack label { display: block; margin: .7rem 0 .2rem; font-weight: 600; font-size: .88rem; }
form.stack input[type=text], form.stack input[type=email], form.stack input[type=password],
form.stack input[type=date], form.stack input[type=number], form.stack input[type=time],
form.stack select, form.stack textarea,
.toolbar input[type=text], .toolbar input[type=date], .toolbar select {
  width: 100%; max-width: 26rem; padding: .5rem .7rem; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 1rem; background: var(--card); color: var(--ink);
}
.toolbar input[type=text], .toolbar input[type=date], .toolbar select { width: auto; }
form.stack input:focus, form.stack select:focus, form.stack textarea:focus,
.toolbar input:focus, .toolbar select:focus {
  outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold);
}
form.inline { display: inline; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar form { display: flex; gap: .4rem; align-items: center; }

.flash { border-radius: var(--radius-sm); padding: .6rem 1rem; margin-bottom: 1rem; border: 1px solid; }
.flash.ok { background: color-mix(in srgb, var(--brand) 12%, var(--card)); border-color: var(--brand); }
.flash.err { background: color-mix(in srgb, var(--danger) 12%, var(--card)); border-color: var(--danger); }

/* ---------- Confirm dialog ---------- */
dialog.confirm-dialog {
  border: 1px solid var(--line); border-top: 4px solid var(--danger);
  border-radius: var(--radius); padding: 1.2rem 1.4rem; max-width: 24rem;
  background: var(--card); color: var(--ink); box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
dialog.confirm-dialog::backdrop { background: rgba(6, 8, 12, .55); }
.confirm-message { margin: 0 0 1rem; }
.confirm-actions { display: flex; gap: .6rem; justify-content: flex-end; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--card); margin-top: auto; }
.site-footer .wrap { display: flex; justify-content: space-between; padding: .5rem 1rem; font-size: .85rem; color: var(--ink-soft); }
.site-footer a { color: var(--ink-soft); }
.footer-links { display: inline-flex; gap: 1rem; }

/* ---------- Hero (always night, like the header) ---------- */
.hero {
  background: var(--hero-bg);
  color: var(--hero-ink); border-radius: var(--radius); padding: 1.35rem 1.7rem; margin-bottom: 1rem;
  border: 1px solid var(--hero-border); border-bottom: 3px solid var(--gold);
  box-shadow: var(--shadow);
}
.hero h1 {
  margin: 0 0 .4rem; color: transparent;
  background: linear-gradient(180deg, var(--hero-h1-top) 15%, var(--hero-h1-bottom) 100%);
  -webkit-background-clip: text; background-clip: text;
  text-shadow: none; font-size: 1.75rem;
}
.hero p { margin: 0; color: var(--hero-sub); max-width: 46rem; }
.stat-row { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: .65rem; }
.stat {
  background: var(--hero-tile-bg); border: 1px solid var(--hero-tile-line);
  border-radius: var(--radius-sm); padding: .45rem .9rem;
}
.stat b { display: block; font-size: 1.25rem; color: var(--hero-tile-accent); }
.hero-purpose { margin-top: .4rem !important; font-size: .88rem; line-height: 1.45; max-width: 52rem; }
.hero-purpose a { color: var(--hero-link); }
.next-event { margin: .6rem 0 0; color: var(--hero-sub); }
.next-event b { color: var(--hero-tile-accent); }
.next-event a { color: var(--hero-link); }

/* Stat tiles on normal page background (player profile). */
.stat-row-page { margin-bottom: 1rem; }
.stat.on-card { background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat.on-card b { color: var(--accent-text); }
.finish-input { width: 4.5rem; padding: .25rem .4rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); }

.muted { color: var(--ink-soft); font-size: .85rem; }

/* Light/dark pill toggle (dark surfaces: header corner, admin ribbon). */
.theme-toggle {
  display: inline-flex; border: 1px solid #3a4152; border-radius: 999px;
  overflow: hidden; margin-left: .4rem;
}
/* Public header: pinned to the top-right corner; nav reserves the space. */
.site-header .theme-toggle { position: absolute; top: .4rem; right: 1rem; margin-left: 0; }
.site-header .site-nav { margin-right: 5.4rem; }
.theme-toggle button {
  background: transparent; border: 0; cursor: pointer; font: inherit;
  color: #aeb6c4; font-size: .65rem; padding: .2rem .55rem;
  font-weight: 600; /* constant weight: the active state must not change text width */
}
.theme-toggle button.active {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #231a05;
}

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  .btn, .site-nav a, button.linklike { min-height: 44px; display: inline-flex; align-items: center; }
  .btn.small { padding: .5rem .8rem; font-size: .95rem; }
  .brand-logo { height: 48px; }
  form.stack input[type=text], form.stack input[type=email], form.stack input[type=password],
  form.stack input[type=date], form.stack input[type=number], form.stack input[type=time],
  form.stack select { max-width: 100%; min-height: 44px; }
}
