/* =========================================================================
   ONLINE MULTIPLAYER — Live Status Notices, Room Badge & Lobby / QR Modal
   ========================================================================= */

.online-room-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.45);
  cursor: pointer;
  white-space: nowrap;
}
.online-room-pill:hover {
  border-color: rgba(56, 189, 248, 0.85);
  background: rgba(30, 41, 59, 0.92);
}
.online-room-pill.hidden {
  display: none;
}
.online-room-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
}

/* ---- Live In-Game Status Banner ("Tu turno", "Esperando a...", "Viendo a...") ---- */
.online-status-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 28;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 10px;
  border-radius: 999px;
  background: rgba(10, 16, 26, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  color: #f8fafc;
  pointer-events: auto;
  max-width: min(92%, 540px);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.online-status-banner.hidden {
  display: none;
}

.online-status-banner.is-your-turn {
  border-color: rgba(52, 211, 153, 0.72);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.22);
}
.online-status-banner.is-waiting {
  border-color: rgba(251, 191, 36, 0.7);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.22);
}
.online-status-banner.is-watching {
  border-color: rgba(56, 189, 248, 0.72);
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.24);
}
.online-status-banner.is-resuming,
.online-status-banner.is-reconnecting {
  border-color: rgba(248, 113, 113, 0.75);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.25);
}

.online-status-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: onlinePulse 1.6s ease-in-out infinite;
}
.is-your-turn .online-status-pulse { background: #34d399; }
.is-waiting .online-status-pulse { background: #fbbf24; }
.is-watching .online-status-pulse { background: #38bdf8; }
.is-resuming .online-status-pulse,
.is-reconnecting .online-status-pulse { background: #f87171; }

@keyframes onlinePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.55; }
}

.online-status-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  background-color: #1e293b;
}
.online-status-avatar.hidden {
  display: none;
}

.online-status-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.online-status-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.online-status-detail {
  font-size: 11px;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-status-action {
  margin-left: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.65);
  background: rgba(251, 191, 36, 0.16);
  color: #fef08a;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.online-status-action:hover {
  background: rgba(251, 191, 36, 0.3);
}
.online-status-action.hidden {
  display: none;
}

/* ---- Online Lobby & QR Modal ---- */
.online-modal-card {
  width: min(760px, calc(94vw / var(--ui-scale, 1)));
  max-height: calc(92dvh / var(--ui-scale, 1));
  overflow-y: auto;
  padding: 20px 22px;
  text-align: left;
  background: linear-gradient(155deg, #172525, #101919 55%, #0d1518);
  border: 1px solid #405351;
  color: #eef1e9;
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.online-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.online-modal-head h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.03em;
  color: #eef1e9;
}
.online-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(182, 219, 200, 0.14);
  color: #b6dbc8;
  border: 1px solid rgba(182, 219, 200, 0.36);
}
.online-role-badge.is-owner {
  background: rgba(221, 216, 188, 0.16);
  color: #eee8ce;
  border-color: rgba(221, 216, 188, 0.45);
}

.online-entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.online-box {
  background: #121f1f;
  border: 1px solid #2e403e;
  border-radius: 14px;
  padding: 14px 16px;
}
.online-box h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #eef1e9;
}
.online-box p {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: #a9b8b6;
  line-height: 1.4;
}

.online-code-input-row {
  display: flex;
  gap: 8px;
}
.online-code-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(2, 6, 23, 0.7);
  color: #f8fafc;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
}
.online-code-input:focus {
  outline: none;
  border-color: #38bdf8;
}

.online-lobby-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 640px) {
  .online-lobby-grid {
    grid-template-columns: 1fr;
  }
}

.online-qr-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  padding: 14px;
}
.online-qr-box {
  background: #ffffff;
  border-radius: 10px;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.online-qr-box svg {
  display: block;
  width: 168px;
  height: 168px;
}
.online-room-code {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #fde68a;
}
.online-qr-actions {
  display: flex;
  gap: 6px;
  width: 100%;
}
.online-qr-actions .btn {
  flex: 1;
  font-size: 11px;
  padding: 6px 8px;
}

.online-config-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.online-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}
.online-field-row label {
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 600;
}
.online-select {
  background: rgba(2, 6, 23, 0.8);
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.online-peers-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.online-peer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.16);
}
.online-peer-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background-color: #0f172a;
}
.online-peer-name {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
  flex: 1;
}
.online-peer-tag {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
}
.online-peer-tag.owner {
  background: rgba(251, 191, 36, 0.2);
  color: #fde68a;
}
.online-peer-tag.offline {
  background: rgba(248, 113, 113, 0.2);
  color: #fca5a5;
}

.online-saved-banner {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.online-saved-banner p {
  margin: 0;
  font-size: 12px;
  color: #fef3c7;
}

.online-swap-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.online-swap-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.online-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}
.online-status-line {
  font-size: 12px;
  color: #94a3b8;
}

/* The online room opens from the home screen: it must sit above it
   (home overlay z-index 40), with its own solid backdrop */
#online-modal {
  position: fixed;
  z-index: 60;
  background: rgba(4, 7, 12, 0.88);
}

/* Controller focus inside the room window */
#online-modal .pad-focus {
  outline: 3px solid rgba(250, 204, 21, 0.9);
  outline-offset: 2px;
}

/* ---- A player of the match dropped: wait or leave ------------------------ */
.online-dropped {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  max-width: 440px;
  margin: 0 auto;
  animation: onlineDropIn 0.32s ease-out both;
}
.online-dropped h2 { margin: 0; font-size: 1.2rem; }
.online-dropped p { margin: 0; color: rgba(226, 232, 240, 0.82); line-height: 1.45; }
.online-dropped-clock { font-variant-numeric: tabular-nums; color: #fcd34d !important; }
.online-dropped-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 4px; }
/* Signal bars fading in turn: "looking for the link" */
.online-dropped-signal { display: flex; align-items: flex-end; gap: 5px; height: 30px; }
.online-dropped-signal i {
  width: 8px;
  border-radius: 2px;
  background: #fcd34d;
  animation: onlineSignal 1.4s ease-in-out infinite;
}
.online-dropped-signal i:nth-child(1) { height: 10px; }
.online-dropped-signal i:nth-child(2) { height: 19px; animation-delay: 0.2s; }
.online-dropped-signal i:nth-child(3) { height: 28px; animation-delay: 0.4s; }
@keyframes onlineSignal {
  0%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}
@keyframes onlineDropIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .online-dropped, .online-dropped-signal i { animation: none; }
}

/* ---- Conectarse a partida: QR with the camera ----------------------------- */
.online-scan-btn { margin-top: 10px; width: 100%; }
.online-scan { display: grid; gap: 8px; justify-items: center; margin-top: 10px; }
.online-scan.hidden { display: none; }
.online-scan video {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1;
  object-fit: cover;
  border: 2px solid #fcd34d;
  border-radius: 14px;
  background: #000;
}
.online-scan span, .online-scan-note { color: rgba(226, 232, 240, 0.75); font-size: 12px; line-height: 1.4; }
.online-scan-note { margin-top: 10px; }
