/* Hand replay — the modal opened from a result row (play/js/screens/hand-replay.js).
   Its own file because the trainer pages show it too ("Show robot play") and
   do not load play.css. The play app's shared modal pieces it uses — the
   overlay, OK button, bidding table, bid boxes and trick badges — are
   repeated below, scoped to .hand-replay-overlay, so the replay looks the same
   wherever it opens and the trainer's own styles cannot reach into it. */

/* Stacks above the profile/scoring-table modal (z-index: 3000) it opens from. */
.hand-replay-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  animation: hrFadeIn 0.2s ease-out;
}

@keyframes hrFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes hrSlideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.hand-replay-overlay *,
.hand-replay-overlay *::before,
.hand-replay-overlay *::after {
  box-sizing: border-box;
}

.hand-replay-overlay .green-modal-btn {
  background: #0808D9;
  color: #fff;
  border: none;
  padding: 12px 40px;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
  margin-top: 20px;
}

.hand-replay-overlay .green-modal-btn:hover { background: #0606B0; }

.hand-replay-overlay .bidding-modal-table {
  width: 100%;
  border-collapse: collapse;
  background: #1B4332;
  border-radius: 8px;
}

.hand-replay-overlay .bidding-modal-table thead tr { border-bottom: 2px solid #fff; }

.hand-replay-overlay .bidding-modal-table th {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  padding: 10px 8px 8px;
  text-align: center;
}

.hand-replay-overlay .bidding-modal-table tbody tr:first-child td { padding-top: 8px; }

.hand-replay-overlay .bidding-modal-table td {
  padding: 2px 4px;
  text-align: center;
  vertical-align: middle;
  height: 36px;
  border: none;
}

.hand-replay-overlay .bidding-modal-table tbody tr:last-child td { padding-bottom: 10px; }

.hand-replay-overlay .bid-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  min-width: 50px;
  height: 32px;
  font-size: 14px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  color: #00213a;
}

.hand-replay-overlay .bid-box-suit {
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols', 'Apple Symbols', sans-serif;
  margin-left: 1px;
}

.hand-replay-overlay .bid-box-suit-red { color: #FF0000; }
.hand-replay-overlay .bid-box-nt { color: #0808D9; }
.hand-replay-overlay .bid-box-pass { color: #2C7148; font-weight: 400; }

/* Lead "1" badge and gold winner outline on the played cards. */
.hand-replay-overlay .trick-card-wrap { position: relative; display: block; }

.hand-replay-overlay .trick-card-wrap.trick-won .trick-cross-card {
  outline: var(--trick-outline, 2px) solid #FFD700;
  outline-offset: 1px;
}

.hand-replay-overlay .trick-badges {
  position: absolute;
  top: 3px;
  right: 3px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 2;
  pointer-events: none;
}

.hand-replay-overlay .trick-badge {
  width: var(--trick-badge, 14px);
  height: var(--trick-badge, 14px);
  border-radius: 50%;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: calc(var(--trick-badge, 14px) * 0.62);
  line-height: calc(var(--trick-badge, 14px) - 2px);
  text-align: center;
}

.hand-replay-overlay .trick-badge-lead {
  background: #fff;
  color: #000;
  border: 1px solid #00213a;
}

/* L (leider = declarer) / D (dummy) tags, under the "1" when both apply.
   Opt-in per account (replay-seat-tags.js). */
.hand-replay-overlay .trick-badge-seat {
  background: #00213a;
  color: #fff;
  border: 1px solid #fff;
}

/* The replay itself, after the mobile app's RobotAnalysisScreen (bidding with
   the four hands round it) and PlayAnalysisScreen (trick-by-trick replay with
   the playback bar). Colours are the app's: felt #2C7148, table #1B4332,
   action blue #0808D9, winning card gold. */
.hr-screen {
  --hr-card-h: clamp(44px, min(7vw, 8vh), 78px);
  --hr-card-w: calc(var(--hr-card-h) * 0.625);
  --hr-overlap: calc(var(--hr-card-w) * 0.4);
  --hr-pc-h: calc(var(--hr-card-h) * 1.25);
  --hr-pc-w: calc(var(--hr-pc-h) * 0.625);
  background: #2C7148;
  border-radius: 15px;
  padding: 16px 16px 20px;
  width: 96%;
  max-width: 960px;
  max-height: 94vh;
  max-height: 94dvh;
  overflow-y: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Poppins', sans-serif;
  color: #fff;
  animation: hrSlideIn 0.25s ease-out;
}

.hr-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hr-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.hr-play-info {
  font-size: 14px;
  margin-bottom: 6px;
}

.hr-result-bar {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #fff;
  color: #00213a;
  border-radius: 8px;
  padding: 3px 14px;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  margin-bottom: 12px;
}

.hr-result-bar .contract-suit {
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols', 'Apple Symbols', sans-serif;
}

.hr-result-sep {
  margin: 0 8px;
  color: #999;
  font-weight: 400;
}

/* ---- Table: North on top, West | centre | East, South below ---- */
.hr-table {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    ".  n  ."
    "w  c  e"
    ".  s  .";
  align-items: center;
  gap: 10px;
  width: 100%;
}

.hr-seat-n { grid-area: n; justify-self: center; }
.hr-seat-s { grid-area: s; justify-self: center; }
.hr-seat-w { grid-area: w; justify-self: end; }
.hr-seat-e { grid-area: e; justify-self: start; }
.hr-centre { grid-area: c; justify-self: center; }

.hr-seat-n, .hr-seat-s { min-height: var(--hr-card-h); }

.hr-hand { display: flex; }
.hr-hand-horizontal { flex-wrap: nowrap; }
.hr-hand-vertical { flex-direction: column; gap: 4px; }
.hr-seat-w .hr-hand-vertical { align-items: flex-end; }
.hr-seat-e .hr-hand-vertical { align-items: flex-start; }

.hr-suit { display: flex; }
.hr-hand-horizontal .hr-suit + .hr-suit { margin-left: 4px; }

.hr-card {
  height: var(--hr-card-h);
  width: var(--hr-card-w);
  border-radius: 4px;
}

.hr-suit .hr-card + .hr-card {
  margin-left: calc(var(--hr-overlap) * -1);
}

/* ---- Bidding view centre ---- */
.hr-bid-box {
  background: #1B4332;
  border-radius: 8px;
  padding: 8px;
  min-width: 240px;
  box-sizing: border-box;
}

.hr-bid-info {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
  margin-bottom: 4px;
}

.hr-bidding-table td { height: 34px; }

.hr-show-play {
  background: #0808D9;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  margin-top: 15px;
  font-family: 'Poppins', sans-serif;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
}

.hr-show-play:hover { background: #0606B0; }

/* ---- Play view centre: the playing field ---- */
.hr-field {
  position: relative;
  width: calc(var(--hr-pc-w) * 3 + 24px);
  height: calc(var(--hr-pc-h) * 2.2 + 24px);
  min-width: 150px;
  background: #1B4332;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  --trick-badge: 18px;
  --trick-outline: 2px;
}

.hr-tally, .hr-trick-no {
  position: absolute;
  top: 6px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 5;
}

.hr-tally { left: 6px; }
.hr-trick-no { right: 6px; }

.hr-start-play {
  background: none;
  border: none;
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 22px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
}

/* Scoped like the shared .trick-card-wrap copy above (position: relative),
   which would otherwise outrank this and drop the cards into normal flow. */
.hand-replay-overlay .hr-played {
  position: absolute;
  display: block;
}

.hr-played-card {
  height: var(--hr-pc-h);
  width: var(--hr-pc-w);
  border-radius: 5px;
  display: block;
}

.hr-played-n { top: 8px; left: 50%; transform: translateX(-50%); z-index: 4; }
.hr-played-s { bottom: 8px; left: 50%; transform: translateX(-50%); z-index: 2; }
.hr-played-w { left: 8px; top: 50%; transform: translateY(-50%); z-index: 1; }
.hr-played-e { right: 8px; top: 50%; transform: translateY(-50%); z-index: 3; }

.hr-final { text-align: center; padding: 0 8px; }
.hr-final-result { font-size: 48px; font-weight: 700; line-height: 1.1; }
.hr-claim { font-size: 14px; font-weight: 700; opacity: 0.85; margin-top: 4px; }

/* ---- Playback bar (the app's SVG buttons) ---- */
.hr-playback {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  margin-top: 16px;
}

.hr-pb {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  line-height: 0;
}

.hr-pb img { width: 58px; height: 40px; }
.hr-pb.hr-toggle { margin: 0 8px; }
.hr-pb:disabled { opacity: 0.5; cursor: default; }

/* Phones: no room for West and East beside the centre, so they sit side by
   side under North and the centre gets the full width. */
@media (max-width: 600px) {
  .hr-screen { padding: 12px 8px 16px; width: 100%; max-height: 100dvh; border-radius: 0; }
  .hr-table {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "n  n"
      "w  e"
      "c  c"
      "s  s";
  }
  .hr-seat-w { justify-self: start; }
  .hr-seat-w .hr-hand-vertical { align-items: flex-start; }
  .hr-seat-e { justify-self: end; }
  .hr-seat-e .hr-hand-vertical { align-items: flex-end; }
  .hr-bid-box { min-width: 0; width: 100%; }
  .hr-title { font-size: 20px; }
  .hr-pb img { width: 52px; height: 36px; }
}
