/* ═══════════════════════════════════════════════════════════
   Match Stats Modal
   ═══════════════════════════════════════════════════════════ */

.ms-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  background: var(--bg-overlay, rgba(0,0,0,0.6));
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: msFadeIn 0.2s ease-out;
}

.ms-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border-dark);
  border-radius: 16px;
  width: 92%;
  max-width: 460px;
  height: 75vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
  box-shadow: 0 16px 48px var(--black-50, rgba(0,0,0,0.4));
  animation: msScaleIn 0.25s ease-out;
}

@media (max-width: 768px) {
  .ms-overlay { align-items: flex-end; }
  .ms-modal {
    margin: 0px 3px;
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    height: 80vh;
    animation: msSlideUp 0.3s ease-out;
  }
}

/* ─── Toolbar ─── */
.ms-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 16px 16px 0 0;
  background: var(--bg-elevated);
  /* border-bottom: 1px solid var(--border-dark); */
}

.ms-toolbar-league {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1;
}

.ms-league-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 2px;
}

.ms-league-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
  font-family: 'Proxima Nova Cond', sans-serif;
  text-transform: uppercase;
}

.ms-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ms-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(239,68,68,0.15);
  background: var(--red-bg, rgba(239,68,68,0.15));
  color: #ef4444;
  color: var(--red, #ef4444);
  cursor: pointer;
  transition: opacity 0.15s;
}
@media (hover: hover) {
  .ms-close-btn:hover { opacity: 0.8; }
}

.ms-bet-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 16px;
  border-radius: 8px;
  border: none;
  background: #22c55e;
  background: var(--accent-green, #22c55e);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: opacity 0.15s;
}
@media (hover: hover) {
  .ms-bet-btn:hover { opacity: 0.85; }
}

/* ─── Header ─── */
.ms-header {
  flex-shrink: 0;
  background: var(--bg-elevated);
  padding: 4px 3px 12px;
  border-bottom: 1px solid var(--border-dark);
}

.ms-teams {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  padding: 0 24px;
}

.ms-team {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1 1;
  min-width: 0;
}

.ms-serve-icon {
  position: absolute;
  top: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}
.ms-team-home .ms-serve-icon {
  right: -18px;
}
.ms-team-away .ms-serve-icon {
  left: -18px;
}

.ms-team-name-wrap {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  max-width: 140px;
  min-width: 0;
}

.ms-team-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'Proxima Nova Cond', sans-serif;
  text-align: center;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.ms-score-block {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 120px;
}

