/* ── Match Report (§Pro Phase 1) ──────────────────────────────────────────────
   Self-contained styles for the shared report overlay (match-report.js). Every
   selector is namespaced .mr-* so this file cannot affect any existing page.
   Inherits the host page's CSS variables where they exist, with hard fallbacks so
   it renders correctly on all three pages (game, lobby, profile). */

.mr-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;                 /* above the game's stats modal (which opens it) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(2px);
}
.mr-overlay[hidden] { display: none; }

.mr-box {
  width: min(1080px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: var(--panel, var(--bg-panel, #fff));
  color: var(--ink, var(--text, #1b1b1b));
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  overflow: hidden;
}

.mr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(128, 128, 128, .22);
  flex: 0 0 auto;
}
.mr-title { font-size: 1.05rem; font-weight: 700; }
.mr-close {
  border: 0; background: transparent; cursor: pointer;
  font-size: 1.2rem; line-height: 1; padding: 6px 8px; border-radius: 8px;
  color: inherit; opacity: .7;
}
.mr-close:hover { opacity: 1; background: rgba(128, 128, 128, .14); }

.mr-body { padding: 16px 18px 22px; overflow-y: auto; flex: 1 1 auto; }

/* Two columns on desktop; a single stack on mobile (free facts first). */
.mr-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
@media (max-width: 900px) { .mr-cols { grid-template-columns: 1fr; gap: 18px; } }

/* ── Hero ── */
.mr-hero { margin-bottom: 16px; }
.mr-hero-win { font-size: 1.35rem; font-weight: 800; margin-bottom: 8px; }
.mr-hero-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.mr-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; font-size: .78rem;
  background: rgba(128, 128, 128, .14);
}

.mr-sec-hd {
  font-size: .82rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; opacity: .75;
  margin: 18px 0 8px;
}
.mr-sub { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: .8; }

/* ── Result table ── */
.mr-table-wrap { overflow-x: auto; }        /* wide tables scroll INSIDE, never the page */
.mr-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.mr-table th, .mr-table td { padding: 7px 8px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, .16); }
.mr-table th { font-size: .74rem; opacity: .7; font-weight: 600; }
.mr-table .mr-num { text-align: right; font-variant-numeric: tabular-nums; }
.mr-table tr.mr-winner { background: rgba(255, 196, 0, .1); }
.mr-table tr.mr-you td { font-weight: 700; }
.mr-na { opacity: .35; }
.mr-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.mr-tag { font-size: .68rem; padding: 1px 5px; border-radius: 5px; margin-left: 5px; background: rgba(128, 128, 128, .18); }
.mr-tag-you { background: rgba(56, 120, 224, .2); }
.mr-tag-win { background: transparent; }

