:root {
  color-scheme: dark;
  --bg: #0b0908;
  --panel: #171210;
  --panel-2: #211814;
  --line: #554533;
  --line-bright: #9b7841;
  --text: #fff7e6;
  --muted: #d7c59b;
  --soft: #ffd778;
  --accent: #c72e22;
  --accent-2: #8aa04b;
  --focus: #f0c84a;
  --danger: #e85c3f;
  --bone: #efe0b7;
  --radius: 8px;
  --grid-line: rgba(255, 215, 120, 0.06);
  --grid-line-soft: rgba(255, 215, 120, 0.04);
  --stripe-line: rgba(199, 46, 34, 0.045);
  --body-glow: rgba(199, 46, 34, 0.18);
  --body-gradient: linear-gradient(135deg, #15100d 0%, #070604 52%, #18110c 100%);
  --sidebar-wash: rgba(199, 46, 34, 0.18);
  --sidebar-bg: rgba(10, 7, 6, 0.94);
  --topbar-bg: rgba(10, 7, 6, 0.76);
  --control-bg: rgba(23, 18, 16, 0.82);
  --input-bg: rgba(12, 9, 7, 0.86);
  --input-bg-soft: rgba(15, 11, 9, 0.78);
  --panel-glass: rgba(18, 12, 9, 0.62);
  --surface-soft: rgba(12, 9, 7, 0.72);
  --surface-strong: rgba(18, 12, 9, 0.82);
  --table-head: rgba(47, 34, 23, 0.92);
  --nav-active-bg: linear-gradient(90deg, rgba(199, 46, 34, 0.34), rgba(30, 22, 16, 0.86));
  --button-bg: rgba(30, 22, 16, 0.88);
  --button-bg-hover: rgba(52, 37, 24, 0.94);
  --button-border: rgba(240, 200, 74, 0.36);
  --button-text: #fff7e6;
  --button-muted-text: #d7c59b;
  --primary-bg: linear-gradient(180deg, rgba(255, 215, 120, 0.24), rgba(199, 46, 34, 0.22)), rgba(104, 54, 25, 0.92);
  --primary-bg-hover: linear-gradient(180deg, rgba(255, 215, 120, 0.34), rgba(199, 46, 34, 0.3)), rgba(125, 63, 28, 0.96);
  --primary-border: rgba(255, 215, 120, 0.68);
  --primary-text: #fff8e7;
  --primary-text-shadow: 0 1px 6px rgba(0, 0, 0, 0.72);
  --active-button-bg: linear-gradient(180deg, rgba(199, 46, 34, 0.36), rgba(240, 200, 74, 0.16)), rgba(54, 32, 19, 0.92);
  --active-button-border: rgba(240, 200, 74, 0.7);
  --active-button-text: #fff8e7;
  --modal-bg: rgba(18, 12, 9, 0.96);
  --overlay-bg: rgba(0, 0, 0, 0.64);
  --scroll-fade: rgba(18, 12, 9, 0.92);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark-dugout"] {
  color-scheme: dark;
  --bg: #080b0b;
  --panel: #121a18;
  --panel-2: #1c2a25;
  --line: #3f5a4d;
  --line-bright: #9ebc7a;
  --text: #f4fff2;
  --muted: #bfd0ba;
  --soft: #c7e56f;
  --accent: #b94030;
  --accent-2: #4e9b72;
  --focus: #d8f26a;
  --danger: #f06c4f;
  --bone: #e4f0d7;
  --grid-line: rgba(199, 229, 111, 0.055);
  --grid-line-soft: rgba(126, 184, 128, 0.055);
  --stripe-line: rgba(185, 64, 48, 0.035);
  --body-glow: rgba(78, 155, 114, 0.18);
  --body-gradient: linear-gradient(135deg, #111a17 0%, #060807 54%, #1d1710 100%);
  --sidebar-wash: rgba(78, 155, 114, 0.18);
  --sidebar-bg: rgba(7, 11, 10, 0.94);
  --topbar-bg: rgba(7, 11, 10, 0.78);
  --control-bg: rgba(18, 28, 25, 0.86);
  --input-bg: rgba(8, 12, 11, 0.88);
  --input-bg-soft: rgba(10, 16, 14, 0.8);
  --panel-glass: rgba(14, 22, 19, 0.66);
  --surface-soft: rgba(8, 13, 12, 0.74);
  --surface-strong: rgba(14, 22, 19, 0.84);
  --table-head: rgba(30, 45, 38, 0.94);
  --nav-active-bg: linear-gradient(90deg, rgba(78, 155, 114, 0.36), rgba(25, 35, 29, 0.88));
  --button-bg: rgba(18, 32, 27, 0.88);
  --button-bg-hover: rgba(30, 52, 42, 0.96);
  --button-border: rgba(158, 188, 122, 0.42);
  --button-text: #f4fff2;
  --button-muted-text: #bfd0ba;
  --primary-bg: linear-gradient(180deg, rgba(199, 229, 111, 0.24), rgba(78, 155, 114, 0.28)), rgba(39, 82, 58, 0.94);
  --primary-bg-hover: linear-gradient(180deg, rgba(216, 242, 106, 0.34), rgba(78, 155, 114, 0.34)), rgba(48, 101, 70, 0.98);
  --primary-border: rgba(216, 242, 106, 0.72);
  --primary-text: #f7fff3;
  --primary-text-shadow: 0 1px 6px rgba(0, 0, 0, 0.68);
  --active-button-bg: linear-gradient(180deg, rgba(78, 155, 114, 0.38), rgba(216, 242, 106, 0.16)), rgba(28, 55, 42, 0.92);
  --active-button-border: rgba(216, 242, 106, 0.7);
  --active-button-text: #f7fff3;
  --modal-bg: rgba(10, 16, 14, 0.96);
  --scroll-fade: rgba(10, 16, 14, 0.94);
}

:root[data-theme="dark-warpstone"] {
  color-scheme: dark;
  --bg: #0a0710;
  --panel: #151020;
  --panel-2: #21172d;
  --line: #56476a;
  --line-bright: #a380d6;
  --text: #fff9ef;
  --muted: #d5c3e8;
  --soft: #88ef9e;
  --accent: #d54f7f;
  --accent-2: #71c655;
  --focus: #a4f073;
  --danger: #ff6d7a;
  --bone: #f3e7cc;
  --grid-line: rgba(136, 239, 158, 0.052);
  --grid-line-soft: rgba(163, 128, 214, 0.05);
  --stripe-line: rgba(213, 79, 127, 0.042);
  --body-glow: rgba(113, 198, 85, 0.18);
  --body-gradient: linear-gradient(135deg, #171123 0%, #07050b 50%, #181b10 100%);
  --sidebar-wash: rgba(213, 79, 127, 0.16);
  --sidebar-bg: rgba(8, 6, 12, 0.94);
  --topbar-bg: rgba(8, 6, 12, 0.78);
  --control-bg: rgba(22, 16, 32, 0.86);
  --input-bg: rgba(9, 7, 14, 0.88);
  --input-bg-soft: rgba(12, 9, 18, 0.8);
  --panel-glass: rgba(20, 14, 29, 0.66);
  --surface-soft: rgba(10, 8, 15, 0.74);
  --surface-strong: rgba(20, 14, 29, 0.84);
  --table-head: rgba(38, 28, 50, 0.94);
  --nav-active-bg: linear-gradient(90deg, rgba(213, 79, 127, 0.33), rgba(30, 22, 43, 0.88));
  --button-bg: rgba(25, 18, 38, 0.9);
  --button-bg-hover: rgba(44, 29, 62, 0.96);
  --button-border: rgba(163, 128, 214, 0.44);
  --button-text: #fff9ef;
  --button-muted-text: #d5c3e8;
  --primary-bg: linear-gradient(180deg, rgba(164, 240, 115, 0.22), rgba(213, 79, 127, 0.28)), rgba(72, 38, 87, 0.94);
  --primary-bg-hover: linear-gradient(180deg, rgba(164, 240, 115, 0.32), rgba(213, 79, 127, 0.36)), rgba(90, 46, 108, 0.98);
  --primary-border: rgba(164, 240, 115, 0.7);
  --primary-text: #fff9ef;
  --primary-text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
  --active-button-bg: linear-gradient(180deg, rgba(213, 79, 127, 0.38), rgba(164, 240, 115, 0.14)), rgba(51, 31, 66, 0.92);
  --active-button-border: rgba(164, 240, 115, 0.68);
  --active-button-text: #fff9ef;
  --modal-bg: rgba(12, 9, 18, 0.96);
  --scroll-fade: rgba(12, 9, 18, 0.94);
}

:root[data-theme="light-parchment"] {
  color-scheme: light;
  --bg: #f5eddc;
  --panel: #fffaf0;
  --panel-2: #eadcc4;
  --line: #b99566;
  --line-bright: #8f5e2e;
  --text: #211915;
  --muted: #66523d;
  --soft: #8d4d21;
  --accent: #b83228;
  --accent-2: #4f7d58;
  --focus: #a46a19;
  --danger: #bd3d30;
  --bone: #fff7e6;
  --grid-line: rgba(143, 94, 46, 0.12);
  --grid-line-soft: rgba(79, 125, 88, 0.08);
  --stripe-line: rgba(184, 50, 40, 0.045);
  --body-glow: rgba(184, 50, 40, 0.12);
  --body-gradient: linear-gradient(135deg, #fbf5e9 0%, #efe0c7 52%, #f7f1e4 100%);
  --sidebar-wash: rgba(184, 50, 40, 0.1);
  --sidebar-bg: rgba(255, 250, 240, 0.94);
  --topbar-bg: rgba(255, 250, 240, 0.84);
  --control-bg: rgba(255, 247, 230, 0.9);
  --input-bg: rgba(255, 252, 245, 0.92);
  --input-bg-soft: rgba(255, 252, 245, 0.86);
  --panel-glass: rgba(255, 250, 240, 0.76);
  --surface-soft: rgba(255, 252, 245, 0.78);
  --surface-strong: rgba(255, 250, 240, 0.9);
  --table-head: rgba(224, 203, 173, 0.94);
  --nav-active-bg: linear-gradient(90deg, rgba(184, 50, 40, 0.18), rgba(255, 246, 228, 0.92));
  --button-bg: rgba(255, 247, 230, 0.96);
  --button-bg-hover: rgba(242, 224, 194, 0.98);
  --button-border: rgba(143, 94, 46, 0.46);
  --button-text: #211915;
  --button-muted-text: #66523d;
  --primary-bg: linear-gradient(180deg, rgba(184, 50, 40, 0.92), rgba(143, 94, 46, 0.92));
  --primary-bg-hover: linear-gradient(180deg, rgba(199, 61, 48, 0.98), rgba(160, 104, 46, 0.98));
  --primary-border: rgba(143, 94, 46, 0.78);
  --primary-text: #fffaf0;
  --primary-text-shadow: none;
  --active-button-bg: linear-gradient(180deg, rgba(184, 50, 40, 0.22), rgba(143, 94, 46, 0.14)), rgba(255, 241, 216, 0.96);
  --active-button-border: rgba(184, 50, 40, 0.62);
  --active-button-text: #211915;
  --modal-bg: rgba(255, 250, 240, 0.98);
  --overlay-bg: rgba(65, 45, 28, 0.34);
  --scroll-fade: rgba(255, 250, 240, 0.94);
}

:root[data-theme="light-sideline"] {
  color-scheme: light;
  --bg: #eef4ee;
  --panel: #fbfff8;
  --panel-2: #dae8d7;
  --line: #8aa47e;
  --line-bright: #4d7d48;
  --text: #172019;
  --muted: #4a634d;
  --soft: #3f762f;
  --accent: #b94a32;
  --accent-2: #477c8f;
  --focus: #608b2c;
  --danger: #c84833;
  --bone: #f7f7df;
  --grid-line: rgba(77, 125, 72, 0.11);
  --grid-line-soft: rgba(71, 124, 143, 0.08);
  --stripe-line: rgba(185, 74, 50, 0.04);
  --body-glow: rgba(71, 124, 143, 0.12);
  --body-gradient: linear-gradient(135deg, #f8fcf4 0%, #e2eddf 54%, #f1f4e6 100%);
  --sidebar-wash: rgba(71, 124, 143, 0.1);
  --sidebar-bg: rgba(251, 255, 248, 0.94);
  --topbar-bg: rgba(251, 255, 248, 0.84);
  --control-bg: rgba(246, 252, 242, 0.9);
  --input-bg: rgba(252, 255, 250, 0.92);
  --input-bg-soft: rgba(252, 255, 250, 0.86);
  --panel-glass: rgba(251, 255, 248, 0.76);
  --surface-soft: rgba(252, 255, 250, 0.78);
  --surface-strong: rgba(251, 255, 248, 0.9);
  --table-head: rgba(216, 231, 209, 0.94);
  --nav-active-bg: linear-gradient(90deg, rgba(71, 124, 143, 0.18), rgba(246, 252, 242, 0.92));
  --button-bg: rgba(246, 252, 242, 0.96);
  --button-bg-hover: rgba(224, 239, 220, 0.98);
  --button-border: rgba(77, 125, 72, 0.44);
  --button-text: #172019;
  --button-muted-text: #4a634d;
  --primary-bg: linear-gradient(180deg, rgba(71, 124, 143, 0.96), rgba(77, 125, 72, 0.92));
  --primary-bg-hover: linear-gradient(180deg, rgba(80, 141, 163, 0.98), rgba(89, 145, 82, 0.98));
  --primary-border: rgba(77, 125, 72, 0.72);
  --primary-text: #fbfff8;
  --primary-text-shadow: none;
  --active-button-bg: linear-gradient(180deg, rgba(71, 124, 143, 0.2), rgba(77, 125, 72, 0.12)), rgba(237, 248, 232, 0.96);
  --active-button-border: rgba(71, 124, 143, 0.58);
  --active-button-text: #172019;
  --modal-bg: rgba(251, 255, 248, 0.98);
  --overlay-bg: rgba(42, 58, 43, 0.34);
  --scroll-fade: rgba(251, 255, 248, 0.94);
}

:root[data-theme="light-altdorf"] {
  color-scheme: light;
  --bg: #eef1f6;
  --panel: #fbfcff;
  --panel-2: #dce3ee;
  --line: #8797ad;
  --line-bright: #536e92;
  --text: #151c28;
  --muted: #506077;
  --soft: #7d3f38;
  --accent: #b63c32;
  --accent-2: #4b7d75;
  --focus: #9a6726;
  --danger: #be3e35;
  --bone: #fff4df;
  --grid-line: rgba(83, 110, 146, 0.11);
  --grid-line-soft: rgba(75, 125, 117, 0.08);
  --stripe-line: rgba(182, 60, 50, 0.04);
  --body-glow: rgba(75, 125, 117, 0.12);
  --body-gradient: linear-gradient(135deg, #fbfcff 0%, #e5ebf3 52%, #f8f1e6 100%);
  --sidebar-wash: rgba(182, 60, 50, 0.1);
  --sidebar-bg: rgba(251, 252, 255, 0.94);
  --topbar-bg: rgba(251, 252, 255, 0.84);
  --control-bg: rgba(246, 249, 253, 0.92);
  --input-bg: rgba(255, 255, 255, 0.94);
  --input-bg-soft: rgba(255, 255, 255, 0.88);
  --panel-glass: rgba(251, 252, 255, 0.78);
  --surface-soft: rgba(255, 255, 255, 0.8);
  --surface-strong: rgba(251, 252, 255, 0.92);
  --table-head: rgba(220, 227, 238, 0.96);
  --nav-active-bg: linear-gradient(90deg, rgba(182, 60, 50, 0.16), rgba(246, 249, 253, 0.94));
  --button-bg: rgba(246, 249, 253, 0.96);
  --button-bg-hover: rgba(226, 234, 245, 0.98);
  --button-border: rgba(83, 110, 146, 0.42);
  --button-text: #151c28;
  --button-muted-text: #506077;
  --primary-bg: linear-gradient(180deg, rgba(83, 110, 146, 0.96), rgba(182, 60, 50, 0.9));
  --primary-bg-hover: linear-gradient(180deg, rgba(96, 127, 168, 0.98), rgba(197, 72, 60, 0.98));
  --primary-border: rgba(83, 110, 146, 0.72);
  --primary-text: #fbfcff;
  --primary-text-shadow: none;
  --active-button-bg: linear-gradient(180deg, rgba(83, 110, 146, 0.2), rgba(182, 60, 50, 0.12)), rgba(236, 242, 250, 0.96);
  --active-button-border: rgba(83, 110, 146, 0.58);
  --active-button-text: #151c28;
  --modal-bg: rgba(251, 252, 255, 0.98);
  --overlay-bg: rgba(39, 50, 67, 0.32);
  --scroll-fade: rgba(251, 252, 255, 0.94);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 96px 100%,
    linear-gradient(0deg, transparent 0 47px, var(--grid-line-soft) 48px 49px, transparent 50px) 0 0 / 100% 96px,
    repeating-linear-gradient(90deg, var(--stripe-line) 0 1px, transparent 1px 24px),
    radial-gradient(circle at 18% 0%, var(--body-glow), transparent 32%),
    var(--body-gradient),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px;
  border-right: 1px solid var(--line);
  overflow: hidden;
  background:
    linear-gradient(180deg, var(--sidebar-wash), transparent 30%),
    var(--sidebar-bg);
}

.sidebar > * {
  position: relative;
  z-index: 1;
}

.nav-overlay,
.nav-toggle {
  display: none;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(240, 200, 74, 0.55);
  border-radius: var(--radius);
  background: #f3eee2;
  box-shadow: 0 0 0 3px rgba(199, 46, 34, 0.18);
}

.brand-mark img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 4px;
  margin-top: 28px;
}

.nav-list a {
  position: relative;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
}

.nav-list a:hover,
.nav-list a.active {
  background: var(--nav-active-bg);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  color: var(--muted);
  font-size: 13px;
}

.legal-note {
  margin: 10px 0 0;
  color: rgba(201, 189, 152, 0.86);
  line-height: 1.45;
}

.legal-note a {
  display: inline-block;
  margin-top: 6px;
  color: var(--soft);
  text-decoration: none;
}

.legal-note a:hover {
  text-decoration: underline;
}

.main {
  min-width: 0;
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}

.theme-picker {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--button-border);
  border-radius: var(--radius);
  background: var(--button-bg);
  color: var(--button-muted-text);
  font-size: 12px;
  font-weight: 900;
}

.theme-picker select {
  width: 138px;
  min-height: 30px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--button-text);
  font: inherit;
  cursor: pointer;
}

.auth-button {
  max-width: 148px;
  padding: 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-toggle {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--button-border);
  border-radius: var(--radius);
  background: var(--button-bg);
  color: var(--button-text);
  cursor: pointer;
}

.nav-toggle svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 760px;
}

.search-wrap svg {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 18px;
  height: 18px;
  translate: 0 -50%;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 2;
}

.search-wrap input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: var(--input-bg-soft);
  color: var(--text);
}

.search-wrap input:focus {
  border-color: var(--focus);
}

.icon-text-button {
  min-width: 48px;
  min-height: 44px;
  border: 1px solid var(--button-border);
  border-radius: var(--radius);
  background: var(--button-bg);
  color: var(--button-text);
  cursor: pointer;
}

.theme-picker:hover,
.nav-toggle:hover,
.icon-text-button:hover:not(:disabled) {
  border-color: var(--line-bright);
  background: var(--button-bg-hover);
}

.icon-text-button:disabled {
  cursor: default;
  color: var(--button-muted-text);
}

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

.auth-modal {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.auth-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: var(--overlay-bg);
  cursor: pointer;
}

.auth-dialog {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(199, 46, 34, 0.14), transparent),
    var(--modal-bg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.52);
}

