@import url('https://fonts.googleapis.com/css?family=Itim:700|Itim:400');

@font-face {
  font-family: "Gen Jyuu Gothic Web";
  src: url("../fonts/GenJyuuGothic-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #070a0b;
  --bg-soft: #0f1517;
  --panel: #0b1114;
  --panel-strong: #11181a;
  --panel-soft: #182124;
  --line: #3f4766;
  --line-soft: #252b3d;
  --line-strong: #7676aa;
  --text: #ebf1f2;
  --muted: #a6c4c8;
  --muted-strong: #d6e3e4;
  --blue: #a6c4c8;
  --blue-soft: rgba(166, 196, 200, .16);
  --gold: #e6b557;
  --gold-soft: #3a3020;
  --green: #55c98b;
  --green-soft: #19392c;
  --status-green: #55c98b;
  --status-green-soft: #19392c;
  --red: #ed8178;
  --red-soft: #432a2b;
  --purple: #a898ff;
  --purple-soft: #302b57;
  --class-same: #2997ff;
  --class-same-soft: rgba(41, 151, 255, .16);
  --class-fa: #ed8178;
  --class-fa-soft: #432a2b;
  --class-wildcard: #a898ff;
  --class-wildcard-soft: #302b57;
  --class-external: #e6b557;
  --class-external-soft: #3a3020;
  --shadow: 0 14px 40px rgba(0, 0, 0, .28);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #ebf1f2;
  --bg-soft: #f4f8f8;
  --panel: #ffffff;
  --panel-strong: #f4f8f8;
  --panel-soft: #dce8e9;
  --line: #a6c4c8;
  --line-soft: #cbdadd;
  --line-strong: #7676aa;
  --text: #070a0b;
  --muted: #3f4766;
  --muted-strong: #18242a;
  --blue: #3f4766;
  --blue-soft: #e6eeee;
  --gold: #9a690d;
  --gold-soft: #fff3d6;
  --green: #187a4b;
  --green-soft: #e6f6ee;
  --status-green: #187a4b;
  --status-green-soft: #e6f6ee;
  --red: #b84d47;
  --red-soft: #fff0ef;
  --purple: #6859cc;
  --purple-soft: #efedff;
  --class-same: #0071e3;
  --class-same-soft: #e8f2ff;
  --class-fa: #b84d47;
  --class-fa-soft: #fff0ef;
  --class-wildcard: #6859cc;
  --class-wildcard-soft: #efedff;
  --class-external: #9a690d;
  --class-external-soft: #fff3d6;
  --shadow: 0 12px 28px rgba(7, 10, 11, .1);
}
* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { min-width: 320px; margin: 0; background: var(--bg); color: var(--text); font-family: "Itim", "Gen Jyuu Gothic Web", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; font-size: 14px; letter-spacing: 0; }
button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button, select { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.site-shell { width: min(1440px, calc(100% - 36px)); margin: 0 auto; padding: 22px 0 46px; }
.site-header, .brand, .site-nav, .panel-heading, .hero-meta, .data-status, .filter-row, .selected-slot-note { display: flex; align-items: center; }
.site-header { justify-content: space-between; gap: 24px; margin-bottom: 38px; border-bottom: 1px solid var(--line-soft); }
.brand { gap: 11px; min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-strong); color: var(--text); font-size: 13px; font-weight: 800; letter-spacing: .1em; }
.brand-mark { overflow: hidden; }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: cover; }
.brand-copy { display: grid; gap: 3px; min-width: 0; }
.brand-copy small, .eyebrow { margin: 0; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.brand-copy strong { font-size: 17px; line-height: 1.1; }
.site-nav { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.site-nav a, .site-nav button { min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--muted-strong); font-size: 12px; }
.site-nav a:hover, .site-nav button:hover { border-color: var(--blue); color: var(--blue); }
.site-nav button { display: inline-flex; align-items: center; gap: 6px; }

.hero-band { display: flex; align-items: end; justify-content: space-between; gap: 28px; padding: 0 0 28px; border-bottom: 1px solid var(--line); }
.hero-band h1 { margin: 7px 0 8px; font-size: clamp(30px, 4vw, 48px); font-weight: 750; letter-spacing: -.02em; line-height: 1.05; }
.hero-copy { max-width: 690px; margin: 0; color: var(--muted); line-height: 1.7; }
.hero-meta { flex-wrap: wrap; justify-content: flex-end; gap: 9px 16px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.data-status { gap: 7px; color: var(--muted-strong); }
.data-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--status-green); box-shadow: 0 0 0 4px var(--status-green-soft); }

.panel { margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); box-shadow: var(--shadow); }
.panel-heading { justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 20px; font-weight: 720; line-height: 1.2; }
.quiet-button, .source-badge, .result-count { color: var(--muted); font-size: 11px; }
.quiet-button { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--muted-strong); }
.quiet-button:hover { border-color: var(--red); color: var(--red); }
.source-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-soft); white-space: nowrap; }

