:root { color-scheme: light dark; --bg: #0b0c10; --fg: #e6edf3; --muted: #9aa4b2; --card: #161b22; --accent: #238636; --border: #30363d; --ability-ring: rgba(96,165,250,0.85); }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--fg); }
.container { max-width: 1000px; margin: 0 auto; padding: 16px; }
header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
header h1 { margin: 0; font-size: 20px; }
header nav a { color: var(--muted); text-decoration: none; margin-left: 12px; }
header nav a:hover { color: var(--fg); }
header nav { display: flex; align-items: center; gap: 12px; }
header nav .account-switcher { position: relative; }
header nav .account-switcher > button { background: #1f6feb; border: 1px solid #2f81f7; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--border); border-radius: 8px; min-width: 260px; max-height: 340px; overflow: auto; box-shadow: 0 6px 24px rgba(0,0,0,0.35); padding: 8px; z-index: 20; }
.dropdown .chip { width: 100%; justify-content: space-between; border-radius: 6px; }
.dropdown .chip .id { margin-left: 8px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
input { padding: 8px 10px; background: #0f1420; color: var(--fg); border: 1px solid var(--border); border-radius: 6px; }
.actions { display: flex; gap: 8px; }
button { background: var(--accent); border: 1px solid #2ea043; color: white; padding: 8px 12px; border-radius: 6px; cursor: pointer; }
button:hover { filter: brightness(1.1); }
.results { margin-top: 12px; }
/* Pager for match history */
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.pager .page-label { color: var(--muted); }
.pager .page-btn[disabled] { opacity: 0.6; cursor: not-allowed; }
/* Tables stretch to content; scroll horizontally within .card when needed */
table { min-width: 100%; width: max-content; border-collapse: collapse; margin-top: 8px; table-layout: auto; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
/* Allow tables to fit content better; fallback to horizontal scroll */
.card { overflow-x: auto; }
th, td { white-space: nowrap; }
.teammates-multiline { white-space: normal; line-height: 1.35; }
.spinner { color: var(--muted); padding: 10px; }
.error { color: #ff7b72; padding: 8px; border: 1px solid #b62324; background: #2a1414; border-radius: 6px; }
.muted { color: var(--muted); }
.footer { color: var(--muted); }
.checkbox { display: flex; align-items: center; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); background: #0f1420; border-radius: 999px; cursor: pointer; font-weight: 600; letter-spacing: 0.2px; }
.chip:hover { border-color: #3b82f6; }
.chip .id { color: var(--muted); font-size: 12px; }
/* Subtle subsection heading */
h4.subtle { color: var(--muted); margin: 10px 0 4px; font-size: 14px; font-weight: 600; }
/* Spend summary tweaks */
.chips.spend { margin-top: 4px; }
.chips.spend .chip .id { margin-left: 6px; }
/* Action label base colors (inline style adjusts intensity by tier) */
.act.item-spirit { color: rgba(147, 51, 234, 0.9); }
.act.item-gun    { color: rgba(255, 159, 67, 0.9); }
.act.item-survival{ color: rgba(34, 197, 94, 0.9); }
.act.item-ability{ color: rgba(96, 165, 250, 0.95); }
/* Item type tints */
.chip.item-spirit { background: rgba(147, 51, 234, 0.18); border-color: rgba(147, 51, 234, 0.35); }
.chip.item-gun    { background: rgba(255, 159, 67, 0.18); border-color: rgba(255, 159, 67, 0.35); }
.chip.item-survival{ background: rgba(34, 197, 94, 0.18); border-color: rgba(34, 197, 94, 0.35); }
.chip.item-ability{ background: rgba(96, 165, 250, 0.15); border-color: rgba(96, 165, 250, 0.38); }
/* Small badge for item tier */
.chip .badge { font-size: 11px; line-height: 1; padding: 2px 6px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.12); color: #e6edf3; background: rgba(0,0,0,0.25); margin-left: 2px; }
th.sortable { cursor: pointer; }
/* Small inline icons for tables and chips */
img.icon { width: 20px; height: 20px; object-fit: contain; vertical-align: -4px; margin-right: 6px; border-radius: 2px; }

/* Percentile bucket badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; line-height: 1; padding: 2px 6px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.12); color: #e6edf3; background: rgba(0,0,0,0.25); margin-left: 6px; }
.badge.bucket.p99 { background: rgba(34, 197, 94, 0.25); border-color: rgba(34,197,94,0.45); }
.badge.bucket.p95 { background: rgba(34, 197, 94, 0.20); border-color: rgba(34,197,94,0.40); }
.badge.bucket.p90 { background: rgba(52, 211, 153, 0.20); border-color: rgba(52,211,153,0.40); }
.badge.bucket.p75 { background: rgba(59, 130, 246, 0.18); border-color: rgba(59,130,246,0.38); }
.badge.bucket.p50 { background: rgba(107, 114, 128, 0.25); border-color: rgba(107,114,128,0.45); }
.badge.bucket.p25 { background: rgba(234, 179, 8, 0.22); border-color: rgba(234,179,8,0.42); }
.badge.bucket.p10 { background: rgba(249, 115, 22, 0.22); border-color: rgba(249,115,22,0.42); }
.badge.bucket.p5  { background: rgba(244, 63, 94, 0.22); border-color: rgba(244,63,94,0.42); }
.badge.bucket.p1  { background: rgba(190, 18, 60, 0.25); border-color: rgba(190,18,60,0.45); }

/* Text accents for inline win/loss counts */
.text-win { color: var(--accent); font-weight: 600; }
.text-loss { color: #ff7b72; font-weight: 600; }

/* Match details side panel */
.panel { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; justify-content: flex-end; z-index: 50; }
.panel[hidden] { display: none; }
.panel .panel-content { background: var(--card); border-left: 1px solid var(--border); width: min(900px, 95vw); height: 100%; overflow: auto; padding: 16px; position: relative; }
.panel .panel-close { position: absolute; top: 8px; right: 8px; background: transparent; border: 1px solid var(--border); color: var(--fg); width: 28px; height: 28px; border-radius: 6px; cursor: pointer; }

/* Left-side detail panel */
.panel.left { justify-content: flex-start; }
.panel.left .panel-content { border-left: none; border-right: 1px solid var(--border); width: min(900px, 95vw); }

/* Center modal variant */
.panel.center { justify-content: center; align-items: center; }
.panel.center .panel-content { width: min(800px, 95vw); height: auto; max-height: 90vh; border: 1px solid var(--border); border-radius: 10px; }

/* Win/Loss row tints for tables */
tr.row-win { background: rgba(34, 197, 94, 0.12); }
tr.row-loss { background: rgba(255, 99, 71, 0.12); }

/* W/L badges in co-play table */
.badge.win { background: rgba(34, 197, 94, 0.25); border-color: rgba(34, 197, 94, 0.45); color: #d1fae5; }
.badge.loss { background: rgba(255, 99, 71, 0.25); border-color: rgba(255, 99, 71, 0.45); color: #ffe4e1; }

/* Details header with large icon */
.detail-header { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.icon-xxl { width: 96px; height: 96px; object-fit: contain; border-radius: 12px; border: 1px solid rgba(255,255,255,0.12); background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(0,0,0,0)); box-shadow: 0 8px 22px rgba(0,0,0,0.5); }
.detail-title { font-size: 20px; font-weight: 700; }
.detail-sub { color: var(--muted); }

/* Global prefetch banner */
.prefetch-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 70; display: flex; align-items: center; justify-content: center; gap: 10px; height: 36px; background: rgba(35, 134, 54, 0.15); border-bottom: 1px solid var(--border); color: var(--fg); backdrop-filter: blur(2px); opacity: 0; transform: translateY(-100%); transition: opacity 200ms ease, transform 200ms ease; pointer-events: none; }
.prefetch-banner.show { opacity: 1; transform: translateY(0); }
.prefetch-banner .spinner-inline { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: rgba(63,130,246,0.15); }
/* Match history row outcome tints */
.row-win { background: rgba(34, 197, 94, 0.14); }
.row-loss { background: rgba(244, 63, 94, 0.14); }
/* Preserve tint on hover with a slight intensification */
.clickable-row.row-win:hover { background: rgba(34, 197, 94, 0.20); }
.clickable-row.row-loss:hover { background: rgba(244, 63, 94, 0.20); }

/* Player link styles in roster */
.player-link { color: var(--fg); text-decoration: none; cursor: pointer; }
.player-link:hover { text-decoration: underline; }
.player-link.tracked { color: #3b82f6; font-weight: 600; }
.player-link.tracked-player { color: #3b82f6; font-weight: 600; }
.player-link.tracked-player:hover { color: #60a5fa; text-decoration: underline; }
.untracked-player { color: var(--muted); }

/* Result badges in roster */
.result-badge { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  width: 24px; 
  height: 24px; 
  border-radius: 50%; 
  font-weight: 700; 
  font-size: 12px; 
  text-align: center; 
}
.result-badge.result-w { 
  background: rgba(34, 197, 94, 0.2); 
  color: #22c55e; 
  border: 1px solid rgba(34, 197, 94, 0.4); 
}
.result-badge.result-l { 
  background: rgba(244, 63, 94, 0.2); 
  color: #f43f5e; 
  border: 1px solid rgba(244, 63, 94, 0.4); 
}

/* Make player insights tables feel clickable */
#player-results tbody tr { cursor: pointer; }
#player-results tbody tr:hover { background: rgba(63,130,246,0.15); }

/* Team background colors in roster */
.team-red { background: rgba(244, 63, 94, 0.15); }
.team-red:hover { background: rgba(244, 63, 94, 0.25); }
.team-green { background: rgba(34, 197, 94, 0.15); }
.team-green:hover { background: rgba(34, 197, 94, 0.25); }

/* Abilities section */
.abilities { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; margin-top: 8px; justify-content: space-evenly; width: 100%; }
.ability { position: relative; width: 88px; text-align: center; padding-top: 12px; }
.ability .icon-lg { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; border: 1px solid rgba(255,255,255,0.12); background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0)); box-shadow: 0 4px 10px rgba(0,0,0,0.35); }
.ability .levels { position: absolute; top: -28px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 5; pointer-events: none; }
.ability .bar { width: 46px; height: 7px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.55); box-shadow: 0 2px 4px rgba(0,0,0,0.5); background: linear-gradient(180deg, rgba(160,170,180,0.38), rgba(80,88,96,0.30)); }
.ability .bar.active { background: linear-gradient(180deg, rgba(255,255,255,0.99), rgba(255,255,255,0.86)); border-color: rgba(255,255,255,0.9); box-shadow: 0 0 0 1px rgba(255,255,255,0.6), 0 0 12px rgba(96,165,250,0.35), 0 3px 7px rgba(0,0,0,0.6); }
/* Intensity scaling with level */
.ability.lvl-1 .bar.active { opacity: 0.92; }
.ability.lvl-2 .bar.active { opacity: 0.97; box-shadow: 0 0 0 1px rgba(255,255,255,0.65), 0 0 14px rgba(96,165,250,0.45), 0 3px 7px rgba(0,0,0,0.65); }
.ability.lvl-3 .bar.active, .ability.lvl-4 .bar.active { opacity: 1; box-shadow: 0 0 0 1px rgba(255,255,255,0.7), 0 0 16px rgba(96,165,250,0.55), 0 4px 8px rgba(0,0,0,0.7); }
.ability .label { margin-top: 6px; font-size: 12.5px; color: var(--fg); max-width: 84px; line-height: 1.2; text-align: center; text-shadow: 0 1px 2px rgba(0,0,0,0.7); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Level rings (thicker border with subtle outer glow) */
.ability.lvl-1 .icon-lg { box-shadow: 0 0 0 2px var(--ability-ring), 0 0 14px rgba(96,165,250,0.35), 0 8px 16px rgba(0,0,0,0.5); }
.ability.lvl-2 .icon-lg { box-shadow: 0 0 0 5px var(--ability-ring), 0 0 0 9px rgba(96,165,250,0.20), 0 0 18px rgba(96,165,250,0.40), 0 9px 18px rgba(0,0,0,0.6); }
.ability.lvl-3 .icon-lg { box-shadow: 0 0 0 10px var(--ability-ring), 0 0 0 14px rgba(96,165,250,0.24), 0 0 22px rgba(96,165,250,0.55), 0 10px 20px rgba(0,0,0,0.65); }
.ability.lvl-4 .icon-lg { box-shadow: 0 0 0 15px var(--ability-ring), 0 0 0 20px rgba(96,165,250,0.26), 0 0 28px rgba(96,165,250,0.65), 0 12px 24px rgba(0,0,0,0.7); }

/* Match details account switcher */
.account-switcher-match { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 8px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
.account-switcher-match .switch-label { color: var(--muted); font-size: 14px; font-weight: 600; }
.account-switcher-match .account-btn { background: #0f1420; border: 1px solid var(--border); color: var(--fg); padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; }
.account-switcher-match .account-btn:hover { border-color: #3b82f6; background: rgba(59, 130, 246, 0.1); }
.account-switcher-match .account-btn.active { background: #1f6feb; border-color: #2f81f7; color: white; }

/* Match banner */
.match-banner { display: flex; justify-content: space-between; align-items: center; padding: 20px; margin-bottom: 24px; border-radius: 12px; border: 1px solid var(--border); position: relative; overflow: hidden; gap: 24px; }
.match-banner:before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; opacity: 0.08; z-index: 0; }
.match-banner.result-win:before { background: linear-gradient(135deg, #22c55e, #16a34a); }
.match-banner.result-loss:before { background: linear-gradient(135deg, #ef4444, #dc2626); }
.match-banner.result-unknown:before { background: linear-gradient(135deg, #6b7280, #4b5563); }

.match-info, .match-stats { position: relative; z-index: 1; }
.match-info { display: flex; flex-direction: column; gap: 8px; min-width: 200px; }
.match-result { font-size: 24px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.match-banner.result-win .match-result { color: #22c55e; }
.match-banner.result-loss .match-result { color: #ef4444; }
.match-banner.result-unknown .match-result { color: #6b7280; }

.match-hero { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 600; }
.match-hero .hero-icon { width: 32px; height: 32px; border-radius: 6px; }
.match-meta { display: flex; gap: 16px; color: var(--muted); font-size: 14px; }

.match-stats { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.stat-group { text-align: center; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.stat-value { font-size: 18px; font-weight: 700; color: var(--fg); }
.stat-total { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* Trend values in match banner */
.trend-value { padding: 2px 6px; border-radius: 4px; font-size: 16px; }

/* Responsive match banner */
@media (max-width: 768px) {
  .match-banner { flex-direction: column; gap: 16px; text-align: center; }
  .match-stats { flex-wrap: wrap; justify-content: center; gap: 16px; }
}
