:root {
  --ink-deep: #050a16;
  --ink: #0a1628;
  --ink-2: #0f1e36;
  --ink-3: #1a2c4d;
  --ink-4: #2a3f64;
  --muted: #5b6b85;
  --muted-2: #8497b5;

  --rink: #ffffff;
  --frost: #f4f8ff;
  --frost-2: #e8efff;
  --frost-3: #d8e4f8;
  --line: #d9e4f4;
  --line-2: #c1d1e8;
  --line-strong: #93a8c8;

  --ice-100: #eaf3ff;
  --ice-200: #c8dbfb;
  --ice-300: #8fb4f5;
  --ice-400: #4f86e8;

  --blue: #2563eb;
  --blue-bright: #3b82f6;
  --blue-dark: #1d4ed8;
  --accent: var(--blue);
  --blue-deep: #1e3a8a;
  --blue-glow: #60a5fa;
  --cyan: #06b6d4;
  --cyan-bright: #22d3ee;

  --gold: #f59e0b;
  --gold-bg: #fef3c7;
  --red: #ef233c;
  --red-bg: #ffe1e6;
  --green: #10b981;
  --green-bg: #d1fae5;
  --purple: #8b5cf6;
  --purple-bg: #ede9fe;

  --shadow-xs: 0 1px 2px rgba(10, 22, 40, 0.06);
  --shadow-sm: 0 2px 6px rgba(10, 22, 40, 0.08);
  --shadow: 0 14px 30px rgba(10, 22, 40, 0.10);
  --shadow-lg: 0 28px 60px rgba(10, 22, 40, 0.18);
  --shadow-blue: 0 14px 36px rgba(37, 99, 235, 0.28);

  --radius-xs: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --font-serif: "Newsreader", Georgia, serif;
  --font-sans: "Instrument Sans", "Aptos", "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", "Consolas", monospace;

  --nav-height: 64px;

  /* Surface tokens (light defaults). These map onto the same tokens used by
     /draft-order/ so a single theme toggle drives the whole site. */
  --bg: var(--frost);
  --surface: #ffffff;
  --surface-2: #f7faff;
  --border: var(--line);
  --border-2: var(--line-2);
  --text: var(--ink);
  --text-2: #334155;
  --nav-bg: rgba(255, 255, 255, 0.85);
}

/* Dark theme — activated by [data-theme="dark"] on <html>.
   Persisted via localStorage.doTheme so the choice carries across all pages. */
[data-theme="dark"] {
  --frost: #050a16;
  --frost-2: #0a1628;
  --frost-3: #0f1e36;
  --rink: #0f1e36;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.32);
  --ice-100: rgba(96, 165, 250, 0.16);
  --ice-200: rgba(96, 165, 250, 0.36);
  --ice-300: rgba(96, 165, 250, 0.55);
  --muted: #94a3b8;
  --muted-2: #64748b;
  --ink: #f1f5f9;
  --ink-2: #cbd5e1;
  --ink-3: #94a3b8;
  --ink-4: #64748b;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --blue-deep: #1d4ed8;
  --blue-glow: #60a5fa;
  --accent: var(--blue);
  --gold-bg: rgba(245, 158, 11, 0.18);
  --red-bg: rgba(239, 35, 60, 0.18);
  --green-bg: rgba(16, 185, 129, 0.18);
  --purple-bg: rgba(139, 92, 246, 0.18);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.5);
  --shadow: 0 14px 30px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 28px 60px rgba(0, 0, 0, 0.6);

  --bg: #050a16;
  --surface: #0f1e36;
  --surface-2: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.16);
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --nav-bg: rgba(10, 22, 40, 0.85);
}

* {
  box-sizing: border-box;
}

html,
body {
  background: var(--frost);
}

/* Global no-italics override — kills all italic styling site-wide (including
   the default browser italic on <em>, <i>, <cite>, <address>, <dfn>, <var>).
   Component CSS that previously set font-style: italic is overridden here. */
*,
*::before,
*::after { font-style: normal !important; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 600px at 80% -100px, rgba(59, 130, 246, 0.10), transparent 70%),
    radial-gradient(900px 500px at -10% 200px, rgba(96, 165, 250, 0.08), transparent 70%),
    var(--frost);
  background-attachment: fixed;
}

main {
  max-width: 1620px;
  margin: 0 auto;
}

body.drawer-open,
body.modal-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 36px;
  padding: 0 0.95rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius-full);
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, color 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--ink-2);
  box-shadow: 0 10px 22px rgba(10, 22, 40, 0.18);
}

button:active {
  transform: translateY(0);
}

button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-blue);
}

button.primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

button.ghost {
  background: transparent;
  border-color: var(--line-2);
  color: var(--ink);
}

button.ghost:hover {
  background: var(--ice-100);
  border-color: var(--ice-300);
}

button.subtle {
  background: var(--frost-2);
  border-color: var(--frost-2);
  color: var(--ink);
}

button.subtle:hover {
  background: var(--ice-100);
  border-color: var(--ice-200);
}

.not-found-main {
  min-height: calc(100vh - var(--nav-height));
  display: grid;
  place-items: center;
  padding: 2rem;
}

.not-found-card {
  width: min(720px, 100%);
  padding: clamp(1.4rem, 4vw, 2.6rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--rink);
  box-shadow: var(--shadow);
}

.not-found-card h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.not-found-card h1 em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  color: var(--blue);
}

/* 404 ships without draft-order.css, so give its eyebrow the house treatment. */
.not-found-card .do-eyebrow {
  margin: 0 0 0.6rem;
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.not-found-card p:not(.do-eyebrow) {
  max-width: 560px;
  margin: 0.9rem 0 0;
  color: var(--ink-2);
  font-size: 1rem;
}

.not-found-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.4rem;
}

.not-found-primary,
.not-found-secondary {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  border: 1px solid var(--blue);
  border-radius: var(--radius-full);
  font-weight: 800;
  text-decoration: none;
}

.not-found-primary {
  background: var(--blue);
  color: #fff;
}

.not-found-secondary {
  background: transparent;
  color: var(--blue);
}

button.danger {
  background: #fff;
  border-color: var(--red);
  color: var(--red);
}

button.danger:hover {
  background: var(--red-bg);
  border-color: var(--red);
  color: #b91c1c;
}

button.icon {
  width: 36px;
  min-width: 36px;
  padding: 0;
}

label {
  display: block;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.10em;
  margin-bottom: 0.36rem;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0.55rem 0.72rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input::placeholder {
  color: var(--muted);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%231a2c4d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5L6 6.5L11 1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* === FOCUS ============================================================= */
/* Universal keyboard focus ring. Components that paint their own
   :focus-visible style (e.g. /ranks/ cards) win by specificity/order. */
button:focus-visible,
a:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Form fields already glow on :focus — drop the glow while the universal
   ring shows so the two never stack into a double ring. */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  box-shadow: none;
}

.muted {
  color: var(--muted);
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* === NAV =============================================================== */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--nav-height);
  padding: 0 clamp(1rem, 3vw, 2.4rem);
  border-bottom: 1px solid var(--border);
  background: var(--nav-bg);
  backdrop-filter: blur(18px);
  color: var(--text);
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 0.65rem;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.18rem;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: transparent;
  box-shadow: 0 8px 20px rgba(20, 99, 232, 0.18);
  overflow: hidden;
  position: relative;
}

.brand-mark::before {
  display: none;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-mark i {
  display: none;
}

.brand-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  margin-left: 0.4rem;
  border-radius: var(--radius-full);
  background: var(--ice-100);
  color: var(--blue);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: none;
}

.brand-wordmark-short {
  display: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: 0.6rem;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 0.75rem;
  border-radius: var(--radius-full);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.14s ease, color 0.14s ease;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--ice-100);
  color: var(--blue);
}

.nav-meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.nav-meta::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--cyan-bright);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
  animation: pulse 2.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.45; }
}

/* Per-page status counts ("36 drafts · 8,518 picks", etc.) and the live dot
   were crowding the top nav; pages surface the same context in their own
   mastheads. Keep the .nav-meta container only to host the search trigger. */
.nav-meta > span { display: none; }
.nav-meta::before { display: none; }