.setup-grid { display: grid; grid-template-columns: minmax(260px, .9fr) minmax(0, 1.6fr); gap: 12px; }
.select-field, .search-field { display: grid; gap: 6px; min-width: 0; }
.select-field > span { color: var(--muted); font-size: 11px; }
.select-field select, .search-field input { width: 100%; min-height: 38px; border: 1px solid var(--line); border-radius: 7px; outline: none; background: var(--panel-strong); color: var(--text); }
.select-field select { padding: 0 10px; }
.select-field select:focus, .search-field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.deck-summary { align-self: end; display: flex; align-items: center; gap: 10px; min-width: 0; height: 38px; min-height: 38px; padding: 0 13px; border-left: 3px solid var(--blue); background: var(--panel-soft); }
.deck-summary strong { flex: 0 0 auto; overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.deck-summary span { min-width: 0; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }

.dashboard { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.metric-card { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.metric-card > span { display: block; color: var(--muted); font-size: 11px; }
.metric-card > strong { display: block; margin-top: 6px; color: var(--text); font-size: 23px; line-height: 1; }
.metric-card > small { display: block; min-height: 15px; margin-top: 8px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.metric-progress > strong { margin-bottom: 11px; }
.progress-track { height: 5px; overflow: hidden; border-radius: 999px; background: var(--panel-soft); }
.progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--blue); transition: width 180ms ease; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 18px; }
.workspace > .panel { min-width: 0; }
.picker-panel { display: none; }
.picker-empty-state { display: grid; align-content: center; min-height: 210px; gap: 8px; padding: 24px 18px; border: 1px dashed var(--line-strong); border-radius: 8px; background: var(--panel-soft); text-align: center; }
.picker-empty-state strong { font-size: 15px; }
.picker-empty-state span { color: var(--muted); font-size: 11px; line-height: 1.6; }
.open-picker-button { width: 100%; min-height: 40px; margin-top: 12px; border: 1px solid var(--blue); border-radius: 7px; background: var(--blue-soft); color: var(--blue); font-size: 12px; }
.open-picker-button:hover { background: var(--blue); color: var(--bg); }
.roster-heading { align-items: flex-end; }
.roster-heading-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; min-width: 0; }
.saved-roster-list { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.saved-roster-item { display: inline-flex; align-items: center; }
.saved-roster-load, .saved-roster-empty, .saved-roster-delete { min-height: 28px; border: 1px solid var(--line); background: var(--panel-soft); color: var(--muted-strong); font-size: 10px; }
.saved-roster-load { padding: 0 8px; border-radius: 6px 0 0 6px; }
.saved-roster-delete { width: 24px; padding: 0; border-left: 0; border-radius: 0 6px 6px 0; color: var(--muted); }
.saved-roster-empty { display: inline-flex; align-items: center; padding: 0 8px; border-style: dashed; border-radius: 6px; color: var(--muted); }
.saved-roster-load:hover, .saved-roster-delete:hover { border-color: var(--blue); color: var(--blue); }
.saved-roster-delete:hover { border-left: 0; }
.quiet-button:disabled { cursor: not-allowed; opacity: .45; }
.roster-heading-actions .selected-slot-note { max-width: 220px; }
.selected-slot-note { justify-content: center; min-height: 28px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 10px; text-align: center; }
.selected-slot-note.is-selected { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.roster-content { display: grid; gap: 16px; }
.roster-group { min-width: 0; }
.roster-group-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 0 7px; border-bottom: 1px solid var(--line); }
.roster-group-heading strong { font-size: 12px; }
.roster-group-heading span { color: var(--muted); font-size: 10px; }
.slot-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; padding-top: 8px; }
.slot-grid.bench-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.slot-grid.pitcher-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.slot-grid.reliever-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.slot-card { position: relative; display: grid; min-width: 0; min-height: 86px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-strong); color: var(--text); text-align: left; transition: border-color 150ms ease, background 150ms ease; }
.slot-card:hover, .slot-card.is-selected { border-color: var(--blue); background: var(--blue-soft); }
.slot-card.is-filled { border-color: var(--line-strong); }
.slot-card.is-fa { border-color: var(--class-fa); background: var(--class-fa-soft); }
.slot-card button { position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; }
.slot-card button:hover { color: var(--red); }
.slot-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.slot-code { color: var(--muted); font-size: 11px; font-weight: 800; }
.slot-name { overflow: hidden; color: var(--blue); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.slot-grid.bench-grid .slot-code, .slot-grid.pitcher-grid .slot-code, .slot-grid.reliever-grid .slot-code { order: 2; }
.slot-grid.bench-grid .slot-name, .slot-grid.pitcher-grid .slot-name, .slot-grid.reliever-grid .slot-name { order: 1; }
.slot-empty { display: grid; align-content: center; min-height: 42px; color: var(--muted); font-size: 10px; }
.slot-player { display: grid; align-content: center; gap: 3px; min-width: 0; padding-top: 8px; }
.slot-player strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.slot-player span { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.slot-status { margin-top: 5px; color: var(--green); font-size: 9px; }

.picker-heading { align-items: end; }
.picker-heading .result-count { white-space: nowrap; }
.picker-filters { display: grid; gap: 9px; }
.search-field { position: relative; }
.search-field > span { position: absolute; top: 8px; left: 10px; color: var(--blue); font-size: 20px; line-height: 1; }
.search-field input { padding: 0 10px 0 32px; }
.filter-row { align-items: end; gap: 8px; }
.filter-row .select-field { flex: 1; }
.picker-hint { margin: 12px 0 8px; padding: 8px 9px; border-left: 2px solid var(--line-strong); color: var(--muted); font-size: 10px; line-height: 1.5; }
.card-list { display: grid; gap: 7px; max-height: min(660px, 65vh); overflow: auto; padding-right: 2px; scrollbar-width: thin; }
.picker-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-strong); color: var(--text); text-align: left; }
.picker-card:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-soft); }
.picker-card:disabled { cursor: default; opacity: .48; }
.picker-card.is-selected { border-color: var(--green); background: var(--green-soft); }
.picker-card-main { display: grid; gap: 4px; min-width: 0; }
.picker-card-top, .picker-card-meta, .picker-card-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 8px; min-width: 0; }
.picker-card-top strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.mini-badge { display: inline-flex; align-items: center; min-height: 18px; padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.mini-badge.grade-4 { border-color: var(--purple); color: var(--purple); background: var(--purple-soft); }
.mini-badge.grade-3 { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.picker-card-meta, .picker-card-foot { color: var(--muted); font-size: 10px; }
.picker-card-meta span + span::before, .picker-card-foot span + span::before { content: "/"; margin-right: 8px; color: var(--line-strong); }
.picker-card-action { display: grid; place-items: center; align-self: center; min-width: 42px; min-height: 30px; border: 1px solid var(--blue); border-radius: 6px; color: var(--blue); font-size: 11px; }
.picker-card:disabled .picker-card-action { border-color: var(--line); color: var(--muted); }
.load-more-button { width: 100%; min-height: 34px; margin-top: 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-strong); color: var(--muted-strong); font-size: 11px; }
.load-more-button:hover { border-color: var(--blue); color: var(--blue); }
.empty-state { padding: 30px 14px; border: 1px dashed var(--line); color: var(--muted); font-size: 12px; text-align: center; }

body.picker-is-open { overflow: hidden; }
.picker-modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 18px; }
.picker-modal[hidden] { display: none !important; }
.picker-modal-backdrop { position: absolute; inset: 0; background: rgba(4, 7, 10, .72); backdrop-filter: blur(4px); }
.picker-dialog { position: relative; display: flex; flex-direction: column; width: min(780px, 100%); max-height: min(840px, calc(100dvh - 36px)); padding: 18px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--panel); box-shadow: 0 24px 80px rgba(0, 0, 0, .42); }
.picker-dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.picker-dialog-heading h2 { margin: 4px 0 3px; font-size: 22px; }
.picker-modal-context { margin: 0; color: var(--muted); font-size: 11px; }
.picker-close-button { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted-strong); font-size: 22px; line-height: 1; }
.picker-close-button:hover { border-color: var(--blue); color: var(--blue); }
.picker-modal-filters { flex: 0 0 auto; }
.picker-primary-filters { align-items: end; }
.picker-position-field[hidden] { display: none; }
.advanced-filters { margin-top: 2px; border-top: 1px solid var(--line); }
.advanced-filters summary { padding: 10px 0 4px; color: var(--muted-strong); cursor: pointer; font-size: 11px; }
$1repeat(2, minmax(0, 1fr)); gap: 8px; padding-top: 8px; }
.picker-dialog .picker-hint { flex: 0 0 auto; margin-bottom: 8px; }
.picker-dialog .card-list { min-height: 180px; max-height: none; flex: 1 1 auto; overflow: auto; }
.picker-dialog .load-more-button { flex: 0 0 auto; }

