:root {
  color-scheme: dark;
  --bg:#1a1a1a;
  --panel:#2b2b2b;
  --border:#444;
  --text:#f0f0f0;
  --muted:#888;
  --accent:#ffb019;
  --accent2:#ffcf70;
  --order:#6bb2ff;
  --destro:#ff6b6b;
  --tank:#c0c0c0;
  --dps:#b48dcd;
  --healer:#6bff9b;
  --confirmed:#8fdcb0;
  --inferred:#ffcf70;
  --ambiguous:#ff8781;
  --incomplete:#777;
}

* { box-sizing:border-box; }
html { min-width:300px; }
body {
  margin:0;
  padding:20px;
  background:var(--bg) url("assets/ror.jpg") center / cover fixed no-repeat;
  color:var(--text);
  font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color:var(--accent); }
[hidden] { display:none !important; }
.page, .wrap { max-width:1200px; margin:0 auto; }
.app-header {
  max-width:1200px;
  margin:0 auto 10px;
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:center;
  gap:8px;
}
.app-header h1 { margin:0 0 10px; color:var(--accent); text-align:center; font-size:2rem; }
.app-header h1 a { color:inherit; text-decoration:none; }
.subtitle { color:var(--muted); font-size:inherit; font-weight:inherit; }
.internal-nav { display:flex; justify-content:flex-end; gap:0; flex-wrap:wrap; }
.internal-nav a { margin-left:8px; color:var(--accent); text-decoration:none; font-size:.9em; opacity:.6; }
.internal-nav a:hover { text-decoration:underline; }
.internal-nav a[aria-current="page"] { opacity:1; text-decoration:underline; }
.back-link, .link, .text-link { color:var(--accent); text-decoration:none; }
.back-link:hover, .link:hover, .text-link:hover { text-decoration:underline; }
.box, .panel {
  min-width:0;
  margin:0;
  padding:16px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--panel);
}
.box h2, .panel h2 { margin:6px 0 2px; font-size:1.1rem; }
.overview-page .box > h3 { margin:6px 0; padding-bottom:8px; border-bottom:1px solid var(--border); color:var(--accent2); }
.container { max-width:1200px; margin:0 auto; display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:20px; }
.stack { display:grid; gap:12px; }
.muted { color:var(--muted); }
.small { font-size:.85em; }
.button, .control, .btn {
  padding:6px 10px;
  border:1px solid var(--accent);
  border-radius:6px;
  background:transparent;
  color:var(--accent);
}
.button { cursor:pointer; }
.button:disabled { opacity:.5; cursor:not-allowed; }
select.control, input.control { border-color:var(--border); color:var(--text); background:#222; }
.header-left { display:flex; align-items:center; gap:8px; }
.auto-refresh { display:flex; align-items:center; gap:8px; }
.switch { position:relative; display:inline-block; width:36px; height:20px; }
.switch input { opacity:0; width:0; height:0; }
.slider { position:absolute; inset:0; border-radius:20px; background:#444; cursor:pointer; }
.slider::before { position:absolute; width:14px; height:14px; left:3px; top:3px; border-radius:50%; background:#fff; content:""; transition:.2s; }
.switch input:checked + .slider { background:var(--accent); }
.switch input:checked + .slider::before { transform:translateX(16px); }
.state { display:flex; min-height:90px; padding:16px; align-items:center; justify-content:center; flex-direction:column; gap:7px; color:var(--muted); text-align:center; }
.state-error strong { color:var(--ambiguous); }
.stat { display:grid; grid-template-columns:1fr auto; gap:6px; margin:4px 0; font-size:.92em; }
.stat.muted { text-align:left; font-size:.85em; }
.stat-divider { height:7px; }
.status { display:inline-flex; align-items:center; gap:6px; color:var(--muted); font-size:.85em; white-space:nowrap; }
.status-dot { width:9px; height:9px; border-radius:50%; background:var(--incomplete); }
.status-confirmed { color:var(--confirmed); }
.status-confirmed .status-dot { background:var(--confirmed); }
.status-inferred { color:var(--inferred); }
.status-inferred .status-dot { background:var(--inferred); }
.status-ambiguous { color:var(--ambiguous); }
.status-ambiguous .status-dot { background:var(--ambiguous); }
.status-incomplete { color:var(--incomplete); }
.status-compact { font-size:1em; }
.status-compact .status-dot { width:10px; height:10px; }
.status:focus-visible, .evidence-count:focus-visible { outline:2px solid var(--accent); outline-offset:2px; border-radius:3px; }
.realm-order { color:var(--order); }
.realm-destruction, .realm-destro { color:var(--destro); }
.realm-badge { width:20px; height:20px; object-fit:contain; vertical-align:middle; filter:drop-shadow(0 0 1px rgba(0,0,0,.4)); }
.faction-badge { position:absolute; top:8px; right:8px; width:55px; height:55px; object-fit:contain; filter:drop-shadow(0 0 1px rgba(0,0,0,.4)); }
.career { display:inline-flex; align-items:center; gap:8px; min-width:0; }
.career img { width:18px; height:18px; object-fit:contain; filter:drop-shadow(0 0 1px rgba(0,0,0,.4)); }
.career-chip { display:flex; align-items:center; gap:6px; margin:2px 0; padding:2px 8px; border:none; border-radius:999px; font-size:.85em; }
.career-chip img { width:18px; height:18px; object-fit:contain; filter:drop-shadow(0 0 1px rgba(0,0,0,.4)); }
.chips { display:flex; flex-direction:column; gap:4px; }
.role-title { margin:4px 0; }
.role-title.tank { color:var(--tank); }
.role-title.dps { color:var(--dps); }
.role-title.healer { color:var(--healer); }
.role-sep td { padding-top:10px; font-weight:700; }
.role-sep.tank td { color:var(--tank); background:rgba(192,192,192,.08); border-top:1px solid rgba(192,192,192,.25); }
.role-sep.dps td { color:var(--dps); background:rgba(180,141,205,.06); border-top:1px solid rgba(180,141,205,.2); }
.role-sep.healer td { color:var(--healer); background:rgba(107,255,155,.06); border-top:1px solid rgba(107,255,155,.2); }
.role-sep.unknown td { color:#bfbfbf; background:rgba(255,255,255,.03); border-top:1px solid rgba(255,255,255,.1); }
.badge { display:inline-block; padding:2px 8px; border:1px solid #3a3a3a; border-radius:999px; background:rgba(255,255,255,.06); color:#ddd; font-size:.85em; font-weight:600; }
.panel-head, .summary-line, .toolbar { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.table-scroll { max-width:100%; overflow:auto; }
table { width:100%; margin-top:8px; border-collapse:collapse; font-size:.92em; }
th, td { padding:6px; border-bottom:1px solid #333; text-align:left; }
th { color:var(--accent); }
.name-wrap { white-space:nowrap; }
.ext-link { margin-left:4px; color:var(--muted); text-decoration:none; font-size:.75em; opacity:.7; }
.ext-link:hover { color:var(--accent); opacity:1; }

/* Overview */
.overview-charts { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:20px; }
.chart-box { padding:12px; }
.chart-nav { display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:10px; }
.chart-nav h2 { text-align:center; }
.chart-nav .button { padding:2px 6px; border-radius:6px; font-size:16px; }
.chart-subtitle { color:var(--muted); text-align:center; font-size:.85em; }
.chart-wrap { position:relative; height:260px; overflow:hidden; }
.chart-wrap canvas { width:100% !important; height:100% !important; display:block; }
.chart-empty { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:var(--muted); font-size:.9em; opacity:.9; pointer-events:none; }
.rolling-grid { margin-top:20px; display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:20px; }
.rolling-grid h3 { color:var(--accent2); }
.date-heading { display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:10px; }
.date-heading span { text-align:center; }
.overview-page .muted { font-size:.85em; text-align:center; }
.overview-page .stat.muted { text-align:left; }
.overview-page .date-heading > span > .muted { font-size:1.2rem; font-weight:600; }
.realm-runs-grid { margin-top:20px; display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:20px; }
.realm-columns, .run-columns { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.realm-col, .run-col { min-width:0; padding:8px; border:1px solid var(--border); border-radius:6px; }
.realm-col h4, .run-col h4 { margin:4px 0; }
.realm-col.order h4, .run-col.order h4 { color:var(--order); }
.realm-col.destro h4, .run-col.destro h4 { color:var(--destro); }
.run-items { display:flex; flex-direction:column; gap:4px; }
.run-col .run-items { padding-top:8px; }
.run-mini { display:grid; grid-template-columns:1fr 10ch 2ch; gap:6px; align-items:center; padding:0; color:inherit; text-decoration:none; line-height:1.2; }
.run-mini:hover .run-time { color:var(--accent); }
.run-time { color:var(--text); }
.run-dur { color:var(--muted); text-align:right; white-space:nowrap; }
.compare-panel { margin-top:20px; }
.compare-controls { display:flex; gap:12px; flex-wrap:wrap; align-items:flex-end; margin-bottom:8px; }
.compare-controls label { display:grid; gap:3px; color:var(--muted); font-size:.85em; }
.compare-controls .compare-group { display:flex; gap:6px; }
.compare-controls .realm-filter { margin-left:auto; }
.compare-results { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:12px; margin-top:10px; }
.compare-results .box { padding:12px; }
.compare-results h4 { margin:4px 0; }
.compare-left { color:var(--dps); }
.compare-right { color:#9aa0a6; }
.pos { color:var(--healer); }
.neg { color:var(--destro); }
.spinner { display:inline-block; width:14px; height:14px; border:2px solid var(--muted); border-top-color:var(--accent); border-radius:50%; vertical-align:middle; animation:dungeon-spin .8s linear infinite; }
.spinner.lg { width:18px; height:18px; border-width:3px; }
.compare-busy { margin-left:8px; }
@keyframes dungeon-spin { to { transform:rotate(360deg); } }
.last-updated { margin:16px 0; color:var(--muted); text-align:center; font-size:.85em; }

/* Run page */
.run-layout, .character-layout { display:grid; grid-template-columns:320px minmax(0,1fr); gap:20px; }
.run-page .left-box { align-self:start; }
.list-accordion { width:100%; }
.list-accordion summary { display:flex; align-items:center; justify-content:space-between; padding:4px 6px 8px; list-style:none; cursor:pointer; }
.list-accordion summary::-webkit-details-marker { display:none; }
.list-accordion .sum-title { margin:.2rem 0 .6rem; font-weight:600; }
.run-page .list-accordion summary { padding-bottom:6px; }
.caret { width:8px; height:8px; margin-left:8px; border-right:2px solid var(--muted); border-bottom:2px solid var(--muted); transform:rotate(45deg); transition:.15s; }
.list-accordion[open] .caret { transform:rotate(225deg); }
.list-toggle { display:flex; align-items:center; gap:6px; padding:0 6px 6px; flex-wrap:wrap; }
.toggle-btn { padding:4px 8px; border:1px solid #3a3a3a; border-radius:999px; background:transparent; color:var(--muted); font-size:.85em; cursor:pointer; }
.toggle-btn.on { border-color:#555; background:rgba(255,255,255,.06); color:#fff; }
.toggle-btn:hover { color:#ddd; border-color:#555; }
.toggle-btn:focus-visible { outline:2px solid var(--accent); outline-offset:1px; }
.run-list, .character-list { max-height:70vh; overflow:auto; border-top:1px solid #333; scrollbar-width:thin; scrollbar-color:#555 #1e1e1e; }
.list-sep { padding:6px; border-bottom:1px solid #333; color:var(--muted); font-weight:600; }
.run-row, .character-row { width:100%; padding:8px 6px; border:0; border-bottom:1px solid #333; background:transparent; color:inherit; text-align:left; text-decoration:none; cursor:pointer; }
.run-row:hover, .character-row:hover { background:#262626; }
.run-row:focus-visible, .character-row:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
.run-row.active, .character-row.active { background:rgba(255,255,255,.03); box-shadow:inset -3px 0 0 rgba(255,176,25,.45); }
.run-row-top { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.run-row-left { display:flex; align-items:center; gap:8px; min-width:0; }
.run-row-time { color:var(--muted); font-size:.95em; white-space:nowrap; }
.run-row .badge { padding:2px 6px; font-size:.8em; }
.run-row .status-compact { font-size:1.3em; line-height:1; }
.run-row .status-compact .status-dot { width:auto; height:auto; border-radius:0; background:none; }
.run-row .status-compact .status-dot::before { content:"•"; }
.run-row .status-confirmed { color:#7ad39a; }
.run-row .status-confirmed .status-dot { background:none; }
.composition-strip { display:flex; justify-content:flex-end; align-items:center; flex-wrap:wrap; gap:3px 6px; margin-top:2px; }
.composition-strip img { width:14px; height:14px; object-fit:contain; filter:drop-shadow(0 0 1px rgba(0,0,0,.4)); }
#detailCol { position:relative; }
#detailCol.order { border-top:3px solid var(--order); padding-top:8px; }
#detailCol.destro, #detailCol.destruction { border-top:3px solid var(--destro); padding-top:8px; }
.detail-section { margin-top:12px; }
.detail-section:first-child { margin-top:0; }
.detail-section > h3 { margin:.2rem 0 .6rem; padding:0; border:0; color:var(--text); }
#selectedSummary { position:relative; }
.summary-corner { position:absolute; top:8px; right:12px; color:var(--muted); font-size:.85em; }
.subtle-link { color:var(--muted); text-decoration:none; }
.subtle-link:hover { color:var(--accent); }
.summary-realm { min-height:55px; }
.realm-icon { width:55px; height:55px; object-fit:contain; vertical-align:middle; filter:drop-shadow(0 0 1px rgba(0,0,0,.4)); cursor:pointer; }
.summary-spacer { height:12px; }
.summary-grid { display:grid; grid-template-columns:repeat(2,minmax(220px,1fr)); gap:4px 20px; }
.summary-status { grid-column:1/-1; min-height:24px; }
.summary-note, .evidence-note { margin:7px 0 0; color:var(--muted); font-size:.85em; }
.boss-groups { display:grid; gap:12px; }
.boss-group h4 { margin:6px 0; color:var(--accent2); }
.boss-list { display:grid; gap:0; }
.boss-row { display:grid; grid-template-columns:minmax(0,1fr) auto auto; align-items:center; gap:10px; padding:7px 6px; border-bottom:1px solid #333; }
.boss-name { min-width:0; }
.boss-provenance { color:var(--muted); font-size:.8em; }
.boss-timing { color:var(--muted); font-size:.82em; white-space:nowrap; }
.role-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:10px; }
.role-card { padding:16px; border:1px solid var(--border); border-radius:8px; background:var(--panel); }
.role-spacer { height:10px; }
.role-careers { display:flex; flex-wrap:wrap; gap:8px; }
.role-careers img { width:18px; height:18px; object-fit:contain; }
.enc-summary { margin:4px 0 8px; color:var(--muted); font-size:.9em; }
.enc-summary a { color:var(--muted); text-decoration:none; }
.enc-summary a:hover { color:var(--accent); }
.encounter-box { margin:10px 0; padding:16px; border:1px solid var(--border); border-radius:8px; background:var(--panel); }
.encounter-head { display:block; }
.source-child-link { color:var(--muted); }
.run-page #scoreboard table, .run-page #encounters table { font-size:1em; }
.run-page .ext-link { margin-left:14px; font-size:.5em; opacity:.75; }
.run-page .status-compact + .ext-link { margin-left:6px; }
.run-page #scoreboard .status-compact { font-size:1.3em; line-height:1; }
.run-page #scoreboard .status-compact .status-dot { width:auto; height:auto; border-radius:0; background:none; }
.run-page #scoreboard .status-compact .status-dot::before { content:"•"; }

/* Character page */
.search-wrap { position:relative; }
input[type="search"]::-webkit-search-cancel-button { appearance:none; -webkit-appearance:none; }
.search-wrap input { width:100%; padding:8px 28px 8px 8px; }
.clear-search { position:absolute; top:50%; right:8px; padding:0 6px; border:0; background:transparent; color:var(--muted); font-size:18px; line-height:1; transform:translateY(-50%); cursor:pointer; z-index:3; }
.character-list { border-top:0; }
.character-row { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:6px 4px; }
.character-main { display:flex; align-items:center; gap:8px; min-width:0; }
.character-main img { width:20px; height:20px; object-fit:contain; filter:drop-shadow(0 0 1px rgba(0,0,0,.4)); }
.character-main > span { min-width:0; }
.character-main strong { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.career-icon-link { flex:0 0 auto; line-height:0; }
.character-meta { color:var(--muted); font-size:.9em; text-align:right; }
.character-detail { position:relative; }
.character-title { display:flex; align-items:center; gap:10px; margin:0 0 8px; }
.character-title img { width:28px; height:28px; object-fit:contain; filter:drop-shadow(0 0 1px rgba(0,0,0,.4)); }
.character-summary { color:var(--muted); font-size:.9em; }
.character-charts { display:block; margin-top:0; }
.character-chart { height:220px; }
.character-chart + .character-chart { margin-top:10px; }
.characters-page table { font-size:.9em; }
.placeholder { padding:20px 10px; color:var(--muted); text-align:center; }
.placeholder .emoji { display:block; margin-bottom:6px; font-size:1.8rem; }
.placeholder .tips { margin-top:6px; font-size:.95em; line-height:1.4; }
.character-list::-webkit-scrollbar { width:8px; height:8px; }
.character-list::-webkit-scrollbar-track { background:#1e1e1e; border-radius:6px; }
.character-list::-webkit-scrollbar-thumb { border:2px solid #1e1e1e; border-radius:6px; background:#555; }
.character-list::-webkit-scrollbar-thumb:hover { background:#666; }
.faction-badge { opacity:1; cursor:pointer; }
.credit-wrap { display:inline-flex; align-items:center; gap:5px; }
.credit-count { color:var(--muted); font-size:.82em; }
.characters-page .credit-wrap .status-compact { font-size:1.3em; line-height:1; }
.characters-page .credit-wrap .status-compact .status-dot { width:auto; height:auto; border-radius:0; background:none; }
.characters-page .credit-wrap .status-compact .status-dot::before { content:"•"; }
.characters-page .credit-wrap .status-confirmed { color:#7ad39a; }

/* Leaderboards */
.leaderboard-stack { display:grid; gap:16px; }
.leaderboard-stack .box { padding:12px; }
.leaderboard-controls { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.leaderboard-controls label { display:flex; align-items:center; gap:5px; }
.leaderboard-controls .search-wrap { display:inline-block; }
.leaderboard-controls input { min-width:220px; }
.leaderboards-page select.control, .leaderboards-page input.control { background:transparent; }
.leaderboard-progress { margin-left:auto; }
.leader-name { display:flex; align-items:center; gap:8px; }
.leader-person { min-width:0; }
.leader-name .career span { white-space:nowrap; }
.metric-link { font-weight:700; }
#leaderboard th:last-child, #leaderboard td:last-child { text-align:right; }
.leaderboards-page #leaderboardTitle { margin:6px 0; font-size:1.17em; }

@media (max-width:820px) {
  body { padding:12px; }
  .app-header { grid-template-columns:1fr; }
  .overview-page .app-header, .run-page .app-header { gap:8px; }
  .characters-page .app-header { gap:4px; }
  .leaderboards-page .app-header { gap:6px; }
  .app-header > :first-child { display:none; }
  .app-header h1 { text-align:left; font-size:1.2rem; }
  .internal-nav { justify-content:flex-end; }
  .header-left { display:none; }
  .compare-controls .realm-filter { margin-left:0; width:100%; }
  .run-layout, .character-layout { grid-template-columns:1fr; gap:12px; }
  .summary-grid, .role-grid { grid-template-columns:1fr; }
  .run-row { padding:12px 8px; }
  .run-row.active, .character-row.active { box-shadow:inset -4px 0 0 rgba(255,176,25,.5); }
  .summary-corner { position:static; display:block; margin-bottom:8px; text-align:left; }
  .run-page .ext-link { margin-left:8px; font-size:.65em; }
  .character-list { max-height:42vh; }
  .character-row { gap:6px; }
  .character-title { flex-wrap:wrap; }
  table.responsive { width:100%; border:0; }
  table.responsive thead { display:none; }
  table.responsive tbody, table.responsive tr, table.responsive td { display:block; width:100%; }
  table.responsive tr { margin:8px 0; padding:8px; border:1px solid var(--border); border-radius:8px; background:rgba(255,255,255,.02); }
  table.responsive td { display:flex; justify-content:space-between; gap:10px; padding:6px 0; border:0; }
  table.responsive td::before { content:attr(data-label); padding-right:10px; color:var(--muted); font-weight:600; }
  table.responsive .role-sep { display:block; margin:10px 0 4px; padding:6px 8px; border:0; }
  table.responsive .role-sep td { display:block; padding:0; }
  table.responsive .role-sep td::before { content:none; }
  .leaderboard-controls { flex-direction:column; align-items:stretch; }
  .leaderboard-controls label { display:block; width:100%; }
  .leaderboard-controls select, .leaderboard-controls input, .leaderboard-controls .button, .leaderboard-controls .search-wrap { width:100%; }
  .leaderboard-progress { margin-left:0; }
  .leaderboards-page .internal-nav { justify-content:flex-start; }
}

@media (max-width:620px) {
  .realm-columns, .run-columns { grid-template-columns:1fr; }
  .compare-controls .compare-group { display:grid; grid-template-columns:1fr 1fr; }
  .boss-row { grid-template-columns:minmax(0,1fr) auto; }
  .boss-timing { grid-column:1/-1; text-align:right; }
}

@media (min-width:721px) {
  .list-accordion summary { cursor:default; }
  .list-accordion .caret { display:none; }
}
