/* ═══════════════════════════════════════════════════════════════════════════
   S.A.F — MULTIPLAYER STYLES  |  coin-multi.css
   Load AFTER coin.css in index.html:
       <link rel="stylesheet" href="coin-multi.css">
   ═══════════════════════════════════════════════════════════════════════════ */

/* ══════════════════════════ LOBBY ENTRY ═════════════════════════════════════
   Slide-in animation for the whole lobby card when first rendered.
═══════════════════════════════════════════════════════════════════════════ */
.mp-lobby-animate {
  animation: mpLobbyIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes mpLobbyIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Section label accent for online section */
.mp-section-label {
  position: relative;
}
.mp-section-label::after {
  content: 'LIVE';
  font-family: 'DM Sans', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 8px;
  vertical-align: middle;
  animation: mpLivePulse 2.4s ease-in-out infinite;
}
@keyframes mpLivePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Feature pill row ───────────────────────────────────────────────────── */
.mp-feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 18px;
}
.mp-feat {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  color: rgba(201, 168, 76, 0.7);
  background: rgba(201, 168, 76, 0.07);
  border: 1px solid rgba(201, 168, 76, 0.18);
  border-radius: 20px;
  padding: 3px 11px;
  white-space: nowrap;
}

/* ── Find-match button ──────────────────────────────────────────────────── */
.mp-find-btn {
  width: 100%;
  max-width: 240px;
  position: relative;
  overflow: hidden;
}
.mp-find-btn::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: rgba(255, 255, 255, 0.08);
  transform: skewX(-20deg);
  transition: left 0.5s ease;
}
.mp-find-btn:hover::before { left: 130%; }

/* ══════════════════════════ SEARCHING STATE ═════════════════════════════════ */
.mp-search-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: linear-gradient(135deg,
    rgba(201, 168, 76, 0.05),
    rgba(201, 168, 76, 0.02));
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 14px;
}
.mp-spinner {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(201, 168, 76, 0.15);
  border-top-color: #c9a84c;
  border-radius: 50%;
  animation: mpSpin 0.75s linear infinite;
}
@keyframes mpSpin { to { transform: rotate(360deg); } }

.mp-search-copy { flex: 1 1 auto; }
.mp-search-title {
  font-family: var(--font-title, 'Cinzel', serif);
  font-size: 14px;
  font-weight: 700;
  color: #c9a84c;
  margin-bottom: 3px;
  letter-spacing: 0.3px;
}
.mp-search-sub {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  color: var(--text-dim, #6e6660);
}

/* Dot-wave loading indicator */
.mp-queue-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
}
.mp-queue-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(201, 168, 76, 0.35);
  animation: mpDotBounce 1.4s ease-in-out infinite;
}
.mp-queue-dots span:nth-child(2) { animation-delay: 0.2s; }
.mp-queue-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes mpDotBounce {
  0%, 80%, 100% { transform: scale(1);   opacity: 0.35; }
  40%           { transform: scale(1.5); opacity: 1; background: #c9a84c; }
}

/* ══════════════════════════ MATCH FOUND CARD ════════════════════════════════ */
.mp-match-found-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg,
    rgba(18, 10, 28, 0.95),
    rgba(8, 4, 14, 0.95));
  border: 1px solid rgba(201, 168, 76, 0.4);
  border-radius: 16px;
  padding: 22px 18px 18px;
  text-align: center;
  animation: mpMatchCardIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-play-state: paused; /* JS sets running */
}
@keyframes mpMatchCardIn {
  from { opacity: 0; transform: scale(0.88) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
/* Radial glow at top */
.mp-match-found-card::before {
  content: '';
  position: absolute;
  top: -40px; left: 50%;
  width: 220px; height: 120px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(201,168,76,0.12) 0%, transparent 70%);
  pointer-events: none;
}
/* Shimmer scan line */
.mp-match-found-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(201,168,76,0.04) 0%,
    transparent 50%,
    rgba(201,168,76,0.02) 100%
  );
  pointer-events: none;
}

.mp-mf-eyebrow {
  font-family: var(--font-title, 'Cinzel', serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(201, 168, 76, 0.6);
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}

/* ── VS layout ──────────────────────────────────────────────────────────── */
.mp-match-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}
.mp-player-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: 1;
  max-width: 88px;
}