.rule-list { display: grid; gap: 8px; }
.rule-row { display: grid; grid-template-columns: 48px minmax(0, 1.15fr) minmax(0, 1fr) minmax(150px, .8fr); align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-strong); }
.rule-row.is-met { border-color: var(--green); background: var(--green-soft); }
.rule-row.is-next { border-color: var(--blue); }
.rule-level { color: var(--gold); font-size: 13px; font-weight: 800; }
.rule-condition, .rule-normalized, .rule-effects { min-width: 0; }
.rule-condition strong, .rule-normalized strong { display: block; margin-bottom: 3px; font-size: 11px; line-height: 1.45; }
.rule-condition small, .rule-normalized small { display: block; color: var(--muted); font-size: 10px; line-height: 1.45; }
.rule-effects { display: flex; flex-wrap: wrap; gap: 4px; }
.effect-chip { display: inline-flex; align-items: center; min-height: 22px; padding: 0 6px; border: 1px solid var(--gold); border-radius: 5px; color: var(--gold); font-size: 10px; white-space: nowrap; }
.rule-state { justify-self: end; color: var(--muted); font-size: 10px; white-space: nowrap; }
.rule-row.is-met .rule-state { color: var(--green); }
.rule-notes { margin-top: 12px; border-top: 1px solid var(--line); }
.rule-notes summary { padding-top: 12px; color: var(--muted-strong); cursor: pointer; font-size: 12px; }
.rule-notes-body { display: grid; gap: 6px; padding: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.rule-notes-body p { margin: 0; }

.selected-list { overflow-x: auto; }
.audit-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.audit-table th, .audit-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
.audit-table th { color: var(--muted); font-size: 10px; font-weight: 600; }
.audit-table td:last-child { white-space: normal; }
.audit-table tr:last-child td { border-bottom: 0; }
.classification { display: inline-flex; align-items: center; min-height: 22px; padding: 0 6px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted-strong); font-size: 10px; }
.classification.fa { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.audit-empty { padding: 24px 0; color: var(--muted); font-size: 12px; text-align: center; }

.site-footer { display: flex; justify-content: space-between; gap: 14px; margin-top: 24px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.back-to-top { position: fixed; right: 22px; bottom: 22px; display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line-strong); border-radius: 50%; background: color-mix(in srgb, var(--panel) 82%, transparent); color: var(--muted-strong); font-size: 21px; opacity: .86; }
.back-to-top:hover { border-color: var(--blue); color: var(--blue); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 5; max-width: min(90vw, 460px); padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--panel-strong); color: var(--text); font-size: 11px; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: opacity 160ms ease, transform 160ms ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .picker-panel { position: static; }
  .card-list { max-height: 530px; }
}

