/* Replay page follows the same layout system as /player and /gifs */

.replay-page-main{
  max-width: 1200px;
  margin: 22px auto 32px;
  padding: 0 14px;
}

.replay-page{
  min-width: 0;
}

.replay-page-head{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.replay-head-left{
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.replay-back{
  width: fit-content;
}

.replay-title-row{
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.replay-title{
  margin: 0;
  font-size: var(--fz-sec);
  letter-spacing: -0.2px;
}

.replay-meta{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.replay-meta-item{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.replay-meta-item i{
  color: var(--muted2);
}

.replay-speed{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.replay-speed-label{
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}

.replay-speed-select{
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.replay-status{
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.replay-status:empty{
  display: none;
}

.replay-layout{
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.replay-player,
.replay-side{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}

.replay-player-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.replay-player-foot{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: nowrap;
}

.replay-timeline{
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  flex: 1 1 auto;
  min-width: 180px;
}

/* Compact controls: keep the strip clean and modern */
.replay-player-foot #btn-play span{
  display: none;
}

.replay-player-foot .replay-speed{
  padding: 6px 8px;
}

.replay-player-foot .replay-speed-label{
  display: none;
}

.replay-player-foot .replay-speed-select{
  height: 34px;
  min-width: 74px;
}

.replay-player-foot .replay-status{
  flex: 0 0 auto;
  white-space: nowrap;
}

.replay-time{
  font-size: 12px;
  font-weight: 900;
  color: var(--muted);
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.replay-seek{
  flex: 1 1 auto;
  width: 100%;
  height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}

.replay-zoom{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.replay-player-frame{
  aspect-ratio: 16 / 9;
  width: 100%;
  position: relative;
}

/* ===== In-player HUD (score + match clock) ==================== */
.replay-hud{
  position:absolute;
  left:10px;
  right:10px;
  top:10px;
  z-index: 5;
  pointer-events:none;
  display:flex;
  align-items:center;
  justify-content:center;
}

.replay-hud-score{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding: 8px 12px;
  border-radius: 12px;
  border:1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.replay-hud-dot{
  width:10px;
  height:10px;
  border-radius: 3px;
  background: var(--muted2);
}

.replay-hud-dot--red{ background: var(--hot); }
.replay-hud-dot--blue{ background: var(--cool); }

.replay-hud-num{
  min-width: 14px;
  text-align:center;
}

.replay-hud-sep{ color: var(--muted); font-weight: 900; }

.replay-hud-clock{
  position:absolute;
  right: 0;
  display:inline-flex;
  align-items:center;
  padding: 8px 10px;
  border-radius: 12px;
  border:1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

#replay-canvas{
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: optimizeSpeed;
  image-rendering: crisp-edges;
  image-rendering: -moz-crisp-edges;
  image-rendering: -o-crisp-edges;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
}

.replay-side{
  display: flex;
  flex-direction: column;
}

.replay-side-head{
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.replay-side-head h2{
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.2px;
}

.replay-events-filters{
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 100%;
}

.replay-filter-types{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-items: stretch;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  width: 100%;
}

.replay-filter-chip{
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: relative;
  width: 100%;
}

.replay-filter-check{
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.replay-filter-chip > span{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  transition: filter 120ms ease, background 120ms ease, border-color 120ms ease, color 120ms ease;
  width: 100%;
  justify-content: flex-start;
}

/* Small indicator on the left (acts like a premium check) */
.replay-filter-chip > span::before{
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.replay-filter-check:checked + span{
  color: var(--ink);
  border-color: var(--gold);
  background: var(--panel);
}

.replay-filter-check:checked + span::before{
  border-color: var(--gold);
  background: var(--gold);
}

.replay-filter-chip:hover > span{
  filter: brightness(1.03);
}

.replay-filter-check:focus-visible + span{
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.replay-filter-chip:hover{
  filter: brightness(1.02);
}

.replay-filter-select{
  height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  max-width: none;
}

.replay-events{
  padding: 12px 14px;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 12px;
  color: var(--ink);
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

/* Keep event cards nicely spaced */
#replay-events-log{
  display:flex;
  flex-direction:column;
  gap:0px;
}

.replay-event{
  padding: 3px 0;
  white-space: pre-wrap;
  color: var(--muted);
  font-weight: 700;
}

.replay-event--plain{
  padding: 3px 0;
}

.replay-event--rich{
  display:flex;
  align-items:center;
  gap:6px;
  padding:4px 0;
  border:none;
  border-bottom:1px solid var(--line);
  background:transparent;
  border-radius:0;
  white-space: normal;
  cursor:default;
  user-select:none;
}

.replay-event--rich:last-child{
  border-bottom:none;
}



.replay-event-time{
  font-weight:900;
  font-size:10px;
  color:var(--muted);
  font-variant-numeric: tabular-nums;
  padding:2px 6px;
  border-radius:999px;
  border:1px solid var(--line);
  background:var(--panel);
  flex:0 0 auto;
}

.replay-event-main{
  min-width:0;
  flex:1 1 auto;
  display:flex;
  flex-direction:row;
  align-items:center;
  gap:6px;
  flex-wrap:nowrap;
}

.replay-event-top{
  display:flex;
  align-items:center;
  gap:6px;
  min-width:0;
  flex:1 1 auto;
  overflow:hidden;
}

.replay-event-chip{
  font-weight:900;
  font-size:9px;
  letter-spacing:.2px;
  padding:3px 7px;
  border-radius:999px;
  border:1px solid var(--line);
  background:var(--panel);
  color:var(--ink);
  flex:0 0 auto;
}

.replay-event-title{
  font-weight:900;
  font-size:11px;
  color:var(--ink);
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.replay-event-sub{
  display:inline-flex;
  align-items:center;
  flex-wrap:nowrap;
  gap:4px;
  color:var(--muted);
  font-size:10px;
  min-width:0;
  max-width:45%;
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
}

.replay-event-context{
  /* Context sentences tend to break layout; keep them out of the inline view. */
  display:none;
}

.replay-event-pill{
  font-weight:900;
  font-size:9px;
  color:var(--muted);
  border:1px solid var(--line);
  background:var(--panel);
  border-radius:999px;
  padding:2px 7px;
  font-variant-numeric: tabular-nums;
  flex:0 0 auto;
}

/* Keep the inline layout calm: de-emphasize details unless hovered/focused */
.replay-event--rich .replay-event-sub{
  opacity:0.92;
}
.replay-event--rich:hover .replay-event-sub,
.replay-event--rich:focus-visible .replay-event-sub{
  opacity:1;
}

/* Type accents (use existing theme tokens only) */
.replay-event[data-kind="goal"] .replay-event-chip{ border-color: var(--ok); }
.replay-event[data-kind="owngoal"] .replay-event-chip{ border-color: var(--gold); }
.replay-event[data-kind="error"] .replay-event-chip{ border-color: var(--hot); }
.replay-event[data-kind="shot"] .replay-event-chip{ border-color: var(--cool); }
.replay-event[data-kind="save"] .replay-event-chip{ border-color: var(--cool); }
.replay-event[data-kind="interception"] .replay-event-chip{ border-color: var(--gold); }
.replay-event[data-kind="pass-good"] .replay-event-chip{ border-color: var(--ok); }
.replay-event[data-kind="pass-bad"] .replay-event-chip{ border-color: var(--gold); }
.replay-event[data-kind="control-good"] .replay-event-chip{ border-color: var(--ok); }
.replay-event[data-kind="control-bad"] .replay-event-chip{ border-color: var(--hot); }

.replay-side-hint{
  padding: 10px 14px 14px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

/* ===== Players overlay (ESC) ================================== */

.replay-players-overlay{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  background:rgba(255,255,255,.55);
  backdrop-filter:saturate(140%) blur(8px);
  z-index:5;
}

.replay-players-panel{
  width:min(760px, 100%);
  max-height:100%;
  overflow:auto;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}

.replay-players-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border-bottom:1px solid var(--line);
}

.replay-players-title{
  font-weight:900;
  font-size:14px;
  letter-spacing:.2px;
}

.replay-players-hint{
  font-weight:900;
  font-size:11px;
  color:var(--muted);
  border:1px solid var(--line);
  background:var(--panel2);
  border-radius:10px;
  padding:6px 10px;
}

.replay-players-body{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:8px;
  padding:10px 12px 12px;
}

@media (max-width: 720px){
  .replay-players-body{
    grid-template-columns: 1fr;
  }
}

.replay-players-team{
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
  background:var(--panel2);
}

.replay-players-team-title{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  font-weight:900;
  font-size:12px;
  border-bottom:1px solid var(--line);
  background:var(--panel);
}

.replay-players-badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
}

.replay-players-dot{
  width:10px;
  height:10px;
  border-radius:999px;
  background:var(--muted2);
}

.replay-players-team--red .replay-players-dot{ background:var(--hot); }
.replay-players-team--blue .replay-players-dot{ background:var(--cool); }

.replay-players-list{
  display:flex;
  flex-direction:column;
}

.replay-players-row{
  display:grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-bottom:1px solid var(--line);
}

.replay-players-row:last-child{
  border-bottom:none;
}

.replay-players-left{
  display:flex;
  align-items:center;
  gap:8px;
}

.replay-players-avatar{
  width:22px;
  height:22px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--line);
  background:var(--panel);
  font-weight:900;
  font-size:11px;
  color:var(--ink);
  flex:0 0 auto;
}

.replay-players-flag{
  width:16px;
  height:16px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:11px;
  line-height:1;
  flex:0 0 auto;
  font-weight:900;
  color:var(--muted2);
  letter-spacing:.2px;
  text-transform:uppercase;
}

.replay-players-main{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
}

.replay-players-admin{
  width:18px;
  height:18px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:11px;
  font-weight:900;
  color:var(--gold);
  border:1px solid var(--line);
  background:var(--panel);
  flex:0 0 auto;
}

.replay-players-right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
}

.replay-players-ping{
  display:flex;
  align-items:flex-end;
  gap:2px;
  height:14px;
}

.replay-players-pbar{
  width:3px;
  border-radius:3px;
  background:var(--line);
}

.replay-players-pbar.on{ background:var(--ok); }
.replay-players-pbar.warn{ background:var(--gold); }
.replay-players-pbar.bad{ background:var(--hot); }

.replay-players-pms{
  font-weight:900;
  font-size:10px;
  color:var(--muted);
  font-variant-numeric: tabular-nums;
  min-width:28px;
  text-align:right;
}

.replay-players-name{
  font-weight:800;
  font-size:12px;
  color:var(--ink);
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.replay-code{
  font-weight: 900;
  color: var(--ink);
}

@media (max-width: 1024px){
  .replay-layout{
    grid-template-columns: 1fr;
  }

  /* In single-column layout the side panel is below the player, so cap the log height. */
  .replay-events{
    max-height: 60vh;
  }
}

@media (max-width: 520px){
  .replay-player-actions{
    width: 100%;
    flex-wrap: wrap;
  }

  .replay-timeline{
    width: 100%;
    min-width: 0;
  }

  .replay-player-foot{
    padding: 10px 10px 12px;
    flex-wrap: wrap;
  }

  .replay-speed{
    width: 100%;
    justify-content: space-between;
  }

  .replay-zoom{
    margin-left: auto;
  }

  .replay-status{
    width: 100%;
    justify-content: center;
  }
}