.auth-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.auth-dialog h2 {
  margin: 0;
  font-size: 24px;
}

.auth-form,
.auth-account {
  display: grid;
  gap: 12px;
}

.auth-form[hidden],
.auth-account[hidden],
.auth-form [hidden] {
  display: none;
}

.auth-account p {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--soft);
  font-weight: 800;
}

.auth-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(232, 92, 63, 0.54);
  border-radius: var(--radius);
  background: rgba(232, 92, 63, 0.12);
  color: #ffb199;
}

body.auth-open {
  overflow: hidden;
}

.view {
  position: relative;
  isolation: isolate;
  min-height: calc(100vh - 81px);
  padding: 28px;
}

.view::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

.view::after {
  z-index: -1;
  background:
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 96px 100%,
    linear-gradient(0deg, transparent 0 47px, var(--grid-line-soft) 48px 49px, transparent 50px) 0 0 / 100% 96px,
    repeating-linear-gradient(90deg, var(--stripe-line) 0 1px, transparent 1px 24px),
    radial-gradient(circle at 52% 0%, rgba(255, 215, 120, 0.1), transparent 28%),
    linear-gradient(180deg, transparent, var(--bg)),
    linear-gradient(90deg, var(--surface-strong), transparent 36%, transparent 66%, var(--surface-strong));
}