/* === HERO ============================================================== */

.hero {
  position: relative;
  padding: clamp(2.6rem, 4.5vw, 4.2rem) clamp(1rem, 2.5vw, 2rem) 1.2rem;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(700px 360px at 88% -10%, rgba(59, 130, 246, 0.16), transparent 70%),
    radial-gradient(620px 340px at -8% 110%, rgba(34, 211, 238, 0.10), transparent 70%);
  pointer-events: none;
}

.hero-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(380px, 0.85fr);
  gap: 2.4rem 3rem;
  align-items: end;
}

.hero-copy {
  min-width: 0;
}

.hero h1 {
  margin: 0.7rem 0 0;
  font-family: var(--font-sans);
  font-size: clamp(2.6rem, 4.8vw, 5.4rem);
  font-weight: 800;
  line-height: 0.96;
  letter-spacing: -0.022em;
  color: var(--ink);
}

.hero h1 em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  color: var(--blue);
}

.hero p {
  max-width: 640px;
  margin: 1.1rem 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.5rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
}

.hero-card {
  position: relative;
  align-self: end;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 0.8rem;
  padding: 1.1rem 1.2rem 1.2rem;
  border-radius: var(--radius-xl);
  background: linear-gradient(160deg, var(--ink) 0%, var(--ink-2) 60%, var(--ink-3) 100%);
  color: #fff;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -10%;
  width: 60%;
  height: 80%;
  background: radial-gradient(closest-side, rgba(59, 130, 246, 0.35), transparent 70%);
  filter: blur(40px);
  pointer-events: none;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, 0.18) 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 60px);
  pointer-events: none;
}

.hero-card-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.hero-card-head .eyebrow {
  color: var(--cyan-bright);
}

.hero-card-head .eyebrow::before {
  background: currentColor;
}

.hero-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55rem;
}

.hero-stats div {
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.hero-stats strong {
  display: block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1;
  color: #fff;
  letter-spacing: -0.01em;
}

.hero-stats span {
  display: block;
  margin-top: 0.28rem;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.hero-pill-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.7rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.74rem;
  font-weight: 700;
}

.hero-pill b {
  color: var(--cyan-bright);
  font-family: var(--mono);
  font-weight: 700;
}

/* === APP SHELL ========================================================= */

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  padding: 1rem;
}

.board-panel,
.database-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: #fff;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.board-panel {
  position: sticky;
  top: calc(var(--nav-height) + 12px);
  max-height: calc(100vh - var(--nav-height) - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  color: #fff;
}

.panel-head h2 {
  margin: 0.15rem 0 0;
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.3rem;
  line-height: 1;
  letter-spacing: -0.01em;
}

.panel-head .eyebrow {
  color: var(--cyan-bright);
}

.panel-head .eyebrow::before {
  background: currentColor;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 30px;
  padding: 0 0.55rem;
  border-radius: var(--radius-full);
  background: var(--blue);
  color: #fff;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.86rem;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.45);
}

.board-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.42rem;
  padding: 0.8rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: var(--frost);
}

.board-actions button {
  min-height: 36px;
  padding: 0 0.6rem;
  font-size: 0.82rem;
}

.board-actions .full {
  grid-column: 1 / -1;
}

.board-actions .share-btn {
  background: var(--blue);
  border-color: var(--blue);
}

.board-actions .share-btn:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.rank-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0;
  padding: 0.8rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.rank-item {
  display: grid;
  /* row 1: [drag] [#N] [photo] [main column         ] [✎ ×]
     row 2 (optional collapsible note spans cols 3-end) */
  grid-template-columns: 14px 28px 40px minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.4rem 0.5rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: grab;
  transition: border-color 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}
.rank-drag {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  user-select: none;
  cursor: grab;
}
.rank-item:hover .rank-drag { color: var(--blue); }
.rank-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 18%;
  background: var(--frost-2);
  border: 1px solid var(--line);
}
.rank-photo-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 0.7rem;
  color: var(--muted);
}

.rank-item:hover {
  border-color: var(--ice-300);
  box-shadow: var(--shadow-sm);
}

.rank-item.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.rank-item.drop-target {
  border-color: var(--blue);
  background: var(--ice-100);
}

.rank-item.tier-S { border-left: 4px solid var(--gold); padding-left: 0.55rem; }
.rank-item.tier-A { border-left: 4px solid var(--blue); padding-left: 0.55rem; }
.rank-item.tier-B { border-left: 4px solid var(--cyan); padding-left: 0.55rem; }
.rank-item.tier-C { border-left: 4px solid var(--muted-2); padding-left: 0.55rem; }
.rank-item.tier-watch { border-left: 4px solid var(--purple); padding-left: 0.55rem; }
.rank-item.tier-avoid { border-left: 4px solid var(--red); padding-left: 0.55rem; }

.rank-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.95rem;
}

.rank-item.tier-S .rank-num { background: var(--gold); color: var(--ink); }
.rank-item.tier-A .rank-num { background: var(--blue); }
.rank-item.tier-B .rank-num { background: var(--cyan); color: var(--ink); }
.rank-item.tier-watch .rank-num { background: var(--purple); }
.rank-item.tier-avoid .rank-num { background: var(--red); }

.rank-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.rank-name-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
}

.rank-name-row strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: -0.005em;
  color: var(--text);
}

.rank-pos {
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: var(--ice-100);
  color: var(--blue-dark);
  text-transform: uppercase;
  white-space: nowrap;
}

.rank-team {
  color: var(--muted);
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Smart stat pills row */
.rank-stats {
  display: flex;
  gap: 0.32rem;
  flex-wrap: wrap;
  margin-top: 0.18rem;
}
.rank-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 0.22rem;
  padding: 0.14rem 0.48rem;
  border-radius: 999px;
  background: var(--frost-2);
  color: var(--text-2);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}