@media (max-width: 760px) {
  .site-shell { width: min(100% - 24px, 640px); padding-top: 14px; }
  .site-header { align-items: flex-start; margin-bottom: 28px; }
  .site-nav { gap: 5px; }
  .site-nav a { display: none; }
  .hero-band { display: grid; gap: 18px; }
  .hero-meta { justify-content: flex-start; }
  .setup-grid, .dashboard { grid-template-columns: 1fr; }
  .dashboard { gap: 7px; }
  .metric-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 5px 12px; padding: 11px 12px; }
  .metric-card > span, .metric-card > strong, .metric-card > small { margin: 0; }
  .metric-card > strong { grid-column: 2; grid-row: 1 / span 2; }
  .metric-card > small { grid-column: 1; }
  .metric-progress { display: block; }
  .metric-progress > strong { margin: 7px 0 9px; }
  .metric-progress > small { margin-top: 7px; }
  .rule-row { grid-template-columns: 38px minmax(0, 1fr) auto; gap: 7px; }
  .rule-normalized { grid-column: 2 / -1; }
  .rule-effects { grid-column: 2 / -1; }
  .rule-state { grid-column: 3; grid-row: 1; }
}

@media (max-width: 500px) {
  .panel { padding: 13px; border-radius: 9px; }
  .panel-heading h2 { font-size: 18px; }
  .brand-mark { width: 42px; height: 42px; }
  .brand-copy strong { font-size: 15px; }
  .hero-band h1 { font-size: 32px; }
  .hero-copy { font-size: 12px; }
  .filter-row { display: grid; grid-template-columns: 1fr 1fr; }
  .picker-modal { align-items: end; padding: 0; }
  .picker-dialog { width: 100%; max-height: calc(100dvh - 10px); padding: 14px; border-radius: 13px 13px 0 0; }
  .picker-dialog-heading h2 { font-size: 19px; }
  .advanced-filter-grid { grid-template-columns: 1fr 1fr; }
  .roster-heading { display: grid; align-items: start; }
  .roster-heading-actions { justify-content: flex-start; }
  .roster-heading-actions .selected-slot-note { max-width: 100%; }
  .selected-slot-note { justify-self: stretch; }
  .slot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .slot-grid.bench-grid, .slot-grid.pitcher-grid, .slot-grid.reliever-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .slot-card { min-height: 78px; padding: 8px; }
  .slot-player strong { font-size: 12px; }
  .rule-row { grid-template-columns: 34px minmax(0, 1fr); }
  .rule-state { grid-column: 2; grid-row: auto; justify-self: start; }
  .site-footer { display: grid; gap: 4px; }
  .back-to-top { right: 14px; bottom: 14px; width: 38px; height: 38px; }
}

