/* ===== ONLINE MULTIPLAYER STYLES ===== */

/* ---- Toast Container & Toasts ---- */
.toast-container {
  position: fixed;
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 200;
  pointer-events: none;
  max-width: 90vw;
  width: 360px;
}

.toast {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  color: var(--c-text);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  pointer-events: auto;
  animation: slideUp var(--dur-mid) var(--ease-bounce);
}

.toast--error {
  border-color: var(--c-danger);
  background: rgba(239, 83, 80, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.toast__close {
  background: transparent;
  border: none;
  color: var(--c-text-muted);
  font-size: var(--fs-lg);
  cursor: pointer;
  padding: 0 var(--sp-1);
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Lobby Online Button ---- */
.lobby__online-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--c-accent), #4a78d4);
  color: #fff;
  border: none;
  border-radius: var(--r-lg);
  box-shadow: 0 4px 16px rgba(91, 141, 238, 0.4);
  font-size: var(--fs-lg);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
}
.lobby__online-btn:active {
  transform: scale(0.98);
}
.lobby__online-icon {
  font-size: var(--fs-xl);
}

/* ---- Form View (#/online) ---- */
.online-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.online-form-container {
  flex: 1;
  padding: var(--sp-6) var(--sp-4);
  max-width: 440px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.online-hint {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
  line-height: 1.6;
  text-align: center;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.form-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--c-text);
}

.form-input {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font);
  font-size: var(--fs-md);
  color: var(--c-text);
  min-height: 48px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.form-input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 2px rgba(91, 141, 238, 0.25);
}

.inline-error {
  background: rgba(239, 83, 80, 0.15);
  border: 1px solid var(--c-danger);
  border-radius: var(--r-md);
  color: #ff8a80;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  line-height: 1.5;
  display: none;
}
.inline-error.visible {
  display: block;
}

/* ---- Waiting Room (#/room) ---- */
.room-container {
  flex: 1;
  padding: var(--sp-4);
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.room-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

.player-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  position: relative;
  box-shadow: var(--shadow-sm);
}
.player-card--empty {
  border-style: dashed;
  opacity: 0.7;
}

.player-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.player-card__nick {
  font-size: var(--fs-md);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-card__badge {
  font-size: var(--fs-xs);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  border: 1px solid var(--c-border);
}
.player-card__badge--you {
  background: rgba(91, 141, 238, 0.2);
  border-color: var(--c-accent);
  color: var(--c-accent);
  font-weight: 700;
}
.player-card__badge--ready {
  background: rgba(45, 212, 191, 0.2);
  border-color: var(--c-p1);
  color: var(--c-p1);
  font-weight: 700;
}

.player-card__status {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online { background: #10b981; box-shadow: 0 0 6px rgba(16, 185, 129, 0.6); }
.status-dot.offline { background: var(--c-text-muted); }
.status-dot.reconnecting { background: var(--c-p0); }

/* Invite Bar */
.invite-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  gap: var(--sp-2);
}
.invite-bar__text {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

/* Room Game Picker */
.room-picker-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--c-text-muted);
  margin-top: var(--sp-1);
}

.room-game-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

.room-game-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  text-align: center;
  position: relative;
  min-height: 100px;
}
.room-game-card:disabled {
  cursor: default;
  opacity: 0.85;
}
.room-game-card.selected {
  border-color: var(--c-accent);
  background: rgba(91, 141, 238, 0.12);
  box-shadow: 0 0 12px rgba(91, 141, 238, 0.35);
}
.room-game-card__name {
  font-size: var(--fs-sm);
  font-weight: 700;
}
.room-game-card__art {
  width: 50px;
  height: 50px;
}

.room-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
}

/* ---- Online Game View (#/online-game) ---- */
.connection-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  flex-shrink: 0;
}
.connection-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.connection-chip.online .dot { background: #10b981; box-shadow: 0 0 6px #10b981; }
.connection-chip.reconnecting .dot { background: var(--c-p0); animation: pulse 1s infinite; }
.connection-chip.offline .dot { background: var(--c-danger); }

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.banner-disconnected {
  background: rgba(245, 166, 35, 0.2);
  border-bottom: 1px solid var(--c-p0);
  color: #ffcc80;
  padding: var(--sp-2) var(--sp-4);
  text-align: center;
  font-size: var(--fs-sm);
  font-weight: 600;
  animation: fadeIn var(--dur-mid) var(--ease-out);
}

.online-player-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-xs);
}

.player-badge {
  display: flex;
  align-items: center;
  gap: 6px;
}
.player-badge .turn-dot {
  width: 10px;
  height: 10px;
}
.player-badge__you {
  background: rgba(91, 141, 238, 0.25);
  border: 1px solid var(--c-accent);
  border-radius: var(--r-xs);
  padding: 1px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--c-accent);
}
