/* ==========================================================================
   BattleStats - components
   ========================================================================== */

/* ---------- icons ---------- */
.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon--lg { width: 1.6em; height: 1.6em; }
.icon--fill { fill: currentColor; stroke: none; }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--bg-3); --btn-fg: var(--text); --btn-bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-bd); border-radius: 4px;
  text-decoration: none; white-space: nowrap; user-select: none;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease), color 0.15s var(--ease);
}
.btn:hover { --btn-bg: var(--bg-4); --btn-bd: var(--amber-b); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled='true'] { opacity: 0.5; pointer-events: none; }
.btn--primary { --btn-bg: var(--amber); --btn-fg: var(--amber-ink); --btn-bd: var(--amber); }
.btn--primary:hover { --btn-bg: var(--amber-2); --btn-bd: var(--amber-2); }
.btn--ghost { --btn-bg: transparent; --btn-bd: var(--line-2); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 0.95rem; }
.btn--icon { padding: 0; width: 42px; }
.btn--icon.btn--sm { width: 34px; }
.btn[aria-pressed='true'] { --btn-bg: var(--amber-a); --btn-bd: var(--amber); --btn-fg: var(--amber-2); }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-family: var(--font-head); font-weight: 600; font-size: 0.9rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-2); }
.input, .select {
  width: 100%; min-height: 44px; padding: 0 14px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 4px;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.input::placeholder { color: var(--text-3); }
.input:hover, .select:hover { border-color: #4a5763; }
.input:focus-visible, .select:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; border-color: var(--amber); }
.select { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }
.select option { background: var(--bg-2); color: var(--text); }
.input--sm, .select--sm { min-height: 36px; font-size: 0.95rem; }

/* segmented radio group (platform picker) */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 6px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 8px 14px; border-radius: 4px; font-family: var(--font-head); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.95rem; color: var(--text-2); transition: background 0.15s, color 0.15s; }
.segmented label:hover span { color: var(--text); background: var(--bg-3); }
.segmented input:checked + span { background: var(--amber); color: var(--amber-ink); }
.segmented input:focus-visible + span { outline: 2px solid var(--amber-2); outline-offset: 2px; }

/* ---------- cards ---------- */
.card { position: relative; background: linear-gradient(180deg, var(--bg-2), var(--bg-1)); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: clamp(16px, 2.4vw, 24px); box-shadow: var(--shadow-1); min-width: 0; }
.card--flat { background: var(--bg-1); box-shadow: none; }
.card--tight { padding: 14px 16px; }
.card--link { display: block; color: inherit; transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), background 0.2s; }
.card--link:hover { border-color: var(--amber-b); transform: translateY(-2px); text-decoration: none; }
.card--link:focus-visible { outline-offset: -3px; }
/* HUD corner brackets */
.bracket::before {
  content: ''; position: absolute; inset: -1px; pointer-events: none; border-radius: inherit;
  background:
    linear-gradient(var(--amber), var(--amber)) top left / 16px 2px no-repeat,
    linear-gradient(var(--amber), var(--amber)) top left / 2px 16px no-repeat,
    linear-gradient(var(--amber), var(--amber)) bottom right / 16px 2px no-repeat,
    linear-gradient(var(--amber), var(--amber)) bottom right / 2px 16px no-repeat;
}
.card__title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card__title h2, .card__title h3 { font-size: 1.2rem; }
.side-title { font-size: 1.05rem; letter-spacing: 0.04em; }

/* ---------- section headings ---------- */
.eyebrow { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 600; font-size: 0.95rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--amber); }
.eyebrow::before { content: ''; width: 28px; height: 2px; background: var(--amber); }
.section { margin-top: clamp(32px, 5vw, 56px); }
.section__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 18px; }
.section__head h2 { margin-top: 6px; }