/* Compact stage effects and audit rows keep the simulator readable on narrow screens. */
.rule-row { display: grid; grid-template-columns: 1fr; align-items: stretch; gap: 10px; padding: 12px; }
.rule-row-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.rule-row.is-met { border-color: color-mix(in srgb, var(--green) 55%, var(--line)); background: var(--green-soft); }
.rule-row.is-next { border-color: var(--blue); }
.rule-state { min-width: 0; color: var(--muted); font-size: 10px; line-height: 1.4; text-align: right; white-space: normal; }
.rule-row.is-met .rule-state { color: var(--green); }
.rule-effects { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.rule-effects-label { flex: 0 0 auto; color: var(--muted); font-size: 10px; font-weight: 700; }
.effect-chip { min-height: 23px; padding: 0 7px; border-color: color-mix(in srgb, var(--gold) 58%, var(--line)); background: color-mix(in srgb, var(--gold-soft) 58%, transparent); }
.rule-requirement { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 9px; align-items: baseline; padding: 9px 10px; border-left: 3px solid var(--red); border-radius: 5px; background: var(--red-soft); }
.rule-requirement strong { color: var(--red); font-size: 11px; }
.rule-requirement span { min-width: 0; color: var(--text); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.rule-requirement em { grid-column: 2; color: var(--muted); font-size: 10px; font-style: normal; line-height: 1.45; overflow-wrap: anywhere; }
.rule-original { border-top: 1px solid var(--line); }
.rule-original summary { padding-top: 8px; color: var(--muted); cursor: pointer; font-size: 10px; }
.rule-original p { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }

.audit-summary { display: inline-flex; align-items: center; justify-content: flex-end; max-width: min(100%, 760px); min-width: 0; flex-wrap: wrap; white-space: normal; text-align: right; line-height: 1.4; }
.audit-main, .audit-total { display: inline-block; flex: 0 0 auto; white-space: nowrap; }
.audit-total { margin-left: 0.75em; }
.selected-list { overflow: visible; }
.audit-list { display: grid; }
.audit-head, .audit-row { display: grid; grid-template-columns: 48px minmax(170px, 1.1fr) minmax(105px, .7fr) minmax(180px, 1.5fr); gap: 10px; align-items: start; }
.audit-head { padding: 0 8px 8px; color: var(--muted); font-size: 10px; font-weight: 600; }
.audit-row { padding: 10px 8px; border-top: 1px solid var(--line); font-size: 11px; }
.audit-position { color: var(--text); font-weight: 700; }
.audit-card { display: grid; gap: 3px; min-width: 0; }
.audit-card strong { overflow-wrap: anywhere; }
.audit-card span, .audit-reason { color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.audit-reason { min-width: 0; }
.classification { justify-self: start; white-space: nowrap; }
.classification.same { border-color: var(--class-same); background: var(--class-same-soft); color: var(--class-same); }
.classification.fa { border-color: var(--class-fa); background: var(--class-fa-soft); color: var(--class-fa); }
.classification.wildcard { border-color: var(--class-wildcard); background: var(--class-wildcard-soft); color: var(--class-wildcard); }
.classification.external { border-color: var(--class-external); background: var(--class-external-soft); color: var(--class-external); }
.classification.eligible { border-color: var(--green); background: var(--green-soft); color: var(--green); }

@media (max-width: 760px) {
  .audit-panel .panel-heading { align-items: flex-start; flex-wrap: wrap; }
  .audit-summary { flex: 1 1 100%; justify-content: flex-start; max-width: 100%; box-sizing: border-box; text-align: left; }
  .audit-total { margin-left: 0.75em; }
  .audit-head, .audit-row { grid-template-columns: 40px minmax(130px, 1fr) minmax(92px, auto); gap: 7px; }
  .audit-reason { grid-column: 2 / -1; }
}

@media (max-width: 500px) {
  .rule-row-heading { align-items: flex-start; }
  .rule-state { text-align: right; }
  .audit-head { display: none; }
  .audit-row { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 6px; padding: 10px 2px; }
  .audit-reason { grid-column: 2 / -1; padding-top: 2px; }
  .audit-summary { font-size: 10px; }
}

/* Reset the earlier responsive grid placement for the newer rule markup. */
.rule-row-heading, .rule-effects, .rule-requirement, .rule-original { grid-column: 1 / -1 !important; width: 100%; min-width: 0; box-sizing: border-box; }
.rule-effects { align-self: stretch; }
.rule-requirement { grid-template-columns: auto minmax(0, 1fr); }

@media (max-width: 760px) {
  .rule-row { grid-template-columns: minmax(0, 1fr) !important; }
  .rule-row-heading, .rule-effects, .rule-requirement, .rule-original { grid-column: 1 !important; }
  .rule-row-heading { display: flex; width: 100%; }
  .rule-state { flex: 0 1 auto; max-width: 72%; }
  .rule-effects { display: flex; width: 100%; }
  .rule-requirement { display: grid; width: 100%; }
}

/* Shared topbar alignment and a single compact area for all unmet conditions. */
.site-nav.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; }
.site-nav .topbar-note, .site-nav .back-link, .site-nav .theme-toggle { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; line-height: 1.2; vertical-align: middle; }
.site-nav .topbar-note { gap: 7px; color: var(--muted); white-space: nowrap; }
.site-nav .topbar-note i { flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--status-green); box-shadow: 0 0 0 4px var(--status-green-soft); }
.site-nav .back-link, .site-nav .theme-toggle { min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--blue); }
.site-nav .theme-toggle { border-radius: 999px; color: var(--muted-strong); }
.site-nav .back-link:hover, .site-nav .theme-toggle:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }

.missing-summary { margin-top: 12px; padding: 12px; border: 1px solid var(--red); border-radius: 8px; background: var(--red-soft); }
.missing-summary-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.missing-summary-heading strong { color: var(--red); font-size: 12px; }
.missing-summary-heading span { color: var(--muted); font-size: 10px; }
.missing-condition-list { display: grid; gap: 7px; margin-top: 9px; }
.missing-condition { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 8px; padding-top: 8px; border-top: 1px solid rgba(237, 129, 120, .25); }
.missing-condition:first-child { padding-top: 0; border-top: 0; }
.missing-condition > strong { color: var(--red); font-size: 11px; }
.missing-condition b { display: block; color: var(--text); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.missing-condition > div > span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.missing-condition .rule-original { margin-top: 5px; }

@media (min-width: 761px) {
  body { font-size: 15px; }
  .brand-copy strong { font-size: 19px; }
  .brand-copy small, .eyebrow { font-size: 11px; }
  .site-nav .back-link, .site-nav .theme-toggle, .site-nav .topbar-note { font-size: 13px; }
  .hero-copy { font-size: 15px; }
  .panel-heading h2 { font-size: 22px; }
  .select-field > span { font-size: 12px; }
  .deck-summary strong { font-size: 18px; }
  .deck-summary span { font-size: 13px; }
  .metric-card > span { font-size: 12px; }
  .metric-card > strong { font-size: 26px; }
  .metric-card > small { font-size: 11px; }
  .roster-group-heading strong { font-size: 13px; }
  .roster-group-heading span { font-size: 11px; }
  .slot-code { font-size: 12px; }
  .slot-name { font-size: 10px; }
  .slot-empty { font-size: 11px; }
  .slot-player strong { font-size: 14px; }
  .slot-player span, .slot-status { font-size: 10px; }
  .picker-empty-state strong { font-size: 16px; }
  .picker-empty-state span { font-size: 12px; }
  .picker-card-top strong { font-size: 14px; }
  .picker-card-meta, .picker-card-foot { font-size: 11px; }
  .picker-card-action { font-size: 12px; }
  .rule-level { font-size: 14px; }
  .rule-state, .rule-effects-label { font-size: 11px; }
  .effect-chip { font-size: 11px; }
  .missing-condition b { font-size: 13px; }
  .missing-condition > div > span { font-size: 12px; }
  .audit-row { font-size: 12px; }
}

@media (max-width: 760px) {
  .site-nav .topbar-note { display: none; }
}

@media (min-width: 1101px) and (pointer: fine) {
  .site-shell { width: min(1600px, 100%); padding: 0 28px 58px; }
  .site-header { min-height: 82px; gap: 24px; margin-bottom: 44px; }
  .brand-mark { width: 48px; height: 48px; }
  .brand-copy strong { font-size: 19px; }
  .site-nav .back-link, .site-nav .theme-toggle { min-height: 36px; }
  .hero-band { gap: 36px; padding-bottom: 34px; }
  .hero-band h1 { font-size: 54px; }
  .hero-copy { max-width: 820px; font-size: 16px; }
  .panel { padding: 22px; }
  .panel-heading h2 { font-size: 24px; }
  .select-field > span { font-size: 13px; }
  .select-field select, .search-field input { min-height: 44px; font-size: 15px; }
  .deck-summary { height: 44px; min-height: 44px; }
  .deck-summary strong { font-size: 20px; }
  .deck-summary span { font-size: 14px; }
  .metric-card { display: grid; align-content: center; padding: 17px; }
  .metric-card > span { font-size: 13px; }
  .metric-card > strong { font-size: 29px; }
  .metric-card > small { font-size: 12px; }
  .workspace { gap: 22px; }
  .roster-group-heading strong { font-size: 14px; }
  .roster-group-heading span { font-size: 12px; }
  .slot-card { min-height: 96px; padding: 11px; }
  .slot-code { font-size: 13px; }
  .slot-name { font-size: 11px; }
  .slot-player strong { font-size: 15px; }
  .slot-player span, .slot-status { font-size: 11px; }
  .picker-dialog-heading h2 { font-size: 24px; }
  .picker-modal-context, .picker-card-meta, .picker-card-foot { font-size: 12px; }
  .picker-card { padding: 12px; }
  .picker-card-top strong { font-size: 15px; }
  .picker-card-action { min-width: 48px; min-height: 34px; font-size: 13px; }
  .audit-head { font-size: 11px; }
  .audit-row { font-size: 13px; }
  .audit-summary { font-size: 13px; }
  .classification { font-size: 11px; }
}

/* Keep the mobile page headers aligned across the three tools. */
@media (max-width: 760px) {
  .site-header {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 12px 0;
  }
  .site-nav.topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    justify-content: initial;
    gap: 8px;
  }
  .site-nav .topbar-note {
    display: inline-flex;
    min-width: 0;
    overflow: hidden;
    justify-content: flex-start;
  }
  .site-nav .topbar-note > span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
.site-nav > .back-link,
.site-nav > .theme-toggle {
    display: inline-flex;
    min-width: 0;
    min-height: 34px;
    padding: 0 9px;
    font-size: 11px;
    white-space: nowrap;
  }
}