.league-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 28px;
  align-items: center;
  min-height: 320px;
  margin-bottom: 30px;
  padding: 30px;
  border: 1px solid rgba(239, 224, 183, 0.2);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(199, 46, 34, 0.22), transparent 42%),
    linear-gradient(180deg, rgba(255, 215, 120, 0.08), transparent),
    var(--panel-glass);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.league-hero-copy h1 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(34px, 5vw, 66px);
  line-height: 0.98;
}

.league-hero-copy p {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--bone);
  font-size: 17px;
  line-height: 1.55;
}

.league-hero-media {
  display: grid;
  min-height: 260px;
  place-items: center;
  border: 1px solid rgba(240, 200, 74, 0.38);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff8e7, #d9c28d);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

.league-hero-media img {
  width: min(100%, 280px);
  max-height: 270px;
  object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(42, 30, 10, 0.28));
}

.page-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-head h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}

.page-head p {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 18px;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-glass);
  backdrop-filter: blur(5px);
}

.filter-field {
  display: grid;
  gap: 6px;
}

.filter-field span {
  color: var(--muted);
  font-size: 12px;
}

.filter-field select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: var(--input-bg);
  color: var(--text);
}

.filter-field input {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: var(--input-bg);
  color: var(--text);
}

.filter-field input:focus,
.filter-field select:focus {
  border-color: var(--focus);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius);
  background: var(--primary-bg);
  color: var(--primary-text);
  font-weight: 700;
  text-decoration: none;
  text-shadow: var(--primary-text-shadow);
  cursor: pointer;
}