.rank-stat b {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-transform: none;
}
.rank-stat.is-pts { background: rgba(37, 99, 235, 0.10); color: var(--blue-dark); border-color: rgba(37, 99, 235, 0.22); }
.rank-stat.is-pts b { color: var(--blue-dark); }
.rank-stat.is-ppg-elite { background: rgba(245, 158, 11, 0.16); color: #92400e; border-color: rgba(245, 158, 11, 0.45); }
.rank-stat.is-ppg-elite b { color: #92400e; }
.rank-stat.is-peer-elite { background: rgba(220, 38, 38, 0.10); color: #b91c1c; border-color: rgba(220, 38, 38, 0.3); }
.rank-stat.is-peer-elite b { color: #b91c1c; }
.rank-stat.is-peer-strong { background: rgba(16, 185, 129, 0.10); color: #047857; border-color: rgba(16, 185, 129, 0.32); }
.rank-stat.is-peer-strong b { color: #047857; }

/* Bottom row inside .rank-main: stat pills (left) + tier select (right) */
.rank-bottom {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
  flex-wrap: wrap;
}
.rank-bottom .rank-stats { margin: 0; flex: 1; }
.rank-bottom .tier-select {
  flex: 0 0 auto;
  width: auto;
  min-height: 26px;
  padding: 0 1.5rem 0 0.5rem;
  font-size: 0.66rem;
  border-radius: 999px;
  background-color: var(--frost-2);
  border-color: transparent;
}
[data-theme="dark"] .rank-bottom .tier-select {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

/* Stack of action icons on the right of the row (note + remove only). */
.rank-actions {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}
.rank-name-row strong[data-board-action="select"] { cursor: pointer; }
.rank-name-row strong[data-board-action="select"]:hover { color: var(--blue-dark); text-decoration: underline; }
.rank-actions button {
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 7px;
  font-size: 0.72rem;
  background: var(--frost-2);
  border-color: transparent;
  color: var(--ink);
}
.rank-actions button:hover {
  background: var(--ice-200);
  transform: none;
  box-shadow: none;
}
.rank-actions button.danger {
  background: var(--red-bg);
  color: var(--red);
}
.rank-actions button.danger:hover {
  background: #ffc8d0;
}

/* Note input: collapsed until user clicks the ✎ button */
.rank-item .note-input {
  grid-column: 3 / -1;
  width: 100%;
  margin-top: 0.45rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.74rem;
  border-radius: 8px;
  display: none;
}
.rank-item.is-note-open .note-input {
  display: block;
}

/* Dark mode: re-tone the stat pills + photo background */
[data-theme="dark"] .rank-photo { background: rgba(255, 255, 255, 0.06); border-color: var(--border); }
[data-theme="dark"] .rank-pos { background: rgba(96, 165, 250, 0.18); color: var(--blue-glow); }
[data-theme="dark"] .rank-stat { background: rgba(255, 255, 255, 0.05); color: var(--text-2); }
[data-theme="dark"] .rank-stat b { color: var(--text); }
[data-theme="dark"] .rank-stat.is-pts { background: rgba(96, 165, 250, 0.16); color: var(--blue-glow); border-color: rgba(96, 165, 250, 0.3); }
[data-theme="dark"] .rank-stat.is-pts b { color: var(--blue-glow); }
[data-theme="dark"] .rank-stat.is-ppg-elite { background: rgba(245, 158, 11, 0.18); color: #fbbf24; border-color: rgba(245, 158, 11, 0.4); }
[data-theme="dark"] .rank-stat.is-ppg-elite b { color: #fbbf24; }
[data-theme="dark"] .rank-stat.is-peer-elite { background: rgba(239, 68, 68, 0.16); color: #fca5a5; border-color: rgba(239, 68, 68, 0.32); }
[data-theme="dark"] .rank-stat.is-peer-elite b { color: #fca5a5; }
[data-theme="dark"] .rank-stat.is-peer-strong { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.32); }
[data-theme="dark"] .rank-stat.is-peer-strong b { color: #6ee7b7; }
[data-theme="dark"] .rank-actions button { background: rgba(255, 255, 255, 0.06); color: var(--text); }
[data-theme="dark"] .rank-actions button:hover { background: rgba(96, 165, 250, 0.18); color: var(--blue-glow); }
[data-theme="dark"] .rank-actions button.danger { background: rgba(239, 68, 68, 0.12); color: #fca5a5; }

/* Board size selector chips (Top 3 / 5 / 10 / 16 / 32) */
.board-size-row {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  flex-wrap: wrap;
  padding: 0 0.85rem 0.5rem;
  margin: 0 0 0.4rem;
}
.board-size-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 0.18rem;
}
.board-size-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  min-height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.board-size-chip:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--ice-100);
}
.board-size-chip.is-active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.32);
}
[data-theme="dark"] .board-size-chip { background: rgba(255, 255, 255, 0.04); color: var(--text-2); }
[data-theme="dark"] .board-size-chip:hover { background: rgba(96, 165, 250, 0.14); color: var(--blue-glow); }

.tier-select {
  width: auto;
  min-height: 28px;
  padding: 0 1.7rem 0 0.45rem;
  border-radius: var(--radius-full);
  background-color: var(--frost-2);
  font-size: 0.7rem;
  font-weight: 700;
  border-color: transparent;
}

.tier-select:focus {
  border-color: var(--blue);
}

.note-input {
  flex: 1;
  min-width: 0;
  min-height: 28px;
  padding: 0 0.6rem;
  border-radius: var(--radius-full);
  background: var(--frost-2);
  border-color: transparent;
  font-size: 0.74rem;
}

.note-input:focus {
  background: #fff;
  border-color: var(--blue);
}

/* === DATABASE PANEL =================================================== */

.database-panel {
  min-width: 0;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1.6fr) repeat(5, minmax(118px, 1fr)) minmax(160px, 1.2fr);
  gap: 0.7rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, var(--frost));
}

.database-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.database-status #dbStatus b {
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 700;
}

.database-status-actions {
  display: flex;
  gap: 0.4rem;
}

#showUnranked,
#compareToggle {
  min-height: 32px;
  padding: 0 0.75rem;
  font-size: 0.78rem;
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

#showUnranked:hover,
#compareToggle:hover {
  background: var(--ice-100);
  border-color: var(--ice-300);
  color: var(--blue-dark);
}

#showUnranked.active,
#compareToggle.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

[data-theme="dark"] #showUnranked,
[data-theme="dark"] #compareToggle {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] #showUnranked:hover,
[data-theme="dark"] #compareToggle:hover {
  background: rgba(96, 165, 250, 0.18);
  border-color: rgba(96, 165, 250, 0.45);
  color: var(--blue-glow);
}

.source-strip {
  display: flex;
  gap: 0.42rem;
  overflow-x: auto;
  padding: 0.72rem 1rem;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.source-strip::-webkit-scrollbar { height: 6px; }
.source-strip::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

.source-chip {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-height: 44px;
  padding: 0.32rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: all 0.14s ease;
}

.source-chip:hover {
  border-color: var(--ice-300);
  background: var(--frost);
  transform: none;
  box-shadow: var(--shadow-xs);
}

.source-chip.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-blue);
}

.source-chip strong {
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 800;
}

.source-chip.active strong { color: #fff; }

.source-chip span {
  color: var(--muted);
  font-size: 0.6rem;
}

.source-chip.active span { color: rgba(255, 255, 255, 0.75); }

/* === CARD GRID ========================================================= */

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  padding: 0.85rem;
}

.player-tile {
  position: relative;
  display: grid;
  grid-template-rows: 178px auto;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}

.player-tile::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  background: transparent;
  transition: height 0.18s ease;
  z-index: 4;
}

.player-tile.medal-gold::after {
  height: 5px;
  background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 50%, #b45309 100%);
  box-shadow: 0 2px 14px rgba(251, 191, 36, 0.55);
}

.player-tile.medal-silver::after {
  height: 4px;
  background: linear-gradient(90deg, #e5e7eb 0%, #9ca3af 50%, #4b5563 100%);
  box-shadow: 0 2px 10px rgba(156, 163, 175, 0.4);
}

.player-tile.medal-bronze::after {
  height: 4px;
  background: linear-gradient(90deg, #fb923c 0%, #c2410c 50%, #7c2d12 100%);
  box-shadow: 0 2px 10px rgba(194, 65, 12, 0.4);
}

.player-tile:hover {
  transform: translateY(-3px);
  border-color: var(--ice-300);
  box-shadow: var(--shadow);
}

.player-tile.on-board {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue), var(--shadow-xs);
}

.player-tile.compare-active {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan), var(--shadow);
}

.tile-photo {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-3) 50%, var(--blue-deep) 100%);
}

.tile-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  transition: transform 0.4s ease;
}

.player-tile:hover .tile-photo img {
  transform: scale(1.05);
}

.tile-photo::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 22, 40, 0.0) 35%, rgba(10, 22, 40, 0.55) 70%, rgba(10, 22, 40, 0.95) 100%);
  z-index: 1;
}

.tile-rank,
.tile-user-rank {
  position: absolute;
  z-index: 2;
  top: 0.55rem;
  min-width: 46px;
  border-radius: 10px;
  padding: 0.28rem 0.42rem;
  color: #fff;
  text-align: center;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.36);
}

.tile-rank {
  right: 0.55rem;
  background: rgba(10, 22, 40, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.tile-user-rank {
  left: 0.55rem;
  background: var(--blue);
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.55);
}

.tile-rank span,
.tile-user-rank span {
  display: block;
  font-size: 0.46rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.78;
}

.tile-rank b,
.tile-user-rank b {
  display: block;
  font-family: var(--mono);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1;
}

.tile-pos-chip {
  position: absolute;
  z-index: 2;
  bottom: 0.55rem;
  right: 0.55rem;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.22rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tile-title {
  position: absolute;
  z-index: 2;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.6rem;
  color: #fff;
}

.tile-title strong {
  display: block;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
  overflow-wrap: anywhere;
}

.tile-title span {
  display: block;
  margin-top: 0.18rem;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.7rem;
  font-weight: 700;
}

.tile-body {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
}

.tile-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--frost);
}

.tile-stats div {
  min-width: 0;
  padding: 0.45rem 0.2rem;
  text-align: center;
  border-right: 1px solid var(--line);
}

.tile-stats div:last-child {
  border-right: 0;
}

.tile-stats b {
  display: block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1;
  color: var(--ink);
}

.tile-stats span {
  display: block;
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tile-context {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-height: 22px;
}

.tile-context span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 0.1rem 0.5rem;
  background: var(--frost);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}

