/* ============================================================================
   Spelportalen — shared "juice" layer styles
   ----------------------------------------------------------------------------
   Companion to game-juice.js. Styles the persistent sound toggle (mirrors the
   portal-nav pill in the top-LEFT — this sits top-RIGHT), the full-screen
   confetti canvas, and the first-run discovery pulse. Motion is gated behind
   prefers-reduced-motion. Loaded after each page's own styles and games-theme.
   ============================================================================ */

/* ── Sound toggle pill (top-right, frosted, matches .portal-nav) ── */
.juice-sound-btn {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top, 0px));
  right: calc(1rem + env(safe-area-inset-right, 0px));
  z-index: 61;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: #e8e6f0;
  background: rgba(28, 28, 48, 0.72);
  border: 1px solid rgba(130, 130, 180, 0.18);
  border-radius: 100px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: color 0.15s ease, border-color 0.15s ease,
              background 0.15s ease, transform 0.15s ease;
}

.juice-sound-btn:hover {
  border-color: rgba(130, 130, 180, 0.4);
  background: rgba(28, 28, 48, 0.92);
  transform: scale(1.06);
}

.juice-sound-btn:active {
  transform: scale(0.94);
}

.juice-sound-btn:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
}

/* First-run invitation: a calm glowing pulse drawing the eye to the toggle. */
.juice-sound-btn.juice-hint {
  animation: juiceHintPulse 1.8s ease-in-out infinite;
}

@keyframes juiceHintPulse {
  0%, 100% {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25),
                0 0 0 0 rgba(167, 139, 250, 0.45);
  }
  50% {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25),
                0 0 0 10px rgba(167, 139, 250, 0);
  }
}

/* ── Confetti canvas — above everything, never intercepts input ── */
.juice-confetti {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9998;
}

/* ── Capture poof — expanding burst centered on a removed piece ── */
.juice-poof {
  position: fixed;
  width: 2.6rem;
  height: 2.6rem;
  margin: -1.3rem 0 0 -1.3rem;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9997;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.85) 0%, rgba(253, 230, 138, 0.55) 35%, rgba(251, 191, 36, 0) 70%);
  animation: juicePoof 0.5s ease-out forwards;
}

@keyframes juicePoof {
  0%   { transform: scale(0.3); opacity: 0.95; }
  100% { transform: scale(1.9); opacity: 0; }
}

@media (max-width: 400px) {
  .juice-sound-btn {
    top: 0.5rem;
    right: 0.5rem;
    width: 2.4rem;
    height: 2.4rem;
    font-size: 1rem;
  }
}

/* ============================================================================
   Victory screen — upgrades the shared #gameover screen into a themed hero.
   Scoped under #gameover.juice-* so it only applies once a result is set, and
   the high ID specificity cleanly overrides each game's own .result-text/.btn
   styling. The game's own #resultText line and any detail (scores) are kept.
   ============================================================================ */

#gameover.juice-over {
  position: relative;
}

/* The generic "Spelet slut" title becomes a quiet eyebrow above the badge. */
#gameover.juice-over > h2 {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #6b6a7e;
  margin-bottom: 0.1rem;
}

.juice-victory {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 6.5rem;
  margin: 0.2rem 0 0.3rem;
  pointer-events: none;
}