.primary-button:hover {
  border-color: var(--line-bright);
  background: var(--primary-bg-hover);
}

.full-width {
  width: 100%;
}

.chip,
.filter-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--button-border);
  border-radius: var(--radius);
  background: var(--button-bg);
  color: var(--button-muted-text);
  text-decoration: none;
}

.chip:hover,
.filter-button:hover,
.ghost-button:hover {
  border-color: var(--line-bright);
  background: var(--button-bg-hover);
  color: var(--button-text);
}

.filter-button {
  cursor: pointer;
}

.ghost-button {
  justify-content: center;
  min-height: 38px;
  cursor: pointer;
}

.filter-button.active {
  border-color: var(--active-button-border);
  background: var(--active-button-bg);
  color: var(--active-button-text);
}

.skill-roll-panel {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid rgba(240, 200, 74, 0.38);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(199, 46, 34, 0.12), transparent),
    var(--surface-soft);
}

.skill-roll-controls {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.skill-roll-result {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg-soft);
}

.skill-roll-die {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: var(--radius);
  background: rgba(240, 200, 74, 0.16);
  color: var(--soft);
  font-weight: 700;
}

.skill-roll-result-link {
  color: var(--focus);
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.skill-roll-placeholder {
  color: var(--muted);
}

.skill-table-mobile {
  display: none;
}

.skill-table-desktop {
  display: block;
}

.team-roster-desktop {
  display: block;
}

.team-roster-mobile {
  display: none;
}

.team-roster-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.team-roster-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--table-head);
}

.content-panel .team-roster-card h2 {
  margin: 0;
  color: var(--soft);
  font-size: 17px;
  line-height: 1.25;
}

.team-roster-card header span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 700;
}

.team-roster-card header strong {
  flex: 0 0 auto;
  color: var(--soft);
}

.team-stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.team-stat-grid div {
  display: grid;
  gap: 4px;
  padding: 10px 6px;
  border-left: 1px solid rgba(85, 69, 51, 0.62);
  text-align: center;
}

.team-stat-grid div:first-child {
  border-left: 0;
}

.team-stat-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.team-stat-grid dd {
  margin: 0;
  color: var(--text);
  font-weight: 800;
}

.team-roster-field {
  display: grid;
  gap: 7px;
  padding: 11px 12px;
  border-top: 1px solid rgba(85, 69, 51, 0.45);
}

.team-stat-grid + .team-roster-field {
  border-top: 0;
}

.team-roster-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.team-roster-field > div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.team-roster-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid rgba(85, 69, 51, 0.45);
}

.team-roster-columns .team-roster-field {
  border-top: 0;
}