.ms-match-status {
  font-size: 10px;
  font-weight: 500;
  color: #ef4444;
  color: var(--red, #ef4444);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 16px;
  white-space: nowrap;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

/* Force all timer children to inherit red color */
.ms-match-status span,
.ms-match-status .ms-timer,
.ms-match-status .card-timer,
.ms-match-status .basketball-timer,
.ms-match-status .hockey-timer {
  color: #ef4444 !important;
  color: var(--red, #ef4444) !important;
}

.ms-tennis-points {
  display: flex;
  align-items: center;
  justify-content: center;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.ms-tp-val {
  min-width: 30px;
  font-size: 13px;
  font-weight: 600;
  color: #f7be0f;
}
.ms-tp-val:first-child {
  text-align: right;
}
.ms-tp-val:last-child {
  text-align: left;
}
.ms-tp-sep {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  font-size: 13px;
  color: #f7be0f;
  opacity: 0.6;
}

.ms-match-date {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  margin-bottom: 4px;
}

.ms-team-icon-wrap {
  background: #fff;
  border-radius: 10px;
  padding: 5px;
  border: 1px solid var(--white-10);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ms-main-score {
  font-family: 'Oswald', sans-serif;
  font-size: 36px;
  font-weight: 600;
  color: var(--text-primary);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ms-score-val {
  min-width: 30px;
}
.ms-score-home {
  text-align: right;
}
.ms-score-away {
  text-align: left;
}
.ms-score-sep {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}
.ms-main-score-tennis {
  line-height: 1;
}

.ms-main-score .score-flash {
  animation: ms-score-flash 1.2s ease-out;
}

@keyframes ms-score-flash {
  0% { opacity: 0; color: #fff; text-shadow: 0 0 20px #fff, 0 0 40px var(--accent); }
  12% { opacity: 1; }
  22% { opacity: 0; }
  34% { opacity: 1; color: var(--accent); text-shadow: 0 0 12px var(--accent); }
  46% { opacity: 0.15; }
  58% { opacity: 1; color: #fff; text-shadow: 0 0 8px var(--accent); }
  72% { opacity: 0.3; }
  85% { opacity: 1; }
  100% { opacity: 1; color: var(--text-primary); text-shadow: none; }
}

/* Red card badge */
.ms-red-card {
  background: #ef4444;
  background: var(--color-live, #ef4444);
  color: #fff;
  font-size: 9px;
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 700;
  margin-left: 4px;
  flex-shrink: 0;
  vertical-align: middle;
}

/* VAR badge */
.ms-var-badge {
  background: #ef4444;
  background: var(--color-live, #ef4444);
  color: #fff !important;
  font-size: 8px;
  padding: 1px 4px;
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.ms-timer {
  display: flex;
  gap: 5px;
  align-items: center;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

/* Period scores — separate row below teams */
.ms-period-scores {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
}

.ms-period-badge {
  font-family: 'Oswald', sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary);
  background: var(--white-10);
  padding: 1px 5px;
  border-radius: 2px;
  letter-spacing: 0.5px;
}

/* ─── Period Tabs ─── */
.ms-tabs {
  display: flex;
  gap: 0;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-shrink: 0;
}
.ms-tabs::-webkit-scrollbar { display: none; }

.ms-tab {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ms-tab-active {
  color: #4a9eff;
  color: var(--accent-blue, #4a9eff);
  border-bottom-color: #4a9eff;
  border-bottom-color: var(--accent-blue, #4a9eff);
}

@media (hover: hover) {
  .ms-tab:not(.ms-tab-active):hover {
    color: var(--text-secondary);
  }
}

/* ─── Body ─── */
.ms-body {
  padding: 12px 16px 20px;
  flex: 1 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--white-10) transparent;
}

.ms-loading {
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

.ms-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--white-10);
  border-top-color: #4a9eff;
  border-top-color: var(--accent-blue, #4a9eff);
  border-radius: 50%;
  animation: msSpin 0.7s linear infinite;
}

.ms-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
}
.ms-empty-icon {
  color: var(--text-quaternary);
  opacity: 0.5;
}
.ms-empty-text {
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ─── Baseball BSO ─── */
.ms-baseball-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 48px 20px;
}
.ms-bso {
  display: flex;
  align-items: center;
  gap: 24px;
}
.ms-bso-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ms-bso-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
}
.ms-bso-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ─── Stats ─── */
.ms-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ms-stat-item {
  border-radius: 6px;
}

.ms-stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px;
}

.ms-stat-value {
  font-family: 'Oswald', sans-serif;
  font-size: 16px;
  font-weight: 500;
  min-width: 30px;
  text-align: center;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.ms-stat-value.ms-home {
  color: #4a9eff;
  color: var(--accent-blue, #4a9eff);
}

.ms-stat-value.ms-away {
  color: #ff6b6b;
  color: var(--accent-red, #ff6b6b);
}

.ms-stat-bar-wrap {
  flex: 1 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ms-stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ms-stat-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  gap: 2px;
}

.ms-bar-home {
  background: #4a9eff;
  background: var(--accent-blue, #4a9eff);
  border-radius: 3px;
  min-width: 4px;
  transition: width 0.4s ease-out;
}

.ms-bar-away {
  background: #ff6b6b;
  background: var(--accent-red, #ff6b6b);
  border-radius: 3px;
  min-width: 4px;
  transition: width 0.4s ease-out;
}

/* ─── Animations ─── */
@keyframes msFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes msScaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes msSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes msSpin {
  to { transform: rotate(360deg); }
}