.tile-context b {
  margin-right: 0.22rem;
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 700;
}

/* === Tile trophy & tier mark ============================================ */

.tile-trophy {
  position: absolute;
  z-index: 3;
  top: 0.5rem;
  left: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.55rem 0.22rem 0.42rem;
  border-radius: var(--radius-full);
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
  color: #2a1100;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.tile-trophy::before {
  content: "★";
  font-size: 0.78rem;
  line-height: 1;
}

.player-tile.on-board .tile-trophy {
  top: 3.1rem;
}

.tier-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 0.74rem;
  line-height: 1;
  color: #fff;
  margin-left: 0.4rem;
  flex: 0 0 auto;
}

.tier-mark.tier-S { background: linear-gradient(135deg, #fbbf24, #b45309); color: #1f0d00; }
.tier-mark.tier-A { background: linear-gradient(135deg, #fb7185, #be123c); }
.tier-mark.tier-B { background: linear-gradient(135deg, #fb923c, #9a3412); }
.tier-mark.tier-C { background: linear-gradient(135deg, #22d3ee, #0e7490); color: #052331; }
.tier-mark.tier-D { background: linear-gradient(135deg, #a78bfa, #5b21b6); }

/* === Insight chips (rich peer-rank with gauge) ========================== */

.tile-insights {
  display: grid;
  gap: 0.4rem;
}

.insight-chip {
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  gap: 0.22rem;
  padding: 0.42rem 0.6rem 0.5rem;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--ink-2) 0%, var(--ink-deep) 100%);
  color: #fff;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(10, 22, 40, 0.22);
}

.insight-chip.regular {
  background: linear-gradient(180deg, var(--blue) 0%, var(--blue-dark) 100%);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.22);
}

.insight-chip.playoff {
  background: linear-gradient(180deg, #f59e0b 0%, #b45309 100%);
  color: #2a1100;
  box-shadow: 0 6px 16px rgba(180, 83, 9, 0.28);
}

.insight-chip.playoff .insight-chip-gauge {
  background: rgba(0, 0, 0, 0.18);
}

.insight-chip.playoff .insight-chip-fill {
  background: #fff7ed;
  box-shadow: 0 0 8px rgba(255, 247, 237, 0.7);
}

.insight-chip.prior {
  background: linear-gradient(180deg, #475569 0%, #1e293b 100%);
  color: #f1f5f9;
  box-shadow: 0 6px 16px rgba(30, 41, 59, 0.32);
}

.insight-chip.class {
  background: linear-gradient(180deg, #6366f1 0%, #3730a3 100%);
  color: #fff;
}

.insight-chip.consensus {
  background: linear-gradient(180deg, var(--ink-2) 0%, var(--ink-deep) 100%);
  color: #fff;
}

.insight-chip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
}

.insight-chip-label {
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.insight-chip-rank {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.96rem;
  line-height: 1;
  letter-spacing: -0.01em;
  flex: 0 0 auto;
}

.insight-chip-rank b {
  font-weight: 700;
}

.insight-chip-rank em {
  font-style: normal;
  opacity: 0.7;
  font-size: 0.76rem;
}

.insight-chip-rank .pct {
  margin-left: 0.32rem;
  font-style: normal;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.7rem;
  opacity: 0.78;
}

.insight-chip-gauge {
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
  margin-top: 0.12rem;
}

.insight-chip-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.55);
}

.insight-chip.empty {
  background: var(--frost);
  color: var(--muted);
  box-shadow: none;
  border: 1px dashed var(--line-2);
}

.insight-chip.empty .insight-chip-gauge {
  display: none;
}

.insight-chip.empty .insight-chip-rank {
  font-size: 0.74rem;
  opacity: 0.55;
}

.tile-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
}

.tile-actions button {
  min-height: 36px;
  font-size: 0.78rem;
  padding: 0 0.7rem;
}

.tile-actions .add-btn {
  background: var(--blue);
  border-color: var(--blue);
}

.tile-actions .add-btn:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.tile-actions .add-btn.on {
  background: var(--frost-2);
  border-color: var(--frost-2);
  color: var(--ink);
}

.tile-actions .compare-btn {
  width: 36px;
  padding: 0;
  background: #fff;
  border-color: var(--line);
  color: var(--muted);
}

.tile-actions .compare-btn:hover {
  background: var(--frost-2);
  color: var(--ink);
}

.tile-actions .compare-btn.active {
  background: var(--cyan);
  border-color: var(--cyan);
  color: var(--ink);
}

.empty-note {
  margin: 0.85rem;
  padding: 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--frost);
  text-align: center;
}

.board-empty {
  padding: 1.4rem 1rem;
  margin: 0.85rem;
  border: 1px dashed var(--ice-300);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--muted);
  background: var(--frost);
}

.board-empty strong {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--ink);
  font-size: 0.95rem;
}

/* === DRAWER ============================================================ */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(5, 10, 22, 0.62);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.drawer-backdrop.show {
  opacity: 1;
}

.drawer-backdrop[hidden] {
  display: none;
}

.player-drawer {
  position: fixed;
  top: 0;
  right: -880px;
  z-index: 90;
  width: min(880px, 100vw);
  height: 100vh;
  overflow: auto;
  background: var(--frost);
  box-shadow: -28px 0 60px rgba(5, 10, 22, 0.28);
  transition: right 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.player-drawer.open,
.player-drawer[aria-hidden="false"] {
  right: 0 !important;
}

.drawer-top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 248, 255, 0.94);
  backdrop-filter: blur(14px);
}

.drawer-top h2 {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1;
}

.drawer-top .eyebrow {
  color: var(--blue);
}

.drawer-close {
  padding: 0 0.95rem;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.drawer-close:hover {
  background: var(--frost-2);
  border-color: var(--ice-300);
}

.player-card {
  margin: 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow);
}

.pc-hero {
  position: relative;
  height: 320px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--ink) 0%, var(--blue-deep) 100%);
}

.pc-hero img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 14%;
}

.pc-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5, 10, 22, 0.02) 18%, rgba(5, 10, 22, 0.28) 54%, rgba(5, 10, 22, 0.96) 100%);
  z-index: 1;
}

.pc-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 80px);
  z-index: 1;
  pointer-events: none;
}

.pc-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--ice-200);
  font-family: var(--font-serif);
  font-size: 4.5rem;
  font-weight: 600;
}

.pc-rank {
  position: absolute;
  z-index: 2;
  top: 1rem;
  right: 1rem;
  min-width: 72px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background: rgba(10, 22, 40, 0.78);
  backdrop-filter: blur(8px);
  color: #fff;
  text-align: center;
  padding: 0.46rem 0.6rem;
}