/* Avatars */
.mp-chip-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title, 'Cinzel', serif);
  font-size: 15px;
  font-weight: 700;
  border: 2px solid;
  transition: box-shadow 0.3s;
}
.mp-chip-you {
  background: linear-gradient(135deg, #7a1e30, #3d0f18);
  border-color: rgba(201, 168, 76, 0.55);
  color: #c9a84c;
  box-shadow: 0 0 20px rgba(201, 168, 76, 0.15),
              0 0 40px rgba(201, 168, 76, 0.06);
  animation: mpAvatarGlow 3s ease-in-out infinite;
}
@keyframes mpAvatarGlow {
  0%, 100% { box-shadow: 0 0 16px rgba(201,168,76,0.15); }
  50%       { box-shadow: 0 0 30px rgba(201,168,76,0.3); }
}
.mp-chip-opp {
  background: linear-gradient(135deg, #1a2a5a, #0a1128);
  border-color: rgba(96, 165, 250, 0.5);
  color: #93c5fd;
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.12);
}

.mp-chip-name {
  font-family: var(--font-title, 'Cinzel', serif);
  font-size: 10px;
  font-weight: 700;
  color: rgba(220, 210, 195, 0.85);
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.2px;
}
.mp-chip-tag {
  font-family: 'DM Sans', sans-serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border-radius: 3px;
  padding: 1px 5px;
}
.mp-chip-tag-you {
  background: rgba(201, 168, 76, 0.12);
  color: rgba(201, 168, 76, 0.7);
  border: 1px solid rgba(201, 168, 76, 0.25);
}
.mp-chip-tag-opp {
  background: rgba(96, 165, 250, 0.1);
  color: rgba(96, 165, 250, 0.6);
  border: 1px solid rgba(96, 165, 250, 0.22);
}

.mp-vs-orb {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg,
    rgba(201, 168, 76, 0.1),
    rgba(201, 168, 76, 0.03));
  border: 1px solid rgba(201, 168, 76, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title, 'Cinzel', serif);
  font-size: 11px;
  font-weight: 900;
  color: rgba(201, 168, 76, 0.75);
  letter-spacing: 1.5px;
}

.mp-turn-reveal {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: rgba(200, 185, 165, 0.6);
  font-style: italic;
  position: relative;
  z-index: 1;
  min-height: 18px;
}

/* ══════════════════════════ IN-GAME HUD ═════════════════════════════════════
   #mp-game-hud is injected into #coin-game-overlay by coin.js.
═══════════════════════════════════════════════════════════════════════════ */
#mp-game-hud {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9855;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  pointer-events: none;
  animation: mpHudSlideIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes mpHudSlideIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Turn badge */
.mp-hud-badge {
  font-family: var(--font-title, 'Cinzel', serif);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 5px 16px;
  border-radius: 20px;
  border: 1px solid;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
  transition: background 0.35s ease, border-color 0.35s ease, color 0.35s ease;
}

/* My turn — gold glow */
.mp-hud.mp-my-turn .mp-hud-badge {
  background: rgba(201, 168, 76, 0.18);
  border-color: rgba(201, 168, 76, 0.55);
  color: #f5e070;
  box-shadow: 0 0 24px rgba(201, 168, 76, 0.22);
  animation: mpMyTurnPulse 2s ease-in-out infinite;
}
@keyframes mpMyTurnPulse {
  0%, 100% { box-shadow: 0 0 16px rgba(201,168,76,0.18); }
  50%       { box-shadow: 0 0 36px rgba(201,168,76,0.38); }
}

/* Waiting — muted purple */
.mp-hud.mp-waiting .mp-hud-badge {
  background: rgba(30, 20, 50, 0.72);
  border-color: rgba(120, 90, 170, 0.28);
  color: rgba(180, 160, 220, 0.6);
  animation: none;
}

/* Player name strip */
.mp-hud-names {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(6, 3, 12, 0.78);
  border: 1px solid rgba(201, 168, 76, 0.12);
  border-radius: 20px;
  padding: 3px 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.mp-hud-you {
  font-family: var(--font-title, 'Cinzel', serif);
  font-size: 9px;
  font-weight: 700;
  color: #c9a84c;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mp-hud-sep {
  font-size: 8px;
  color: rgba(180, 160, 140, 0.35);
  font-family: 'DM Sans', sans-serif;
}
.mp-hud-opp {
  font-family: var(--font-title, 'Cinzel', serif);
  font-size: 9px;
  font-weight: 700;
  color: #93c5fd;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Snap flash — briefly highlights the board when layout snaps to Firestore data */
@keyframes mpSnapFlash {
  0%   { outline: 2px solid rgba(201,168,76,0.0); }
  20%  { outline: 2px solid rgba(201,168,76,0.5); }
  100% { outline: 2px solid rgba(201,168,76,0.0); }
}
#coin-game-canvas.mp-snapping {
  animation: mpSnapFlash 0.6s ease forwards;
}

/* ══════════════════════════ NETWORK STATUS DOT ══════════════════════════════
   A tiny pulsing dot added to the HUD when a listener is active.
═══════════════════════════════════════════════════════════════════════════ */
.mp-net-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74,222,128,0.6);
  animation: mpNetPulse 2s ease-in-out infinite;
}
.mp-net-dot.disconnected {
  background: #f87171;
  box-shadow: 0 0 6px rgba(248,113,113,0.6);
  animation: none;
}
@keyframes mpNetPulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(1.3); }
}

/* ══════════════════════════ MOBILE ══════════════════════════════════════════ */
@media (max-width: 520px) {
  .mp-match-vs       { gap: 10px; }
  .mp-chip-avatar    { width: 44px; height: 44px; font-size: 13px; }
  .mp-vs-orb         { width: 36px; height: 36px; font-size: 10px; }
  .mp-hud-badge      { font-size: 10px; padding: 4px 12px; letter-spacing: 1.5px; }
  .mp-hud-names      { padding: 2px 10px; gap: 6px; }
  .mp-hud-you,
  .mp-hud-opp        { max-width: 64px; font-size: 8px; }
  .mp-search-banner  { gap: 12px; padding: 14px 16px; }
  .mp-search-title   { font-size: 13px; }
}
