/* ═══════════════════════════════════════════════════════════════════════════
   TPS — shared/multiplayer.css
   Multiplayer Lobby Modal — Full-Screen Overlay UI
   Palette: Deep Navy (#0f172a), Slate (#1e293b), Gold (#fbbf24), Blue (#3b82f6)
   ═══════════════════════════════════════════════════════════════════════════
   This file is COMPLETELY ISOLATED from all single-player game modules.
   It only activates when the player opens the Multiplayer modal.
   ═══════════════════════════════════════════════════════════════════════════ */


/* ── Overlay ────────────────────────────────────────────────────────────── */
.mp-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 22, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: mp-fadeIn 0.3s ease;
}

.mp-overlay.active {
  display: flex;
}

@keyframes mp-fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Main Modal Card ────────────────────────────────────────────────────── */
.mp-modal {
  width: 94%;
  max-width: 780px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 16px;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.7),
    0 0 60px rgba(59, 130, 246, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  animation: mp-slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mp-slideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Scrollable Body ────────────────────────────────────────────────────── */
.mp-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 0 1.4rem 1.4rem;
}

.mp-modal__body::-webkit-scrollbar {
  width: 5px;
}
.mp-modal__body::-webkit-scrollbar-track {
  background: transparent;
}
.mp-modal__body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}


/* ══════════════════════════════════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════════════════════════════════ */
.mp-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.4rem;
  border-bottom: 1px solid rgba(59, 130, 246, 0.1);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.04), transparent);
  position: relative;
  flex-shrink: 0;
}

.mp-header__icon {
  font-size: 1.5rem;
  line-height: 1;
}

.mp-header__title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #f0f1f7;
  letter-spacing: 0.01em;
}

.mp-header__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #a0a5c0;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.mp-header__close:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}


/* ══════════════════════════════════════════════════════════════════════════
   DASHBOARD CARDS (4-column grid)
   ══════════════════════════════════════════════════════════════════════════ */
.mp-dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  padding: 1rem 1.4rem;
}

.mp-dash-card {
  background: #1e293b;
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  text-align: center;
  transition: border-color 0.2s ease;
}
.mp-dash-card:hover {
  border-color: rgba(59, 130, 246, 0.3);
}

.mp-dash-card__label {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7094;
  margin-bottom: 0.25rem;
}

.mp-dash-card__value {
  font-size: 0.95rem;
  font-weight: 800;
  color: #f0f1f7;
  line-height: 1.3;
}

/* Status card has special accent when connected */
.mp-dash-card--status .mp-dash-card__value {
  color: #fbbf24;
  font-size: 0.78rem;
}

.mp-dash-card--status.connected .mp-dash-card__value {
  color: #fbbf24;
}

.mp-dash-card--status.idle .mp-dash-card__value {
  color: #6b7094;
}


/* ══════════════════════════════════════════════════════════════════════════
   SECTIONS — shared card-section styling
   ══════════════════════════════════════════════════════════════════════════ */
.mp-section {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(59, 130, 246, 0.08);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.6rem;
}

.mp-section__title {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #a0a5c0;
  margin-bottom: 0.5rem;
}


/* ══════════════════════════════════════════════════════════════════════════
   QUICK STEPS — Room code + copy buttons
   ══════════════════════════════════════════════════════════════════════════ */
.mp-quicksteps__desc {
  font-size: 0.7rem;
  color: #6b7094;
  margin-bottom: 0.65rem;
  line-height: 1.5;
}

.mp-quicksteps__row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.mp-room-code-input {
  flex: 1;
  min-width: 160px;
  padding: 0.5rem 0.75rem;
  background: #0f172a;
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 6px;
  color: #fbbf24;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: 'Inter', monospace;
  letter-spacing: 0.1em;
}
.mp-room-code-input:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.4);
}

.mp-copy-btn {
  padding: 0.45rem 0.7rem;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #a0a5c0;
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.mp-copy-btn:hover {
  background: #334155;
  border-color: rgba(59, 130, 246, 0.3);
  color: #f0f1f7;
}
.mp-copy-btn:active {
  transform: scale(0.96);
}
.mp-copy-btn.copied {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: #4ade80;
}


/* ══════════════════════════════════════════════════════════════════════════
   SERVER STATUS
   ══════════════════════════════════════════════════════════════════════════ */
.mp-server__text {
  font-size: 0.72rem;
  color: #6b7094;
  line-height: 1.5;
}


/* ══════════════════════════════════════════════════════════════════════════
   LOBBY ACTIONS — Inputs + Buttons
   ══════════════════════════════════════════════════════════════════════════ */
.mp-actions__inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.mp-input {
  padding: 0.55rem 0.75rem;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #f0f1f7;
  font-size: 0.78rem;
  font-family: inherit;
  transition: border-color 0.2s ease;
}
.mp-input::placeholder {
  color: #4b5078;
}
.mp-input:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.08);
}

