/* === Modal Styles === */

/* =========================================================
   Matchup Research Modal + Info Button
   (added for on-demand matchup enrichment)
   ========================================================= */

/* Place the "i" button without affecting row height */
.matchup-name{
  position: relative;
  /*padding-right: 11px; /* room for the i button */
}

/* The "i" button */
.matchup-info-btn{
  position: absolute;
  top: 0px;
  right: 0px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(180,180,180,0.35);
  background: rgb(40 40 40 / 65%);
  color: #f3f3f3;
  font-size: 10px;
  line-height: 12px;
  padding: 0;
  cursor: pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.matchup-info-btn:hover{
  background: rgba(255,206,145,0.95);
  border-color: #d99900;
  color: #111;
}
.matchup-info-btn:active{
  transform: scale(0.98);
}

/* Dim background + center modal */
.matchup-modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.60);
  z-index: 5000; /* must beat sticky headers (950/1020 etc) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px; /*was 18px*/
}

/* Modal box */
.matchup-modal{
  width: min(860px, 96vw);
  max-height: min(720px, 92dvh);
  background: rgb(16,16,18);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  overflow: hidden;
  position: relative;
  color: #f3f3f3;

  /* Key fix: make modal a column layout so only body scrolls */
  display: flex;
  flex-direction: column;
}

/* Close button */
.matchup-modal-close{
  position:absolute;
  top: 4px;
  right: 4px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(30,30,32,0.95);
  cursor:pointer;
  font-size: 18px;
  line-height: 28px;
  padding: 0;
  color: #f3f3f3;
}
.matchup-modal-close:hover{
  background: rgba(255,206,145,0.95);
  border-color: #d99900;
  color: #111;
}

