/* ==========================================================================
   Squad Achieves — dark parchment / black-and-gold design system
   Hand-written, no framework, system font stack only.
   ========================================================================== */

:root {
  /* Palette */
  --color-bg: #0e0c09;
  --color-bg-raised: #1a1610;
  --color-bg-card: #1c1710;
  --color-parchment: #e7d8b8;
  --color-parchment-dim: #b8a888;
  --color-gold: #c9a24a;
  --color-gold-bright: #e8c76c;
  --color-gold-dim: #7a622f;
  --color-border: #3a3123;
  --color-border-strong: #55462c;

  --color-crimson: #b3453f;
  --color-crimson-bg: #2a1414;
  --color-sage: #6f9b6a;
  --color-sage-bg: #16241a;
  --color-amber: #c98b3a;
  --color-amber-bg: #2a1f10;
  --color-slate: #7d93a3;
  --color-slate-bg: #16202a;

  --focus-ring: #e8c76c;

  /* Typography */
  --font-body: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "Consolas", "SFMono-Regular", Menlo, monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.75rem;
  --fs-2xl: 2.25rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Hard edges — PoE UI is angular/framed, not soft. Kept as tokens so the whole
     system stays sharp; a hair of radius (1px) only to avoid fuzzy AA on borders. */
  --radius-sm: 0px;
  --radius-md: 0px;
  --radius-lg: 0px;

  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.45);
  --shadow-raised: 0 6px 20px rgba(0, 0, 0, 0.55);

  /* Content column. The shell should use most of the viewport rather than
     stranding the board in a narrow ribbon, but stop before lines get too long
     to scan — 100rem ≈ 1600px, with the sidebar sitting flush beside it. */
  --shell-max: 100rem;

  /* Minimum comfortable hit area for pointer/touch controls (WCAG 2.5.8). */
  --tap-min: 44px;
}

/* ==========================================================================
   Reset / base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--color-bg);
  background-image:
    radial-gradient(ellipse 120% 55% at 50% -8%, rgba(201, 162, 74, 0.08), transparent 60%),
    radial-gradient(ellipse 90% 60% at 50% 115%, rgba(0, 0, 0, 0.65), transparent 55%);
  color: var(--color-parchment);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.55;
  min-height: 100vh;
}

img { max-width: 100%; display: block; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--color-gold-bright);
  line-height: 1.25;
  margin: 0 0 var(--space-3);
}

h1 { font-size: var(--fs-xl); letter-spacing: 0.02em; }
h2 {
  font-size: var(--fs-lg);
  font-variant: small-caps;
  letter-spacing: 0.06em;
  font-weight: 600;
}
h3 { font-size: var(--fs-md); letter-spacing: 0.02em; }
h4 { font-size: var(--fs-base); }

/* Section-title flourish: a short diamond-tipped gold rule under headings.
   Opt-in via .flourish so it never disrupts headings inside flex headers. */
.flourish {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
}
.flourish::after {
  content: "";
  flex: 1;
  height: 1px;
  background:
    /* small diamond tip, then a fading rule */
    linear-gradient(45deg, transparent 45%, var(--color-gold) 45% 55%, transparent 55%) left center / 9px 9px no-repeat,
    linear-gradient(90deg, var(--color-gold-dim), transparent 78%) left center / 100% 1px no-repeat;
}

p { margin: 0 0 var(--space-3); }

a {
  color: var(--color-gold);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s ease;
}
a:hover { text-decoration-color: currentColor; }

small, .text-muted { color: var(--color-parchment-dim); }

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-5) 0;
}

ul, ol { padding-left: 1.25rem; }

/* Focus visibility everywhere */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--color-gold-bright);
  color: #14110d;
  padding: var(--space-2) var(--space-4);
  z-index: 200;
  font-weight: 600;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  left: 0;
}

/* ==========================================================================
   Layout shell
   ========================================================================== */