.pc-rank span {
  display: block;
  color: var(--cyan-bright);
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pc-rank b {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

.pc-name {
  position: absolute;
  z-index: 2;
  left: 1.2rem;
  right: 1.2rem;
  bottom: 1rem;
  color: #fff;
}

.pc-name h3 {
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(2.2rem, 6.5vw, 3.8rem);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.pc-name h3 span {
  color: var(--cyan-bright);
}

.pc-name p {
  margin: 0.6rem 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.85rem;
  font-weight: 700;
}

.pc-bio {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: var(--frost);
}

.pc-bio div {
  min-width: 0;
  padding: 0.7rem 0.7rem;
  border-right: 1px solid var(--line);
}

.pc-bio div:last-child {
  border-right: 0;
}

.pc-bio span,
.pc-section-title {
  display: block;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pc-bio b {
  display: block;
  margin-top: 0.18rem;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.16;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.pc-seasons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  padding: 0.85rem;
}

.season-box {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.season-box h4 {
  margin: 0;
  padding: 0.5rem 0.7rem;
  color: #fff;
  background: var(--ink);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: 0.005em;
}

.season-box.prior h4 {
  background: var(--ink-3);
}

.season-box.playoff h4 {
  background: linear-gradient(90deg, var(--blue-dark), var(--blue));
}

.season-box.playoff {
  grid-column: 1 / -1;
}

.season-line {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  text-align: center;
}

.season-line div {
  min-width: 0;
  padding: 0.55rem 0.22rem;
  border-right: 1px solid var(--line);
}

.season-line div:last-child {
  border-right: 0;
}

.season-line b {
  display: block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--ink);
}

.season-line span {
  display: block;
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.peer-rank-band {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.5rem 0.6rem 0.6rem;
  border-top: 1px solid var(--line);
  background: var(--frost);
}

.rank-pill {
  display: inline-grid;
  max-width: 100%;
  min-height: 24px;
  align-items: center;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 0.32rem 0.5rem;
  background: #fff;
  color: var(--ink);
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1.14;
  overflow-wrap: anywhere;
}

.rank-pill span {
  color: var(--muted);
  font-size: 0.55rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rank-pill b {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.72rem;
}

.rank-pill em {
  color: var(--muted);
  font-style: normal;
  font-size: 0.58rem;
}

.rank-pill-good {
  border-color: var(--ice-300);
  background: var(--ice-100);
  color: var(--blue-dark);
}

.rank-pill-elite {
  border-color: var(--gold);
  background: var(--gold-bg);
  color: #92400e;
}

.table-rank-cell {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  min-width: 118px;
}

.table-rank-cell .rank-pill {
  width: fit-content;
  max-width: 200px;
  min-height: 20px;
  padding: 0.18rem 0.4rem;
  font-size: 0.6rem;
}

.rank-context-note {
  margin: 0 0.85rem 0.85rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--ice-200);
  border-radius: 14px;
  background: var(--ice-100);
  color: var(--ink-3);
  font-size: 0.78rem;
  font-weight: 600;
}

.pc-section {
  padding: 0.85rem;
  border-top: 1px solid var(--line);
}

.card-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button-link {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 0 0.95rem;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  transition: all 0.14s ease;
}

.button-link:hover {
  background: var(--frost-2);
  border-color: var(--ice-300);
  text-decoration: none;
}

.button-link.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-blue);
}

.button-link.primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.pc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-top: 0.5rem;
}

.pc-tag {
  display: inline-flex;
  max-width: 100%;
  min-height: 26px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 0.22rem 0.6rem;
  background: #fff;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.pc-tag.good {
  border-color: var(--ice-300);
  background: var(--ice-100);
  color: var(--blue-dark);
}

.pc-tag.blue {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.pc-tag.gold {
  border-color: var(--gold);
  background: var(--gold-bg);
  color: #92400e;
}

.pc-tag.cyan {
  border-color: var(--cyan);
  background: rgba(34, 211, 238, 0.12);
  color: #155e75;
}

.pc-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.6rem;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.pc-table th,
.pc-table td {
  padding: 0.5rem 0.4rem;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.pc-table th {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: var(--frost);
}

.pc-table td.num,
.pc-table th.num {
  text-align: right;
  font-family: var(--mono);
}

.pc-table tr:hover td {
  background: var(--frost);
}

/* === TOAST ============================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 130;
  transform: translateX(-50%) translateY(20px);
  max-width: min(540px, calc(100vw - 2rem));
  padding: 0.78rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  background: var(--ink);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: var(--shadow-lg);
  font-weight: 700;
  font-size: 0.86rem;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === MODAL ============================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(5, 10, 22, 0.62);
  backdrop-filter: blur(6px);
  padding: 1rem;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  width: min(640px, 100%);
  max-height: 90vh;
  overflow: auto;
  border-radius: var(--radius-xl);
  background: #fff;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--ink), var(--ink-2));
  color: #fff;
}

.modal-head h3 {
  margin: 0;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.005em;
}

.modal-head .eyebrow {
  color: var(--cyan-bright);
}

.modal-head .eyebrow::before {
  background: currentColor;
}

.modal-close {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.22);
}

.modal-body {
  padding: 1.2rem;
}

.modal-body p {
  margin: 0 0 0.8rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.share-url {
  display: flex;
  gap: 0.4rem;
  margin: 0.85rem 0 1rem;
}

.share-url input {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--frost);
}

.share-summary {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--frost);
  padding: 0.9rem 1rem;
  margin-top: 0.8rem;
}

.share-summary ol {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.86rem;
  color: var(--ink);
}

.share-summary ol li {
  margin: 0.18rem 0;
}

.share-summary ol li b {
  font-weight: 800;
}

.share-summary ol li em {
  color: var(--muted);
  font-style: normal;
  margin-left: 0.4rem;
  font-size: 0.78rem;
}

/* === COMPARE BAR ======================================================== */

.compare-bar {
  position: fixed;
  bottom: 1.1rem;
  left: 50%;
  z-index: 70;
  transform: translateX(-50%) translateY(140%);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.7rem 0.6rem 1rem;
  border-radius: var(--radius-full);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.10);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: calc(100vw - 2rem);
}

.compare-bar.show {
  transform: translateX(-50%) translateY(0);
}

.compare-bar-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.84rem;
  font-weight: 700;
}

.compare-bar-label b {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--cyan-bright);
}

.compare-bar-players {
  display: flex;
  gap: 0.35rem;
}

.compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.65rem 0.32rem 0.32rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  max-width: 200px;
}

.compare-chip img {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  object-fit: cover;
  background: var(--ink-3);
}

.compare-chip-fallback {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--ink-3);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
}

.compare-chip strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.compare-chip .x {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
}

.compare-chip .x:hover {
  background: rgba(239, 35, 60, 0.85);
}

.compare-bar button {
  min-height: 34px;
  padding: 0 0.85rem;
}

/* === COMPARE PANEL (drawer reused) ====================================== */