/* ---------- badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 3px; font-family: var(--font-head); font-weight: 600; font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; background: var(--bg-3); color: var(--text-2); border: 1px solid var(--line-2); line-height: 1.3; white-space: nowrap; }
.badge--amber { background: var(--amber-a); color: var(--amber-2); border-color: var(--amber-b); }
.badge--win { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.badge--top { background: rgba(127, 148, 64, 0.2); color: var(--olive-2); border-color: rgba(127, 148, 64, 0.5); }
.badge--danger { background: rgba(229, 72, 77, 0.14); color: #ff8b8f; border-color: rgba(229, 72, 77, 0.45); }
.badge--ok { background: rgba(88, 194, 125, 0.14); color: var(--green); border-color: rgba(88, 194, 125, 0.4); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 4px; background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text-2); font-weight: 500; font-size: 0.95rem; text-decoration: none; transition: all 0.15s var(--ease); }
a.chip:hover, button.chip:hover { color: var(--text); border-color: var(--amber-b); background: var(--bg-3); text-decoration: none; }
button.chip[aria-pressed='true'] { background: var(--amber-a); border-color: var(--amber); color: var(--amber-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot--ok { background: var(--green); box-shadow: 0 0 0 3px rgba(88, 194, 125, 0.18); }
.dot--bad { background: var(--red); box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.18); }
.dot--warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-a); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; flex: none; padding: 14px 18px; background: none; border: 0; color: var(--text-2); font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none; transition: color 0.15s; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-selected='true'] { color: var(--amber-2); }
.tab[aria-selected='true']::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; background: var(--amber); border-radius: 2px 2px 0 0; }
.tab:focus-visible { outline-offset: -4px; }

/* ---------- stat tiles ---------- */
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat__label { font-family: var(--font-head); font-weight: 600; font-size: 0.88rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.stat__value { font-family: var(--font-head); font-weight: 700; font-size: clamp(1.7rem, 3.4vw, 2.4rem); line-height: 1.05; color: var(--text); font-variant-numeric: tabular-nums; }
.stat__value--amber { color: var(--amber); }
.stat__sub { font-size: 0.9rem; color: var(--text-2); }
.stats-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.tile--hl { border-color: var(--amber-b); background: linear-gradient(180deg, var(--amber-a), var(--bg-1)); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-1); -webkit-overflow-scrolling: touch; }
.table-wrap:focus-visible { outline-offset: 0; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 11px 14px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.table th:first-child, .table td:first-child { text-align: left; }
.table .l { text-align: left; }
.table .c { text-align: center; }
.table thead th { position: sticky; top: 0; z-index: 1; background: var(--bg-2); font-family: var(--font-head); font-weight: 600; font-size: 0.88rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.table thead th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.table thead th button:hover { color: var(--text); }
.table thead th button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.table thead th[aria-sort] { color: var(--amber-2); }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: var(--bg-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.is-me { background: var(--amber-a); }
.table tr.is-me td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.table a { color: var(--text); font-weight: 500; }
.table a:hover { color: var(--amber-2); }

/* ---------- skeleton / loading ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--bg-2); border-radius: var(--radius); min-height: 1em; }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--amber); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: flex; align-items: center; gap: 14px; justify-content: center; padding: 48px 16px; color: var(--text-2); }

/* ---------- notices / empty / error ---------- */
.notice { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--bg-2); }
.notice .icon { margin-top: 2px; }
.notice--warn { border-color: var(--amber-b); background: var(--amber-a); }
.notice--warn > .icon { color: var(--amber); }
.notice--error { border-color: rgba(229, 72, 77, 0.5); background: rgba(229, 72, 77, 0.08); }
.notice--error > .icon { color: var(--red); }
.notice h2, .notice h3 { font-size: 1.15rem; margin-bottom: 4px; }
.notice__body { flex: 1; min-width: 0; }
.empty { text-align: center; padding: clamp(32px, 6vw, 64px) 16px; color: var(--text-2); }
.empty h2, .empty h3 { color: var(--text); margin-bottom: 8px; font-size: 1.4rem; }
.empty .icon { width: 44px; height: 44px; color: var(--text-3); margin: 0 auto 14px; }
.hazard { height: 6px; border-radius: 2px; background: repeating-linear-gradient(-45deg, var(--amber) 0 10px, #15191d 10px 20px); opacity: 0.9; }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 900; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: var(--radius); background: var(--bg-3); border: 1px solid var(--line-2); border-left: 3px solid var(--amber); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); animation: toast-in 0.25s var(--ease); }
.toast--error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- modal / lightbox ---------- */
.modal { position: fixed; inset: 0; z-index: 800; display: grid; place-items: center; padding: 16px; background: rgba(5, 7, 9, 0.82); animation: fade-in 0.18s var(--ease); }
.modal__panel { position: relative; width: min(960px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: clamp(16px, 3vw, 28px); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.modal__close { position: absolute; top: 10px; right: 10px; z-index: 2; }
.modal__img { width: 100%; max-height: 70dvh; object-fit: contain; border-radius: var(--radius); background: #000; }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- tooltip (charts / replay) ---------- */
.tooltip { position: fixed; z-index: 700; pointer-events: none; padding: 8px 10px; border-radius: 4px; background: #05070a; border: 1px solid var(--line-2); color: var(--text); font-size: 0.9rem; line-height: 1.35; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); max-width: 260px; }
.tooltip b { color: var(--amber-2); font-weight: 600; }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-body); font-size: 12px; fill: var(--text-3); }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.bar-row { display: grid; grid-template-columns: minmax(70px, 150px) 1fr auto; align-items: center; gap: 12px; padding: 5px 0; }
.bar-row__label { color: var(--text-2); font-size: 0.95rem; }
.bar-row__track { height: 10px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.bar-row__fill { height: 100%; background: linear-gradient(90deg, var(--amber-3), var(--amber)); border-radius: 2px; transition: width 0.6s var(--ease); }
.bar-row__fill--olive { background: linear-gradient(90deg, var(--olive), var(--olive-2)); }
.bar-row__val { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.9rem; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- placement pills (match results) ---------- */
.place { display: inline-grid; place-items: center; min-width: 44px; height: 30px; padding: 0 8px; border-radius: 3px; font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; letter-spacing: 0.02em; background: var(--bg-3); color: var(--text-2); border: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
.place--1 { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.place--top { background: rgba(127, 148, 64, 0.22); color: var(--olive-2); border-color: rgba(127, 148, 64, 0.55); }
.place--mid { background: var(--bg-3); color: var(--text); }

/* ---------- pagination ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* card titles that sit directly under the page h1 are h2s for correct heading order; keep the compact size */
.map-card__body h2, .room-map-card__body h2, .tool h2, .row > h2 { font-size: 1.25rem; }