.juice-victory-badge {
  position: relative;
  z-index: 1;
  font-size: 4.4rem;
  line-height: 1;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
  animation: juiceBadgePop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Sunburst behind the badge — shown for wins, hidden otherwise.
   The gold wedges only paint where CSS masking is supported; without a mask the
   wedges would render as a full square, so we gate the background behind
   @supports and degrade to an invisible element (the badge glow still carries
   the win). */
.juice-victory-rays {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15rem;
  height: 15rem;
  margin: -7.5rem 0 0 -7.5rem;
  opacity: 0;
  transition: opacity 0.4s ease;
}

@supports ((-webkit-mask: radial-gradient(#000, #000)) or (mask: radial-gradient(#000, #000))) {
  .juice-victory-rays {
    background: repeating-conic-gradient(
      rgba(253, 230, 138, 0.30) 0deg 7deg,
      transparent 7deg 21deg
    );
    -webkit-mask: radial-gradient(circle, transparent 2.3rem, #000 2.6rem, #000 6.6rem, transparent 7.2rem);
            mask: radial-gradient(circle, transparent 2.3rem, #000 2.6rem, #000 6.6rem, transparent 7.2rem);
  }
}

/* ── Win: gold trophy, spinning rays, gold gradient result line ── */
#gameover.juice-won .juice-victory-badge {
  filter: drop-shadow(0 0 18px rgba(251, 191, 36, 0.55)) drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
}
#gameover.juice-won .juice-victory-rays {
  opacity: 1;
  animation: juiceRaysSpin 11s linear infinite;
}
#gameover.juice-won #resultText {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fde68a 0%, #fbbf24 45%, #f59e0b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ── Draw / spectator: calm neutral ── */
#gameover.juice-draw #resultText,
#gameover.juice-spectator #resultText {
  font-size: 1.7rem;
  font-weight: 800;
  color: #cfcde0;
}
#gameover.juice-spectator .juice-victory-badge,
#gameover.juice-draw .juice-victory-badge {
  filter: drop-shadow(0 0 14px rgba(167, 139, 250, 0.4)) drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
}

/* ── Loss: encouraging, never punishing ── */
#gameover.juice-lost #resultText {
  font-size: 1.7rem;
  font-weight: 800;
  color: #9fb0e0;
}
#gameover.juice-lost .juice-victory-badge {
  filter: drop-shadow(0 0 14px rgba(96, 165, 250, 0.35)) drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
}

/* Primary CTA gets a soft lift + glow on the victory screen. */
#gameover.juice-over .btn-primary {
  box-shadow: 0 10px 28px rgba(99, 102, 241, 0.38);
  animation: juiceCtaRise 0.5s ease 0.12s both;
}