.compare-grid {
  display: grid;
  grid-template-columns: 180px repeat(var(--cols, 3), minmax(0, 1fr));
  border-top: 1px solid var(--line);
  background: #fff;
  margin: 0 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.compare-grid > div {
  padding: 0.7rem 0.85rem;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.84rem;
}

.compare-grid > div:nth-child(-n + var(--cols-plus-1, 4)) {
  border-top: 0;
}

.compare-grid > div:last-child {
  border-right: 0;
}

.compare-grid .compare-label {
  background: var(--frost);
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.compare-grid .compare-head {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: linear-gradient(180deg, var(--ink), var(--ink-2));
  color: #fff;
  border-top: 0;
}

.compare-grid .compare-head strong {
  font-size: 1rem;
  font-weight: 800;
}

.compare-grid .compare-head span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.72rem;
}

/* === RESPONSIVE ========================================================= */

@media (max-width: 1440px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
  .hero-stats {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .board-panel {
    position: static;
    max-height: none;
  }
  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .toolbar .search-field {
    grid-column: 1 / -1;
  }
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Intermediate widths (721-1239px): brand + full nav links + meta + palette
   trigger + theme toggle outgrow one row before the 720px column nav takes
   over. Let the links wrap and compact the right side so the header never
   causes document-level horizontal scroll. */
@media (min-width: 721px) and (max-width: 1329px) {
  .site-nav {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--nav-height);
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
    row-gap: 0.3rem;
  }
  .nav-links {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
    row-gap: 0.25rem;
  }
  .nav-meta > span,
  .nav-meta::before {
    display: none;
  }
  /* Icon-only palette trigger; ancestor selectors outrank the module's
     injected base styles without touching hid-palette.js. */
  .nav-meta .hid-pal-trigger .hid-pal-trigger-lbl,
  .nav-meta .hid-pal-trigger kbd,
  .do-nav-right .hid-pal-trigger .hid-pal-trigger-lbl,
  .do-nav-right .hid-pal-trigger kbd {
    display: none;
  }
}

@media (max-width: 720px) {
  .site-nav {
    align-items: stretch;
    flex-direction: column;
    height: auto;
    padding: 0.8rem 1rem;
  }
  .brand {
    align-self: flex-start;
  }
  .brand-wordmark-full {
    display: none;
  }
  .brand-wordmark-short {
    display: inline;
  }
  .nav-links {
    flex-wrap: wrap;
    margin-left: 0;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .nav-links a {
    min-height: 32px;
    height: auto;
    padding: 0.26rem 0.68rem;
  }
  .nav-meta {
    text-align: left;
    margin-left: 0;
  }
  .hero,
  .app-shell {
    padding-left: 0.7rem;
    padding-right: 0.7rem;
  }
  .hero-stats,
  .toolbar,
  .card-grid,
  .pc-seasons {
    grid-template-columns: 1fr;
  }
  .database-status {
    align-items: flex-start;
    flex-direction: column;
  }
  .pc-hero {
    height: 280px;
  }
  .pc-bio {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .season-line {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .compare-grid {
    grid-template-columns: 1fr;
  }
}

/* === Theme toggle + dark-mode polish + condensed card variant =========== */
/* Dark theme: surface adjustments. Most rules inherit via CSS vars, but a few
   hard-coded whites and light/dark colour pairs need an explicit flip. */
[data-theme="dark"] html,
[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}
[data-theme="dark"] body {
  background:
    radial-gradient(1400px 700px at 80% -50px, rgba(59, 130, 246, 0.16), transparent 70%),
    radial-gradient(900px 500px at -10% 200px, rgba(34, 211, 238, 0.08), transparent 70%),
    var(--bg);
}
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-color: var(--border);
}
[data-theme="dark"] select {
  /* CRITICAL: re-declare repeat + position with the new arrow SVG, otherwise
     the browser tiles it across the whole input ("hatched" look). */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%23cbd5e1' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5L6 6.5L11 1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-color: rgba(255, 255, 255, 0.04);
}
[data-theme="dark"] input::placeholder { color: var(--muted); }
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--blue-glow);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
}
[data-theme="dark"] input:focus-visible,
[data-theme="dark"] select:focus-visible,
[data-theme="dark"] textarea:focus-visible {
  box-shadow: none;
}

/* Default button look in dark mode (no .primary / .ghost / .subtle modifier) —
   the bare buttons were invisible "white-on-white" otherwise. */
[data-theme="dark"] button {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text);
}
[data-theme="dark"] button:hover {
  background: rgba(96, 165, 250, 0.18);
  border-color: rgba(96, 165, 250, 0.45);
  color: var(--blue-glow);
}
[data-theme="dark"] button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
[data-theme="dark"] button.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
[data-theme="dark"] button.ghost { color: var(--text); background: transparent; border-color: var(--border-2); }
[data-theme="dark"] button.subtle { background: rgba(255, 255, 255, 0.06); color: var(--text); border-color: var(--border); }
[data-theme="dark"] button.danger { background: rgba(239, 35, 60, 0.10); color: #fca5a5; border-color: rgba(239, 35, 60, 0.5); }
[data-theme="dark"] button.danger:hover { background: rgba(239, 35, 60, 0.18); color: #fecaca; }

/* Source-strip chips — were invisible white-on-white. */
[data-theme="dark"] .source-strip { background: transparent; }
[data-theme="dark"] .source-chip {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-2);
}
[data-theme="dark"] .source-chip:hover {
  background: rgba(96, 165, 250, 0.16);
  border-color: rgba(96, 165, 250, 0.45);
  color: var(--blue-glow);
}
[data-theme="dark"] .source-chip.active {
  background: linear-gradient(135deg, var(--blue), var(--blue-bright));
  border-color: var(--blue-bright);
  color: #fff;
}
[data-theme="dark"] .source-chip strong,
[data-theme="dark"] .source-chip span { color: inherit; }

/* My Board panel-head + count pill flip for dark */
[data-theme="dark"] .panel-head {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(34, 211, 238, 0.16));
  color: var(--text);
}
[data-theme="dark"] .panel-head h2 { color: var(--text); }
[data-theme="dark"] .panel-head .eyebrow { color: var(--blue-glow); }
[data-theme="dark"] .count-pill {
  background: rgba(96, 165, 250, 0.22);
  color: #fff;
  border-color: rgba(96, 165, 250, 0.6);
}

/* Tile inner overlays (rank chip / user-rank / pos chip) — keep dark and
   legible on the photo gradient. */
[data-theme="dark"] .tile-rank,
[data-theme="dark"] .tile-user-rank {
  background: rgba(10, 22, 40, 0.78);
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text);
}
[data-theme="dark"] .tile-pos-chip {
  background: rgba(10, 22, 40, 0.78);
  color: var(--text);
}

/* Database status row + filter labels in dark */
[data-theme="dark"] .database-status { color: var(--text-2); }
[data-theme="dark"] .database-status b { color: var(--text); }
[data-theme="dark"] label { color: var(--muted); }

