/* Match replay system — /replays list, /replays/watch viewer, and the
   victory-screen replay bar. */

/* ── Victory screen bar ─────────────────────────────────────────────── */
.game-over-replay-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 6px auto 10px;
}
.game-over-replay-watch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.25);
  color: #ffe9b0;
  text-decoration: none;
  font-weight: 700;
  border: 1px solid rgba(255, 233, 176, 0.4);
}
.game-over-replay-watch:hover {
  background: rgba(0, 0, 0, 0.4);
}

/* ── Save control (shared) ──────────────────────────────────────────── */
.replay-save-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.replay-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 18px;
  border: 1px solid rgba(120, 190, 120, 0.6);
  background: rgba(30, 90, 30, 0.35);
  color: #d7ffd7;
  font-weight: 700;
  cursor: pointer;
}
.replay-save-btn:hover {
  background: rgba(30, 110, 30, 0.55);
}
.replay-save-btn-saved {
  border-color: rgba(255, 210, 90, 0.7);
  background: rgba(120, 90, 10, 0.4);
  color: #ffe9b0;
}
.replay-save-error {
  font-size: 0.85em;
  color: #ff9d9d;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.replay-save-manage-link {
  color: #ffe9b0;
  text-decoration: underline;
}

/* ── Watch page ─────────────────────────────────────────────────────── */
.replays-watch {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px;
  color: var(--text);
}
.replays-watch-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--cloud-bg2);
  border: 1px solid var(--surface-border);
}
.replays-back-link {
  color: inherit;
  opacity: 0.8;
  text-decoration: none;
  white-space: nowrap;
}
.replays-back-link:hover { opacity: 1; }
.replays-watch-title {
  font-size: 1.2em;
  font-weight: 700;
  display: flex;
  gap: 8px;
}
.replays-watch-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  opacity: 0.9;
}
.replays-tag-red { color: indianred; }
.replays-tag-blue { color: #6fa8dc; }
.replays-vs { opacity: 0.7; }
.replays-score { font-weight: 700; }
.replays-winner-badge {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 700;
  text-transform: capitalize;
}
.replays-winner-red { background: rgba(205, 92, 92, 0.3); color: indianred; }
.replays-winner-blue { background: rgba(111, 168, 220, 0.3); color: #6fa8dc; }
.replays-date { font-size: 0.85em; opacity: 0.7; }

/* ── Frame: toolbar + board + transport ─────────────────────────────── */
.replay-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--surface-border);
  color: var(--text);
  margin-bottom: 8px;
}
.replay-action-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.replay-turn-label {
  font-weight: 700;
  white-space: nowrap;
}
.replay-action-text { font-weight: 600; }
.replay-action-red { color: indianred; }
.replay-action-blue { color: #6fa8dc; }
.replay-clock {
  opacity: 0.75;
  font-size: 0.9em;
  white-space: nowrap;
}
.replay-think {
  font-size: 0.85em;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(255, 210, 90, 0.18);
  color: #ffe9b0;
  white-space: nowrap;
}
.replay-toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.replay-seat-toggle {
  display: inline-flex;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--surface-border);
}
.replay-seat-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 700;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.replay-seat-btn.active {
  cursor: default;
}
.replay-seat-red.active { background: rgba(205, 92, 92, 0.45); }
.replay-seat-blue.active { background: rgba(111, 168, 220, 0.45); }

/* The real game board, made inert: replays are read-only. */
.replay-board {
  position: relative;
  pointer-events: none;
  user-select: none;
  border-radius: 12px;
  overflow: hidden;
}
/* Cards in a replay are informational — never render them dimmed/greyscale
   the way unaffordable cards are in a live game. */
.replay-board .card-container,
.replay-board .card-container.dimmed {
  filter: brightness(100%) !important;
}
.replay-board .card-container.dimmed .card {
  filter: none !important;
}
/* No pulsing "your turn" cues in a recording. */
.replay-board .playable {
  animation: none !important;
}

.replay-transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 0 4px;
}
.replay-transport-btn {
  width: 46px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--surface-border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-size: 1.05em;
  cursor: pointer;
}
.replay-transport-btn:hover:not(:disabled) {
  background: var(--surface-hover);
}
.replay-transport-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.replay-autoplay-btn.playing {
  background: rgba(255, 210, 90, 0.25);
  border-color: rgba(255, 210, 90, 0.6);
}
.replay-speed-btn {
  font-weight: 700;
  font-size: 0.95em;
}