/* --------------------------------------------------------------------------
   App shell: fixed left sidebar + scrolling main area (concept layout)
   -------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: 16rem 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5) 0 var(--space-4);
  background:
    linear-gradient(180deg, #18130c, #100d09 70%);
  border-right: 1px solid var(--color-gold-dim);
  box-shadow: inset -1px 0 0 rgba(201, 162, 74, 0.12);
  z-index: 90;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4) var(--space-4);
  margin: 0 var(--space-4);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-gold-bright);
  text-decoration: none;
  font-family: var(--font-display);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  background:
    linear-gradient(135deg, var(--color-gold-bright), var(--color-gold-dim));
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  box-shadow: 0 0 8px rgba(201, 162, 74, 0.4);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.15;
}
.brand-league {
  font-size: var(--fs-xs);
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--color-parchment-dim);
}

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; }

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0 var(--space-3);
}
.nav-list a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-parchment);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-variant: small-caps;
  letter-spacing: 0.05em;
  padding: 0.6rem var(--space-3);
  border-left: 3px solid transparent;
}
.nav-list a:hover {
  color: var(--color-gold-bright);
  background: rgba(201, 162, 74, 0.08);
}
.nav-list a[aria-current="page"] {
  color: var(--color-gold-bright);
  background: linear-gradient(90deg, rgba(201, 162, 74, 0.16), transparent 85%);
  border-left-color: var(--color-gold);
}

.nav-badge {
  margin-left: auto;
  background: var(--color-crimson);
  color: #fff;
  font-size: var(--fs-xs);
  line-height: 1;
  padding: 0.15em 0.45em;
  border-radius: 0;
}

.sidebar-foot {
  padding: var(--space-4) var(--space-4) 0;
  margin: 0 var(--space-4);
  border-top: 1px solid var(--color-border);
  text-align: center;
}
.brazier {
  display: block;
  width: 100%;
  height: 3.5rem;
  margin-bottom: var(--space-2);
  background:
    radial-gradient(ellipse 40% 90% at 50% 100%, rgba(232, 160, 60, 0.55), rgba(201, 90, 30, 0.25) 45%, transparent 70%),
    radial-gradient(ellipse 22% 70% at 50% 100%, rgba(255, 220, 130, 0.8), transparent 65%);
}
.online-count {
  font-size: var(--fs-xs);
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--color-parchment-dim);
}

/* Top bar */
.main-area { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: linear-gradient(180deg, #16120c, #100d09);
  border-bottom: 1px solid var(--color-gold-dim);
  position: sticky;
  top: 0;
  z-index: 80;
}
.topbar-league {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }

.league-clock {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  color: var(--color-parchment-dim);
  white-space: nowrap;
}
.league-clock strong { color: var(--color-gold); }

.league-pill-static,
.league-select select {
  font-size: var(--fs-sm);
  color: var(--color-gold-bright);
  background: var(--color-bg-raised);
  border: 1px solid var(--color-gold-dim);
  border-radius: var(--radius-sm);
  padding: 0.4em 0.8em;
  font-variant: small-caps;
  letter-spacing: 0.04em;
}
.league-select { display: flex; align-items: center; min-width: 0; max-width: 100%; }
.league-select select { max-width: 100%; min-width: 0; }

/* Nav toggle (JS-driven mobile drawer button) */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 5px;
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0.5rem;
  cursor: pointer;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-bg-raised);
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--color-gold);
  border-radius: 1px;
}

.profile-menu { position: relative; }
.profile-menu > a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.profile-menu-panel {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  min-width: 10rem;
  box-shadow: var(--shadow-raised);
  z-index: 50;
}
.profile-menu:hover .profile-menu-panel,
.profile-menu:focus-within .profile-menu-panel {
  display: block;
}
.profile-menu-panel a,
.profile-menu-panel form button {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}

main {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-5) var(--space-7);
}

.site-footer {
  border-top: 1px solid var(--color-border);
  color: var(--color-parchment-dim);
  font-size: var(--fs-xs);
  text-align: center;
  padding: var(--space-5) var(--space-4);
}