/* Compare bar at the bottom of the screen */
[data-theme="dark"] .compare-bar {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.55);
}
[data-theme="dark"] .compare-bar-label b { color: var(--blue-glow); }
[data-theme="dark"] .player-tile,
[data-theme="dark"] .board-panel,
[data-theme="dark"] .database-panel,
[data-theme="dark"] .hero-card,
[data-theme="dark"] .modal,
[data-theme="dark"] .player-drawer { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .tile-photo { background: linear-gradient(135deg, #0a1628 0%, #1a2c4d 50%, #1d4ed8 100%); }
[data-theme="dark"] .rank-item { background: rgba(255, 255, 255, 0.03); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .rank-item:hover { background: rgba(96, 165, 250, 0.10); }
[data-theme="dark"] .hero p,
[data-theme="dark"] .hero-stats span,
[data-theme="dark"] .panel-head .eyebrow { color: var(--muted); }
[data-theme="dark"] .hero h1,
[data-theme="dark"] .hero-stats strong { color: var(--text); }
[data-theme="dark"] .hero-pill { background: rgba(255, 255, 255, 0.05); border-color: var(--border); color: var(--text-2); }
[data-theme="dark"] .source-strip,
[data-theme="dark"] .toolbar,
[data-theme="dark"] .database-status { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .empty-note { color: var(--muted); }

/* Theme toggle button (sun/moon, same shape as /draft-order/) */

.theme-toggle {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover {
  background: var(--ice-100);
  color: var(--blue);
  border-color: var(--blue);
}
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Quick-preset chips above the filter toolbar */

.board-presets {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.7rem 0.85rem 0.2rem;
}
.board-preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.75rem;
  min-height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.board-preset-chip:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--ice-100);
}
.board-preset-chip.is-active {
  background: linear-gradient(135deg, var(--blue), var(--blue-bright));
  border-color: var(--blue-bright);
  color: #fff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.32);
}
[data-theme="dark"] .board-preset-chip { background: rgba(255, 255, 255, 0.04); color: var(--text-2); }
[data-theme="dark"] .board-preset-chip:hover { background: rgba(96, 165, 250, 0.14); color: var(--blue-glow); }

/* Condensed player tile (horizontal layout, more per row).
   Activated when .card-grid has the .is-condensed class. */

.card-grid.is-condensed {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  padding: 0.6rem;
}
@media (min-width: 1480px) { .card-grid.is-condensed { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 980px)  { .card-grid.is-condensed { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px)  { .card-grid.is-condensed { grid-template-columns: 1fr; } }

.card-grid.is-condensed .player-tile {
  grid-template-rows: none;
  grid-template-columns: 92px 1fr;
  border-radius: 12px;
  padding: 0;
}
.card-grid.is-condensed .player-tile .tile-photo {
  height: 100%;
  min-height: 130px;
  border-radius: 12px 0 0 12px;
}
.card-grid.is-condensed .player-tile .tile-body {
  padding: 0.55rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
/* Photo is a clean headshot — hide every overlay chip. The same data is
   restated in the body where it doesn't sit on top of the player's face. */
.card-grid.is-condensed .tile-rank,
.card-grid.is-condensed .tile-user-rank,
.card-grid.is-condensed .tile-pos-chip,
.card-grid.is-condensed .tile-trophy,
.card-grid.is-condensed .tile-title { display: none; }

/* Inline chip row inside the body: consensus rank pill + "My #N" + trophy.
   Sits above the name so it reads "[chip] [chip]  Player Name" top-down. */
.card-grid.is-condensed .tile-body-chips {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  flex-wrap: wrap;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.card-grid.is-condensed .chip-rank {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: var(--ice-100);
  color: var(--blue-dark);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.55rem;
}
.card-grid.is-condensed .chip-rank b {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: -0.02em;
  font-weight: 800;
  text-transform: none;
}
.card-grid.is-condensed .chip-mine {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.55rem;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.32);
}
.card-grid.is-condensed .chip-mine b {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: -0.02em;
  font-weight: 800;
  text-transform: none;
}
.card-grid.is-condensed .chip-trophy {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.18rem 0.5rem 0.18rem 0.4rem;
  border-radius: 999px;
  background: var(--gold-bg);
  color: #92400e;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  border: 1px solid rgba(245, 158, 11, 0.5);
}
[data-theme="dark"] .card-grid.is-condensed .chip-rank {
  background: rgba(96, 165, 250, 0.16);
  color: var(--blue-glow);
}
[data-theme="dark"] .card-grid.is-condensed .chip-trophy {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.45);
}
.card-grid.is-condensed .tile-body-name {
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}
.card-grid.is-condensed .tile-body-meta {
  font-size: 0.66rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.card-grid.is-condensed .tile-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.3rem;
  padding: 0;
  border: none;
}
.card-grid.is-condensed .tile-stats div {
  padding: 0.28rem 0.4rem;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: center;
}
.card-grid.is-condensed .tile-stats b { font-size: 0.78rem; }
.card-grid.is-condensed .tile-stats span { font-size: 0.5rem; letter-spacing: 0.06em; }
.card-grid.is-condensed .tile-insights { display: none; }
.card-grid.is-condensed .tile-actions {
  display: flex;
  gap: 0.32rem;
  padding: 0;
  border: none;
  margin-top: auto;
}
.card-grid.is-condensed .tile-actions .add-btn {
  flex: 1;
  height: 30px;
  min-height: 30px;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 800;
  border-radius: 8px;
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.32);
}
.card-grid.is-condensed .tile-actions .add-btn:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  transform: translateY(-1px);
}
.card-grid.is-condensed .tile-actions .add-btn.on {
  background: var(--surface-2);
  color: var(--blue);
  border-color: var(--blue);
  box-shadow: none;
}
.card-grid.is-condensed .tile-actions .compare-btn {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
  font-weight: 900;
}

/* Empty-board coach mark + progress badge */

.board-empty {
  border: 1px dashed var(--border-2);
  background: var(--surface-2);
  color: var(--text-2);
  padding: 1rem 0.95rem;
  border-radius: 12px;
  margin: 0.7rem 0;
  font-size: 0.86rem;
  line-height: 1.5;
}
.board-empty strong {
  display: block;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.32rem;
}
.board-progress {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.95rem;
  margin: 0 0 0.6rem;
  background: linear-gradient(135deg, var(--blue), var(--blue-bright));
  color: #fff;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: var(--shadow-blue);
}
.board-progress strong {
  font-family: var(--mono);
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  text-transform: none;
}
.board-progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
  margin: 0 0.55rem;
}
.board-progress-bar span {
  display: block;
  height: 100%;
  background: #fff;
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* Shared launch UX: player drawer, source details, mobile sheets, and crawlable context blocks */
.launch-context {
  margin: clamp(2rem, 5vw, 4rem) 0 0;
  padding: clamp(1.2rem, 3vw, 2rem) 0 0;
  border-top: 1px solid var(--border, rgba(148, 163, 184, 0.34));
  color: var(--text, #0a1628);
}

.launch-context h2 {
  margin: 0 0 0.75rem;
  max-width: 880px;
  font-size: clamp(1.45rem, 2.2vw, 2.1rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.launch-context h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  line-height: 1.2;
}

.launch-context p {
  max-width: 980px;
  margin: 0 0 0.85rem;
  color: var(--muted, #50627a);
  font-size: 0.98rem;
  line-height: 1.68;
}

.launch-context a {
  color: var(--accent, #0f766e);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, currentColor 35%, transparent);
}

.launch-context a:hover {
  border-bottom-color: currentColor;
}

.launch-kicker {
  margin-bottom: 0.4rem !important;
  color: var(--accent, #0f766e) !important;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem !important;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.launch-context-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0 0.8rem;
}

.launch-context-grid > div {
  min-width: 0;
  padding-top: 0.8rem;
  border-top: 2px solid var(--border, rgba(148, 163, 184, 0.34));
}

.launch-context-grid p {
  margin-bottom: 0;
  font-size: 0.92rem;
}

.launch-citations {
  font-size: 0.9rem !important;
}

[data-theme="dark"] .launch-context {
  border-top-color: rgba(148, 163, 184, 0.22);
}

[data-theme="dark"] .launch-context,
[data-theme="dark"] .launch-context h2,
[data-theme="dark"] .launch-context h3 {
  color: var(--text, #f8fafc);
}

[data-theme="dark"] .launch-context p {
  color: var(--muted, #94a3b8);
}

[data-theme="dark"] .launch-context-grid > div {
  border-top-color: rgba(148, 163, 184, 0.24);
}

@media (max-width: 760px) {
  .launch-context-grid {
    grid-template-columns: 1fr;
  }
}

.hid-player-drawer.do-drawer,
.hid-player-drawer.v3-drawer,
.hid-player-drawer.tp-drawer,
.hid-player-drawer.season-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(760px, calc(100vw - 22px));
  height: 100dvh;
  z-index: 1200;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -28px 0 70px rgba(10, 22, 40, 0.24);
  transform: translateX(104%);
  transition: transform 0.24s ease;
}

.hid-player-drawer.do-drawer[aria-hidden="false"],
.hid-player-drawer.v3-drawer[aria-hidden="false"],
.hid-player-drawer.tp-drawer[aria-hidden="false"],
.hid-player-drawer.season-drawer[aria-hidden="false"] {
  transform: translateX(0);
}

.hid-player-drawer-backdrop.do-drawer-backdrop,
.hid-player-drawer-backdrop.v3-drawer-backdrop,
.hid-player-drawer-backdrop.tp-drawer-backdrop,
.hid-player-drawer-backdrop.season-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1190;
  background: rgba(5, 10, 22, 0.42);
  backdrop-filter: blur(4px);
}

.hid-player-drawer-backdrop[hidden] {
  display: none !important;
}

.hid-drawer-card {
  min-height: 100%;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), transparent 240px),
    var(--surface);
}

.hid-d-head {
  position: relative;
  padding: clamp(1.15rem, 3vw, 2rem);
  border-bottom: 1px solid var(--border);
}

.hid-d-close,
.hid-d-copy {
  min-height: 34px;
  border-radius: 8px;
}

.hid-d-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  padding: 0;
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
  box-shadow: none;
}

.hid-d-copy {
  margin-top: 0.85rem;
  padding: 0 0.85rem;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.hid-d-kicker {
  margin: 0 3.2rem 0.45rem 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hid-d-head h2 {
  margin: 0;
  max-width: 12ch;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 4.3rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.hid-d-head p {
  max-width: 62ch;
  margin: 0.72rem 0 0;
  color: var(--text-2);
  font-size: 0.98rem;
}

.hid-d-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  margin-top: 0.9rem;
}

.hid-d-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 0.58rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 850;
  white-space: nowrap;
}

.hid-d-badge.tone-strong,
.hid-d-badge.tone-production {
  color: var(--blue-deep);
  background: var(--ice-100);
  border-color: var(--ice-200);
}

.hid-d-badge.tone-source {
  color: #7c4a03;
  background: var(--gold-bg);
  border-color: rgba(245, 158, 11, 0.36);
}

.hid-d-badge.tone-event {
  color: #047857;
  background: var(--green-bg);
  border-color: rgba(16, 185, 129, 0.32);
}

.hid-d-badge.tone-watch,
.hid-d-badge.tone-goalie {
  color: #5b21b6;
  background: var(--purple-bg);
  border-color: rgba(139, 92, 246, 0.32);
}

.hid-d-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 0.35rem;
  padding: 0.7rem clamp(0.8rem, 2vw, 1.35rem);
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
}

.hid-d-tabs button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 0.72rem;
  border-radius: 8px;
  border-color: var(--border);
  background: transparent;
  color: var(--text-2);
  box-shadow: none;
  font-size: 0.78rem;
}

.hid-d-tabs button.is-active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.hid-d-panel {
  display: none;
  padding: clamp(0.95rem, 2.4vw, 1.45rem);
}

.hid-d-panel.is-active {
  display: block;
}

.hid-d-overview {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.hid-d-photo {
  position: sticky;
  top: 66px;
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.hid-d-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hid-d-photo span {
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 800;
}

.hid-d-photo.has-photo span {
  display: none;
}

.hid-d-photo.is-empty img {
  display: none;
}

.hid-d-photo.is-empty span {
  display: block;
}

.hid-d-statcards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}

.hid-d-statcard,
.hid-d-meta div {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.hid-d-statcard {
  padding: 0.75rem;
}

.hid-d-statcard span,
.hid-d-meta dt,
.hid-d-rank-source dt {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hid-d-statcard strong {
  display: block;
  margin-top: 0.25rem;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
}

.hid-d-statcard em {
  display: block;
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.hid-d-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin: 0;
}

.hid-d-meta div {
  min-width: 0;
  padding: 0.72rem;
}

.hid-d-meta dd {
  margin: 0.2rem 0 0;
  color: var(--text);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.hid-d-rank-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.hid-d-rank-summary span {
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.hid-d-rank-summary b {
  display: block;
  margin-top: 0.2rem;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
  text-transform: none;
}

.hid-d-rank-list {
  display: grid;
  gap: 0.5rem;
}

.hid-d-rank-source {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}

.hid-d-rank-source.is-best {
  border-color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}

.hid-d-rank-source summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.72rem 0.8rem;
  cursor: pointer;
  list-style: none;
}

.hid-d-rank-source summary::-webkit-details-marker {
  display: none;
}

.hid-d-rank-source summary span {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.hid-d-rank-source summary b {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hid-d-rank-source summary em {
  color: var(--muted);
  font-size: 0.75rem;
}

.hid-d-rank-source summary strong {
  flex: 0 0 auto;
  min-width: 52px;
  padding: 0.22rem 0.48rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.82rem;
  text-align: center;
}

.hid-d-rank-source dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0 0.8rem 0.85rem;
}

.hid-d-rank-source dd {
  margin: 0.14rem 0 0;
  color: var(--text-2);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.hid-d-rank-source a {
  color: var(--blue);
  font-weight: 800;
}

.hid-d-table-section + .hid-d-table-section {
  margin-top: 0.9rem;
}

.hid-d-table-section h4 {
  margin: 0 0 0.45rem;
  color: var(--text);
  font-size: 0.9rem;
}

.hid-d-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.hid-d-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.hid-d-table th,
.hid-d-table td {
  padding: 0.55rem 0.62rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.hid-d-table th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hid-d-table tr:last-child td {
  border-bottom: none;
}

.hid-d-table .num {
  text-align: right;
  font-family: var(--mono);
}

.hid-d-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.hid-d-note,
.hid-d-empty {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.hid-d-colour { margin-top: 1rem; }

.hid-d-quote {
  margin: 0 0 0.7rem;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--blue);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--blue) 6%, var(--surface));
}

.hid-d-quote blockquote {
  margin: 0;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1.5;
  font-weight: 500;
}

.hid-d-quote blockquote::before { content: "\201C"; }
.hid-d-quote blockquote::after { content: "\201D"; }

.hid-d-quote figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.5;
}

.hid-d-quote-src {
  color: var(--blue);
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.hid-d-quote-conf {
  margin-left: 0.4rem;
  color: var(--muted-2);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
}

.hid-d-dot { color: var(--muted-2); }

.hid-d-tidbit {
  margin: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.hid-d-tidbit-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.35rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--ice-100);
  color: var(--blue-deep);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

[data-theme="dark"] .hid-d-tidbit-chip { color: var(--blue-glow); }

.hid-d-tidbit p {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
}

.hid-d-tidbit cite {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  font-style: normal;
}

.hid-d-tidbit cite a { color: var(--blue); font-weight: 800; }

@media (prefers-reduced-motion: no-preference) {
  .hid-d-colour { animation: hidColourIn 0.26s ease both; }
  @keyframes hidColourIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
  }
}

.hid-source-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.7fr) auto;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.8rem;
  padding: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.hid-source-detail strong {
  display: block;
  color: var(--text);
  font-size: 0.92rem;
}

.hid-source-detail span,
.hid-source-detail p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.hid-source-detail a {
  color: var(--blue);
  font-weight: 850;
}

.hid-source-detail button {
  min-height: 34px;
  border-radius: 8px;
}

.hid-mobile-actions a.button {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
}

.hid-mobile-actions a.button:hover {
  border-color: var(--ice-300);
  background: var(--ice-100);
}

.hid-mobile-actions a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 0.8rem;
  font-weight: 850;
}

.hid-mobile-bar,
.hid-mobile-sheet,
.hid-mobile-sheet-backdrop {
  display: none;
}

@media (max-width: 760px) {
  body.hid-has-mobile-controls {
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
  }

  .hid-player-drawer.do-drawer,
  .hid-player-drawer.v3-drawer,
  .hid-player-drawer.tp-drawer,
  .hid-player-drawer.season-drawer {
    inset: 0;
    width: 100vw;
    max-width: none;
    border-left: none;
  }

  .hid-d-head {
    padding: 1rem;
  }

  .hid-d-head h2 {
    max-width: 10ch;
    font-size: clamp(2.05rem, 13vw, 3.45rem);
  }

  .hid-d-overview,
  .hid-d-rank-summary,
  .hid-d-rank-source dl,
  .hid-source-detail {
    grid-template-columns: 1fr;
  }

  /* Atomic facts stay two-up on mobile so the Overview isn't an endless
     stack of one-fact-per-row cards. */
  .hid-d-meta,
  .hid-d-statcards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hid-d-photo {
    position: relative;
    top: auto;
    width: min(210px, 62vw);
    margin: 0 auto;
  }

  .hid-d-panel {
    padding: 0.88rem;
  }

  .hid-d-tabs {
    gap: 0.28rem;
    padding: 0.6rem 0.7rem;
  }

  .hid-d-tabs button {
    font-size: 0.72rem;
  }

  .hid-mobile-bar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 1180;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0.42rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(14px);
  }

  .hid-mobile-bar button {
    min-width: 0;
    min-height: 46px;
    padding: 0.32rem 0.2rem;
    border-radius: 8px;
    border-color: transparent;
    background: transparent;
    color: var(--text);
    box-shadow: none;
    display: grid;
    gap: 0.12rem;
  }

  .hid-mobile-bar button span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 20px;
    color: var(--blue);
    line-height: 1;
  }

  .hid-mobile-bar button span svg {
    width: 20px;
    height: 20px;
  }

  .hid-mobile-bar button b {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.66rem;
    font-weight: 900;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }

  .hid-mobile-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1210;
    display: block;
    background: rgba(5, 10, 22, 0.38);
    backdrop-filter: blur(4px);
  }

  .hid-mobile-sheet-backdrop[hidden] {
    display: none;
  }

  .hid-mobile-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1220;
    display: block;
    max-height: min(78dvh, 680px);
    overflow: auto;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    background: var(--surface);
    box-shadow: 0 -24px 64px rgba(10, 22, 40, 0.24);
    transform: translateY(104%);
    transition: transform 0.22s ease;
  }

  .hid-mobile-sheet[aria-hidden="false"] {
    transform: translateY(0);
  }

  .hid-mobile-sheet-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  .hid-mobile-sheet-head span {
    display: block;
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .hid-mobile-sheet-head h3 {
    margin: 0.1rem 0 0;
    color: var(--text);
    font-size: 1.02rem;
  }

  .hid-mobile-sheet-head button {
    width: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
    box-shadow: none;
  }

  .hid-mobile-sheet-body {
    display: grid;
    gap: 0.85rem;
    padding: 1rem;
  }

  .hid-mobile-field,
  .hid-mobile-actions {
    display: grid;
    gap: 0.4rem;
  }

  .hid-mobile-field label {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .hid-mobile-field input,
  .hid-mobile-field select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    padding: 0 0.75rem;
  }

  .hid-mobile-choice-list {
    display: grid;
    gap: 0.45rem;
  }

  .hid-mobile-choice-list button {
    justify-content: space-between;
    min-height: 42px;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
    box-shadow: none;
  }

  .hid-mobile-choice-list button.is-active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
  }
}

/* === REDUCED MOTION ===================================================== */
/* Global guard — neutralizes every animation/transition site-wide,
   including route CSS loaded after this file (!important wins the cascade). */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