@media (max-width: 520px) {
  .site-nav.topbar-actions {
    grid-template-columns: 1fr 1fr;
  }
  .site-nav .topbar-note {
    grid-column: 1 / -1;
  }
  .site-nav > .back-link,
  .site-nav > .theme-toggle {
    width: 100%;
  }
}

/* Keep the simulator's mobile surface in the same neutral visual system as the indexes. */
@media (max-width: 760px) {
  .site-nav > .data-status {
    padding-inline-start: 8px;
  }
  .site-shell {
    width: min(1320px, calc(100% - 28px));
    padding: 0 0 46px;
  }
  .site-header {
    padding: 12px 0;
    margin-bottom: 28px;
    border-bottom-color: var(--line-soft);
  }
  .panel {
    border-color: var(--line-soft);
    box-shadow: none;
  }
  .selected-slot-note.is-selected {
    border-color: var(--line);
    background: var(--panel-soft);
    color: var(--muted-strong);
  }
  .open-picker-button {
    border-color: var(--line);
    background: var(--panel-soft);
  }
  .rule-row.is-next {
    background: var(--panel-strong);
  }
  .rule-effects {
    border-color: var(--line-soft);
    background: var(--panel-strong);
  }
}

/* Final shared brand lockup: same size and rhythm on desktop and mobile. */
.brand { gap: 13px; }
.brand-mark { width: 48px; height: 48px; border: 0; border-radius: 12px; }
.brand-copy { display: grid; gap: 2px; min-width: 0; }
.brand-copy small, .brand-copy strong { display: block; margin: 0; }
.brand-copy small { color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .14em; line-height: 1.2; }
.brand-copy strong { font-size: 19px; font-weight: 650; line-height: 1.1; }

/* Keep the whole top row aligned when moving between the three pages. */
.site-nav > .theme-toggle > span:first-child {
  display: inline-flex;
  width: 17px;
  height: 17px;
  align-items: center;
  justify-content: center;
  flex: 0 0 17px;
  font-size: 17px;
  line-height: 1;
}

@media (min-width: 761px) {
  .site-header { min-height: 82px; gap: 24px; border-bottom-color: var(--line-soft); }
  .site-nav { gap: 12px; }
  .site-nav > .topbar-note,
  .site-nav > .back-link,
  .site-nav > .theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: auto;
    height: 36px;
    min-height: 36px;
    line-height: 1.2;
    vertical-align: middle;
  }
  .site-nav > .back-link,
  .site-nav > .theme-toggle { padding: 0 13px; }
}