/* Messages */
.messages {
  max-width: var(--shell-max);
  margin: var(--space-4) auto 0;
  padding: 0 var(--space-5);
  list-style: none;
  width: 100%;
}
.messages li {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  border: 1px solid var(--color-border);
  background: var(--color-bg-raised);
}
.messages li.success { border-color: var(--color-sage); background: var(--color-sage-bg); color: var(--color-parchment); }
.messages li.error { border-color: var(--color-crimson); background: var(--color-crimson-bg); }
.messages li.warning { border-color: var(--color-amber); background: var(--color-amber-bg); }

/* ==========================================================================
   Mobile nav collapse (< 40rem)
   ========================================================================== */

/* Collapse the sidebar into an off-canvas drawer on narrow screens. */
@media (max-width: 63.99rem) {
  .shell { grid-template-columns: 1fr; }

  .nav-toggle { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 16rem;
    max-width: 82vw;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-raised);
  }
  @media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
  }
  .sidebar.is-open { transform: translateX(0); }

  /* Dim scrim behind the open drawer */
  .sidebar.is-open::before {
    content: "";
    position: fixed;
    inset: 0 auto 0 16rem;
    width: 100vw;
    background: rgba(0, 0, 0, 0.55);
    z-index: -1;
  }
}

@media (max-width: 40rem) {
  main { padding: var(--space-5) var(--space-4) var(--space-6); }
  .topbar { padding: var(--space-3) var(--space-4); }
  .topbar-league { gap: var(--space-2); flex-wrap: wrap; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 0.55em 1.1em;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong);
  background: var(--color-bg-raised);
  color: var(--color-parchment);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--color-gold); color: var(--color-gold-bright); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, var(--color-gold-bright), var(--color-gold));
  border-color: var(--color-gold-dim);
  color: #1a1408;
}
.btn-primary:hover { color: #1a1408; filter: brightness(1.06); }

.btn-danger {
  background: var(--color-crimson-bg);
  border-color: var(--color-crimson);
  color: #f4d9d7;
}
.btn-danger:hover { color: #fff; border-color: #d05f58; }

.btn-approve {
  background: var(--color-sage-bg);
  border-color: var(--color-sage);
  color: #d7ead4;
}
.btn-approve:hover { color: #fff; }

.btn-sm { font-size: var(--fs-xs); padding: 0.4em 0.8em; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

form.inline-btn { display: inline; }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.015), transparent 40%),
    var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-5);
}

/* ==========================================================================
   Ornate framing — thin gold outer line, inset gutter, gold corner accents.
   This "material" is what makes every panel read as PoE at a glance.
   ========================================================================== */
.card,
.achievement-card,
.trophy-card,
.hero-champion,
.stat-tile {
  position: relative;
  border-color: var(--color-gold-dim);
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(232, 199, 108, 0.06);
}
.card::after,
.achievement-card::after,
.trophy-card::after,
.hero-champion::after,
.stat-tile::after {
  content: "";
  position: absolute;
  inset: 4px;
  pointer-events: none;
  z-index: 1;
  border: 1px solid rgba(201, 162, 74, 0.14);
  /* Gold corner ticks drawn over the inset hairline */
  background:
    linear-gradient(var(--color-gold) 0 0) top left     / 14px 2px,
    linear-gradient(var(--color-gold) 0 0) top left     / 2px 14px,
    linear-gradient(var(--color-gold) 0 0) top right    / 14px 2px,
    linear-gradient(var(--color-gold) 0 0) top right    / 2px 14px,
    linear-gradient(var(--color-gold) 0 0) bottom left  / 14px 2px,
    linear-gradient(var(--color-gold) 0 0) bottom left  / 2px 14px,
    linear-gradient(var(--color-gold) 0 0) bottom right / 14px 2px,
    linear-gradient(var(--color-gold) 0 0) bottom right / 2px 14px;
  background-repeat: no-repeat;
}
/* Stat tiles are small; use tighter corner ticks and a little inset. */
.stat-tile::after { inset: 3px; }

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 40rem) {
  .card-grid.cols-2 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 64rem) {
  .card-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.empty-state {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--color-parchment-dim);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
}
.empty-state .icon { font-size: 2rem; display: block; margin-bottom: var(--space-2); }