/* Header */
.matchup-modal-header{
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.matchup-modal-title{
  font-size: 16px;
  font-weight: 700;
  color: #f3f3f3;
}

.matchup-modal-event-meta{
  margin-top: 6px;
}

.mr-event-line{
  font-size: 11px;
  line-height: 1.25;
  color: rgba(243,243,243,0.82);
}

.mr-event-headline{
  font-weight: 700;
  color: rgba(255,206,145,0.95);
}

/* Tabs */
.matchup-modal-tabs{
  display:flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.matchup-modal-tab{
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(30,30,32,0.9);
  cursor:pointer;
  font-size: 12px;
  font-weight: 600;
  color: #f3f3f3;
}
.matchup-modal-tab.is-active{
  background: rgba(255,206,145,0.95);
  color: #111;
  border-color: #d99900;
}

/* Body + panels */
.matchup-modal-body{
  padding: 12px 14px 28px; /* extra bottom padding */
  /*padding: 12px 88px 28px;*/
  overflow: auto;

  /* Key fix: let flex control height; avoid calc() issues on mobile */
  max-height: none;
  flex: 1 1 auto;
  min-height: 0; /* IMPORTANT: allows inner scrolling on mobile flex */

  /* iOS scroll behavior */
  -webkit-overflow-scrolling: touch;
}
.matchup-modal-panel{
  font-size: 11px;
}

/* Prevent background scroll when modal is open */
body.modal-open{
  overflow: hidden;
}

/* ---------- Matchup Research table layout ---------- */
.mr-grid-2{
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.mr-last10-card .mr-table thead th:nth-child(2){
  text-align: center;
}
.mr-last10-card .mr-table tbody td:nth-child(2){
  text-align: left;
}

.mr-record{
  opacity: 0.85;
  font-weight: 700;
  margin-left: 4px;
}

@media (max-width: 760px){
  .mr-grid-2{
    grid-template-columns: 1fr;
  }
}

.mr-card{
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  margin-bottom: 10px;

  /* allow scroll only if needed */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.mr-card-title{
  padding: 10px 10px 6px 10px;
  font-size: 13px;
  font-weight: 800;
  color: #f3f3f3;
}

.mr-subtitle{
  padding: 0 10px 10px 10px;
  font-size: 13px;
  color: rgba(243,243,243,0.85);
}

.mr-table{
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.mr-table thead th{
  text-align: center;
  padding: 8px 10px;
  border-top: 1px solid rgba(255,255,255,0.10);
  border-bottom: 1px solid rgba(255,255,255,0.10);
  color: rgba(243,243,243,0.85);
  font-weight: 700;
  background: rgba(255,255,255,0.06);
}
.mr-table tbody td{
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #f3f3f3;
}
.mr-table tbody tr:hover{
  background: rgb(0 231 255 / 12%);
}

.mr-win{
  font-weight: 800;
  color: #7CFF8D;
}
.mr-loss{
  font-weight: 800;
  color: #FF7C7C;
}

.mr-table tbody td.mr-win{
  color: #7CFF8D;
  font-weight: 800;
}
.mr-table tbody td.mr-loss{
  color: #FF7C7C;
  font-weight: 800;
}

/* ---------- H2H layout ---------- */
.mr-h2h-list{
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mr-h2h-game{
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px minmax(0, 1fr);
  gap: 2px;
  align-items: center;
  padding: 8px 2px;  /* was 10px 12px */
  border-top: 1px solid rgba(255,255,255,0.08);

  max-width: 820px;
  margin: 0 auto;
}

.mr-h2h-side{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  width: 100%;
  justify-content: space-between;
}

.mr-h2h-left{
  justify-content: space-between;
}

.mr-h2h-right{
  justify-content: space-between;
  text-align: right;
}

/* Force symmetry regardless of DOM order */
.mr-h2h-left .mr-h2h-team{ order: 0; }
.mr-h2h-left .mr-h2h-score{ order: 1; }

.mr-h2h-right .mr-h2h-score{ order: 0; }  /* inner edge */
.mr-h2h-right .mr-h2h-team{ order: 1; }   /* far right */
.mr-h2h-score{
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
  min-width: 36px;
  flex: 0 0 auto;
  text-align: center;
}

.mr-h2h-team{
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

/* Desktop: push team blocks to outer edges (fixes right-side "hug") */
@media (min-width: 521px){
  .mr-h2h-left .mr-h2h-team{
    justify-content: flex-start;
  }

  .mr-h2h-right .mr-h2h-team{
    justify-content: flex-end;
  }
}

@media (max-width: 520px){
  /* Stack logo above name and center (prevents "Camels" cutoff) */
  .mr-h2h-team{
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }

  /* Home side: keep logo above name even though DOM is name then logo */
  .mr-h2h-right .mr-h2h-team{
    flex-direction: column-reverse;
  }

  .mr-h2h-team img.mr-team-logo{
    margin-right: 0;
  }

  .mr-h2h-team span{
    text-align: center;
    line-height: 1.05;
    max-width: 100%;

    white-space: nowrap;          /* prevents "He" / "at" */
    overflow-wrap: normal;
    word-break: keep-all;
    font-size: 11px;
    /*font-size: clamp(10px, 2.4vw, 11px);  /* slight auto-shrink */
  }

  /* Pull scores inward + keep separation from names */
  .mr-h2h-side{
    justify-content: space-between;
    gap: 8px;
  }

  .mr-h2h-left .mr-h2h-score,
  .mr-h2h-right .mr-h2h-score{
    margin: 0 4px;
  }
}

.mr-h2h-meta{
  text-align: center;
  opacity: 0.9;
}

.mr-h2h-meta-line{
  font-weight: 700;
  font-size: 11px;
}

.mr-h2h-meta-sub{
  font-size: 10.5px;
  opacity: 0.8;
  margin-top: 2px;
}

.mr-h2h-empty{
  padding: 10px 0;
  opacity: 0.85;
  text-align: center;
}

.mr-h2h-winner{
  background: none;
  border-radius: 0;
  padding: 0;
}

.mr-h2h-winner .mr-h2h-score,
.mr-h2h-winner .mr-h2h-team{
  font-weight: 800;
  text-shadow: 0 0 10px rgba(255,206,145,0.18);
}

.mr-h2h-loser{
  opacity: 0.72;
}

.mr-team-logo,
.mr-opp-logo{
  box-shadow: 0 0 6px rgba(255,255,255,0.18);
  background: rgb(0 0 0 / 0%);
  border-radius: 999px;
  filter: brightness(1.5) drop-shadow(rgba(255, 255, 255, 0.5) 0px 0px 1px);
}

.mr-team-logo{
  width: 18px;
  height: 18px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 2px;
  flex: 0 0 auto;
}

.mr-title-line{
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* H2H only: allow team names to wrap */
.mr-h2h-team .mr-title-line{
  display: inline;
}

.mr-at{
  opacity: 0.85;
  margin: 0 10px;
}


/* Last10 opponent cell: loc + logo + name */
.mr-opp-cell{
  white-space: nowrap;
}
.mr-opp-loc{
  display: inline-block;
  min-width: 18px;
  opacity: 0.85;
}
.mr-opp-logo{
  width: 14px;
  height: 14px;
  margin: 0 1px 0 1px;
  vertical-align: -2px;
}
.mr-opp-name{
  white-space: nowrap;
  line-height: 1.1;
}

@media (max-width: 520px){

  /* Keep last two columns (W/L + Score) visible */
  .mr-table thead th:last-child,
  .mr-table tbody td:last-child{
    white-space: nowrap;
    width: 1%;
  }

  .mr-table thead th:nth-last-child(2),
  .mr-table tbody td:nth-last-child(2){
    white-space: nowrap;
    width: 1%;
  }

  .matchup-modal{
    width: 96vw;

    /* Key fix for mobile browser UI bars (prevents cutoff) */
    max-height: 92dvh;
  }

  .matchup-modal-body{
    padding: 10px 10px 22px 10px;
  }

  .mr-grid-2{
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .mr-opp-name{
    font-size: 11px;
  }

  .mr-table{
    font-size: 11px;
  }

  .mr-table thead th{
    padding: 6px 8px;
  }

  .mr-table tbody td{
    padding: 6px 8px;
  }

  /* H2H: mobile portrait stability */
  .mr-h2h-game{
    grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr);
    padding: 8px 2px;
    /*padding: 8px 10px; was this originally - reduced to allow room for team names*/

  }

  .mr-h2h-side{
    gap: 6px;
  }

  .mr-h2h-score{
    font-size: 14px;
    min-width: 20px;
  }

  .mr-h2h-team{
    font-size: 11px;
    line-height: 1.1;
  }

  .mr-h2h-team .mr-title-line{
    display: inline; /* allow wrapping */
  }

  /* Give the title room so it never sits under the close button */
  .matchup-modal-header{
    padding-right: 48px; /* close button is ~30px wide + breathing room */
  }

  /* Tighten the title row (logos + names) on mobile */
  .matchup-modal-title{
    font-size: 13px;
    line-height: 1.15;
  }

  .mr-event-line{
    font-size: 10.5px;
    line-height: 1.2;
  }

  /* If your title line uses these helpers, tighten them */
  .mr-title-line{
    gap: 2px;            /* was larger; reduces logo/name spacing */
  }

  .mr-team-logo{
    width: 16px;
    height: 16px;
  }

  /* H2H meta: put "@ Team" on its own line on small screens */
  .mr-h2h-meta-line{
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.05;
    font-size: 11px;
  }

  .mr-h2h-meta-line .mr-at{
    display: block;
    margin: 0;
    font-size: 10.5px;
  }
}
@media (max-width: 420px){
  .matchup-modal{
    width: 98vw;
    max-height: 94dvh;
    border-radius: 12px;
  }

  .matchup-modal-body{
    padding: 10px 10px 18px 10px;
    max-height: calc(94dvh - 110px);
  }
}
