/* ─── Онлайн-игра вдвоём (в модальном окне) ─── */
.mp-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.5);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.mp-modal {
  max-width: 380px;
  width: 100%;
  margin: auto;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  padding-top: 2.5rem;
  isolation: isolate;
}
.mp-modal-close {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 3rem;
  height: 3rem;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.08));
  color: var(--text-muted, #666);
  cursor: pointer;
  border-radius: 8px;
  z-index: 9999;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.mp-modal-close:hover {
  color: var(--text-primary, #1a1a1a);
  background: var(--border, rgba(0,0,0,0.08));
}
.mp-modal .mp-wrap { margin-top: 0; padding-top: 0; border-top: none; }
.mp-close-btn { margin-top: 1rem; padding: 0.5rem 1rem; font-size: 0.9rem; font-family: inherit; width: 100%; cursor: pointer; border-radius: 8px; background: var(--bg-body, #f5f5f4); border: 1px solid var(--border-input, #d4d4d4); color: var(--text-primary); }
.mp-close-btn:hover { border-color: var(--accent, #22c55e); background: var(--accent-subtle, rgba(34, 197, 94, 0.08)); }
#mp-wrap { min-height: 2rem; }

.mp-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  margin: 0 0 0.75rem;
}

[data-mp-screen] {
  display: none;
}

[data-mp-screen="idle"] {
  display: block;
}

.mp-status {
  font-size: 0.85rem;
  color: var(--text-muted, #666);
  margin-bottom: 0.5rem;
  padding: 0.35rem 0;
}

.mp-status-error {
  color: #b91c1c;
}

.mp-you-are {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  margin: 0 0 0.25rem;
}

.mp-waiting {
  font-size: 0.85rem;
  color: var(--text-muted, #666);
  margin: 0 0 0.5rem;
}

.mp-btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-primary, #1a1a1a);
  background: var(--bg-body, #f5f5f4);
  border: 1px solid var(--border-input, #d4d4d4);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.mp-btn:hover {
  border-color: var(--accent, #22c55e);
  background: var(--accent-subtle, rgba(34, 197, 94, 0.08));
}

.mp-total {
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted, #666);
}
.mp-total-label { font-weight: 500; }
.mp-total #mp-total1, .mp-total #mp-total2 { font-weight: 700; color: var(--text-primary, #1a1a1a); }
.mp-scores {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
}

.mp-game-area {
  position: relative;
  width: 100%;
  height: 200px;
  min-height: 180px;
  background: var(--bg-body, #f5f5f4);
  border-radius: 12px;
  border: 1px dashed var(--border-input, #d4d4d4);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mp-mouse {
  position: absolute;
  width: 48px;
  height: 48px;
  left: 50%;
  top: 50%;
  margin: -24px 0 0 -24px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
  pointer-events: none;
  transition: left 0.1s ease-out, top 0.1s ease-out;
}

.mp-mouse.is-visible {
  display: flex;
}

#mp-result {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent, #22c55e);
  text-align: center;
}

.mp-replay-wrap {
  margin-top: 1rem;
}
.mp-replay-wrap .mp-btn {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent-subtle, rgba(34, 197, 94, 0.2));
  border: 2px solid var(--accent, #22c55e);
}
.mp-replay-wrap .mp-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  background: var(--border-input, #404040);
  border-color: var(--border-input, #404040);
}
.mp-leave-wrap {
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}

.mp-leave-wrap .mp-btn {
  display: block;
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  z-index: 10;
  cursor: pointer;
}

/* Мобильная версия: крупнее модалка и игровая зона */
@media (max-width: 900px) {
  .mp-modal-overlay {
    padding: 0.75rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
  .mp-modal {
    max-width: min(100%, 440px);
    width: 100%;
    max-height: 90vh;
  }
  .mp-game-area {
    height: min(55vh, 360px);
    min-height: 260px;
  }
  .mp-mouse { width: 64px; height: 64px; margin: -32px 0 0 -32px; font-size: 2.75rem; }
  .mp-scores { font-size: 0.85rem; }
  .mp-total { font-size: 0.8rem; }
}
