:root {
  --bg: #06130f;
  --panel: #0c211a;
  --panel-2: #102a21;
  --panel-3: #163629;
  --line: rgba(255,255,255,.09);
  --text: #f3f7f5;
  --muted: #97aaa2;
  --green: #4fd18b;
  --green-2: #2aa66a;
  --gold: #f4c95d;
  --red: #ff7373;
  --shadow: 0 20px 55px rgba(0,0,0,.22);
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  background:
    linear-gradient(rgba(4, 12, 10, 0.72), rgba(4, 12, 10, 0.84)),
    url('zoo-background.png') center center / cover fixed no-repeat,
    var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(1500px, calc(100% - 32px)); margin: 0 auto; padding: 38px 0 70px; }
.hero { display:flex; gap:24px; justify-content:space-between; align-items:flex-end; margin-bottom:28px; }
.eyebrow, .section-kicker { color: var(--green); font-size: .73rem; font-weight: 800; letter-spacing: .16em; }
h1 { font-size: clamp(2.2rem, 5vw, 4.6rem); line-height:.96; margin:9px 0 12px; letter-spacing:-.055em; }
.hero p { margin:0; color:var(--muted); font-size:1.03rem; }
.creator-credit { margin-top:8px; color:#c3d0ca; font-size:.78rem; font-weight:650; letter-spacing:.01em; }
.hero-actions { display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.card { background: linear-gradient(180deg, rgba(17,44,34,.96), rgba(10,31,24,.96)); border:1px solid var(--line); border-radius:20px; box-shadow:var(--shadow); }
.toolbar { padding:16px; display:grid; grid-template-columns: 1.15fr 1.8fr .8fr 1fr auto; gap:12px; align-items:end; margin-bottom:16px; }
.field { display:flex; flex-direction:column; gap:7px; }
.field label { font-size:.76rem; color:var(--muted); font-weight:700; }
.field input, .field select { width:100%; color:var(--text); background:#081a14; border:1px solid var(--line); border-radius:11px; padding:11px 12px; outline:none; transition:.16s ease; }
.field input:focus, .field select:focus { border-color:rgba(79,209,139,.62); box-shadow:0 0 0 3px rgba(79,209,139,.09); }
.help { color:var(--muted); line-height:1.45; }
.btn { border:0; border-radius:11px; padding:11px 15px; font-weight:750; color:var(--text); white-space:nowrap; }
.btn-primary { background:var(--green); color:#042116; }
.btn-primary:hover { background:#64dfa0; }
.btn-secondary { background:rgba(255,255,255,.075); border:1px solid var(--line); }
.btn-ghost { background:transparent; border:1px solid var(--line); color:var(--muted); }
.btn-danger { background:rgba(255,115,115,.11); border:1px solid rgba(255,115,115,.24); color:#ff9c9c; }
.toolbar-actions { display:flex; justify-content:flex-end; }
.stats-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:16px; }
.stat-card { padding:18px 19px; min-height:112px; }
.stat-label { color:var(--muted); font-size:.76rem; font-weight:700; }
.stat-value { font-size:1.8rem; font-weight:850; letter-spacing:-.045em; margin-top:9px; }
.stat-sub { color:var(--muted); margin-top:5px; font-size:.78rem; }
.stat-grade-value { display:flex; align-items:baseline; gap:10px; min-height:38px; }
.stat-grade-letter { font-size:2.15rem; line-height:1; font-weight:950; letter-spacing:-.04em; background:transparent; }
.stat-grade-score { color:var(--muted); font-size:1rem; font-weight:800; letter-spacing:-.02em; }
.content-grid { display:grid; grid-template-columns:minmax(0,1fr) 320px; gap:16px; align-items:start; }
.leaderboard-card { min-width:0; overflow:hidden; }
.section-heading { padding:20px 21px 15px; display:flex; align-items:flex-end; justify-content:space-between; gap:16px; }
.section-heading.compact { padding-bottom:7px; }
.section-heading h2 { font-size:1.13rem; margin:5px 0 0; letter-spacing:-.025em; }
.results-count { color:var(--muted); font-size:.78rem; }
.table-wrap { overflow:auto; }
table { width:100%; border-collapse:collapse; min-width:990px; }
th { text-align:left; color:#80958b; font-size:.69rem; text-transform:uppercase; letter-spacing:.08em; padding:11px 14px; border-top:1px solid var(--line); border-bottom:1px solid var(--line); background:rgba(0,0,0,.08); }
td { padding:13px 14px; border-bottom:1px solid rgba(255,255,255,.055); font-size:.84rem; }
tbody tr { transition:.12s ease; }
tbody tr:hover { background:rgba(79,209,139,.035); }
.number-col, td.number { text-align:right; font-variant-numeric:tabular-nums; }
.rank-col { width:74px; }
.rank { font-weight:850; color:var(--muted); }
.rank.podium { color:var(--gold); font-size:.98rem; }
.player-name { font-weight:760; max-width:220px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.growth-positive { color:#75dfa5; font-weight:800; }
.growth-negative { color:#ff8b8b; font-weight:800; }
.pending { color:#899a92; font-style:italic; }
.grade { display:inline-flex; width:30px; height:30px; border-radius:8px; align-items:center; justify-content:center; font-weight:900; border:1px solid rgba(255,255,255,.08); }
.grade-S { background:rgba(244,201,93,.15); color:#ffd873; }
.grade-A { background:rgba(79,209,139,.14); color:#75dfa5; }
.grade-B { background:rgba(76,169,255,.13); color:#7ec4ff; }
.grade-C { background:rgba(182,127,255,.13); color:#c39cff; }
.grade-D { background:rgba(255,255,255,.07); color:#bdc8c2; }
.grade-F { background:rgba(255,115,115,.12); color:#ff9696; }
.grade-Pending { width:auto; padding:0 9px; background:rgba(255,255,255,.05); color:#8da097; font-size:.7rem; }
.stat-grade-letter.grade-S, .stat-grade-letter.grade-A, .stat-grade-letter.grade-B, .stat-grade-letter.grade-C, .stat-grade-letter.grade-D, .stat-grade-letter.grade-F { background:transparent; }
.edit-btn { background:transparent; border:1px solid var(--line); color:var(--muted); border-radius:8px; padding:6px 9px; }
.edit-btn:hover { color:var(--text); border-color:rgba(255,255,255,.2); }
.side-column { display:grid; gap:16px; }
.grade-card { padding-bottom:8px; }
.grade-list { padding:8px 17px 12px; display:grid; gap:2px; }
.grade-list > div { display:grid; grid-template-columns:38px 1fr; grid-template-rows:auto auto; column-gap:10px; align-items:center; padding:9px 0; border-bottom:1px solid rgba(255,255,255,.05); }
.grade-list .grade { grid-row:1/3; }
.grade-list b { font-size:.84rem; }
.grade-list small { color:var(--muted); margin-top:2px; }
.note-card { padding:20px; }
.note-card h3 { margin:8px 0 8px; }
.note-card p { color:var(--muted); line-height:1.6; font-size:.87rem; }
.formula { margin-top:15px; padding:12px; border-radius:10px; background:#071a13; border:1px solid var(--line); font-size:.78rem; color:#a8bbb2; }
dialog { width:min(560px, calc(100% - 28px)); padding:0; border:1px solid var(--line); border-radius:20px; color:var(--text); background:#0b2119; box-shadow:0 30px 90px rgba(0,0,0,.5); }
dialog::backdrop { background:rgba(2,8,6,.78); backdrop-filter:blur(3px); }
.modal-form { padding:22px; }
.modal-header { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; margin-bottom:19px; }
.modal-header h2 { margin:5px 0 0; }
.icon-btn { width:36px; height:36px; border-radius:9px; border:1px solid var(--line); background:rgba(255,255,255,.05); color:var(--muted); }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.form-grid .wide { grid-column:1/-1; }
.modal-actions { display:flex; align-items:center; gap:10px; margin-top:22px; }
.spacer { flex:1; }
.hidden { display:none !important; }
.empty-state { text-align:center; color:var(--muted); padding:38px !important; }
@media (max-width:1100px) {
  .toolbar { grid-template-columns:1fr 1.5fr 1fr 1fr; }
  .toolbar-actions { grid-column:1/-1; justify-content:flex-start; }
  .content-grid { grid-template-columns:1fr; }
  .side-column { grid-template-columns:1fr 1fr; }
}
@media (max-width:780px) {
  .app-shell { width:min(100% - 20px, 1500px); padding-top:22px; }
  .hero { align-items:flex-start; flex-direction:column; }
  .hero-actions { justify-content:flex-start; width:100%; }
  .hero-actions .btn { flex:1; }
  .toolbar { grid-template-columns:1fr 1fr; }
  .event-field,.search-field { grid-column:1/-1; }
  .stats-grid { grid-template-columns:1fr 1fr; }
  .side-column { grid-template-columns:1fr; }
}
@media (max-width:480px) {
  .toolbar { grid-template-columns:1fr; }
  .toolbar > * { grid-column:1 !important; }
  .stats-grid { grid-template-columns:1fr 1fr; gap:9px; }
  .stat-card { min-height:98px; padding:15px; }
  .stat-value { font-size:1.45rem; }
  .form-grid { grid-template-columns:1fr; }
  .form-grid .wide { grid-column:auto; }
}
.sync-status {
  display:inline-flex;
  align-items:center;
  align-self:center;
  min-height:38px;
  padding:8px 11px;
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(0,0,0,.28);
  color:var(--muted);
  font-size:.76rem;
  font-weight:750;
  backdrop-filter:blur(8px);
}
.sync-status.ok { color:#75dfa5; }
.sync-status.error { color:#ff9696; }
.sync-status.saving { color:#ffd873; }
button:disabled, select:disabled { opacity:.55; cursor:not-allowed; }

/* Power breakdown */
#playerDialog { width:min(820px, calc(100% - 28px)); max-height:min(900px, calc(100vh - 28px)); overflow:auto; }
.power-breakdown-form { margin-top:22px; padding-top:18px; border-top:1px solid var(--line); }
.breakdown-form-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:18px; margin-bottom:13px; }
.breakdown-form-heading h3 { margin:5px 0 0; font-size:1rem; }
.metric-input-grid { display:grid; grid-template-columns:minmax(150px, 1.15fr) repeat(2, minmax(150px, 1fr)); gap:8px 10px; align-items:center; }
.metric-input-grid label { color:#c6d1cc; font-size:.8rem; font-weight:700; padding:0 2px; }
.metric-input-grid input { width:100%; color:var(--text); background:#081a14; border:1px solid var(--line); border-radius:9px; padding:9px 10px; outline:none; font-variant-numeric:tabular-nums; }
.metric-input-grid input:focus { border-color:rgba(79,209,139,.62); box-shadow:0 0 0 3px rgba(79,209,139,.09); }
.metric-input-head { color:#80958b; font-size:.66rem; font-weight:800; text-transform:uppercase; letter-spacing:.08em; padding:0 2px 4px; }
.metric-input-head:not(:first-child) { text-align:right; }
.row-actions { display:flex; gap:6px; justify-content:flex-end; }
.breakdown-row > td { padding:0 !important; background:rgba(3,13,10,.42); border-bottom:1px solid var(--line); }
.breakdown-row:hover { background:transparent !important; }
.breakdown-title { padding:14px 18px 8px; color:var(--green); font-size:.72rem; font-weight:850; letter-spacing:.12em; text-transform:uppercase; }
.breakdown-table { display:grid; grid-template-columns:minmax(180px, 1.3fr) repeat(3, minmax(120px, 1fr)); padding:0 18px 16px; }
.breakdown-table-metrics { grid-template-columns:minmax(180px, 1.35fr) repeat(3, minmax(110px, .9fr)) minmax(78px, .55fr); }
.breakdown-grade .grade { margin-left:auto; }
.breakdown-table > div { padding:9px 10px; border-bottom:1px solid rgba(255,255,255,.055); }
.breakdown-head { color:#80958b; font-size:.66rem; font-weight:800; text-transform:uppercase; letter-spacing:.08em; }
.breakdown-head.number, .breakdown-number { text-align:right; font-variant-numeric:tabular-nums; }
.breakdown-metric { color:#dce5e0; font-size:.79rem; font-weight:700; }
.breakdown-number { color:#b7c5be; font-size:.79rem; }
.breakdown-empty { padding:18px; color:var(--muted); font-size:.82rem; }

@media (max-width:680px) {
  #playerDialog { width:min(96vw, 820px); }
  .breakdown-form-heading { align-items:flex-start; flex-direction:column; gap:5px; }
  .metric-input-grid { grid-template-columns:minmax(110px, 1.1fr) minmax(100px, 1fr) minmax(100px, 1fr); gap:7px; }
  .metric-input-grid label { font-size:.72rem; }
  .metric-input-grid input { padding:8px; min-width:0; }
  .breakdown-table { grid-template-columns:minmax(130px, 1.2fr) repeat(3, minmax(90px, 1fr)); overflow:auto; }
  .breakdown-table-metrics { grid-template-columns:minmax(145px, 1.2fr) repeat(3, minmax(88px, .85fr)) minmax(78px, .55fr); }
}

/* Alliance / kingdom expansion */
.toolbar { grid-template-columns: 1.05fr 1.55fr .8fr .75fr 1fr auto; }
.alliance-overview-card { margin-bottom:16px; overflow:hidden; }
.alliance-summary-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(230px, 1fr)); gap:12px; padding:0 16px 16px; }
.alliance-summary-card { background:rgba(4,18,13,.5); border:1px solid var(--line); border-radius:14px; padding:15px; min-width:0; }
.alliance-summary-top { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.alliance-tag { display:inline-flex; align-items:center; justify-content:center; max-width:150px; padding:5px 9px; border-radius:999px; background:rgba(79,209,139,.12); border:1px solid rgba(79,209,139,.22); color:#86e8b1; font-size:.72rem; line-height:1; font-weight:850; letter-spacing:.06em; text-transform:uppercase; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.alliance-score-display { display:flex; align-items:center; gap:14px; margin-top:15px; }
.alliance-grade-large { width:68px; height:68px; border-radius:16px; flex:0 0 68px; font-size:2.7rem; line-height:1; }
.alliance-average-score { display:flex; flex-direction:column; min-width:0; }
.alliance-average-score b { font-size:1.18rem; line-height:1.05; font-weight:900; letter-spacing:-.035em; font-variant-numeric:tabular-nums; }
.alliance-average-score small { margin-top:5px; color:var(--muted); font-size:.68rem; font-weight:750; }
.alliance-summary-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-top:14px; padding-top:12px; border-top:1px solid var(--line); }
.alliance-summary-stats span { min-width:0; }
.alliance-summary-stats small { display:block; color:var(--muted); font-size:.62rem; margin-bottom:4px; }
.alliance-summary-stats b { display:block; font-size:.73rem; font-variant-numeric:tabular-nums; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.alliance-member-count { margin-top:10px; color:var(--muted); font-size:.7rem; }
.alliance-empty { grid-column:1/-1; padding:21px; text-align:center; color:var(--muted); font-size:.82rem; }
table { min-width:1080px; }

@media (max-width:1100px) {
  .toolbar { grid-template-columns:1fr 1.3fr 1fr; }
  .toolbar-actions { grid-column:auto; }
}
@media (max-width:780px) {
  .toolbar { grid-template-columns:1fr 1fr; }
  .event-field,.search-field { grid-column:1/-1; }
  .alliance-summary-grid { grid-template-columns:1fr 1fr; }
}
@media (max-width:560px) {
  .alliance-summary-grid { grid-template-columns:1fr; }
}

/* Fair-play disclaimer + cycle controls */
.fair-play-banner {
  width:100%;
  padding:10px 16px;
  text-align:center;
  background:rgba(7,29,22,.94);
  border-bottom:1px solid rgba(79,209,139,.22);
  color:#cfe9dc;
  font-size:.78rem;
  font-weight:750;
  letter-spacing:.01em;
  backdrop-filter:blur(10px);
}
.cycle-status {
  margin-bottom:16px;
  padding:14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  background:linear-gradient(180deg, rgba(12,34,26,.93), rgba(7,24,18,.93));
}
.cycle-status-main { display:flex; align-items:center; gap:12px; min-width:0; }
.cycle-phase-badge { display:inline-flex; align-items:center; justify-content:center; padding:7px 10px; border-radius:999px; font-size:.68rem; font-weight:900; letter-spacing:.06em; text-transform:uppercase; white-space:nowrap; }
.cycle-phase-registration { background:rgba(79,209,139,.13); color:#75dfa5; border:1px solid rgba(79,209,139,.24); }
.cycle-phase-results { background:rgba(244,201,93,.13); color:#ffd873; border:1px solid rgba(244,201,93,.24); }
.cycle-phase-locked { background:rgba(255,255,255,.07); color:#c6d1cc; border:1px solid var(--line); }
.cycle-phase-legacy { background:rgba(76,169,255,.13); color:#7ec4ff; border:1px solid rgba(76,169,255,.22); }
.cycle-status-copy { min-width:0; }
.cycle-status-copy b { display:block; font-size:.84rem; }
.cycle-status-copy small { display:block; color:var(--muted); margin-top:3px; font-size:.72rem; line-height:1.35; }
.cycle-deadlines { display:flex; gap:18px; flex-wrap:wrap; justify-content:flex-end; }
.cycle-deadlines span { min-width:145px; }
.cycle-deadlines small { display:block; color:var(--muted); font-size:.61rem; text-transform:uppercase; letter-spacing:.07em; font-weight:800; }
.cycle-deadlines b { display:block; margin-top:4px; font-size:.74rem; font-variant-numeric:tabular-nums; }

.previous-cycle-panel {
  margin-top:16px;
  padding:13px 14px;
  border:1px solid var(--line);
  border-radius:12px;
  background:rgba(0,0,0,.16);
}
.previous-cycle-grid { display:grid; grid-template-columns:1.2fr repeat(2,1fr); gap:10px; margin-top:8px; }
.previous-cycle-grid span { min-width:0; }
.previous-cycle-grid small { display:block; color:var(--muted); font-size:.62rem; margin-bottom:3px; }
.previous-cycle-grid b { display:block; font-size:.84rem; font-variant-numeric:tabular-nums; }
.between-cycle-pill { display:inline-flex; align-items:center; gap:6px; margin-top:5px; font-size:.66rem; color:var(--muted); }
.between-cycle-pill .grade { width:22px; height:22px; border-radius:6px; font-size:.7rem; }

.check-row {
  display:flex;
  gap:11px;
  align-items:flex-start;
  margin-top:14px;
  padding:12px 13px;
  border:1px solid var(--line);
  border-radius:12px;
  background:rgba(255,255,255,.025);
  cursor:pointer;
}
.check-row input { width:18px; height:18px; margin:1px 0 0; accent-color:var(--green); flex:0 0 auto; }
.check-row b { display:block; font-size:.8rem; }
.check-row small { display:block; margin-top:4px; color:var(--muted); font-size:.69rem; line-height:1.4; }
.score-note { display:inline-flex; margin-top:5px; padding:3px 6px; border-radius:6px; background:rgba(244,201,93,.09); color:#e8cc7c; font-size:.61rem; font-weight:750; }
input:disabled, select:disabled { opacity:.58; cursor:not-allowed; }
.form-lock-note { margin-top:14px; padding:10px 12px; border-radius:10px; background:rgba(255,255,255,.045); border:1px solid var(--line); color:var(--muted); font-size:.72rem; }

/* Compact Kingdom view */
.kingdom-table-wrap { overflow:auto; padding:0 16px 16px; }
.kingdom-table { width:100%; min-width:720px; border-collapse:separate; border-spacing:0 7px; }
.kingdom-table th { background:transparent; border:0; padding:0 12px 4px; }
.kingdom-table td { background:rgba(4,18,13,.5); border-top:1px solid var(--line); border-bottom:1px solid var(--line); padding:10px 12px; }
.kingdom-table td:first-child { border-left:1px solid var(--line); border-radius:12px 0 0 12px; width:64px; }
.kingdom-table td:last-child { border-right:1px solid var(--line); border-radius:0 12px 12px 0; }
.kingdom-grade { width:42px; height:42px; border-radius:10px; font-size:1.55rem; }
.kingdom-alliance-name { font-weight:900; letter-spacing:.03em; }
.kingdom-rank-sub { color:var(--muted); font-size:.66rem; margin-top:2px; }
.kingdom-status { font-size:.7rem; font-weight:800; }
.kingdom-status.eligible { color:#75dfa5; }
.kingdom-status.ineligible { color:#ffd873; }
.kingdom-ineligible-row { opacity:.7; }
.kingdom-table .number { text-align:right; }

.focus-alliance-card { margin:0 16px 16px; padding:16px; border:1px solid var(--line); border-radius:14px; background:rgba(4,18,13,.5); display:flex; align-items:center; gap:18px; }
.focus-alliance-card .alliance-grade-large { width:78px; height:78px; flex-basis:78px; font-size:3rem; }
.focus-alliance-main { min-width:0; flex:1; }
.focus-alliance-main h3 { margin:0; font-size:1.15rem; }
.focus-alliance-main .focus-score { margin-top:5px; color:var(--muted); font-size:.78rem; }
.focus-alliance-meta { display:flex; gap:18px; flex-wrap:wrap; margin-top:10px; }
.focus-alliance-meta span small { display:block; color:var(--muted); font-size:.6rem; }
.focus-alliance-meta span b { display:block; margin-top:2px; font-size:.75rem; }

@media (max-width:780px) {
  .cycle-status { align-items:flex-start; flex-direction:column; }
  .cycle-deadlines { width:100%; justify-content:flex-start; }
  .previous-cycle-grid { grid-template-columns:1fr; }
}


/* Leadership PIN gate */
.pin-dialog { width:min(430px, calc(100% - 28px)); }
.pin-help { margin:-3px 0 16px; }
.pin-input {
  text-align:center;
  font-size:1.55rem !important;
  font-weight:900;
  letter-spacing:.32em;
  padding-left:calc(12px + .32em) !important;
  font-variant-numeric:tabular-nums;
}
.pin-error { min-height:20px; margin-top:9px; color:#ff9c9c; font-size:.74rem; font-weight:750; }

/* Section-local controls */
.prep-toolbar {
  margin-bottom:16px;
  padding:14px 16px;
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:14px;
}
.prep-toolbar .event-field { width:min(420px, 100%); }
.prep-toolbar .toolbar-actions { flex:0 0 auto; }

.table-filters {
  padding:0 16px 16px;
  display:grid;
  gap:10px;
  align-items:end;
  border-bottom:1px solid rgba(255,255,255,.045);
}
.kingdom-filters {
  grid-template-columns:minmax(180px, 280px) auto;
  justify-content:start;
}
.player-filters {
  grid-template-columns:minmax(210px, 1.35fr) minmax(125px, .65fr) minmax(160px, .85fr) minmax(110px, .55fr) minmax(210px, 1fr) auto;
}
.filter-reset-wrap { display:flex; align-items:flex-end; }
.btn-filter-reset { min-height:38px; padding:9px 12px; }
.player-reset-wrap { justify-content:flex-end; }
.table-filters .field input,
.table-filters .field select {
  padding:9px 10px;
  border-radius:9px;
}
.kingdom-table-wrap { padding-top:10px; }

/* Registration status: simple open/closed signal */
.cycle-phase-closed {
  background:rgba(255,115,115,.13);
  color:#ff9696;
  border:1px solid rgba(255,115,115,.28);
}

@media (max-width:900px) {
  .player-filters { grid-template-columns:1fr 1fr; }
  .player-reset-wrap { justify-content:flex-start; }
  .player-filters .search-field { grid-column:1/-1; }
}
@media (max-width:620px) {
  .prep-toolbar { align-items:stretch; flex-direction:column; }
  .prep-toolbar .event-field { width:100%; }
  .prep-toolbar .toolbar-actions { width:100%; }
  .prep-toolbar .toolbar-actions .btn { width:100%; }
  .table-filters { grid-template-columns:1fr; }
  .player-filters .search-field { grid-column:auto; }
  .kingdom-filters { grid-template-columns:1fr; }
  .filter-reset-wrap, .player-reset-wrap { justify-content:stretch; }
  .btn-filter-reset { width:100%; }
}

/* Two-stage weighted grading */
.grade-Excluded {
  width:auto;
  padding:0 8px;
  background:rgba(244,201,93,.10);
  color:#e8cc7c;
  font-size:.66rem;
}
.grading-config-wrap {
  overflow:auto;
  padding:4px 14px 8px;
}
.grading-config-table {
  width:100%;
  min-width:500px;
  border-collapse:collapse;
  font-size:.72rem;
}
.grading-config-table th,
.grading-config-table td {
  padding:8px 7px;
  border-bottom:1px solid rgba(255,255,255,.055);
  text-align:right;
  font-variant-numeric:tabular-nums;
}
.grading-config-table th:first-child,
.grading-config-table td:first-child { text-align:left; }
.grading-config-table th { color:var(--muted); font-size:.62rem; text-transform:uppercase; letter-spacing:.06em; }
.grading-config-table td:first-child { font-weight:750; color:#c6d1cc; }
.grading-points-line {
  padding:4px 16px 8px;
  color:#b8c8c1;
  font-size:.7rem;
  line-height:1.5;
}
.grading-calibration-note {
  margin:0 16px 14px;
  padding:9px 10px;
  border:1px solid rgba(244,201,93,.18);
  border-radius:9px;
  background:rgba(244,201,93,.055);
  color:#c9b77b;
  font-size:.65rem;
  line-height:1.45;
}
.breakdown-scroll { overflow:auto; width:100%; }
.breakdown-table-metrics.weighted-breakdown {
  grid-template-columns:minmax(170px,1.35fr) repeat(3,minmax(105px,.9fr)) minmax(90px,.7fr) minmax(80px,.55fr) minmax(70px,.5fr) minmax(105px,.75fr);
  min-width:940px;
}
.weighted-score-summary {
  margin:0 18px 18px;
  padding:12px 14px;
  border:1px solid rgba(79,209,139,.22);
  border-radius:11px;
  background:rgba(79,209,139,.06);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  flex-wrap:wrap;
}
.weighted-score-summary span { display:flex; align-items:center; gap:8px; }
.weighted-score-summary small { color:var(--muted); font-size:.64rem; text-transform:uppercase; letter-spacing:.06em; font-weight:800; }
.weighted-score-summary b { font-size:1.05rem; font-variant-numeric:tabular-nums; }
.weighted-score-summary.pending-score { border-color:var(--line); background:rgba(255,255,255,.025); }
.weighted-score-summary.pending-score .help { max-width:650px; font-size:.7rem; }

/* Alliance category totals */
.kingdom-totals-table { min-width:2050px; }
.kingdom-totals-table th { white-space:nowrap; }
.kingdom-th-sub { display:block; margin-top:3px; color:var(--muted); font-size:.58rem; font-weight:650; letter-spacing:0; text-transform:none; }
.alliance-total-td { min-width:145px; }
.alliance-metric-cell { display:flex; flex-direction:column; align-items:flex-end; gap:2px; white-space:nowrap; font-variant-numeric:tabular-nums; }
.alliance-metric-cell b { font-size:.75rem; line-height:1.15; }
.alliance-metric-cell small { color:var(--green); font-size:.67rem; font-weight:800; }
.alliance-metric-cell em { color:var(--muted); font-size:.56rem; font-style:normal; font-weight:600; }
.kingdom-totals-table .kingdom-ineligible-row { opacity:1; }
.kingdom-totals-table .kingdom-ineligible-row .kingdom-grade,
.kingdom-totals-table .kingdom-ineligible-row > td:nth-child(-n+5) { color:var(--muted); }

/* All Kingdom View columns scroll together horizontally. */

.focus-alliance-totals { align-items:flex-start; }
.focus-alliance-metrics { display:grid; grid-template-columns:repeat(4, minmax(135px, 1fr)); gap:8px; margin-top:15px; padding-top:14px; border-top:1px solid var(--line); }
.focus-alliance-metric { min-width:0; padding:9px 10px; border:1px solid var(--line); border-radius:10px; background:rgba(0,0,0,.08); }
.focus-alliance-metric > span { display:block; margin-bottom:6px; color:var(--muted); font-size:.62rem; font-weight:800; text-transform:uppercase; letter-spacing:.05em; }
.focus-alliance-metric .alliance-metric-cell { align-items:flex-start; }

@media (max-width:900px) {
  .focus-alliance-metrics { grid-template-columns:repeat(2, minmax(130px, 1fr)); }
}
@media (max-width:620px) {
  .focus-alliance-card.focus-alliance-totals { flex-direction:column; }
  .focus-alliance-metrics { grid-template-columns:1fr 1fr; width:100%; }
}


/* Auto-derived overall power totals */
.derived-total-panel {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  padding:12px;
  border:1px solid rgba(79,209,139,.18);
  border-radius:12px;
  background:rgba(79,209,139,.055);
}
.derived-total-item { min-width:0; }
.derived-total-item span { display:block; color:var(--muted); font-size:.68rem; font-weight:800; text-transform:uppercase; letter-spacing:.07em; }
.derived-total-item b { display:block; margin-top:5px; font-size:1.08rem; font-variant-numeric:tabular-nums; }
.derived-total-item b.pending { color:var(--muted); font-style:italic; }
.derived-total-item small { display:block; margin-top:3px; color:var(--muted); font-size:.65rem; }
@media (max-width:560px) {
  .derived-total-panel { grid-template-columns:1fr; }
}

.troop-protection-note {
  margin: 10px 0 12px;
  padding: 9px 11px;
  border: 1px solid rgba(244, 201, 93, .24);
  border-radius: 10px;
  background: rgba(244, 201, 93, .07);
  color: #d9c98d;
  font-size: .76rem;
  line-height: 1.45;
}


/* Creator credit banner */
.creator-top-banner {
  width:100%;
  padding:10px 16px;
  text-align:center;
  background:rgba(7,29,22,.94);
  border-bottom:1px solid rgba(79,209,139,.22);
  color:#cfe9dc;
  font-size:.78rem;
  font-weight:750;
  letter-spacing:.01em;
  backdrop-filter:blur(10px);
}

/* Mobile layout refinement — compact spacing without hiding any data */
@media (max-width: 860px) {
  .creator-top-banner {
    padding: 7px 10px;
    font-size: .69rem;
    line-height: 1.35;
  }

  .app-shell {
    width: min(100% - 14px, 1500px);
    padding: 14px 0 42px;
  }

  .hero {
    gap: 10px;
    margin-bottom: 12px;
    align-items: stretch;
  }
  .hero > div:first-child { min-width: 0; }
  .eyebrow { font-size: .66rem; }
  h1 {
    font-size: clamp(2rem, 9vw, 3rem);
    margin: 5px 0 7px;
    line-height: .98;
  }
  .hero p {
    font-size: .82rem;
    line-height: 1.4;
  }
  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
  }
  .hero-actions .btn,
  .hero-actions .sync-status {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    padding: 8px 9px;
    justify-content: center;
    text-align: center;
    font-size: .73rem;
  }

  .cycle-status {
    margin-bottom: 10px;
    padding: 10px 11px;
    gap: 8px;
  }
  .cycle-status-main {
    width: 100%;
    gap: 8px;
    align-items: flex-start;
  }
  .cycle-phase-badge {
    padding: 6px 8px;
    font-size: .61rem;
  }
  .cycle-status-copy b { font-size: .77rem; }
  .cycle-status-copy small {
    margin-top: 2px;
    font-size: .66rem;
  }
  .cycle-deadlines {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
    width: 100%;
  }
  .cycle-deadlines span { min-width: 0; }
  .cycle-deadlines small { font-size: .56rem; }
  .cycle-deadlines b {
    margin-top: 2px;
    font-size: .68rem;
  }

  .prep-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px 11px;
  }
  .prep-toolbar .event-field { width: auto; }
  .prep-toolbar .toolbar-actions { width: auto; }
  .prep-toolbar .toolbar-actions .btn {
    width: auto;
    min-height: 38px;
    padding: 9px 11px;
  }
  .prep-toolbar .field { gap: 5px; }
  .prep-toolbar .field label { font-size: .68rem; }
  .prep-toolbar .field select { padding: 9px 10px; }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
  }
  .stat-card {
    min-height: 0;
    padding: 11px 12px;
  }
  .stat-label { font-size: .66rem; }
  .stat-value {
    margin-top: 5px;
    font-size: 1.42rem;
  }
  .stat-sub {
    margin-top: 3px;
    font-size: .66rem;
    line-height: 1.3;
  }
  .stat-grade-value {
    min-height: 28px;
    gap: 7px;
  }
  .stat-grade-letter { font-size: 1.7rem; }
  .stat-grade-score { font-size: .82rem; }

  .alliance-overview-card { margin-bottom: 10px; }
  .section-heading {
    padding: 13px 13px 9px;
    gap: 8px;
    align-items: flex-start;
  }
  .section-heading h2 {
    margin-top: 3px;
    font-size: 1rem;
  }
  .section-kicker { font-size: .64rem; }
  .results-count {
    max-width: 48%;
    font-size: .64rem;
    line-height: 1.35;
    text-align: right;
  }

  .table-filters {
    gap: 7px;
    padding: 0 10px 10px;
  }
  .table-filters .field { gap: 4px; }
  .table-filters .field label { font-size: .65rem; }
  .table-filters .field input,
  .table-filters .field select {
    min-height: 38px;
    padding: 8px 9px;
    font-size: .78rem;
  }
  .kingdom-filters {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }
  .kingdom-filters .btn-filter-reset {
    width: auto;
    min-height: 38px;
    padding: 8px 10px;
  }

  .kingdom-table-wrap {
    padding: 6px 10px 10px;
  }
  .kingdom-table {
    border-spacing: 0 5px;
  }
  .kingdom-table th { padding: 0 9px 3px; }
  .kingdom-table td { padding: 8px 9px; }

  .content-grid { gap: 10px; }
  .player-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .player-filters .search-field { grid-column: 1 / -1; }
  .player-reset-wrap { justify-content: flex-start; }
  .player-reset-wrap .btn-filter-reset {
    width: 100%;
    min-height: 38px;
    padding: 8px 9px;
    font-size: .73rem;
  }

  .table-wrap { -webkit-overflow-scrolling: touch; }
  th { padding: 9px 11px; }
  td { padding: 10px 11px; }

  .side-column { gap: 10px; }
  .note-card { padding: 15px; }
  .grade-list { padding: 5px 13px 9px; }
}

@media (max-width: 430px) {
  .app-shell { width: min(100% - 10px, 1500px); }
  .hero-actions { gap: 6px; }
  .hero-actions .btn,
  .hero-actions .sync-status {
    font-size: .69rem;
    padding-inline: 7px;
  }
  .cycle-deadlines { gap: 5px 8px; }
  .section-heading { padding-inline: 11px; }
  .results-count { max-width: 44%; }
  .player-filters,
  .kingdom-filters { gap: 6px; }
}

/* =========================================================
   Attendance Tracker inspired ZOO theme — August 2026
   Visual-only overrides. Keeps all rankings functionality.
   ========================================================= */
:root {
  --bg: #07100b;
  --panel: #07110b;
  --panel-2: #1d261f;
  --panel-3: #252f28;
  --line: rgba(182, 143, 48, .27);
  --text: #f7f4ec;
  --muted: #858c86;
  --green: #b99a43;
  --green-2: #8f742c;
  --gold: #c5a34c;
  --red: #b86169;
  --bronze: #5b2502;
  --bronze-2: #381600;
  --shadow: 0 18px 54px rgba(0,0,0,.40);
}

html { color-scheme: dark; background:#050907; }
body {
  background:
    linear-gradient(180deg, rgba(3, 9, 6, .38) 0%, rgba(3, 10, 6, .56) 44%, rgba(2, 7, 4, .78) 100%),
    url('zoo-background.png') center top / cover fixed no-repeat,
    #07100b;
  color: var(--text);
}
body::before {
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:-1;
  background:
    radial-gradient(circle at 50% 10%, rgba(177,139,49,.075), transparent 36%),
    linear-gradient(90deg, rgba(0,0,0,.18), transparent 23%, transparent 77%, rgba(0,0,0,.22));
}

.creator-top-banner {
  background:rgba(5, 10, 7, .94);
  border-bottom:1px solid rgba(181,143,48,.30);
  color:#cdb774;
  box-shadow:0 6px 24px rgba(0,0,0,.24);
}

.app-shell { position:relative; }
.hero {
  padding:18px 20px 19px;
  border:1px solid rgba(183,145,49,.20);
  border-radius:24px;
  background:linear-gradient(135deg, rgba(5,13,8,.79), rgba(11,20,14,.61));
  box-shadow:0 18px 50px rgba(0,0,0,.30);
  backdrop-filter:blur(8px);
}
.eyebrow,
.section-kicker {
  color:#b89a45;
  text-transform:uppercase;
  letter-spacing:.18em;
}
h1 { color:#fffdf7; text-shadow:0 4px 24px rgba(0,0,0,.42); }
.hero p { color:#d8d9d4; }
.creator-credit { color:#a9a99e; }

.card {
  background:linear-gradient(180deg, rgba(2, 12, 7, .94), rgba(2, 9, 5, .965));
  border:1px solid rgba(180, 143, 47, .26);
  box-shadow:0 20px 56px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.025);
  backdrop-filter:blur(11px);
}
.stat-card {
  background:linear-gradient(145deg, rgba(28,39,31,.94), rgba(15,24,18,.95));
}

.field label { color:#9c9e96; }
.field input,
.field select,
.metric-input-grid input {
  color:#f4f2eb;
  background:rgba(21, 30, 24, .95);
  border-color:rgba(181,143,47,.20);
}
.field input::placeholder { color:#747c76; }
.field input:focus,
.field select:focus,
.metric-input-grid input:focus {
  border-color:rgba(191,154,64,.65);
  box-shadow:0 0 0 3px rgba(190,151,54,.10);
}

.btn {
  border-radius:14px;
  min-height:42px;
  transition:transform .14s ease, filter .14s ease, border-color .14s ease;
}
.btn:hover:not(:disabled) { transform:translateY(-1px); filter:brightness(1.08); }
.btn-primary {
  color:#fff7e8;
  background:linear-gradient(180deg, #642b05, #431a00);
  border:1px solid rgba(196,149,50,.48);
  box-shadow:inset 0 1px 0 rgba(255,214,136,.08), 0 8px 22px rgba(36,12,0,.28);
}
.btn-primary:hover { background:linear-gradient(180deg, #713207, #4b1d00); }
.btn-secondary {
  color:#f4f2ec;
  background:linear-gradient(180deg, rgba(34,43,37,.98), rgba(26,34,29,.98));
  border:1px solid rgba(182,143,47,.25);
}
.btn-ghost {
  color:#c5c6c0;
  background:rgba(13,21,16,.72);
  border:1px solid rgba(182,143,47,.24);
}
.btn-danger {
  color:#d9858b;
  background:rgba(81,17,20,.26);
  border-color:rgba(185,75,82,.34);
}
.icon-btn,
.edit-btn {
  background:rgba(25,34,28,.86);
  border-color:rgba(181,143,47,.22);
  color:#9a9f98;
}
.edit-btn:hover { color:#f5f1e8; border-color:rgba(196,158,62,.45); }

.sync-status {
  background:rgba(8,17,11,.76);
  border-color:rgba(182,143,47,.22);
  color:#949b94;
}
.sync-status.ok { color:#b9a259; }
.sync-status.saving { color:#d6bb68; }
.sync-status.error { color:#cf747a; }

.cycle-phase-badge,
.registration-open,
.status-open {
  color:#e2c96f !important;
  background:rgba(103,77,19,.28) !important;
  border-color:rgba(191,151,52,.34) !important;
}
.registration-closed,
.status-closed { color:#cc777d !important; }

.stat-label,
.results-count,
.help,
.stat-sub { color:#8b928b; }
.stat-value { color:#f7f4ed; }
.stat-grade-score { color:#929891; }

.section-heading h2,
.note-card h3 { color:#faf8f1; }

th {
  color:#9b936f;
  background:rgba(16,23,18,.95);
  border-color:rgba(181,143,47,.16);
}
td { border-color:rgba(181,143,47,.09); }
tbody tr:hover { background:rgba(160,126,40,.055); }
.rank { color:#a6aaa4; }
.rank.podium { color:#d3b757; }
.player-name { color:#fbfaf6; }

.growth-positive { color:#b9a35d; }
.growth-negative { color:#c86b73; }
.pending { color:#7c847e; }

.grade {
  border-color:rgba(255,255,255,.05);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.025);
}
.grade-S { background:rgba(183,143,41,.20); color:#e2c366; }
.grade-A { background:rgba(86,112,74,.26); color:#b7c6a9; }
.grade-B { background:rgba(68,85,77,.30); color:#aebbb4; }
.grade-C { background:rgba(91,75,49,.30); color:#c8ad7c; }
.grade-D { background:rgba(87,82,71,.25); color:#b9b5ab; }
.grade-F { background:rgba(107,38,42,.28); color:#cf7a80; }
.grade-Pending { background:rgba(255,255,255,.035); color:#7e8780; }
.grade-Excluded { background:rgba(172,137,48,.14); color:#c9ae5c; }

.formula {
  color:#aaa99e;
  background:rgba(13,21,16,.86);
  border-color:rgba(181,143,47,.16);
}
.note-card p { color:#999e98; }

.grading-config-table th { color:#938b69; }
.grading-config-table td:first-child { color:#d2d1c8; }
.grading-points-line { color:#aaa89d; }
.grading-calibration-note,
.troop-protection-note {
  color:#c6b16d;
  background:rgba(150,114,29,.075);
  border-color:rgba(187,148,48,.22);
}

.derived-total-panel,
.weighted-score-summary {
  background:rgba(107,82,24,.075);
  border-color:rgba(183,144,45,.22);
}
.focus-alliance-metric {
  background:rgba(17,25,19,.88);
  border-color:rgba(181,143,47,.16);
}
.alliance-metric-cell small { color:#b89c4c; }

#playerDialog,
dialog {
  background:linear-gradient(180deg, rgba(14,24,17,.99), rgba(6,14,9,.995));
  border-color:rgba(189,151,55,.34);
  box-shadow:0 34px 100px rgba(0,0,0,.68);
}
dialog::backdrop {
  background:rgba(2,5,3,.80);
  backdrop-filter:blur(5px);
}

/* Give major sections the Attendance Tracker's rounded framed-block look. */
.alliance-overview-card,
.leaderboard-card,
.grade-card,
.note-card,
.cycle-status,
.prep-toolbar {
  border-radius:26px;
}
.alliance-overview-card,
.leaderboard-card {
  outline:1px solid rgba(0,0,0,.22);
  outline-offset:-2px;
}

/* Subtle bronze emphasis for primary controls, similar to Add Player in Attendance Tracker. */
#addPlayerBtn,
#leadershipPinSubmit,
#savePlayerBtn,
#saveEventBtn {
  background:linear-gradient(180deg, #612905, #401800);
  border-color:rgba(198,151,51,.48);
}

/* Mobile tuning for the more atmospheric background and framed cards. */
@media (max-width: 860px) {
  body {
    background:
      linear-gradient(180deg, rgba(3,9,6,.42), rgba(2,7,4,.77)),
      url('zoo-background.png') 42% top / auto 100vh fixed no-repeat,
      #07100b;
  }
  .hero {
    padding:14px 13px 15px;
    border-radius:20px;
  }
  .card,
  .alliance-overview-card,
  .leaderboard-card,
  .grade-card,
  .note-card,
  .cycle-status,
  .prep-toolbar { border-radius:20px; }
  .btn { border-radius:12px; }
}

@media (max-width: 430px) {
  body { background-position:40% top; }
  .creator-top-banner { color:#b9aa79; }
}
