/* ══════════════════════════════════════════════
   VALORANT MATCH HISTORY CARDS
══════════════════════════════════════════════ */

.val-matches {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.val-match {
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s, transform .15s;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
}
.val-match:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.val-match.win:hover  { border-color: rgba(59,165,92,.4);  box-shadow: 0 0 14px rgba(59,165,92,.12),  0 0 28px rgba(59,165,92,.06); }
.val-match.loss:hover { border-color: rgba(237,66,69,.4);  box-shadow: 0 0 14px rgba(237,66,69,.12), 0 0 28px rgba(237,66,69,.06); }

/* Expand icon hint */
.val-match-expand {
  position: absolute; top: 6px; right: 6px;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.val-match-expand svg { width: 10px; height: 10px; color: rgba(255,255,255,.35); }
.val-match:hover .val-match-expand { opacity: 1; }

.val-match-inner {
  display: flex; align-items: center; gap: 10px;
  padding: .55rem .75rem;
  position: relative;
}
.val-match.win  .val-match-inner { background: rgba(59,165,92,.07); }
.val-match.loss .val-match-inner { background: rgba(237,66,69,.07); }

.val-wl { font-size: .62rem; font-weight: 800; letter-spacing: .08em; width: 22px; text-align: center; flex-shrink: 0; font-family: 'DM Mono', monospace; }
.val-match.win  .val-wl { color: #3ba55c; }
.val-match.loss .val-wl { color: #ed4245; }

.val-agent-wrap { position: relative; flex-shrink: 0; }
.val-agent { width: 36px; height: 36px; border-radius: 7px; object-fit: cover; background: rgba(255,255,255,.05); display: block; }
.val-agent-fallback { width: 36px; height: 36px; border-radius: 7px; background: rgba(255,255,255,.06); display: flex; align-items: center; justify-content: center; font-size: 16px; }

.val-info  { flex: 1; min-width: 0; }
.val-map   { font-size: .78rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.val-mode  { font-size: .62rem; color: var(--muted); font-family: 'DM Mono', monospace; margin-top: 1px; }
.val-date  { color: var(--muted2); font-size: .62rem; }

.val-stats { display: flex; gap: 10px; align-items: center; flex-shrink: 0; text-align: right; }
.val-stat  { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.val-stat-val { font-size: .78rem; font-weight: 700; font-family: 'DM Mono', monospace; color: var(--text); }
.val-stat-lbl { font-size: .56rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.val-kd  .val-stat-val { font-size: .92rem; color: #fff; }
.val-kda .val-stat-val { color: #c8b4ff; }
.val-hs  .val-stat-val { color: #f5c842; }

/* Badges */
.val-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.val-badge  { font-size: .56rem; font-weight: 700; letter-spacing: .07em; font-family: 'DM Mono', monospace; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; }
.badge-kast   { background: rgba(88,101,242,.2);  color: #8a93f8; border: 1px solid rgba(88,101,242,.25); }
.badge-ace    { background: rgba(255,215,0,.15);  color: #ffd700; border: 1px solid rgba(255,215,0,.3); }
.badge-4k     { background: rgba(245,200,66,.12); color: #f5c842; border: 1px solid rgba(245,200,66,.25); }
.badge-clutch { background: rgba(237,66,69,.15);  color: #f47a7c; border: 1px solid rgba(237,66,69,.25); }

/* Loading / error states */
.val-loading {
  text-align: center; padding: .9rem;
  font-size: .72rem; color: var(--muted); font-family: 'DM Mono', monospace;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  grid-column: 1 / -1;
}
.val-spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.1);
  border-top-color: rgba(255,255,255,.4);
  animation: spin .7s linear infinite;
}
.val-error {
  text-align: center; padding: .7rem;
  font-size: .7rem; color: #ed4245; font-family: 'DM Mono', monospace;
  background: rgba(237,66,69,.07); border-radius: 8px;
  grid-column: 1 / -1;
}

/* ══════════════════════════════════════════════
   MATCH THEATER OVERLAY
══════════════════════════════════════════════ */

#match-theater-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  visibility: hidden;
  transition: background .3s ease, visibility 0s .3s;
}
#match-theater-overlay.open {
  visibility: visible;
  transition: background .3s ease, visibility 0s 0s;
  background: rgba(0,0,0,.92);
  pointer-events: all;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.match-theater-box {
  position: relative;
  width: min(980px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: rgba(10,10,10,.97);
  border: 1px solid rgba(138,147,248,.22);
  border-radius: 18px;
  box-shadow:
    0 0 0 1px rgba(138,147,248,.08),
    0 0 40px rgba(138,147,248,.12),
    0 0 80px rgba(0,0,0,.8);
  opacity: 0;
  transform: scale(.94) translateY(20px);
  transition: opacity .3s cubic-bezier(.16,1,.3,1), transform .3s cubic-bezier(.16,1,.3,1);
  pointer-events: none;
  overflow: hidden;
}
#match-theater-overlay.open .match-theater-box {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* ── Theater header bar ── */
.mt-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 1.1rem 1.4rem .9rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}
.mt-header::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(138,147,248,.5), transparent);
}

.mt-agent-portrait {
  width: 58px; height: 58px;
  border-radius: 10px;
  object-fit: cover;
  background: rgba(255,255,255,.06);
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.mt-agent-portrait-fallback {
  width: 58px; height: 58px;
  border-radius: 10px;
  background: rgba(255,255,255,.06);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}

.mt-header-info { flex: 1; min-width: 0; }
.mt-map-name    { font-size: 1.1rem; font-weight: 800; letter-spacing: -.4px; }
.mt-meta        { font-size: .68rem; color: var(--muted); font-family: 'DM Mono', monospace; margin-top: 3px; }

.mt-wl-badge {
  font-size: .75rem; font-weight: 800; letter-spacing: .08em;
  font-family: 'DM Mono', monospace;
  padding: 4px 12px;
  border-radius: 7px;
  flex-shrink: 0;
}
.mt-wl-badge.win  { background: rgba(59,165,92,.15);  color: #3ba55c; border: 1px solid rgba(59,165,92,.3); }
.mt-wl-badge.loss { background: rgba(237,66,69,.15); color: #ed4245; border: 1px solid rgba(237,66,69,.3); }

.mt-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text);
  transition: background .15s, border-color .15s, box-shadow .15s;
  flex-shrink: 0;
}
.mt-close:hover { background: rgba(237,66,69,.15); border-color: rgba(237,66,69,.4); box-shadow: 0 0 10px rgba(237,66,69,.2); }
.mt-close svg   { width: 14px; height: 14px; }

/* ── Your stats bar ── */
.mt-my-stats {
  display: flex;
  align-items: center;
  gap: 0;
  padding: .75rem 1.4rem;
  background: rgba(138,147,248,.04);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.mt-stat-block {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 0 1rem;
  border-right: 1px solid var(--border);
}
.mt-stat-block:first-child { padding-left: 0; }
.mt-stat-block:last-child  { border-right: none; }
.mt-stat-val { font-size: .95rem; font-weight: 800; font-family: 'DM Mono', monospace; color: var(--text); }
.mt-stat-lbl { font-size: .55rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.mt-stat-block.kd   .mt-stat-val { color: #fff; }
.mt-stat-block.kda  .mt-stat-val { color: #c8b4ff; }
.mt-stat-block.hs   .mt-stat-val { color: #f5c842; }
.mt-stat-block.acs  .mt-stat-val { color: #7dd4fc; }
.mt-badges-inline { display: flex; flex-wrap: wrap; gap: 5px; padding-left: 1rem; }

/* ── Round timeline ── */
.mt-rounds-section {
  padding: .7rem 1.4rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mt-rounds-label {
  font-size: .58rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  font-family: 'DM Mono', monospace;
  margin-bottom: 6px;
}
.mt-rounds-scroll {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.mt-rounds-scroll::-webkit-scrollbar { height: 3px; }
.mt-rounds-scroll::-webkit-scrollbar-track { background: transparent; }
.mt-rounds-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }
.mt-round-chip {
  flex-shrink: 0;
  width: 24px; height: 28px;
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: .58rem; font-weight: 700; font-family: 'DM Mono', monospace;
  transition: transform .1s;
}
.mt-round-chip:hover { transform: scaleY(1.1); }
.mt-round-chip.rwin  { background: rgba(59,165,92,.25);  color: #3ba55c; }
.mt-round-chip.rloss { background: rgba(237,66,69,.2);  color: #ed4245; }

/* ── Scoreboard ── */
.mt-scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
.mt-scoreboard::-webkit-scrollbar       { width: 4px; }
.mt-scoreboard::-webkit-scrollbar-track { background: transparent; }
.mt-scoreboard::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.mt-team {
  padding: .6rem 1rem .8rem;
  display: flex; flex-direction: column; gap: 4px;
}
.mt-team:first-child { border-right: 1px solid var(--border); }

.mt-team-header {
  font-size: .58rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; font-family: 'DM Mono', monospace;
  padding: 4px 6px; border-radius: 5px;
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 6px;
}
.mt-team-header.team-win  { color: #3ba55c; background: rgba(59,165,92,.1); }
.mt-team-header.team-loss { color: #ed4245; background: rgba(237,66,69,.1); }
.mt-team-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.mt-team-header.team-win  .mt-team-dot { background: #3ba55c; }
.mt-team-header.team-loss .mt-team-dot { background: #ed4245; }

/* Player row */
.mt-player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 8px;
  transition: background .15s;
}
.mt-player-row:hover { background: rgba(255,255,255,.03); }
.mt-player-row.is-me {
  background: rgba(138,147,248,.1);
  border: 1px solid rgba(138,147,248,.2);
  box-shadow: 0 0 10px rgba(138,147,248,.08);
}
.mt-player-row.is-me:hover { background: rgba(138,147,248,.14); }

.mt-player-agent {
  width: 28px; height: 28px;
  border-radius: 6px;
  object-fit: cover;
  background: rgba(255,255,255,.05);
  flex-shrink: 0;
}
.mt-player-agent-fb {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: rgba(255,255,255,.06);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}

.mt-player-info { flex: 1; min-width: 0; }
.mt-player-name {
  font-size: .72rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mt-player-tag  { color: var(--muted); font-weight: 400; }
.mt-player-me-label {
  font-size: .52rem; font-weight: 700; letter-spacing: .07em;
  color: #8a93f8; font-family: 'DM Mono', monospace;
  text-transform: uppercase;
}

.mt-player-rank {
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.mt-player-rank-icon {
  width: 18px; height: 18px;
  object-fit: contain;
}
.mt-player-rank-name {
  font-size: .58rem; color: var(--muted);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
}

.mt-player-kda {
  font-size: .68rem; font-weight: 700;
  font-family: 'DM Mono', monospace;
  color: #c8b4ff;
  flex-shrink: 0;
  text-align: right;
  min-width: 52px;
}
.mt-player-hs {
  font-size: .62rem; font-weight: 600;
  font-family: 'DM Mono', monospace;
  color: #f5c842;
  flex-shrink: 0;
  min-width: 32px;
  text-align: right;
}

/* ── Footer (Tracker.gg button) ── */
.mt-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .8rem 1.4rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(0,0,0,.3);
}
.mt-tracker-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: .5rem 1.2rem;
  background: rgba(91,75,255,.15);
  border: 1px solid rgba(91,75,255,.35);
  border-radius: 9px;
  color: #a090ff;
  font-size: .72rem; font-weight: 700;
  font-family: 'DM Mono', monospace;
  letter-spacing: .04em;
  text-decoration: none;
  cursor: pointer;
  transition: background .2s, border-color .2s, box-shadow .2s, color .2s;
}
.mt-tracker-btn:hover {
  background: rgba(91,75,255,.28);
  border-color: rgba(91,75,255,.6);
  color: #c4b8ff;
  box-shadow: 0 0 18px rgba(91,75,255,.25), 0 0 36px rgba(91,75,255,.1);
}
.mt-tracker-btn svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ── YouTube Theater Overlay ── */
#theater-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  transition: background .3s ease;
}
#theater-overlay.open {
  background: rgba(0,0,0,.88);
  pointer-events: all;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.theater-box {
  position: relative;
  width: min(860px, 92vw);
  opacity: 0; transform: scale(.94) translateY(16px);
  transition: opacity .3s cubic-bezier(.16,1,.3,1), transform .3s cubic-bezier(.16,1,.3,1);
  pointer-events: none;
}
#theater-overlay.open .theater-box { opacity: 1; transform: scale(1) translateY(0); pointer-events: all; }
.theater-frame-wrap {
  position: relative; width: 100%; padding-top: 56.25%;
  border-radius: 14px; overflow: hidden;
  border: 1px solid rgba(255,68,68,.2);
  box-shadow: 0 0 60px rgba(0,0,0,.8), 0 0 30px rgba(255,68,68,.1);
}
.theater-frame-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.theater-close {
  position: absolute; top: -14px; right: -14px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(20,20,20,.95); border: 1px solid rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.theater-close:hover { background: #1a1a1a; border-color: rgba(255,68,68,.4); box-shadow: 0 0 10px rgba(255,68,68,.2); }
.theater-close svg { width: 14px; height: 14px; }
.theater-label {
  margin-top: 10px; text-align: center;
  font-size: .65rem; color: rgba(255,255,255,.3);
  font-family: 'DM Mono', monospace;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}

/* ══════════════════════════════════════════════
   MOBILE MATCH HISTORY — compact cards
══════════════════════════════════════════════ */
@media (max-width: 680px) {
  /* Single column, compact cards */
  .val-matches {
    grid-template-columns: 1fr !important;
  }
  .val-match:last-child:nth-child(odd) {
    grid-column: auto !important;
  }

  /* Tighter inner padding */
  .val-match-inner {
    padding: .45rem .6rem;
    gap: 7px;
  }

  /* Smaller agent icon */
  .val-agent, .val-agent-fallback {
    width: 28px; height: 28px;
    border-radius: 5px;
    font-size: 13px;
  }

  /* Smaller map/mode text */
  .val-map  { font-size: .7rem; }
  .val-mode { font-size: .58rem; }

  /* Compact stats */
  .val-stats { gap: 6px; }
  .val-stat-val { font-size: .7rem; }
  .val-stat-lbl { font-size: .5rem; }
  .val-kd .val-stat-val { font-size: .8rem; }

  /* Smaller badges */
  .val-badge { font-size: .5rem; padding: 1px 5px; }

  /* Fix: ensure match cards are clickable (no invisible overlay blocking) */
  .val-match { cursor: pointer; -webkit-tap-highlight-color: rgba(138,147,248,0.15); }
  .val-match:active { transform: scale(0.98); }

  /* Match theater box — full screen on mobile */
  .match-theater-box {
    width: 100vw !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
  }

  /* Scoreboard stacks on mobile */
  .mt-scoreboard {
    grid-template-columns: 1fr !important;
  }
  .mt-team:first-child {
    border-right: none !important;
    border-bottom: 1px solid var(--border);
  }

  /* Stat bar wraps */
  .mt-my-stats { gap: 0; row-gap: 6px; }
  .mt-stat-block { padding: 0 .6rem; }

  /* Theater val panel padding */
  .val-panel { padding: 1rem !important; }
}