/* ==========================================================================
   Hero / champion
   ========================================================================== */

.hero-champion {
  background:
    radial-gradient(ellipse at top left, rgba(201, 162, 74, 0.18), transparent 55%),
    linear-gradient(180deg, #241d12, #1a1610);
  border: 1px solid var(--color-gold-dim);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  align-items: center;
  margin-bottom: var(--space-6);
}
.hero-champion .crown { font-size: 2.5rem; line-height: 1; }
.hero-champion h2 { margin-bottom: var(--space-1); }
.hero-champion .subtitle { color: var(--color-parchment-dim); margin: 0; }

/* Oversized trophy cards for major firsts */
.trophy-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
@media (min-width: 40rem) {
  .trophy-row { grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
}

.trophy-card {
  background: linear-gradient(160deg, #2a2213, #1c170f);
  border: 1px solid var(--color-gold-dim);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
}
.trophy-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(232, 199, 108, 0.15), transparent 60%);
  pointer-events: none;
}
.trophy-card .trophy-icon { font-size: 2.25rem; }
.trophy-card .trophy-label {
  font-family: var(--font-display);
  color: var(--color-gold-bright);
  font-size: var(--fs-lg);
  margin: var(--space-2) 0 var(--space-1);
}
.trophy-card .trophy-holder { font-weight: 700; }
.trophy-card .trophy-meta { color: var(--color-parchment-dim); font-size: var(--fs-sm); }

/* ==========================================================================
   Achievement cards
   ========================================================================== */

.achievement-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.achievement-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.achievement-icon { font-size: 1.75rem; }
.achievement-card-header h3 { margin: 0; }
.achievement-card-header .badge-label {
  font-size: var(--fs-xs);
  color: var(--color-gold-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.winner-block {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: baseline;
  background: var(--color-bg-raised);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
}
.winner-block .winner-name { color: var(--color-gold-bright); font-weight: 700; }
.winner-block .stat { color: var(--color-parchment-dim); font-size: var(--fs-sm); }
.winner-block.no-winner { color: var(--color-parchment-dim); font-style: italic; }

.player-status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.player-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--color-bg-raised);
  flex-wrap: wrap;
}
.player-status-row .player-name { font-weight: 600; min-width: 6rem; }
.player-status-row .stat-line { color: var(--color-parchment-dim); font-size: var(--fs-sm); }

.card-actions {
  margin-top: var(--space-4);
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ==========================================================================
   Status pills / badges / medals
   ========================================================================== */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 0.25em 0.7em;
  border-radius: 0;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill-not-submitted { background: var(--color-bg-raised); color: var(--color-parchment-dim); border-color: var(--color-border-strong); }
.pill-draft { background: var(--color-slate-bg); color: var(--color-slate); border-color: var(--color-slate); }
.pill-pending { background: var(--color-amber-bg); color: var(--color-amber); border-color: var(--color-amber); }
.pill-approved { background: var(--color-sage-bg); color: var(--color-sage); border-color: var(--color-sage); }
.pill-rejected { background: var(--color-crimson-bg); color: var(--color-crimson); border-color: var(--color-crimson); }
.pill-contested { background: var(--color-amber-bg); color: var(--color-gold-bright); border-color: var(--color-gold-dim); }

.medal-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-2) 0;
}

.medal {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 0.3em 0.65em;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #2c2412, #201a10);
  border: 1px solid var(--color-gold-dim);
  color: var(--color-gold-bright);
}
.medal-first { border-color: var(--color-gold); box-shadow: 0 0 0 1px rgba(232, 199, 108, 0.25) inset; }
.medal-completion { border-color: var(--color-sage); color: var(--color-sage); background: var(--color-sage-bg); }
.medal-lowest_played,
.medal-fewest_kills,
.medal-lowest_level { color: var(--color-parchment); }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap { overflow-x: auto; }

table.standings {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

table.standings caption { text-align: left; color: var(--color-parchment-dim); margin-bottom: var(--space-2); }

table.standings th,
table.standings td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

table.standings thead th {
  color: var(--color-gold);
  font-weight: 700;
  text-transform: uppercase;
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--color-border-strong);
}