.team-roster-columns .team-roster-field + .team-roster-field {
  border-left: 1px solid rgba(85, 69, 51, 0.45);
}

.roster-pill {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid rgba(240, 200, 74, 0.26);
  border-radius: 999px;
  background: rgba(91, 71, 38, 0.44);
  color: var(--focus);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.roster-pill-muted {
  color: var(--soft);
}

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

.reference-table-mobile {
  display: none;
}

.reference-table-desktop {
  display: block;
}

.reference-table-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.reference-table-card header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--table-head);
}

.reference-table-card header span {
  color: var(--soft);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.reference-table-card header strong {
  display: inline-grid;
  min-width: 36px;
  min-height: 28px;
  place-items: center;
  border-radius: var(--radius);
  background: rgba(240, 200, 74, 0.16);
  color: var(--soft);
}

.content-panel .reference-table-card h2 {
  margin: 0;
  padding: 12px 12px 0;
  color: var(--focus);
  font-size: 17px;
  line-height: 1.25;
}

.content-panel .reference-table-card p {
  margin: 0;
  padding: 12px;
  color: var(--text);
  line-height: 1.55;
}

.skill-table-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.skill-table-group h2 {
  margin: 0;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--table-head);
  color: var(--soft);
  font-size: 16px;
  line-height: 1.2;
}

.content-panel .skill-table-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.content-panel .skill-table-list li {
  display: grid;
  min-height: 38px;
  grid-template-columns: 44px minmax(0, 1fr);
  border-top: 1px solid rgba(85, 69, 51, 0.62);
}

.content-panel .skill-table-list li:first-child {
  border-top: 0;
}

.skill-table-number {
  display: grid;
  place-items: center;
  border-right: 1px solid rgba(85, 69, 51, 0.62);
  color: var(--muted);
  font-weight: 700;
}

.content-panel .skill-table-list a {
  display: flex;
  min-width: 0;
  align-items: center;
  padding: 8px 10px;
  color: var(--focus);
  font-weight: 800;
  line-height: 1.25;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  display: block;
  min-height: 122px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 215, 120, 0.045), transparent),
    var(--panel-glass);
  backdrop-filter: blur(2px);
  text-decoration: none;
}

.card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--focus));
  content: "";
  opacity: 0.72;
}

.card:hover {
  border-color: var(--line-bright);
  background:
    linear-gradient(180deg, rgba(255, 215, 120, 0.08), transparent),
    var(--surface-strong);
}

.card.compact {
  min-height: 88px;
}

.card h2,
.card h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.86);
}

.card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.78);
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.league-reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.league-reference-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-glass);
}

.league-reference-card header {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid rgba(85, 69, 51, 0.72);
  padding-bottom: 10px;
}

.content-panel .league-reference-card h2,
.content-panel .league-reference-card h3 {
  margin: 0;
}

.league-reference-card header span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.league-reference-section {
  display: grid;
  gap: 8px;
}

.league-link-list {
  gap: 6px;
}

.league-star-list {
  max-height: 240px;
  overflow: auto;
  padding-right: 4px;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(91, 71, 38, 0.72);
  color: var(--soft);
  font-size: 12px;
}

.badge.warning {
  background: rgba(217, 73, 45, 0.18);
  color: #ffb199;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
}

.detail-layout > *,
.builder-layout > * {
  min-width: 0;
}

.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.builder-layout-main {
  grid-template-columns: minmax(0, 1fr);
}

.saved-roster-top-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.8fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.builder-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.builder-panel > * {
  min-width: 0;
  max-width: 100%;
}

.builder-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-glass);
  backdrop-filter: blur(5px);
}

.roster-settings-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.roster-settings-panel .builder-form {
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}

.team-rules-panel {
  display: grid;
  grid-template-columns: minmax(160px, 0.5fr) minmax(220px, 0.75fr) minmax(0, 1.4fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-glass);
}

.team-rules-row {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.team-rules-row > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.team-rules-row > strong {
  color: var(--text);
}

.team-rules-row select {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
}

.rule-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.builder-mode-field {
  min-width: 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 40px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.segmented-control button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.segmented-control button + button {
  border-left: 1px solid var(--line);
}

.segmented-control button:hover {
  background: var(--button-bg-hover);
  color: var(--button-text);
}

.segmented-control button.active {
  background: var(--active-button-bg);
  color: var(--active-button-text);
}

.builder-roster {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.builder-addons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.builder-addon {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(255, 215, 120, 0.3);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 215, 120, 0.06), transparent),
    var(--panel-glass);
  backdrop-filter: blur(2px);
}

.builder-addon.disabled {
  border-color: rgba(85, 69, 51, 0.62);
  opacity: 0.72;
}

.builder-addon strong,
.builder-addon span {
  display: block;
}

.builder-addon span {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.builder-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  min-width: 0;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 215, 120, 0.045), transparent),
    var(--panel-glass);
  backdrop-filter: blur(2px);
}

.builder-row-head strong,
.builder-row-head span {
  display: block;
  min-width: 0;
}

