/* =============================================================================
   AL BUILDER — matchmaking.css
   Styles for the Matchmaking tab: mode/QTE picker, search screen, and the
   two-box duel arena (left = you, right = opponent progress view).
   Theme matches the rest of the app (dark arcane purples).
   ============================================================================= */

#page-matchmaking { padding: 18px 14px 60px; }
#mm-root { max-width: 1080px; margin: 0 auto; }

/* ── Shared bits ───────────────────────────────────────────────────────────── */
.mm-center { display: flex; justify-content: center; padding-top: 24px; }
.mm-panel {
  background: linear-gradient(180deg, #14141f, #0f0f18);
  border: 1px solid #25253a; border-radius: 14px;
  padding: 26px 28px; width: 100%; max-width: 620px;
  box-shadow: 0 10px 40px rgba(0,0,0,.45);
}
.mm-title { margin: 0 0 6px; color: #e7e0ff; font-size: 24px; font-weight: 800; letter-spacing: .3px; }
.mm-sub   { color: #9a93b8; font-size: 14px; margin: 0 0 16px; }

.mm-btn {
  appearance: none; cursor: pointer; border: 1px solid #34344e;
  background: #1b1b2a; color: #d6cff2; font-weight: 700; font-size: 14px;
  padding: 9px 18px; border-radius: 9px; transition: .15s;
}
.mm-btn:hover { background: #232338; border-color: #4a4a70; }
.mm-btn-primary {
  background: linear-gradient(180deg, #8b5cf6, #6d3fd4); border-color: #7a4fe0; color: #fff;
}
.mm-btn-primary:hover { filter: brightness(1.08); }

/* ── Home / mode + QTE picker ──────────────────────────────────────────────── */
.mm-mode-toggle { display: inline-flex; gap: 0; margin: 4px 0 12px; border: 1px solid #2c2c44; border-radius: 10px; overflow: hidden; }
.mm-mode-btn {
  cursor: pointer; border: 0; background: #16161f; color: #9a93b8;
  padding: 9px 26px; font-weight: 700; font-size: 14px; transition: .15s;
}
.mm-mode-btn.active { background: linear-gradient(180deg, #8b5cf6, #6d3fd4); color: #fff; }
.mm-mode-btn:not(.active):hover { background: #1f1f2e; color: #cfc7ee; }

.mm-rank-line { color: #b9b0e0; font-size: 14px; margin: 2px 0 14px; }
.mm-rank-line b { color: #e7c66b; }

.mm-bot-diff { margin: 2px 0 14px; }
.mm-bot-diff-label { display: block; color: #7e7aa0; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.mm-diff-row { display: inline-flex; border: 1px solid #2c2c44; border-radius: 9px; overflow: hidden; }
.mm-diff-btn { cursor: pointer; border: 0; background: #16161f; color: #9a93b8; padding: 7px 18px; font-weight: 700; font-size: 13px; transition: .15s; }
.mm-diff-btn + .mm-diff-btn { border-left: 1px solid #2c2c44; }
.mm-diff-btn.active { background: linear-gradient(180deg, #8b5cf6, #6d3fd4); color: #fff; }
.mm-diff-btn:not(.active):hover { background: #1f1f2e; color: #cfc7ee; }

.mm-qte-picker { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.mm-qte-group-label { color: #7e7aa0; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 7px; }
.mm-qte-row { display: flex; flex-wrap: wrap; gap: 8px; }
.mm-qte-btn {
  cursor: pointer; border: 1px solid #2f2f48; background: #181826; color: #d2cbef;
  padding: 9px 16px; border-radius: 9px; font-weight: 700; font-size: 14px; transition: .15s;
}
.mm-qte-btn:hover { background: #262640; border-color: #5a4fb0; transform: translateY(-1px); }

/* ── Searching ─────────────────────────────────────────────────────────────── */
.mm-searching { text-align: center; }
.mm-queue-count { color: #9a93b8; font-size: 13px; margin: 2px 0 16px; }
.mm-queue-count::before { content: '👥 '; }
.mm-spinner {
  width: 46px; height: 46px; margin: 6px auto 16px; border-radius: 50%;
  border: 4px solid #2a2a40; border-top-color: #a98bff; animation: mm-spin .8s linear infinite;
}
@keyframes mm-spin { to { transform: rotate(360deg); } }

/* ── Arena ─────────────────────────────────────────────────────────────────── */
.mm-arena { display: flex; flex-direction: column; gap: 14px; }
.mm-arena-top {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 10px; background: #11111b; border: 1px solid #23233a; border-radius: 12px; padding: 10px 14px;
}
.mm-leave-btn { justify-self: start; padding: 6px 14px; font-size: 13px; }
.mm-roundno { justify-self: end; color: #9a93b8; font-weight: 700; font-size: 14px; }
.mm-scoreboard { display: flex; align-items: center; gap: 16px; }
.mm-pips { color: #a98bff; letter-spacing: 3px; font-size: 16px; }
.mm-timer {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 26px; color: #e7e0ff;
  min-width: 76px; text-align: center;
}
.mm-timer.low { color: #ff6b6b; animation: mm-pulse .9s ease-in-out infinite; }
@keyframes mm-pulse { 50% { opacity: .55; } }

.mm-boxes { display: flex; gap: 16px; align-items: stretch; }
.mm-box {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #13131f, #0e0e17);
  border: 1px solid #23233a; border-radius: 14px; padding: 12px; gap: 10px;
  transition: border-color .2s, box-shadow .2s;
}
.mm-box-me  { border-color: #3a3a64; }
.mm-box-me.failed { border-color: #6a2a2a; box-shadow: 0 0 0 1px #6a2a2a inset; }
.mm-box-opp { background: linear-gradient(180deg, #15101c, #0e0b15); }

.mm-head { display: flex; align-items: center; gap: 10px; }
.mm-head-info { min-width: 0; }
.mm-head-name { color: #e7e0ff; font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-rank-badge { color: #c7b8f0; font-size: 12px; font-weight: 700; margin-top: 2px; }
.mm-rank-rr { color: #e7c66b; }
.mm-orb-click { cursor: pointer; display: inline-block; border-radius: 50%; transition: box-shadow .15s; }
.mm-orb-click:hover { box-shadow: 0 0 0 2px #7a4fe0; }
.mm-report-btn { background: #2a1620; border-color: #5a2330; color: #ff9a9a; margin-top: 8px; }
.mm-report-btn:hover { background: #3a1c2a; }

.mm-qte-host { flex: 1; min-height: 520px; display: flex; flex-direction: column; }
.mm-qte-host .qte-panel { flex: 1; }

/* In a match, show only the playable QTE — strip the QTE Trainer chrome
   (leaderboard button, "Best:" / avg readouts, spear settings). Scoped to the
   match mount, so the Trainer tab is unaffected. */
#mm-qte-mount .lb-open-btn,
#mm-qte-mount [id$="-qte-highscore"],
#mm-qte-mount [id$="-qte-avgtime"],
#mm-qte-mount #spear-settings-btn,
#mm-qte-mount #spear-settings-panel { display: none !important; }
.mm-streak-tag { color: #9a93b8; font-size: 13px; font-weight: 700; text-align: center; min-height: 18px; }

/* Opponent progress view */
.mm-opp-view {
  flex: 1; min-height: 520px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: #0c0a14; border: 1px dashed #2a2440; border-radius: 10px;
}
.mm-opp-status { color: #b9b0e0; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.mm-status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #555; }
.mm-status-dot.waiting { background: #6b6b80; }
.mm-status-dot.playing { background: #56d364; box-shadow: 0 0 8px #56d364; animation: mm-blink 1s ease-in-out infinite; }
.mm-status-dot.failed  { background: #ff5b5b; box-shadow: 0 0 8px #ff5b5b; }
@keyframes mm-blink { 50% { opacity: .4; } }
.mm-opp-streak { color: #fff; font-size: 64px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.mm-opp-streak-label { color: #7e7aa0; font-size: 12px; text-transform: uppercase; letter-spacing: 2px; }

/* Overlay (round + match results) */
.mm-overlay {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: rgba(6,6,12,.72); backdrop-filter: blur(3px);
}
.mm-overlay-card {
  background: linear-gradient(180deg, #17172a, #0f0f1c); border: 1px solid #34344e; border-radius: 16px;
  padding: 30px 40px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.6); min-width: 280px;
}
.mm-overlay-big { font-size: 30px; font-weight: 900; color: #e7e0ff; margin-bottom: 8px; }
.mm-overlay-sub { color: #9a93b8; font-size: 14px; margin-bottom: 16px; }
.mm-overlay.win  .mm-overlay-big { color: #67e08a; text-shadow: 0 0 18px rgba(103,224,138,.4); }
.mm-overlay.lose .mm-overlay-big { color: #ff6b6b; }
.mm-overlay.draw .mm-overlay-big { color: #e7c66b; }
.mm-overlay .mm-btn { margin-top: 6px; }

.mm-av-fallback {
  width: 40px; height: 40px; border-radius: 50%; background: #3a2f63; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}

/* Rank Ladder button + modal */
.mm-ranks-btn { display: block; width: 100%; margin: 4px 0 14px; }

.mm-modal-overlay {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  background: rgba(6,6,12,.74); backdrop-filter: blur(3px); padding: 20px;
}
.mm-modal {
  background: linear-gradient(180deg, #15152400, #0f0f1c), #13131f;
  border: 1px solid #2c2c46; border-radius: 16px; width: 100%; max-width: 460px;
  max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.mm-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 10px; }
.mm-modal-head h3 { margin: 0; color: #e7e0ff; font-size: 19px; font-weight: 800; }
.mm-modal-close { cursor: pointer; background: none; border: 0; color: #9a93b8; font-size: 26px; line-height: 1; padding: 0 4px; }
.mm-modal-close:hover { color: #fff; }
.mm-modal-note { padding: 0 20px 10px; color: #b9b0e0; font-size: 13px; }
.mm-modal-note b { color: #e7c66b; }
.mm-modal-foot { padding: 10px 20px 16px; color: #7e7aa0; font-size: 12px; border-top: 1px solid #20203200; }

.mm-rank-ladder { overflow-y: auto; padding: 4px 14px; display: flex; flex-direction: column; gap: 6px; }
.mm-rank-tier {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #141420; border: 1px solid #22223a; border-left: 4px solid var(--tc);
  border-radius: 9px; padding: 9px 12px;
}
.mm-rank-tier.mine { background: #1c1830; border-color: var(--tc); box-shadow: 0 0 0 1px var(--tc) inset; }
.mm-rank-tier-name { display: flex; align-items: center; gap: 8px; color: #e7e0ff; font-weight: 800; font-size: 14px; white-space: nowrap; }
.mm-rank-chip { width: 12px; height: 12px; border-radius: 3px; background: var(--tc); box-shadow: 0 0 8px var(--tc); }
.mm-rank-divs { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.mm-rank-div { color: #8e88ad; font-size: 11px; font-weight: 700; background: #0e0e18; border: 1px solid #23233a; border-radius: 6px; padding: 3px 7px; white-space: nowrap; }
.mm-rank-div.cur { color: #fff; background: var(--tc); border-color: var(--tc); }

@media (max-width: 760px) {
  .mm-rank-tier { flex-direction: column; align-items: flex-start; gap: 6px; }
  .mm-rank-divs { justify-content: flex-start; }
}

/* ── Mobile: stack the two boxes vertically ────────────────────────────────── */
@media (max-width: 760px) {
  .mm-boxes { flex-direction: column; }
  .mm-qte-host, .mm-opp-view { min-height: 340px; }
  .mm-arena-top { grid-template-columns: auto 1fr auto; }
  .mm-timer { font-size: 22px; min-width: 62px; }
  .mm-opp-streak { font-size: 48px; }
  .mm-panel { padding: 20px 18px; }
}