/* The flying just-played card (spawned by main.js on each forward step). */
.replay-card-flyer {
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45));
  transform-origin: center center;
}
.replay-card-flyer > .card-container,
.replay-card-selection-preview > .card-container {
  width: 100% !important;
  height: 100%;
  transform: none !important;
}
.replay-card-flyer > .card-container > .card,
.replay-card-selection-preview > .card-container > .card {
  width: 100% !important;
  height: 100% !important;
}

/* Before a forward replay step swaps the board, visibly choose the card from
   the acting hand. This makes play/discard intent readable before the card
   flies to the stack, matching the selection beat in live play. */
.replay-board .replay-card-selected,
.replay-card-selection-preview > .replay-card-selected {
  z-index: 30 !important;
  transform: translateY(-28px) scale(1.1) rotate(0deg) !important;
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.2s ease !important;
  filter:
    brightness(1.08)
    drop-shadow(0 0 10px rgba(46, 196, 182, 0.95))
    drop-shadow(0 0 22px rgba(46, 196, 182, 0.7)) !important;
}
.replay-board .replay-card-selected.replay-card-selected-discard,
.replay-card-selection-preview > .replay-card-selected-discard {
  filter:
    brightness(1.08)
    drop-shadow(0 0 10px rgba(255, 184, 77, 0.98))
    drop-shadow(0 0 24px rgba(255, 124, 64, 0.72)) !important;
}
.replay-card-selected::after {
  content: attr(data-replay-action-label);
  position: absolute;
  left: 50%;
  bottom: -13px;
  z-index: 5;
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(46, 196, 182, 0.97);
  color: #083c36;
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.35);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}
.replay-card-selected-discard::after {
  background: rgba(255, 184, 77, 0.98);
  color: #4a2100;
}
.replay-card-selection-preview {
  position: fixed;
  z-index: 10019;
  width: 100px;
  height: 200px;
  pointer-events: none;
  transform-origin: center center;
}

/* ── List page ──────────────────────────────────────────────────────── */
.replays-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 12px 48px;
  color: var(--text);
}
.replays-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.replays-page-header h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.replays-quota {
  padding: 4px 12px;
  border-radius: 14px;
  background: var(--cloud-bg2);
  border: 1px solid var(--surface-border);
  color: var(--text);
  font-weight: 700;
}
.replays-section-title {
  margin: 22px 0 8px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.replays-section-hint {
  font-size: 0.7em;
  font-weight: 400;
  opacity: 0.7;
}
.replays-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.replays-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--cloud-bg2);
  border: 1px solid var(--surface-border);
  color: var(--text);
}
.replays-row-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}
.replays-row-title:hover { text-decoration: underline; }
.replays-row-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.85em;
  opacity: 0.85;
  margin-top: 2px;
}
.replays-row-mode {
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--surface-hover);
  border: 1px solid var(--surface-border);
}
.replays-empty,
.replays-missing {
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--cloud-bg2);
  border: 1px solid var(--surface-border);
  opacity: 0.85;
}

@media (max-width: 700px) {
  .replay-toolbar { flex-direction: column; align-items: stretch; }
  .replay-toolbar-right { justify-content: space-between; }
  .replays-row { flex-direction: column; align-items: flex-start; }
}

/* Google Play "rate us" card on the victory screen (playRatePrompt.jsx). */
.play-rate-card {
  max-width: 420px;
  margin: 8px auto 12px;
  padding: 12px 16px;
  border-radius: 12px;
  text-align: center;
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.35);
}
.play-rate-stars {
  color: #f5b400;
  font-size: 1.1rem;
  letter-spacing: 4px;
}
.play-rate-text {
  color: var(--text);
  margin: 6px 0 10px;
  line-height: 1.4;
}
.play-rate-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.play-rate-btn {
  font-family: inherit;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
}
.play-rate-yes {
  background: #01875f;
  color: #fff;
}
.play-rate-later {
  background: transparent;
  color: var(--text);
  border-color: rgba(128, 128, 128, 0.45);
}