.builder-row-head span {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.builder-row-body {
  display: grid;
  min-width: 0;
}

.builder-row-main {
  display: grid;
  grid-template-columns: minmax(200px, 1.2fr) max-content minmax(180px, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.builder-row-head {
  min-width: 0;
}

.builder-row .team-stat-grid {
  width: max-content;
  max-width: 100%;
  grid-template-columns: repeat(5, 54px);
  overflow: hidden;
  border: 1px solid rgba(85, 69, 51, 0.62);
  border-radius: var(--radius);
}

.builder-row .team-stat-grid div {
  padding: 6px 5px;
}

.builder-row-skills,
.builder-summary-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.builder-row-skills .roster-pill {
  min-height: 28px;
  padding: 0 10px;
  font-size: 13px;
}

.builder-pool,
.builder-selected {
  display: grid;
  gap: 10px;
}

.builder-pool h2,
.builder-selected h2 {
  margin: 4px 0 0;
  font-size: 20px;
}

.builder-player-pool {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.available-player-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 215, 120, 0.065), transparent),
    var(--panel-glass);
  color: var(--text);
  font: inherit;
  text-align: left;
}

.available-player-card:hover {
  border-color: rgba(240, 200, 74, 0.72);
  background:
    linear-gradient(180deg, rgba(240, 200, 74, 0.12), transparent),
    var(--surface-strong);
}

.available-player-card.disabled,
.available-player-card.disabled .add-player-button {
  opacity: 0.56;
}

.available-player-card .team-stat-grid {
  grid-template-columns: repeat(5, minmax(36px, 1fr));
}

.available-player-card .team-stat-grid div {
  padding: 5px 4px;
}

.available-player-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.available-player-head strong,
.available-player-head em,
.available-player-foot {
  display: block;
}

.available-player-head em,
.available-player-foot {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.available-player-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 10px;
  align-items: center;
}

.add-player-button {
  min-width: 40px;
  min-height: 36px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.compact-table-panel {
  padding: 16px;
}

.builder-table-scroll {
  margin: 0;
}

.compact-roster-table {
  min-width: 980px;
  font-size: 13px;
}

.compact-roster-table th,
.compact-roster-table td {
  padding: 8px 10px;
  vertical-align: middle;
}

.compact-roster-table th {
  white-space: nowrap;
}

.compact-roster-table td {
  line-height: 1.35;
}

.compact-roster-table .skills-cell {
  min-width: 190px;
}

.compact-roster-table .roster-pill {
  min-height: 24px;
  padding: 0 8px;
  font-size: 12px;
}

.builder-selected-table {
  min-width: 940px;
}

.saved-roster-table {
  min-width: 1780px;
}

.saved-roster-mobile-list {
  display: none;
  gap: 12px;
}

.mobile-roster-player-card {
  gap: 12px;
}

.mobile-player-title {
  display: grid;
  flex: 1 1 auto;
  gap: 5px;
  min-width: 0;
}

.mobile-player-title > span,
.mobile-player-title small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mobile-player-section {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(85, 69, 51, 0.45);
}

.mobile-player-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.mobile-player-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mobile-skill-editor,
.mobile-advancement-section {
  min-width: 0;
}

.mobile-player-checks {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mobile-advancement-section {
  grid-template-columns: minmax(100px, 0.52fr) minmax(0, 1fr);
}

.spp-cell {
  min-width: 230px;
}

.level-cell {
  min-width: 120px;
}

.advancement-cell {
  min-width: 260px;
}

.spp-counter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(44px, 1fr));
  gap: 5px;
}

.spp-counter-field {
  display: grid;
  gap: 3px;
}

.spp-counter-field span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.spp-counter-field input {
  width: 100%;
  min-height: 28px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-weight: 800;
}

.spp-total {
  display: block;
  margin-top: 6px;
  color: var(--focus);
  font-size: 12px;
}

.player-level-stack,
.advancement-control {
  display: grid;
  gap: 5px;
}

.player-level-stack strong {
  color: var(--focus);
  font-size: 18px;
  line-height: 1;
}

.player-level-stack span,
.player-level-stack small,
.advancement-next {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.advancement-add-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.table-select {
  width: 100%;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-weight: 800;
}

.advancement-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.advancement-pill {
  cursor: pointer;
}

.my-teams-table {
  min-width: 720px;
}

.stat-table-cell {
  width: 44px;
  min-width: 44px;
  text-align: center;
  font-weight: 800;
}

.table-input {
  width: 100%;
  min-width: 130px;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
}

.table-actions,
.table-skill-editor {
  display: flex;
  align-items: center;
  gap: 7px;
}

.table-skill-editor {
  min-width: 210px;
}

.table-skill-editor .table-input {
  min-width: 125px;
}

.compact-action {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.table-plus-button {
  width: 34px;
  min-width: 34px;
  min-height: 30px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.disabled-row {
  opacity: 0.55;
}

.table-stat-control {
  display: grid;
  grid-template-columns: 26px minmax(34px, auto) 26px;
  align-items: center;
  overflow: hidden;
  min-width: 86px;
  border: 1px solid rgba(85, 69, 51, 0.7);
  border-radius: 6px;
  background: var(--surface-soft);
}

.table-stat-control button {
  min-height: 28px;
  border: 0;
  border-right: 1px solid rgba(85, 69, 51, 0.7);
  background: var(--button-bg);
  color: var(--button-muted-text);
  cursor: pointer;
}

.table-stat-control button:hover {
  background: var(--button-bg-hover);
  color: var(--button-text);
}

.table-stat-control button:last-child {
  border-right: 0;
  border-left: 1px solid rgba(85, 69, 51, 0.7);
}

.table-stat-control strong {
  color: var(--text);
}

.stat-table-cell.stat-up {
  background: rgba(63, 167, 92, 0.16);
}

.stat-table-cell.stat-up strong {
  color: #9df0a9;
}

.stat-table-cell.stat-down {
  background: rgba(190, 55, 45, 0.16);
}

.stat-table-cell.stat-down strong {
  color: #ff9a8f;
}

.table-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.table-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--focus);
}

.table-extra-skills {
  margin-top: 6px;
}

.inline-cost-note {
  display: block;
  margin-top: 4px;
}

.saved-team-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.saved-team-name-cell img {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(239, 224, 183, 0.08);
  object-fit: contain;
}

.builder-player-list,
.saved-roster-player-list {
  display: grid;
  gap: 10px;
}

.builder-player-card,
.saved-roster-player-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 215, 120, 0.045), transparent),
    var(--panel-glass);
}

.builder-player-card header,
.saved-roster-player-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.builder-player-card header span,
.saved-roster-player-card header span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.saved-player-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.cost-note {
  margin: 0;
  color: var(--focus);
  font-size: 13px;
  font-weight: 800;
}

.skill-search-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.inline-stepper-control {
  display: grid;
  grid-template-columns: 38px minmax(42px, auto) 38px;
  align-items: center;
  overflow: hidden;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg-soft);
}

.inline-stepper-control strong {
  color: var(--text);
  text-align: center;
}

.inline-stepper-control .filter-button {
  min-height: 38px;
  border: 0;
  border-radius: 0;
}

.editable-stat-line .player-stat-editor.stat-up {
  background: rgba(63, 167, 92, 0.18);
}

.editable-stat-line .player-stat-editor.stat-up strong {
  color: #9df0a9;
}

.editable-stat-line .player-stat-editor.stat-down {
  background: rgba(190, 55, 45, 0.18);
}

.editable-stat-line .player-stat-editor.stat-down strong {
  color: #ff9a8f;
}

.roster-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.roster-slot {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 215, 120, 0.045), transparent),
    var(--panel-glass);
  backdrop-filter: blur(2px);
}

.roster-slot.empty {
  border-style: dashed;
  background: var(--surface-soft);
}

