/* FE: replays (fe-replays.js) in UnforgivaBALLS's highlights style, in Border War's look (the
   site's panels, Border War's green and gold): the Highlights panel on the right beside the
   result card (a vertical frame, its controls under it), and full screen. */

/* While the panel is up the game's canvas is under a still of the field as the game ended (the
   renderer is drawing the frame), and the result card moves left to make room. */
.fe-replay-backdrop { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; pointer-events: none; }
body.bw-replay-up #result { left: calc((100vw - var(--bw-replay-w, 420px)) / 2); max-width: calc(100vw - var(--bw-replay-w, 420px) - 32px); }
body.fe-replay-full #bw-play-wallet, body.fe-replay-full .fe-title-wallet, body.fe-replay-full #network-panel, body.fe-replay-full #volume-controls { visibility: hidden !important; }

/* ---- the panel ---- */
.bw-replay-panel {
  --frame-h: clamp(220px, calc(100dvh - 380px), 620px);
  position: fixed; right: 16px; top: 72px; z-index: 40; max-height: calc(100dvh - 88px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px; width: max-content; max-width: calc(100vw - 32px); padding: 18px; box-sizing: border-box;
  border: var(--fe-panel-edge); border-radius: var(--fe-panel-radius); background: var(--bw-panel); box-shadow: var(--fe-panel-lift);
  color: #fff; font-family: var(--fe-sub); font-weight: 700; text-align: center; animation: bw-replay-in .4s cubic-bezier(.2, 1.4, .4, 1) .08s backwards;
}
@keyframes bw-replay-in { from { opacity: 0; transform: translateX(24px); } }
.fe-replay-heading { margin: 0; font: 400 22px/1 var(--fe-head); letter-spacing: .03em; text-shadow: var(--fe-text-lift); }
.bw-replay-panel:not(.is-playing) .fe-replay-controls { display: none; }
.bw-replay-panel:not(.is-playing) .fe-replay-viewer .fe-replay-frame { height: calc(var(--frame-h) + 150px); }
.bw-replay-panel:not(.is-playing):has(.fe-replay-pre-together:not([hidden])) .fe-replay-viewer .fe-replay-frame { height: calc(var(--frame-h) + 96px); }
.bw-replay-panel.is-playing .fe-replay-pre-together { display: none !important; }
.fe-replay-viewer { width: max(340px, calc((var(--frame-h) + 150px) * 9 / 16)); max-width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.fe-replay-viewer .fe-replay-frame { height: var(--frame-h); }
.fe-replay-pre-together { align-self: stretch; }

.fe-replay-frame { position: relative; aspect-ratio: 9 / 16; flex: none; border-radius: 12px; outline: 3px solid #fff; background: #0f1f1c; overflow: hidden; }
.fe-replay-ink { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.fe-replay-frame.is-saving .fe-replay-ink { opacity: .35; }
.fe-replay-poster { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.fe-replay-frame.is-playing .fe-replay-poster { display: none; }
.fe-replay-poster-text { margin: 0; padding: 4px 12px; border-radius: 999px; background: rgba(6, 16, 14, .6); color: #fff; font-size: .9rem; }

/* Buttons: the result card's (fe-ingame.css), smaller. */
.bw-replay-panel button, .fe-replay-stage button, .fe-replay-invite button {
  min-height: 38px; margin: 0; padding: 0 14px; border: 2px solid #fff; border-radius: 999px; background: var(--bw-fill); color: #fff; box-shadow: var(--fe-lift);
  font: 400 15px/1 var(--fe-head); letter-spacing: .03em; text-shadow: var(--fe-text-lift); white-space: nowrap; cursor: pointer; transition: background .15s, transform .15s;
}
.bw-replay-panel button:hover:not(:disabled), .fe-replay-stage button:hover:not(:disabled), .fe-replay-invite button:hover:not(:disabled) { background: var(--bw-fill-hover); transform: translateY(-1px); }
.bw-replay-panel button.primary, .fe-replay-stage button.primary, .fe-replay-invite button.primary,
.bw-replay-panel .fe-replay-poster-play, .fe-replay-controls .fe-replay-play {
  border: var(--fe-edge); background: var(--bw-gold-fill); color: var(--bw-dark-text); text-shadow: 0 1px 0 rgba(255, 240, 200, .6);
}
.bw-replay-panel button.primary:hover:not(:disabled), .fe-replay-stage button.primary:hover:not(:disabled), .bw-replay-panel .fe-replay-poster-play:hover { background: var(--bw-gold-hover); }
.bw-replay-panel .fe-replay-poster-play { width: 84px; height: 84px; padding: 0; border-radius: 50%; display: grid; place-items: center; box-shadow: var(--fe-lift), 0 6px 30px rgba(6, 16, 14, .55); }
.fe-replay-poster-play svg { width: 42px; height: 42px; margin-left: 5px; fill: currentColor; }

.fe-replay-offer-slot { width: 0; min-width: 100%; }
.bw-replay-panel:has(> .fe-replay-offer-slot:not([hidden])) { --frame-h: clamp(200px, calc(100dvh - 470px), 540px); }
.fe-replay-invite { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: var(--bw-well); }
.fe-replay-invite p { flex-basis: 100%; margin: 0; font: 700 15px/1.3 var(--fe-sub); color: #fff; }
.fe-replay-invite button { min-width: 90px; }
.fe-replay-invite.is-floating {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 70; width: max-content; max-width: calc(100vw - 32px); box-sizing: border-box;
  padding: 12px 16px; border: var(--fe-panel-edge); border-radius: var(--fe-panel-radius); background: var(--bw-panel); box-shadow: var(--fe-panel-lift);
}
.fe-replay-invite.is-floating p { flex-basis: auto; }

/* ---- the controls ---- */
.fe-replay-controls { width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.fe-replay-transport { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fe-replay-time { flex: none; margin-right: auto; color: var(--bw-soft); font: 700 14px/1 var(--fe-sub); font-variant-numeric: tabular-nums; }
.fe-replay-controls .fe-replay-icon { width: 38px; padding: 0; display: grid; place-items: center; flex: none; }
.fe-replay-controls .fe-replay-play { width: 44px; height: 44px; }
.fe-replay-icon svg { width: 20px; height: 20px; fill: currentColor; }
.fe-replay-controls .fe-replay-speed { min-width: 48px; padding: 0 8px; }
.fe-replay-trim { margin: -2px 0 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--bw-soft); font-size: .85rem; }
.fe-replay-trim[hidden] { display: none; }
.fe-replay-controls .fe-replay-whole { min-height: 28px; padding: 0 10px; font-size: 13px; }
.fe-replay-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.fe-replay-row > button { flex: 1 1 auto; }
.bw-replay-panel .fe-replay-together, .fe-replay-stage .fe-replay-together { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.fe-replay-together[hidden] { display: none !important; }
.fe-replay-together svg { width: 18px; height: 18px; fill: currentColor; }
.fe-replay-cams { flex: none; display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--bw-well); }
.fe-replay-controls .fe-replay-cams .fe-replay-cam { min-height: 32px; padding: 0 11px; font-size: 14px; border: 0; background: transparent; box-shadow: none; color: var(--bw-soft); transform: none; }
.fe-replay-controls .fe-replay-cams .fe-replay-cam[aria-pressed="true"] { background: var(--bw-gold-fill); color: var(--bw-dark-text); text-shadow: none; }
.fe-replay-status { margin: 0; color: #fff; font-size: .9rem; text-align: center; }
.fe-replay-status:empty { display: none; }
.fe-replay-note { margin: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; color: var(--bw-soft); font-size: .9rem; text-align: center; }
.fe-replay-note[hidden], .fe-replay-progress[hidden], .fe-replay-cancel[hidden] { display: none !important; }
.fe-replay-progress { height: 10px; border-radius: 999px; background: var(--bw-well); overflow: hidden; }
.fe-replay-progress i { display: block; height: 100%; width: 0; background: var(--bw-gold); border-radius: inherit; transition: width .2s; }
.fe-replay-controls .fe-replay-cancel { align-self: center; }
.is-saving .fe-replay-transport, .is-saving .fe-replay-row { opacity: .45; pointer-events: none; }

/* The scrub bar: the slider keeps only its thumb (the play head); grey under it, blue between the
   trim ends, gold for what has played; marks and ends inset by half the thumb. */
.fe-replay-track { position: relative; flex: 1 0 100%; order: -1; height: 34px; margin-top: 4px; display: grid; align-items: center; }
.fe-replay-track::before { content: ''; position: absolute; left: 8px; right: 8px; top: 50%; height: 10px; transform: translateY(-50%); border-radius: 5px; background: rgba(255, 255, 255, .22); }
.fe-replay-under, .fe-replay-rail { position: absolute; left: 8px; right: 8px; top: 0; bottom: 0; pointer-events: none; }
.fe-replay-rail { z-index: 2; }
.fe-replay-band { position: absolute; top: 50%; height: 10px; transform: translateY(-50%); border-radius: 5px; background: #4ea8ff; }
.fe-replay-played { position: absolute; top: 50%; height: 4px; transform: translateY(-50%); border-radius: 2px; background: var(--bw-gold); }
.fe-replay-track input { -webkit-appearance: none; appearance: none; position: relative; z-index: 1; width: 100%; height: 26px; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer; }
.fe-replay-track input::-webkit-slider-runnable-track { height: 10px; background: transparent; }
.fe-replay-track input::-moz-range-track { height: 10px; background: transparent; }
.fe-replay-track input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -3px; box-sizing: border-box; border: 2px solid #fff; border-radius: 50%; background: var(--bw-gold); box-shadow: 0 1px 3px rgba(6, 16, 14, .5); }
.fe-replay-track input::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; background: var(--bw-gold); }
.fe-replay-track input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; border-radius: 6px; }
.fe-replay-controls .fe-replay-mark {
  position: absolute; top: -4px; z-index: 1; width: 14px; height: 14px; min-width: 0; min-height: 0; margin-left: -7px; padding: 0; border: 2px solid #fff; border-radius: 50%;
  background: #e8662f; box-shadow: 0 2px 0 rgba(6, 16, 14, .55); pointer-events: auto; transform: none;
}
.fe-replay-controls .fe-replay-mark.out { background: #ffd166; }
.fe-replay-controls .fe-replay-mark.mega { background: #a8324a; }
.fe-replay-controls .fe-replay-mark.building { background: #9fb3ad; border-style: dashed; }
.fe-replay-controls .fe-replay-mark:hover, .fe-replay-controls .fe-replay-mark:focus-visible { transform: scale(1.25); outline: none; }
.fe-replay-end { position: absolute; z-index: 2; top: 50%; width: 12px; height: 26px; margin-left: -6px; transform: translateY(-50%); box-sizing: border-box;
  border: 2px solid #fff; border-radius: 4px; background: #4ea8ff; box-shadow: 0 1px 4px rgba(6, 16, 14, .5); cursor: ew-resize; pointer-events: auto; touch-action: none; }
.fe-replay-end::after { content: ''; position: absolute; inset: -8px -10px; }
.fe-replay-end:hover, .fe-replay-end.is-dragging, .fe-replay-end:focus-visible { transform: translateY(-50%) scale(1.15); outline: none; }

/* ---- full screen ---- */
.fe-replay-stage {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; gap: 36px;
  padding: 24px; box-sizing: border-box; overflow: hidden; color: #fff; font-family: var(--fe-sub); font-weight: 700;
}
.fe-replay-stage .fe-replay-frame { height: min(calc(100dvh - 48px), 1280px); box-shadow: 0 0 0 200vmax rgba(8, 20, 18, .96); }
.fe-replay-side {
  position: relative; z-index: 1; width: 380px; display: flex; flex-direction: column; gap: 14px; padding: 20px; box-sizing: border-box;
  background: var(--bw-panel); border: var(--fe-panel-edge); border-radius: var(--fe-panel-radius); box-shadow: var(--fe-panel-lift);
}
.fe-replay-title { margin: 0; font: 400 1.6rem/1.1 var(--fe-head); text-shadow: var(--fe-text-lift); }
.fe-replay-sub { margin: -8px 0 0; color: var(--bw-soft); }

/* Narrow windows: the panel over the field, the result card under it. */
@media (max-width: 980px) {
  .bw-replay-panel { --frame-h: clamp(200px, calc(100dvh - 460px), 480px); left: 50%; right: auto; transform: translateX(-50%); top: 16px; max-height: calc(100dvh - 150px); }
  body.bw-replay-up #result { left: 50%; max-width: calc(100vw - 32px); }
  .fe-replay-viewer { width: max(300px, calc((var(--frame-h) + 150px) * 9 / 16)); }
  .fe-replay-together span { display: none; }
  .fe-replay-stage { flex-direction: column; gap: 12px; padding: 12px; }
  .fe-replay-stage .fe-replay-frame { height: 58vh; }
  .fe-replay-side { width: min(100%, 420px); padding: 14px; gap: 10px; }
}