table.standings tbody tr:hover { background: var(--color-bg-raised); }
table.standings tbody tr.is-self { background: rgba(201, 162, 74, 0.08); }

table.standings td.numeric,
table.standings th.numeric { text-align: right; }

/* ==========================================================================
   Forms
   ========================================================================== */

fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin: 0 0 var(--space-5);
}
legend {
  font-family: var(--font-display);
  color: var(--color-gold-bright);
  padding: 0 var(--space-2);
  font-size: var(--fs-md);
}

.form-row {
  margin-bottom: var(--space-4);
}
.form-row label,
.form-row > legend {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--color-parchment);
}
.form-row .hint {
  display: block;
  color: var(--color-parchment-dim);
  font-size: var(--fs-xs);
  margin-top: var(--space-1);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="datetime-local"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border-strong);
  color: var(--color-parchment);
  border-radius: var(--radius-sm);
  padding: 0.55em 0.75em;
  font-family: inherit;
  font-size: var(--fs-base);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--color-gold);
}

textarea { resize: vertical; min-height: 4.5rem; }

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin-right: var(--space-2);
  accent-color: var(--color-gold);
}

.checkbox-row { display: flex; align-items: center; gap: var(--space-2); }

.field-errors {
  list-style: none;
  margin: var(--space-1) 0 0;
  padding: 0;
  color: var(--color-crimson);
  font-size: var(--fs-sm);
}

.form-errors {
  background: var(--color-crimson-bg);
  border: 1px solid var(--color-crimson);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  color: #f4d9d7;
}
.form-errors ul { margin: 0; padding-left: 1.1rem; }

.form-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-5);
}

/* Played preview target */
#played-preview {
  margin-top: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--color-parchment-dim);
  min-height: 1.2em;
}
#played-preview strong { color: var(--color-gold-bright); }
#played-preview.has-error { color: var(--color-crimson); }

/* Proof upload area */
.proof-upload-help {
  background: var(--color-bg-raised);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: var(--fs-sm);
  color: var(--color-parchment-dim);
}
.proof-upload-help ol { margin: var(--space-2) 0 var(--space-2); }

.proof-form-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  background: var(--color-bg-raised);
}

.existing-proof-thumb {
  display: inline-flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-right: var(--space-3);
  margin-bottom: var(--space-3);
  max-width: 8rem;
}
.existing-proof-thumb img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  aspect-ratio: 4/3;
  object-fit: cover;
}
.existing-proof-thumb .caption { font-size: var(--fs-xs); color: var(--color-parchment-dim); }

/* ==========================================================================
   Player banner / profile
   ========================================================================== */

.player-banner {
  --banner-hue: 42;
  background:
    linear-gradient(140deg,
      hsla(var(--banner-hue), 55%, 22%, 0.9),
      hsla(var(--banner-hue), 40%, 12%, 0.95));
  border: 1px solid hsla(var(--banner-hue), 55%, 45%, 0.6);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  margin-bottom: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.player-banner .avatar {
  width: 5rem;
  height: 5rem;
  border-radius: 0;
  object-fit: cover;
  border: 2px solid hsla(var(--banner-hue), 65%, 60%, 0.8);
  background: var(--color-bg-raised);
}
.player-banner .avatar-fallback {
  width: 5rem;
  height: 5rem;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-family: var(--font-display);
  background: hsla(var(--banner-hue), 45%, 20%, 1);
  border: 2px solid hsla(var(--banner-hue), 65%, 60%, 0.8);
  color: var(--color-gold-bright);
}
.player-banner h1 { margin: 0; color: hsl(var(--banner-hue), 70%, 82%); }
.player-banner .player-meta { color: var(--color-parchment-dim); font-size: var(--fs-sm); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
@media (min-width: 40rem) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-tile {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  text-align: center;
}
.stat-tile .value {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--color-gold-bright);
  display: block;
}
.stat-tile .label {
  font-size: var(--fs-xs);
  color: var(--color-parchment-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Image gallery */
.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-3);
}
.image-gallery figure {
  margin: 0;
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.image-gallery img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
}
.image-gallery figcaption {
  padding: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--color-parchment-dim);
}