.roster-slot header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.roster-slot header strong,
.roster-slot header span {
  display: block;
}

.roster-slot header span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.roster-slot-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.roster-slot-add select {
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
}

.slot-player-editor {
  padding: 0;
}

.slot-player-topline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.slot-stat-editors .player-stat-editor.stat-up {
  background: rgba(63, 167, 92, 0.18);
}

.slot-stat-editors .player-stat-editor.stat-up strong {
  color: #9df0a9;
}

.slot-stat-editors .player-stat-editor.stat-down {
  background: rgba(190, 55, 45, 0.18);
}

.slot-stat-editors .player-stat-editor.stat-down strong {
  color: #ff9a8f;
}

.slot-skill-list {
  padding: 0;
  border-top: 0;
}

.builder-team-link {
  display: block;
  margin-top: -8px;
  color: var(--focus);
  font-weight: 800;
  text-decoration: none;
}

.builder-team-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.builder-summary-roster {
  display: grid;
  gap: 10px;
}

.builder-summary-player {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-glass);
}

.builder-summary-player header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--table-head);
}

.builder-summary-player header strong {
  min-width: 0;
  color: var(--text);
  line-height: 1.25;
}

.builder-summary-player header span {
  flex: 0 0 auto;
  color: var(--soft);
  font-weight: 800;
}

.builder-summary-player .team-stat-grid {
  grid-template-columns: repeat(5, minmax(34px, 1fr));
}

.builder-logo-preview {
  display: block;
  max-width: 120px;
  max-height: 120px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-glass);
  object-fit: contain;
}

.builder-logo-inline {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.builder-logo-inline .builder-logo-preview {
  margin: 0;
}

.summary-logo-block {
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 10px;
  border: 1px solid rgba(255, 215, 120, 0.3);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.summary-logo-block img {
  width: min(100%, 190px);
  max-height: 190px;
  object-fit: contain;
}

.autosave-status {
  margin: -7px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.autosave-status[data-status="saving"] {
  color: var(--soft);
}

.autosave-status[data-status="saved"] {
  color: #cfe5a4;
}

.autosave-status[data-status="error"] {
  color: #ffb199;
}

.saved-team-card img {
  width: 64px;
  height: 64px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(239, 224, 183, 0.08);
  object-fit: contain;
}

.saved-team-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.player-editor {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.compact-field input {
  min-height: 34px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.checkbox-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--focus);
}

.skip-next-field {
  justify-self: start;
  padding: 7px 9px;
  border: 1px solid rgba(85, 69, 51, 0.62);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.player-stat-editors {
  display: grid;
  grid-template-columns: repeat(5, minmax(48px, 1fr));
  overflow: hidden;
  border: 1px solid rgba(85, 69, 51, 0.62);
  border-radius: var(--radius);
}

.player-stat-editor {
  display: grid;
  gap: 5px;
  padding: 8px 6px;
  border-left: 1px solid rgba(85, 69, 51, 0.62);
  text-align: center;
}

.player-stat-editor:first-child {
  border-left: 0;
}

.player-stat-editor > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.player-stat-editor strong {
  color: var(--text);
}

.mini-stepper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.mini-stepper button {
  min-height: 26px;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--button-bg);
  color: var(--button-muted-text);
  cursor: pointer;
}

.mini-stepper button:hover {
  background: var(--button-bg-hover);
  color: var(--button-text);
}

.mini-stepper button:first-child {
  border-left: 0;
}

.player-skill-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.player-skill-editor select,
.player-skill-editor input {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
}

.player-extra-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.builder-summary-skills {
  padding: 10px;
  border-top: 1px solid rgba(85, 69, 51, 0.45);
}

.builder-empty-roster {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-glass);
  color: var(--muted);
}

.inline-rule-link {
  color: var(--soft);
  text-decoration-color: rgba(240, 200, 74, 0.38);
  text-underline-offset: 3px;
}

.inline-rule-link:hover {
  color: var(--focus);
  text-decoration-color: var(--focus);
}

.stepper {
  display: inline-grid;
  grid-template-columns: 38px 44px 38px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg-soft);
}

.stepper button {
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--button-muted-text);
  font-size: 20px;
  cursor: pointer;
}

.stepper button:hover:not(:disabled) {
  background: var(--button-bg-hover);
  color: var(--button-text);
}

.stepper button:disabled {
  cursor: default;
  color: rgba(215, 197, 155, 0.36);
}

.stepper output {
  display: grid;
  min-height: 38px;
  place-items: center;
  border-inline: 1px solid var(--line);
  color: var(--text);
  font-weight: 700;
}

.builder-summary {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 96px;
}

.builder-summary-horizontal {
  position: static;
  grid-template-columns: auto minmax(150px, 0.7fr) minmax(360px, 1.8fr) minmax(260px, 1fr);
  align-items: center;
  margin-bottom: 18px;
  padding: 16px;
}

.builder-summary-horizontal:not(:has(.summary-logo-block)) {
  grid-template-columns: minmax(150px, 0.7fr) minmax(360px, 1.8fr) minmax(260px, 1fr);
}

.saved-roster-summary-panel {
  position: static;
  align-content: start;
  gap: 14px;
  padding: 16px;
}

.saved-roster-summary-panel .summary-stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.saved-roster-summary-panel .summary-actions {
  grid-template-columns: 1fr;
}

.summary-title-block {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.summary-title-block h3 {
  margin: 0;
}

.summary-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
  margin: 0;
}

.summary-stat-grid dt,
.summary-stat-grid dd {
  margin: 0;
}

.summary-stat-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-stat-grid dd {
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
}

.summary-state-block {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.summary-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.builder-warnings,
.builder-ok {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--panel-glass);
}

.builder-warnings {
  border: 1px solid rgba(232, 92, 63, 0.54);
}

.builder-warnings p {
  margin: 0;
  color: #ffb199;
  line-height: 1.45;
}

.builder-warnings p + p {
  margin-top: 8px;
}

.builder-ok {
  border: 1px solid rgba(138, 160, 75, 0.6);
  color: #cfe5a4;
}

.danger-text {
  color: #ffb199;
}

.content-panel,
.side-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  backdrop-filter: blur(6px);
}

.content-panel {
  padding: 22px;
}

.content-panel h2,
.content-panel h3 {
  margin: 24px 0 10px;
}

.content-panel h2:first-child,
.content-panel h3:first-child {
  margin-top: 0;
}