/* ── Dice histogram (FREE — same data as the end-of-game modal) ── */
.mr-dice { display: flex; align-items: flex-end; gap: 4px; height: 130px; }
.mr-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.mr-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.mr-bar { width: 100%; border-radius: 3px 3px 0 0; background: #6b8cc4; min-height: 2px; }
.mr-bar-hot { background: #e0872c; }
.mr-bar-lbl { font-size: .7rem; opacity: .75; margin-top: 3px; }
.mr-bar-cnt { font-size: .66rem; opacity: .5; }

/* ── PRO: dice luck ── */
.mr-up   { color: #1f9254; }
.mr-down { color: #c0453c; }
.mr-luck-hero {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 10px; margin-bottom: 10px;
  background: rgba(128, 128, 128, .1);
}
.mr-luck-pct { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.mr-luck-cap { font-size: .82rem; opacity: .85; color: var(--ink, #1b1b1b); }
.mr-luck-list { display: flex; flex-direction: column; gap: 6px; }
.mr-luck-row {
  display: grid; grid-template-columns: minmax(90px, 1.2fr) 2fr auto auto;
  align-items: center; gap: 8px; font-size: .84rem;
}
.mr-luck-row.mr-you { font-weight: 700; }
.mr-luck-name { display: flex; align-items: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-luck-bar { height: 8px; border-radius: 999px; background: rgba(128, 128, 128, .18); overflow: hidden; }
.mr-luck-fill { display: block; height: 100%; border-radius: 999px; }
.mr-luck-fill.mr-up   { background: #1f9254; }
.mr-luck-fill.mr-down { background: #c0453c; }
.mr-luck-val { font-variant-numeric: tabular-nums; font-weight: 700; }
.mr-luck-rolls { font-size: .72rem; opacity: .55; white-space: nowrap; }

/* ── PRO: resource production ── */
.mr-prod-list { display: flex; flex-direction: column; gap: 12px; }
.mr-prod-row.mr-you .mr-luck-name { font-weight: 700; }
.mr-prod-head { display: flex; justify-content: space-between; align-items: center; font-size: .84rem; margin-bottom: 4px; }
.mr-prod-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.mr-prod-top { font-weight: 400; opacity: .75; font-size: .76rem; margin-left: 4px; }
.mr-prod-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; min-width: 8%; }
.mr-prod-seg { display: block; }
.mr-prod-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; font-size: .72rem; opacity: .75; }
.mr-prod-l { display: inline-flex; align-items: center; gap: 3px; }
.mr-res-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.mr-res-wood  { background: #4b7f45; }
.mr-res-brick { background: #b5613a; }
.mr-res-sheep { background: #8fc65a; }
.mr-res-wheat { background: #e0b33a; }
.mr-res-ore   { background: #7d8a99; }

/* ── PRO: VP composition ── */
.mr-vp-list { display: flex; flex-direction: column; gap: 7px; }
.mr-vp-row { display: grid; grid-template-columns: minmax(90px, 1.2fr) 3fr auto; align-items: center; gap: 8px; font-size: .84rem; }
.mr-vp-row.mr-you { font-weight: 700; }
.mr-vp-bar { display: flex; height: 16px; border-radius: 5px; overflow: hidden; background: rgba(128, 128, 128, .14); }
.mr-vp-seg {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .66rem; color: #fff; min-width: 14px;
}
.mr-vp-set { background: #6b8cc4; }
.mr-vp-cit { background: #3a5f9e; }
.mr-vp-awd { background: #e0872c; }
.mr-vp-oth { background: #8a6fbf; }
.mr-vp-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.mr-vp-key { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; font-size: .72rem; opacity: .75; }
.mr-vp-key span { display: inline-flex; align-items: center; gap: 4px; }
.mr-vp-key .mr-vp-seg { width: 12px; height: 10px; border-radius: 2px; min-width: 12px; }

/* ── Upsell / empty / loading ── */
.mr-upsell {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; border-radius: 12px;
  border: 1px solid rgba(224, 152, 32, .35);
  background: rgba(224, 152, 32, .09);
}
.mr-upsell-ic { font-size: 1.5rem; color: #e09820; }
.mr-upsell-txt { flex: 1; min-width: 0; }
.mr-upsell-hd { font-weight: 700; margin-bottom: 2px; }
.mr-upsell-sub { font-size: .82rem; opacity: .85; }
.mr-upsell-btn {
  border: 0; border-radius: 8px; padding: 9px 14px; cursor: pointer;
  font-weight: 700; white-space: nowrap;
  background: #e09820; color: #fff;
}
.mr-upsell-btn:hover { filter: brightness(1.06); }
@media (max-width: 560px) {
  .mr-upsell { flex-direction: column; align-items: flex-start; }
  .mr-upsell-btn { width: 100%; }
}

.mr-empty, .mr-loading {
  padding: 12px 14px; border-radius: 10px; font-size: .85rem;
  background: rgba(128, 128, 128, .1); opacity: .9;
}
.mr-loading { text-align: center; }

/* Dark mode: the host pages set data-theme / prefers-color-scheme; the panel var
   above already follows them, so only the flat fallbacks need adjusting. */
@media (prefers-color-scheme: dark) {
  .mr-box { background: var(--panel, #22262c); color: var(--ink, #eceff3); }
  .mr-luck-cap { color: var(--ink, #eceff3); }
}
:root[data-theme="dark"] .mr-box { background: var(--panel, #22262c); color: var(--ink, #eceff3); }
:root[data-theme="light"] .mr-box { background: var(--panel, #fff); color: var(--ink, #1b1b1b); }