@keyframes juiceBadgePop {
  0%   { opacity: 0; transform: scale(0.3) rotate(-22deg); }
  60%  { opacity: 1; transform: scale(1.15) rotate(6deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes juiceRaysSpin {
  to { transform: rotate(360deg); }
}

@keyframes juiceCtaRise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   Alive lobby — share moment + presence on the shared waiting screen.
   Elements are injected by shared-lobby.js (markup identical across all games).
   ============================================================================ */

/* The injected presence visual supersedes the old spinner row. */
#waiting.lobby-enhanced .waiting-row { display: none; }

/* Tap-to-copy join code. */
.join-code.lobby-code-tap {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.join-code.lobby-code-tap:hover {
  transform: translateY(-1px);
  border-color: rgba(167, 139, 250, 0.5);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.18);
}
.join-code.lobby-code-tap:active { transform: translateY(0); }
.join-code.lobby-code-tap:focus-visible { outline: 2px solid #a78bfa; outline-offset: 3px; }

/* Primary share button — brand indigo→violet, distinct from per-game accents. */
.lobby-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.9rem 1.8rem;
  font: inherit;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #8b5cf6 55%, #a855f7);
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  animation: juiceShareIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.lobby-share-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(99, 102, 241, 0.5); }
.lobby-share-btn:active { transform: translateY(0); }
.lobby-share-btn:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 3px; }
.lobby-share-ico { font-size: 1.15rem; line-height: 1; }

/* Presence: you ··· friend */
.lobby-presence {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  margin: 0.4rem 0 0.2rem;
}
.lobby-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 4.5rem;
}
.lobby-avatar {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
}
.lobby-slot-you .lobby-avatar {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
.lobby-slot-guest .lobby-avatar {
  background: rgba(130, 130, 180, 0.10);
  border: 2px dashed rgba(167, 139, 250, 0.45);
  color: #8b8a9e;
  animation: juiceGuestPulse 1.8s ease-in-out infinite;
}
.lobby-slot-guest.connected .lobby-avatar {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: none;
  color: #fff;
  animation: juiceGuestPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lobby-slot-label { font-size: 0.72rem; font-weight: 600; color: #8b8a9e; }
.lobby-slot-guest.connected .lobby-slot-label { color: #4ade80; }

.lobby-connector { display: inline-flex; gap: 0.3rem; align-items: center; }
.lobby-connector span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(167, 139, 250, 0.5);
  animation: juiceDot 1.4s ease-in-out infinite;
}
.lobby-connector span:nth-child(2) { animation-delay: 0.2s; }
.lobby-connector span:nth-child(3) { animation-delay: 0.4s; }

@keyframes juiceShareIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes juiceGuestPulse {
  0%, 100% { border-color: rgba(167, 139, 250, 0.30); transform: scale(1); }
  50%      { border-color: rgba(167, 139, 250, 0.70); transform: scale(1.06); }
}
@keyframes juiceGuestPop {
  0%   { transform: scale(0.4); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes juiceDot {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50%      { opacity: 1; transform: translateY(-3px); }
}

/* ── Rematch control on the game-over screen ── */
.lobby-rematch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 2rem;
  font: inherit;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #8b5cf6 55%, #a855f7);
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.38);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.lobby-rematch-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(99, 102, 241, 0.5); }
.lobby-rematch-btn:active:not(:disabled) { transform: translateY(0); }
.lobby-rematch-btn:disabled { opacity: 0.6; cursor: default; }
.lobby-rematch-btn:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 3px; }
.lobby-rematch-btn.offer { animation: juiceRematchPulse 1.6s ease-in-out infinite; }

.lobby-rematch-hint {
  font-size: 0.82rem;
  font-weight: 600;
  color: #c4b5fd;
}

@keyframes juiceRematchPulse {
  0%, 100% { box-shadow: 0 8px 22px rgba(99, 102, 241, 0.38), 0 0 0 0 rgba(167, 139, 250, 0.5); }
  50%      { box-shadow: 0 8px 22px rgba(99, 102, 241, 0.38), 0 0 0 10px rgba(167, 139, 250, 0); }
}

/* ── Portal nav (top-left link back to the portal, injected by shared-lobby) ── */
.portal-nav {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top, 0px));
  left: calc(1rem + env(safe-area-inset-left, 0px));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #9695ac;
  text-decoration: none;
  background: rgba(28, 28, 48, 0.72);
  border: 1px solid rgba(130, 130, 180, 0.18);
  border-radius: 100px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: color 0.15s ease, border-color 0.15s ease,
              background 0.15s ease, transform 0.15s ease;
}
.portal-nav:hover {
  color: #e8e6f0;
  border-color: rgba(130, 130, 180, 0.4);
  background: rgba(28, 28, 48, 0.92);
  transform: translateX(-2px);
}
.portal-nav:focus-visible { outline: 2px solid #a78bfa; outline-offset: 2px; }
.portal-nav .portal-nav-arrow { font-size: 1rem; line-height: 1; }

/* The static per-game .back-link is the no-JS fallback; hide it only once the
   injected portal-nav actually exists (shared-lobby sets the body class). */
body.has-portal-nav .back-link { display: none !important; }

@media (max-width: 400px) {
  .portal-nav {
    top: calc(0.5rem + env(safe-area-inset-top, 0px));
    left: calc(0.5rem + env(safe-area-inset-left, 0px));
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
  }
}

/* Each game positions its own #connStatus dot at 1rem; keep it clear of the
   home indicator / rounded corners (loaded after the page styles, so wins). */
.connection-status {
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  right: calc(1rem + env(safe-area-inset-right, 0px));
}

/* ── Local (hot-seat) chrome, injected by local-game.js ──
   Built on the shared tokens (with fallbacks), so themed games — kalah's
   wood, battleship's navy — tint this chrome to match themselves. */
.local-exit-btn {
  margin-top: 0.5rem;
  padding: 0.4rem 1.2rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--bg-card-border, rgba(130, 130, 180, 0.2));
  border-radius: var(--radius-sm, 8px);
  background: rgba(130, 130, 180, 0.08);
  color: var(--text-muted, #9695ac);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.local-exit-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.local-exit-btn:focus-visible { outline: 2px solid #a78bfa; outline-offset: 2px; }

.local-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 1rem;
  text-align: center;
  background: rgba(15, 15, 26, 0.9);
  color: var(--text-primary, #f0eef8);
  font-family: inherit;
}
/* Handover must fully cover the outgoing player's board (hidden info). */
.local-overlay-handover { background: rgba(15, 15, 26, 0.97); z-index: 200; }

.local-overlay-title { font-size: 1.4rem; font-weight: 800; }
.local-overlay-sub { font-size: 0.95rem; color: var(--text-muted, #9695ac); }
.local-overlay-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; justify-content: center; }

.local-btn {
  padding: 0.8rem 2rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md, 14px);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.local-btn:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 3px; }
.local-btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}
.local-btn-danger { background: rgba(239, 68, 68, 0.85); }
.local-btn-quiet {
  background: rgba(130, 130, 180, 0.12);
  border: 1px solid rgba(130, 130, 180, 0.3);
  color: var(--text-primary, #e8e6f0);
}

/* ── Optional player name (home screen, injected by shared-lobby) ── */
.lobby-name-row {
  width: 100%;
  max-width: 280px;
  display: flex;
  justify-content: center;
}
.lobby-name-row input {
  width: 100%;
  padding: 0.6rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-primary, #f0eef8);
  background: rgba(130, 130, 180, 0.08);
  border: 1px solid var(--bg-card-border, rgba(130, 130, 180, 0.12));
  border-radius: var(--radius-md, 14px);
  outline: none;
  transition: border-color 0.15s ease;
}
.lobby-name-row input:focus { border-color: #a78bfa; }
.lobby-name-row input::placeholder { color: var(--text-dim, #86859e); font-weight: 400; }

/* ── In-game actions: draw offer + resign (injected by shared-lobby) ── */
.lobby-game-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.35rem;
}
.lobby-quiet-btn {
  padding: 0.35rem 0.9rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted, #9695ac);
  background: rgba(130, 130, 180, 0.08);
  border: 1px solid var(--bg-card-border, rgba(130, 130, 180, 0.12));
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.lobby-quiet-btn:hover:not(:disabled) {
  background: rgba(130, 130, 180, 0.16);
  color: var(--text-primary, #f0eef8);
}
.lobby-quiet-btn:disabled { opacity: 0.55; cursor: default; }
.lobby-quiet-btn:focus-visible { outline: 2px solid #a78bfa; outline-offset: 2px; }
.lobby-quiet-btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* ── Action banner (draw offers, abandon nudge) ── */
.lobby-action-banner {
  position: fixed;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 85;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 94vw;
  padding: 0.6rem 0.9rem;
  background: rgba(28, 28, 48, 0.96);
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: juiceToastIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.lobby-action-banner-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e8e6f0;
}
.lobby-banner-btn {
  flex: none;
  padding: 0.45rem 0.95rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: #e8e6f0;
  background: rgba(130, 130, 180, 0.14);
  border: 1px solid rgba(130, 130, 180, 0.3);
  border-radius: 100px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lobby-banner-btn.primary {
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.lobby-banner-btn:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 2px; }

/* ── Loading skeleton (before the first online state arrives) ── */
#game.lobby-awaiting-state { pointer-events: none; }
#game.lobby-awaiting-state > * {
  animation: juiceAwaitPulse 1.4s ease-in-out infinite;
}
@keyframes juiceAwaitPulse {
  0%, 100% { opacity: 0.75; }
  50%      { opacity: 0.4; }
}

/* ── Toasts (shared transient notifications — replaces window.alert) ── */
.juice-toast-wrap {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: min(92vw, 420px);
  pointer-events: none;
}

.juice-toast {
  max-width: 100%;
  padding: 0.7rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  color: #e8e6f0;
  background: rgba(28, 28, 48, 0.94);
  border: 1px solid rgba(130, 130, 180, 0.3);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: juiceToastIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.juice-toast-error { border-color: rgba(248, 113, 113, 0.5); }
.juice-toast-success { border-color: rgba(74, 222, 128, 0.45); }
.juice-toast-leaving { opacity: 0; transform: translateY(-6px); }

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

/* ── Connection banner (visible reconnect state, injected by shared-lobby) ── */
.lobby-conn-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: calc(0.5rem + env(safe-area-inset-top, 0px)) 1rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fde68a;
  background: rgba(45, 35, 12, 0.92);
  border-bottom: 1px solid rgba(253, 230, 138, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform: translateY(-110%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.lobby-conn-banner.show { transform: translateY(0); }
.lobby-conn-banner .lobby-conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fbbf24;
  animation: juiceDot 1.2s ease-in-out infinite;
}

/* ── Opponent presence chip (injected by shared-lobby on presence events) ── */
.lobby-presence-chip {
  position: fixed;
  top: calc(4rem + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 62;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 92vw;
  padding: 0.45rem 0.95rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fde68a;
  background: rgba(28, 28, 48, 0.92);
  border: 1px solid rgba(253, 230, 138, 0.3);
  border-radius: 100px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.lobby-presence-chip.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.lobby-presence-chip .lobby-conn-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fbbf24;
  animation: juiceDot 1.2s ease-in-out infinite;
}

/* ── Respect reduced-motion: kill the pulse (JS already skips confetti). ── */
@media (prefers-reduced-motion: reduce) {
  #game.lobby-awaiting-state > * { animation: none; opacity: 0.6; }
  .juice-toast { animation: none; }
  .lobby-conn-banner { transition: none; }
  .lobby-conn-banner .lobby-conn-dot,
  .lobby-presence-chip .lobby-conn-dot { animation: none; }
  .juice-sound-btn.juice-hint { animation: none; }
  .lobby-rematch-btn.offer { animation: none; }
  .juice-victory-badge { animation: none; }
  #gameover.juice-won .juice-victory-rays { animation: none; }
  #gameover.juice-over .btn-primary { animation: none; }
  .lobby-share-btn,
  .lobby-slot-guest .lobby-avatar,
  .lobby-slot-guest.connected .lobby-avatar,
  .lobby-connector span { animation: none; }

  /* Board-move animations across every game now respect reduced-motion too
     (each game declares these in its own inline styles, which never guarded). */
  .piece-x.just-placed, .piece-o.just-placed,
  .piece.placing, .piece.dropping, .piece.flipping,
  .stone.placing { animation: none !important; }

  /* Game-defined pulses and pops that previously escaped the guard. */
  .turn-indicator.turn-pulse { animation: none; }
  .piece.red.win-piece, .piece.yellow.win-piece { animation: none; }
  .pit.seed-changed .seed-count, .store.seed-changed .seed-count { animation: none; }
  .uno-card.just-played, .playing-card.just-played { animation: none; }
  .confetti-piece { display: none; }
  .floating-reaction { animation: none; }
}

/* ── Head-to-head series tally (injected by shared-lobby) ── */
.lobby-series {
  font-size: 0.82rem;
  font-weight: 700;
  color: #c4b5fd;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 0.15rem 0;
}
#lobbySeriesOver { margin-bottom: 0.3rem; font-size: 0.95rem; }

/* ── Achievement unlock toast (SpelStats) ── */
.achv-toast {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  max-width: 92vw;
  padding: 0.7rem 1.1rem 0.7rem 0.8rem;
  background: linear-gradient(135deg, rgba(251,191,36,0.18), rgba(139,92,246,0.2));
  border: 1px solid rgba(251, 191, 36, 0.5);
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: achvIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.achv-toast-ico { font-size: 2rem; line-height: 1; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4)); }
.achv-toast-text { display: flex; flex-direction: column; gap: 0.05rem; }
.achv-toast-text strong { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #fbbf24; }
.achv-toast-text span { font-size: 0.95rem; font-weight: 700; color: #f0eef8; }
.achv-toast.achv-leaving { opacity: 0; transform: translateX(-50%) translateY(-8px); }
@keyframes achvIn { from { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(0.9); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
@media (prefers-reduced-motion: reduce) { .achv-toast { animation: none; } }

/* ── Play-another-game-together (game-over screen) ── */
.lobby-nextgame-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  margin: 0.5rem auto 0;
  padding: 0.7rem 1.4rem;
  font: inherit; font-size: 0.95rem; font-weight: 700;
  color: #e8e6f0;
  background: rgba(130, 130, 180, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 100px; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.lobby-nextgame-btn:hover { background: rgba(139, 92, 246, 0.18); border-color: rgba(167, 139, 250, 0.6); transform: translateY(-1px); }
.lobby-nextgame-btn:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 3px; }

.nextgame-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  width: 100%; max-width: 380px;
  margin: 0.4rem 0;
}
@media (min-width: 420px) { .nextgame-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.nextgame-item {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  padding: 0.7rem 0.4rem;
  font: inherit; font-size: 0.82rem; font-weight: 600;
  color: #e8e6f0;
  background: linear-gradient(145deg, #1c1c30, #16162a);
  border: 1px solid rgba(130, 130, 180, 0.14);
  border-radius: 12px; cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.nextgame-item:hover { border-color: rgba(167, 139, 250, 0.5); transform: translateY(-2px); }
.nextgame-item:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 2px; }
.nextgame-ico { font-size: 1.6rem; line-height: 1; }
.nextgame-cancel {
  margin-top: 0.4rem;
  padding: 0.55rem 1.4rem;
  font: inherit; font-size: 0.85rem; font-weight: 600;
  color: #9695ac; background: transparent;
  border: 1px solid rgba(130, 130, 180, 0.2); border-radius: 100px; cursor: pointer;
}
.nextgame-cancel:hover { color: #e8e6f0; }