.content-panel p,
.content-panel li {
  color: var(--text);
  line-height: 1.65;
}

.content-panel ul,
.content-panel ol {
  margin: 10px 0 20px;
  padding-left: 28px;
}

.content-panel .numbered-list {
  display: grid;
  gap: 8px;
}

.content-panel .numbered-list li {
  padding-left: 4px;
}

.content-panel a {
  color: var(--focus);
  text-decoration: none;
}

.content-panel a:hover {
  text-decoration: underline;
}

.content-panel img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(239, 224, 183, 0.08);
}

.legal-panel {
  max-width: 900px;
}

.notice-box {
  margin-bottom: 22px;
  padding: 16px;
  border: 1px solid rgba(240, 200, 74, 0.38);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(199, 46, 34, 0.14), transparent),
    var(--surface-strong);
}

.notice-box strong {
  display: block;
  margin-bottom: 8px;
  color: var(--soft);
}

.notice-box p {
  margin: 0;
}

.side-panel {
  align-self: start;
  padding: 16px;
}

.side-panel h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.kv {
  display: grid;
  gap: 10px;
}

.kv div {
  display: grid;
  gap: 3px;
}

.kv span {
  color: var(--muted);
  font-size: 12px;
}

.kv strong {
  font-size: 14px;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 18px -4px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
  scrollbar-color: rgba(240, 200, 74, 0.72) var(--surface-soft);
  scrollbar-width: thin;
}

.table-scroll::-webkit-scrollbar {
  height: 8px;
}

.table-scroll::-webkit-scrollbar-track {
  background: var(--surface-soft);
}

.table-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(240, 200, 74, 0.72);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px;
  border: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: var(--table-head);
  color: var(--soft);
  text-align: left;
}

td {
  background: var(--surface-soft);
}

.numbered-table th:first-child,
.numbered-table td:first-child {
  width: 48px;
  min-width: 48px;
  color: var(--muted);
  text-align: center;
}

.missing-link {
  color: var(--danger);
}

.empty-state,
.loading {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(84vw, 320px);
    height: 100dvh;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 18px 0 36px rgba(0, 0, 0, 0.44);
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

  .sidebar::after {
    display: block;
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .nav-toggle {
    display: grid;
  }

  .nav-overlay {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: block;
    border: 0;
    background: rgba(0, 0, 0, 0.58);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.nav-open {
    overflow: hidden;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  body.nav-open .nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .builder-layout,
  .saved-roster-top-grid,
  .builder-form,
  .builder-addons,
  .team-rules-panel,
  .builder-player-pool,
  .roster-slots,
  .skill-roll-panel {
    grid-template-columns: 1fr;
  }

  .builder-summary {
    position: static;
  }

  .builder-summary-horizontal,
  .builder-summary-horizontal:not(:has(.summary-logo-block)) {
    grid-template-columns: 1fr;
  }

  .summary-actions {
    grid-template-columns: 1fr 1fr;
  }

  .builder-row-main {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .league-hero {
    grid-template-columns: 1fr;
  }

  .league-hero-media {
    min-height: 220px;
  }

  .saved-roster-table-wrap {
    display: none;
  }

  .saved-roster-mobile-list {
    display: grid;
  }
}

@media (max-width: 760px) {
  .theme-picker {
    padding: 0 8px;
  }

  .theme-picker span {
    display: none;
  }

  .theme-picker select {
    width: 108px;
  }

  .auth-button {
    max-width: 104px;
  }
}

@media (max-width: 600px) {
  .topbar {
    align-items: center;
    flex-direction: row;
    padding: 14px;
  }

  .search-wrap {
    min-width: 0;
  }

  .top-actions {
    gap: 6px;
  }

  .theme-picker {
    min-height: 40px;
    padding: 0 6px;
  }

  .theme-picker select {
    width: 88px;
    min-height: 28px;
    font-size: 11px;
  }

  .icon-text-button {
    min-width: 42px;
    min-height: 40px;
  }

  .view {
    padding: 18px 14px;
  }

  .page-head {
    display: block;
  }

  .page-head .primary-button {
    width: 100%;
    margin-top: 14px;
  }

  .league-reference-card header {
    display: grid;
    gap: 4px;
  }

  .builder-row,
  .builder-addon,
  .roster-slot-add,
  .slot-player-topline,
  .saved-player-grid,
  .skill-roll-controls,
  .mobile-roster-player-card header,
  .mobile-player-checks,
  .mobile-advancement-section,
  .mobile-skill-editor,
  .advancement-add-row {
    grid-template-columns: 1fr;
  }

  .mobile-roster-player-card header {
    display: grid;
  }

  .builder-row .team-stat-grid {
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .stepper {
    width: 100%;
    grid-template-columns: 1fr 1fr 1fr;
  }

  .stepper button {
    width: 100%;
  }

  .summary-actions {
    grid-template-columns: 1fr;
  }

  .grid,
  .filter-panel {
    grid-template-columns: 1fr;
  }

  .league-hero {
    min-height: 0;
    padding: 20px;
  }

  .league-hero-media {
    min-height: 180px;
  }

  .league-hero-media img {
    max-height: 190px;
  }

  .content-panel {
    padding: 14px;
  }

  .team-roster-desktop {
    display: none;
  }

  .team-roster-mobile {
    display: grid;
    gap: 12px;
  }

  .skill-table-desktop {
    display: none;
  }

  .skill-table-mobile {
    display: grid;
    gap: 12px;
  }

  .reference-table-desktop {
    display: none;
  }

  .reference-table-mobile {
    display: grid;
    gap: 12px;
  }

  .table-scroll {
    position: relative;
    width: auto;
    max-width: none;
    margin: 16px -14px;
    padding: 0 0 10px 0;
  }

  .table-scroll::after {
    position: sticky;
    right: 0;
    display: block;
    float: right;
    width: 34px;
    height: 1px;
    margin-top: -1px;
    background: linear-gradient(90deg, transparent, var(--scroll-fade));
    content: "";
    pointer-events: none;
  }

  .table-scroll table {
    width: max-content;
    min-width: 720px;
  }

  .table-scroll .builder-table {
    min-width: 980px;
  }

  .table-scroll .builder-selected-table {
    min-width: 940px;
  }

  .table-scroll .saved-roster-table {
    min-width: 1780px;
  }

  .table-scroll .my-teams-table {
    min-width: 720px;
  }
}