.gallery-large {
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
}
.gallery-large img { aspect-ratio: auto; max-height: 32rem; object-fit: contain; background: #0c0a07; }

/* Timeline */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--color-border-strong);
}
.timeline li {
  position: relative;
  padding: 0 0 var(--space-4) var(--space-5);
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -0.35rem;
  top: 0.3rem;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--color-gold);
  border: 2px solid var(--color-bg);
}
.timeline time {
  display: block;
  font-size: var(--fs-xs);
  color: var(--color-parchment-dim);
}

/* ==========================================================================
   Review / comparison layout
   ========================================================================== */

.compare-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 40rem) {
  .compare-grid { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
}
.compare-tile {
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}
.compare-tile.is-current { border-color: var(--color-gold); }
.compare-tile dl { margin: 0; }
.compare-tile dt { font-size: var(--fs-xs); color: var(--color-parchment-dim); text-transform: uppercase; }
.compare-tile dd { margin: 0 0 var(--space-2); font-weight: 600; }

.review-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--fs-sm);
}
.audit-list li {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}
.audit-list time { color: var(--color-parchment-dim); font-size: var(--fs-xs); }

/* ==========================================================================
   Utility
   ========================================================================== */

.u-flex { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.u-flex-between { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.u-mt-0 { margin-top: 0; }
.u-mb-0 { margin-bottom: 0; }
.u-text-center { text-align: center; }
.u-visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Auth pages
   ========================================================================== */

.auth-shell {
  max-width: 26rem;
  margin: var(--space-7) auto;
}
.auth-shell .card { margin-bottom: 0; }

/* --- Blocked-from-submitting popup ------------------------------------- */
.blocked-overlay {
  display: flex;
  justify-content: center;
  padding: var(--space-6) var(--space-4);
}
.blocked-popup {
  max-width: 40rem;
  width: 100%;
  text-align: center;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  padding: var(--space-6);
}
.blocked-title {
  font-family: var(--font-display);
  color: var(--color-gold-bright);
  margin-bottom: var(--space-4);
}
.blocked-gif {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
.blocked-body {
  color: var(--color-parchment);
  margin: var(--space-4) 0 var(--space-5);
}

/* ==========================================================================
   Seasonal theme — "Curse of the Allflame"
   A drowned/abyssal look: near-black teal water, a spectral teal-green
   "Allflame" glow as the accent, and a warm ember core as the hot highlight.
   Applied via data-season="allflame" on <html> (see base.html); layered over
   the base tokens so it's a drop-in reskin — remove the attribute (and this
   block) to return to parchment/gold next league. The accent keeps the same
   token *roles* as gold, so every component reskins without per-rule edits.
   Palette contrast-checked: body 14.8:1, links 8.5:1, headings 13.5:1 (dark).
   ========================================================================== */

html[data-season="allflame"] {
  color-scheme: dark;

  /* The teal is emitted light, not the panel material. Surfaces stay close to
     soot-black while text leans warm-neutral and frames read as oxidised brass. */
  --color-bg: #07100f;
  --color-bg-raised: #0b1716;
  --color-bg-card: #0d1c1a;

  --color-parchment: #d9ddd5;
  --color-parchment-dim: #8f9b94;
  --color-gold: #3fc3a1;
  --color-gold-bright: #82e4c9;
  --color-gold-dim: #28564d;

  --color-border: #20322f;
  --color-border-strong: #3a504a;
  --color-frame: #4c4735;
  --color-frame-bright: #806b42;
  --color-brass: #a9864d;
  --color-brass-dim: #5d4b31;

  /* Ember core — the warm heart of the cold flame. Reused for the amber role. */
  --color-ember: #d98242;
  --color-amber: #d98242;
  --color-amber-bg: #21140b;

  --focus-ring: #82e4c9;

  --shadow-card: 0 5px 18px rgba(0, 0, 0, 0.42);
  --shadow-raised: 0 10px 30px rgba(0, 0, 0, 0.58);
}

/* Hardcoded warm gradients retinted from the (theme-adaptive) tokens, so these
   surfaces follow whichever Allflame theme — dark or light — is active. */
html[data-season="allflame"] .site-header,
html[data-season="allflame"] .topbar,
html[data-season="allflame"] .sidebar {
  background:
    linear-gradient(180deg, rgba(20, 32, 29, 0.98), rgba(5, 13, 13, 0.98) 82%);
}
html[data-season="allflame"] .topbar {
  border-bottom-color: var(--color-frame);
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.26);
}
html[data-season="allflame"] .sidebar {
  border-right-color: var(--color-frame);
  box-shadow:
    inset -1px 0 rgba(128, 107, 66, 0.12),
    8px 0 28px rgba(0, 0, 0, 0.18);
}
html[data-season="allflame"] .hero-champion {
  background:
    radial-gradient(ellipse 52% 170% at 4% 50%, rgba(63, 195, 161, 0.15), transparent 72%),
    linear-gradient(100deg, rgba(13, 31, 29, 0.97), rgba(8, 18, 17, 0.94));
  border-color: var(--color-frame-bright);
  animation: none;
  box-shadow:
    0 0 0 1px rgba(63, 195, 161, 0.08) inset,
    0 8px 30px rgba(0, 0, 0, 0.46);
}
html[data-season="allflame"] .medal {
  background: linear-gradient(180deg, var(--color-bg-raised), var(--color-bg-card));
}
html[data-season="allflame"] .medallion {
  background:
    radial-gradient(circle at 50% 35%, #123a34 0%, #0f2a27 55%, #0a1517 100%);
  box-shadow:
    0 0 0 3px var(--color-bg),
    0 0 0 4px rgba(53, 196, 168, 0.4),
    inset 0 1px 3px rgba(0, 0, 0, 0.7);
}
/* Trophy / first-place tiles carry a warm gold glow authored inline; retint it
   to the spectral flame so they don't read as brown against the teal board. */
html[data-season="allflame"] .first-tile {
  background:
    radial-gradient(circle at 18% 8%, rgba(63, 195, 161, 0.13), transparent 48%),
    linear-gradient(145deg, rgba(14, 32, 29, 0.97), rgba(7, 16, 15, 0.98) 72%);
  border-color: var(--color-frame-bright);
}
html[data-season="allflame"] .stat-tile--first {
  background:
    radial-gradient(circle at top, rgba(130, 228, 201, 0.10), transparent 70%),
    var(--color-bg-card);
}

/* The brazier becomes the Allflame: a cold teal-green ghost-fire with a hot
   ember core. */
html[data-season="allflame"] .brazier {
  background:
    radial-gradient(ellipse 42% 92% at 50% 100%, rgba(53, 196, 168, 0.55), rgba(255, 138, 61, 0.22) 45%, transparent 70%),
    radial-gradient(ellipse 22% 70% at 50% 100%, rgba(140, 255, 224, 0.85), transparent 65%);
}

/* Dark Allflame (default): abyssal teal glow above, deep vignette below. */
html[data-season="allflame"] body {
  background-color: var(--color-bg);
  background-image: none;
}
/* The layered field lives on a compositor-friendly fixed pseudo-element so it
   stays put on scroll WITHOUT the per-frame repaint that background-attachment:
   fixed forces (that caused visible scroll lag). */
html[data-season="allflame"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--color-bg);
  /* Painted abyssal-smoke artwork (Assets/Concept -> static/img, jpg'd).
     It is already near-black, so the scrims above it are light: a touch of
     side shading and a bottom fade so long pages stay readable. */
  background-image:
    linear-gradient(90deg, rgba(2, 7, 7, 0.14), rgba(2, 7, 7, 0.0) 45%, rgba(2, 7, 7, 0.20)),
    linear-gradient(180deg, rgba(4, 10, 10, 0.10), rgba(1, 5, 5, 0.45)),
    url("../img/allflame-bg.eac3158116ed.jpg");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

/* Prominent warm gold glows authored as inline rgba (not tokens) retinted to
   the spectral flame so they don't read as gold halos against the teal board. */
html[data-season="allflame"] .prog-area { fill: rgba(53, 196, 168, 0.14); }
html[data-season="allflame"] .brand-mark {
  background: linear-gradient(145deg, #79d7be, #2c7869);
  box-shadow: 0 0 15px rgba(63, 195, 161, 0.25);
}
html[data-season="allflame"] .first-tile {
  box-shadow: 0 0 0 1px rgba(130, 228, 201, 0.06) inset, var(--shadow-card);
}
/* firsts.css paints "First Overall" as dark ink on a warm gold gradient. Under
   the Allflame palette --color-gold-dim is a deep teal, so that dark ink landed
   on a dark chip and the label was unreadable — it reads as emitted light here
   instead. */
html[data-season="allflame"] .medal-first {
  background: linear-gradient(120deg,
    rgba(63, 195, 161, 0.10), rgba(63, 195, 161, 0.24), rgba(63, 195, 161, 0.10));
  color: var(--color-gold-bright);
  border-color: var(--color-gold);
  text-shadow: none;
  box-shadow: 0 0 0 1px rgba(130, 228, 201, 0.14) inset;
}
html[data-season="allflame"] .trophy-icon { filter: drop-shadow(0 0 7px rgba(63, 195, 161, 0.26)); }

/* Smoked-metal panels let a trace of the procedural field show through. */
html[data-season="allflame"] .card,
html[data-season="allflame"] .achievement-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.014), transparent 38%),
    rgba(10, 23, 21, 0.94);
}

/* Bronze construction lines keep teal inside the interface as light and state,
   rather than outlining every box like a futuristic HUD. */
html[data-season="allflame"] .card,
html[data-season="allflame"] .achievement-card,
html[data-season="allflame"] .trophy-card,
html[data-season="allflame"] .stat-tile {
  border-color: var(--color-frame);
}
html[data-season="allflame"] .card::after,
html[data-season="allflame"] .achievement-card::after,
html[data-season="allflame"] .trophy-card::after,
html[data-season="allflame"] .hero-champion::after,
html[data-season="allflame"] .stat-tile::after {
  border-color: rgba(128, 107, 66, 0.18);
  background:
    linear-gradient(var(--color-frame-bright) 0 0) top left     / 10px 1px,
    linear-gradient(var(--color-frame-bright) 0 0) top left     / 1px 10px,
    linear-gradient(var(--color-frame-bright) 0 0) top right    / 10px 1px,
    linear-gradient(var(--color-frame-bright) 0 0) top right    / 1px 10px,
    linear-gradient(var(--color-frame-bright) 0 0) bottom left  / 10px 1px,
    linear-gradient(var(--color-frame-bright) 0 0) bottom left  / 1px 10px,
    linear-gradient(var(--color-frame-bright) 0 0) bottom right / 10px 1px,
    linear-gradient(var(--color-frame-bright) 0 0) bottom right / 1px 10px;
  background-repeat: no-repeat;
}
html[data-season="allflame"] .flourish::after {
  opacity: 0.64;
  background:
    linear-gradient(45deg, transparent 45%, var(--color-brass) 45% 55%, transparent 55%) left center / 7px 7px no-repeat,
    linear-gradient(90deg, var(--color-brass-dim), transparent 78%) left center / 100% 1px no-repeat;
}
html[data-season="allflame"] .trophy-ribbon {
  background: linear-gradient(90deg, #395c52, #83d6be, #395c52);
}
html[data-season="allflame"] .nav-list a[aria-current="page"] {
  background:
    linear-gradient(90deg, rgba(63, 195, 161, 0.12), transparent 86%),
    linear-gradient(90deg, rgba(128, 107, 66, 0.09), transparent 70%);
}
html[data-season="allflame"] table.standings tbody tr:first-child {
  background: linear-gradient(90deg, rgba(128, 107, 66, 0.13), transparent 82%);
}