/* Button rows */
.mp-actions__row {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.mp-actions__row:last-child {
  margin-bottom: 0;
}

/* Base action button */
.mp-btn {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  background: #1e293b;
  color: #a0a5c0;
}
.mp-btn:hover:not(:disabled) {
  background: #334155;
  border-color: rgba(255, 255, 255, 0.15);
  color: #f0f1f7;
  transform: translateY(-1px);
}
.mp-btn:active:not(:disabled) {
  transform: translateY(0);
}
.mp-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

/* Primary action: Host Room, Start Match */
.mp-btn--primary {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.08));
  border-color: rgba(59, 130, 246, 0.25);
  color: #60a5fa;
}
.mp-btn--primary:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(59, 130, 246, 0.12));
  border-color: rgba(59, 130, 246, 0.5);
  color: #93bbfd;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.08);
}

/* Success/Ready button */
.mp-btn--success {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12), rgba(34, 197, 94, 0.06));
  border-color: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}
.mp-btn--success:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.1));
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
}

/* Danger: Leave Room */
.mp-btn--danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
  border-color: rgba(239, 68, 68, 0.2);
  color: #f87171;
}
.mp-btn--danger:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.18), rgba(239, 68, 68, 0.08));
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* Gold: Start Match (Host) — full width */
.mp-btn--gold {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(251, 191, 36, 0.05));
  border-color: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}
.mp-btn--gold:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(251, 191, 36, 0.1));
  border-color: rgba(251, 191, 36, 0.4);
  color: #fde68a;
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.08);
}


/* ══════════════════════════════════════════════════════════════════════════
   PLAYER LIST
   ══════════════════════════════════════════════════════════════════════════ */
.mp-players__list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.mp-player-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  transition: border-color 0.2s ease;
}
.mp-player-row:hover {
  border-color: rgba(255, 255, 255, 0.08);
}

/* Current player highlight */
.mp-player-row.mp-player--local {
  border-color: rgba(59, 130, 246, 0.2);
  background: rgba(59, 130, 246, 0.04);
}

.mp-player-row__seat {
  font-size: 0.72rem;
  font-weight: 700;
  color: #f0f1f7;
  min-width: 80px;
}

.mp-player-row__name {
  flex: 1;
  font-size: 0.72rem;
  color: #a0a5c0;
}

.mp-player-row__name .mp-you-tag {
  color: #60a5fa;
  font-weight: 700;
  font-size: 0.65rem;
}

.mp-player-row__status {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
}

.mp-player-row__status.not-ready {
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
}

.mp-player-row__status.ready {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.1);
  animation: mp-readyPulse 2s ease-in-out infinite;
}

@keyframes mp-readyPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.mp-player-count {
  font-size: 0.62rem;
  font-weight: 700;
  color: #fbbf24;
  margin-left: auto;
  padding-left: 0.5rem;
}

/* Empty seat */
.mp-player-row--empty {
  opacity: 0.3;
  border-style: dashed;
}
.mp-player-row--empty .mp-player-row__name {
  font-style: italic;
  color: #4b5078;
}

/* ── Toast Notification (inside modal) ─────────────────────────────────── */
.mp-toast-container {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
}

.mp-toast {
  padding: 0.5rem 1.2rem;
  background: #1e293b;
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #f0f1f7;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  animation: mp-toastIn 0.3s ease, mp-toastOut 0.3s ease 2.5s forwards;
  pointer-events: auto;
}

.mp-toast.success {
  border-color: rgba(34, 197, 94, 0.3);
  color: #4ade80;
}
.mp-toast.error {
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.mp-toast.warning {
  border-color: rgba(251, 191, 36, 0.3);
  color: #fbbf24;
}

@keyframes mp-toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes mp-toastOut {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(-10px); }
}


/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .mp-modal {
    width: 98%;
    max-height: 96vh;
    border-radius: 12px;
  }

  .mp-dashboard {
    grid-template-columns: repeat(2, 1fr);
  }

  .mp-actions__inputs {
    grid-template-columns: 1fr;
  }

  .mp-actions__row {
    flex-direction: column;
  }

  .mp-quicksteps__row {
    flex-direction: column;
  }

  .mp-room-code-input {
    min-width: 100%;
  }
}
