* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  background: #0f1117;
  color: #e0e0e0;
  padding: 2rem;
  max-width: 1100px;
  margin: 0 auto;
}

header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

h1 { font-size: 1.4rem; font-weight: 600; color: #fff; }

button {
  padding: 0.5rem 1.2rem;
  background: #f59e0b;
  color: #000;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: #fbbf24; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

#status { font-size: 0.8rem; color: #888; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #2a2a2a;
}
.tab {
  padding: 0.6rem 1.2rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: #888;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: #ccc; }
.tab.active { color: #f59e0b; border-bottom-color: #f59e0b; }

/* Controls bar */
.controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

#empty { padding: 3rem; text-align: center; color: #555; }

.pane { display: none; }
.pane.active { display: block; }

/* Shared elements */
.hero-cell { display: flex; align-items: center; gap: 0.6rem; }
.portrait {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: #2a2a2a;
  flex-shrink: 0;
}

.role-badge {
  display: inline-block;
  padding: 0.15rem 0;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 62px;
  text-align: center;
  flex-shrink: 0;
}
.role-TANK    { background: #1e3a5f; color: #60a5fa; }
.role-DAMAGE  { background: #3f1515; color: #f87171; }
.role-SUPPORT { background: #1a3a1a; color: #4ade80; }

.num { font-variant-numeric: tabular-nums; }

/* ── Filter buttons ────────────────────────────────────────────────────── */

.filter-btn {
  padding: 0.3rem 0.8rem;
  background: #1e1e2e;
  color: #888;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
}
.filter-btn:hover { color: #ccc; border-color: #444; }
.filter-btn.active { color: #fff; border-color: #f59e0b; background: #2a2010; }

/* ── Hero Summary tab ───────────────────────────────────────────────────── */

/* Hero chip grid */
.hero-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.hero-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 8px;
  border: 2px solid transparent;
  width: 66px;
  transition: border-color 0.15s, background 0.15s;
}
.hero-chip:hover { border-color: #444; background: #181822; }
.hero-chip.selected { border-color: #f59e0b; background: #1e1a0a; }

.hero-chip .chip-portrait {
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #2a2a2a;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: #888;
  overflow: hidden;
}
.hero-chip img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }

.hero-chip .chip-name {
  font-size: 0.65rem;
  color: #888;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.hero-chip.selected .chip-name { color: #f59e0b; }

/* Hero detail panel */
#hero-detail, #map-detail {
  background: #13151f;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 1.5rem;
}

@keyframes detail-flash {
  0%   { box-shadow: 0 0 0 2px #f59e0b88; }
  60%  { box-shadow: 0 0 0 6px #f59e0b22; }
  100% { box-shadow: 0 0 0 0px transparent; }
}
#hero-detail.detail-flash {
  animation: detail-flash 0.6s ease-out forwards;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.detail-portrait {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: #2a2a2a;
  flex-shrink: 0;
}
.detail-header-info { display: flex; flex-direction: column; gap: 0.4rem; }
.detail-name { font-size: 1.3rem; font-weight: 700; color: #fff; }
.detail-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }

.comp-tag {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-playstyle {
  font-size: 0.85rem;
  color: #aaa;
  line-height: 1.6;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #2a2a2a;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #2a2a2a;
}

.detail-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
  margin-bottom: 0.75rem;
}

.ability-list { display: flex; flex-direction: column; gap: 0.55rem; }
.ability-item { display: flex; gap: 0.5rem; }
.ability-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #c0a070;
  white-space: nowrap;
  min-width: 100px;
}
.ability-desc { font-size: 0.78rem; color: #999; line-height: 1.4; }

.meta-text {
  font-size: 0.85rem;
  color: #aaa;
  line-height: 1.7;
}
.meta-no-data { font-size: 0.8rem; color: #555; font-style: italic; }

/* Tier chart */
.tier-chart { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.75rem; }
.tier-row { display: flex; align-items: center; gap: 0.5rem; }
.tier-label { font-size: 0.72rem; color: #888; width: 80px; flex-shrink: 0; }
.tier-bar-bg { flex: 1; height: 6px; background: #222; border-radius: 3px; overflow: hidden; }
.tier-bar-fill { height: 100%; border-radius: 3px; background: #4ade80; }
.tier-val { font-size: 0.72rem; color: #aaa; font-variant-numeric: tabular-nums; width: 40px; text-align: right; }

/* Map performance (hero detail) */
.map-perf-list { display: flex; flex-direction: column; gap: 0.3rem; }
.map-row { display: flex; align-items: center; gap: 0.6rem; }
.map-name { font-size: 0.75rem; color: #aaa; width: 130px; flex-shrink: 0; cursor: pointer; text-decoration: underline dotted; }
.map-name:hover { color: #f59e0b; }
.map-type-badge {
  font-size: 0.6rem;
  color: #666;
  width: 60px;
  flex-shrink: 0;
}
.map-bar-bg { flex: 1; height: 5px; background: #222; border-radius: 3px; overflow: hidden; }
.map-bar-fill { height: 100%; border-radius: 3px; }
.map-bar-above { background: #4ade80; }
.map-bar-below { background: #f87171; }
.map-val { font-size: 0.75rem; color: #aaa; font-variant-numeric: tabular-nums; width: 38px; text-align: right; }
.map-delta-label { font-size: 0.7rem; font-variant-numeric: tabular-nums; width: 38px; }
.map-delta-label.pos { color: #4ade80; }
.map-delta-label.neg { color: #f87171; }

/* ── Map Summary tab ───────────────────────────────────────────────────── */

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.map-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  cursor: pointer;
  padding: 0.75rem 0.5rem;
  border-radius: 8px;
  border: 1px solid #222;
  background: #161822;
  transition: border-color 0.15s, background 0.15s;
}
.map-chip:hover { border-color: #444; background: #1c1e2e; }
.map-chip.selected { border-color: #f59e0b; background: #1e1a0a; }

.map-chip-icon {
  font-size: 1.3rem;
  line-height: 1;
  color: #666;
}
.map-chip.selected .map-chip-icon { color: #f59e0b; }

.map-chip-name {
  font-size: 0.8rem;
  color: #ccc;
  font-weight: 500;
  text-align: center;
}
.map-chip.selected .map-chip-name { color: #f59e0b; }

.map-chip-type {
  font-size: 0.62rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Map detail: description */
.map-description {
  font-size: 0.85rem;
  color: #aaa;
  line-height: 1.5;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #2a2a2a;
}

/* Map detail: terrain tags */
.terrain-tag {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 500;
  background: #1e1e2e;
  color: #888;
  border: 1px solid #2a2a2a;
}

.map-detail-type {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Map detail: outlier grid */
.outlier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #2a2a2a;
}

/* Map detail: hero list */
.map-hero-list { display: flex; flex-direction: column; gap: 0; width: fit-content; margin: 0 auto; }
.map-hero-list-full { /* no height cap — scrolls with the page */ }
.map-hero-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #1a1c28;
  border-radius: 4px;
}
.map-hero-row:hover { background: #161822; }
.hero-cell { min-width: 0; }
.map-hero-name { font-size: 0.78rem; color: #ccc; width: 110px; display: inline-block; }

/* ── Meta tier badges ──────────────────────────────────────────────────── */

.controls-label {
  font-size: 0.7rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* small tier letter on hero chips */
.chip-meta-tier {
  font-size: 0.58rem;
  font-weight: 700;
  padding: 0.05rem 0.28rem;
  border-radius: 3px;
  border: 1px solid;
  letter-spacing: 0.06em;
}

/* larger badge in hero detail header */
.meta-tier-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  border: 1px solid;
  letter-spacing: 0.05em;
  cursor: default;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

/* Tablet and below */
@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; gap: 1rem; }
}

/* Mobile (iPhone-sized) */
@media (max-width: 600px) {
  body { padding: 1rem; }

  /* Hero chip grid: auto-fill so columns always fit without overflow/underflow */
  .hero-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 0.4rem; }
  .hero-chip { width: auto; padding: 0.35rem; }
  .hero-chip .chip-portrait { width: 42px; height: 42px; }
  .hero-chip img { width: 42px; height: 42px; }

  /* Map chip grid: narrower cards on mobile */
  .map-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .map-chip { padding: 0.6rem 0.4rem; }
  .map-chip-name { font-size: 0.72rem; }

  /* Panels */
  .outlier-grid { grid-template-columns: 1fr; gap: 1rem; }
  #hero-detail, #map-detail { padding: 1rem; }

  /* Shrink detail portrait so tags have more room */
  .detail-portrait { width: 56px; height: 56px; }

  /* Tabs: larger touch targets */
  .tab { padding: 0.7rem 1rem; font-size: 0.9rem; }

  /* Filter buttons: comfortable touch targets */
  .controls { gap: 0.5rem; }
  .filter-btn { padding: 0.4rem 0.8rem; font-size: 0.78rem; min-height: 36px; }

  /* ── Map perf rows (hero detail) ── */
  .map-type-badge { display: none; }
  .map-name { width: 80px; font-size: 0.7rem; }
  .map-val { width: 34px; font-size: 0.7rem; }
  .map-delta-label { width: 34px; font-size: 0.65rem; }


  /* ── Map hero rows (map detail) ── */
  /* Drop role badge to reclaim ~50px; truncate long hero names */
  .map-hero-row .role-badge { display: none; }
  .hero-cell { min-width: 0; }
  .map-hero-name {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}


/* Extra-small phones (< 390px) */
@media (max-width: 390px) {
  .map-name { width: 62px; }
  .map-hero-name { max-width: 62px; }
  /* Delta labels are the least critical number — drop them to free bar space */
  .map-delta-label { display: none; }
}