@media (max-width: 760px) {
  .site-nav { gap: 8px; }
  .site-nav.topbar-actions {
    gap: 6px;
    min-width: 0;
  }
  .site-nav > .back-link,
  .site-nav > .theme-toggle {
    box-sizing: border-box;
    height: 34px;
    min-height: 34px;
    padding: 0 4px;
    overflow: hidden;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Match the player and cheerleader index type scale. */
body { font-size: 16px; }

@media (min-width: 761px) and (max-width: 1100px) {
  .hero-band h1 {
    font-size: 38px;
    line-height: 1.16;
  }
}

@media (min-width: 1101px) and (pointer: fine) {
  .hero-band h1 {
    font-size: 48px;
    line-height: 1.16;
  }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .hero-band h1 {
    font-size: 28px;
    line-height: 1.16;
  }
}

/* Final shared header rhythm across all three pages. */
.site-nav > .topbar-note,
.site-nav > .back-link,
.site-nav > .theme-toggle {
  box-sizing: border-box;
  align-items: center;
  line-height: 1.2;
}
.site-nav > .theme-toggle { gap: 6px; }
.site-nav > .theme-toggle > span:first-child {
  display: inline-flex;
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
}

@media (max-width: 760px) {
  .site-nav.topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 8px;
  }
  .site-nav > .topbar-note {
    grid-column: 1 / -1;
    min-width: 0;
    overflow: hidden;
    justify-content: flex-start;
  }
  .site-nav > .topbar-note > span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .site-nav > .back-link,
  .site-nav > .theme-toggle {
    width: 100%;
    min-width: 0;
    height: 34px;
    min-height: 34px;
    padding: 0 6px;
    font-size: 11px;
    white-space: nowrap;
  }
}

/* Keep the data-status text scale identical across all three pages. */
.site-nav > .data-status {
  font-size: 13px;
  line-height: 1.25;
}

@media (max-width: 760px) {
  .site-nav > .data-status { font-size: 12px; }
}

/* Keep the mobile header inside the viewport with a small front buffer. */
@media (max-width: 760px) {
  .site-shell {
    width: 100%;
    max-width: none;
    padding-inline: 12px;
  }
  .site-header,
  .brand,
  .site-nav,
  .site-nav.topbar-actions {
    width: 100%;
    min-width: 0;
  }
  .brand-copy,
  .site-nav .topbar-note {
    min-width: 0;
    overflow: hidden;
  }
  .brand-copy small,
  .brand-copy strong,
  .site-nav .topbar-note > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Match the player index intro band on desktop and mobile. */
.site-header { margin-bottom: 0; }
.hero-band {
  display: block;
  padding: 32px 0 26px;
  border-bottom: 0;
}
.hero-band .eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  line-height: 1.2;
}
.hero-band h1 {
  margin: 0 0 8px;
  font-size: 38px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.16;
}
.hero-band .hero-copy {
  max-width: 770px;
  margin: 0;
  color: var(--muted-strong);
  font-size: inherit;
  line-height: 1.55;
}
.setup-panel { margin-top: 0; }

@media (min-width: 761px) {
  .hero-band h1 { font-size: 42px; }
  .hero-band .hero-copy { font-size: 16px; }
}

@media (min-width: 1101px) and (pointer: fine) {
  .hero-band { padding-top: 42px; padding-bottom: 34px; }
  .hero-band h1 { font-size: 48px; }
  .hero-band .hero-copy { font-size: 17px; }
}

@media (max-width: 760px) {
  .hero-band { padding: 23px 0 18px; }
  .hero-band h1 { font-size: 28px; }
  .hero-band .hero-copy { font-size: 15px; }
}

/* Realtime Colors preview layer: green-gray surfaces with Itim Latin text. */
::selection { background: var(--blue); color: var(--text); }
.site-header { border-bottom-color: var(--line); }
.brand-mark { border-color: var(--line); background: var(--panel-soft); color: var(--text); }
.panel, .metric-card, .slot-card, .picker-card, .rule-row, .audit-panel,
.saved-roster-empty, .picker-empty-state { border-color: var(--line-soft); box-shadow: 0 14px 34px rgba(3, 10, 14, .22); }
.panel, .metric-card { background: var(--panel); }
.metric-card, .slot-card, .picker-card, .rule-row { background: var(--panel-soft); }
.search-field input, .select-field select, .quiet-button, .source-badge,
.saved-roster-load, .saved-roster-empty, .saved-roster-delete, .load-more-button {
  border-color: var(--line);
  background: var(--panel-muted);
}
.search-field:focus-within, .select-field select:focus,
.quiet-button:focus-visible, .load-more-button:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
.site-nav .back-link, .site-nav .theme-toggle { background: var(--panel); border-color: var(--line); }
.site-nav .back-link:hover, .site-nav .theme-toggle:hover { background: var(--blue-soft); border-color: var(--blue); }
.deck-summary, .selected-slot-note.is-selected { background: var(--blue-soft); }
.rule-effects { background: var(--panel-muted); border-color: var(--line); }
.slot-card:hover, .slot-card.is-selected, .picker-card:hover:not(:disabled) { background: var(--blue-soft); border-color: var(--blue); }
.picker-dialog { border-color: var(--line-strong); background: var(--panel); box-shadow: 0 24px 80px rgba(0, 0, 0, .52); }
.picker-modal-backdrop { background: rgba(4, 10, 14, .76); }
