/* ───────────────────────────────────────────────────────────
   Multiplayer game UI (matchmaking, Lightning, friends)
   ─────────────────────────────────────────────────────────── */

/* Inline friend invite panel under Lightning card */
.dash-friends-match-panel {
  margin-top: 10px;
  padding: 10px 10px 8px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 0 0, rgba(15, 23, 42, 0.96), transparent 60%),
    rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.6);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.9);
}

.dash-friends-match-panel[hidden] {
  display: none;
}

.dash-friends-match-header h4 {
  margin: 0 0 2px;
  font-size: 0.96rem;
}

.dash-friends-match-eyebrow {
  margin: 0 0 2px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  opacity: 0.85;
}

.dash-friends-match-sub {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: #cbd5f5;
}

.dash-friends-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  padding-right: 2px;
}

.dash-friends-list-empty {
  margin: 2px 0 4px;
  font-size: 0.8rem;
  color: #e2e8f0;
  opacity: 0.8;
}

.dash-friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(51, 65, 85, 0.9);
}

.dash-friend-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.dash-friend-avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #e5e7eb, #9ca3af);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: #020617;
}

.dash-friend-text {
  min-width: 0;
}

.dash-friend-name {
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-friend-meta {
  font-size: 0.75rem;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-friend-invite-btn {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.8);
  background: rgba(15, 23, 42, 0.96);
  color: #e5edff;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.dash-friend-invite-btn:hover:not(:disabled) {
  background: rgba(30, 64, 175, 0.9);
  border-color: rgba(248, 250, 252, 0.95);
}

.dash-friend-invite-btn[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
}

.dash-friends-panel-status {
  margin-top: 6px;
  font-size: 0.78rem;
  min-height: 1.1em;
  color: #e2e8f0;
}

.dash-friends-panel-status.is-error {
  color: #fecaca;
}

.dash-friends-panel-status.is-success {
  color: #bbf7d0;
}

.dash-friends-match-footer {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.dash-friends-close {
  font-size: 0.78rem;
  padding-inline: 12px;
}

/* Friend Lightning invite toast (invitee side) */
.dash-invite-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 980; /* below Lightning (1000) and above main content */
  max-width: 320px;
  pointer-events: none;
}

.dash-invite-toast[hidden] {
  display: none;
}

.dash-invite-card {
  pointer-events: auto;
  padding: 14px 16px 12px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 0 0, rgba(15, 23, 42, 0.98), transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(56, 189, 248, 0.25), transparent 60%),
    rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.7);
  box-shadow:
    0 14px 40px rgba(15, 23, 42, 0.95),
    0 0 0 1px rgba(15, 23, 42, 0.9);
  color: #e5edff;
}

.dash-invite-eyebrow {
  margin: 0 0 2px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  opacity: 0.9;
}

.dash-invite-title {
  margin: 0 0 4px;
  font-size: 0.96rem;
}

.dash-invite-body {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: #cbd5f5;
}

.dash-invite-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.dash-invite-actions .dash-cta {
  margin-top: 0;
}

.dash-invite-status {
  margin-top: 4px;
  font-size: 0.78rem;
  min-height: 1.1em;
}

.dash-invite-status.is-error {
  color: #fecaca;
}

@media (max-width: 640px) {
  .dash-invite-toast {
    right: 12px;
    left: 12px;
    bottom: 16px;
  }

  .dash-invite-card {
    max-width: none;
  }
}

/* ───────────────────────────────────────────────────────────
   Full-screen matchmaking overlay – colorful version
   ─────────────────────────────────────────────────────────── */

body.dashboard-page.is-matchmaking-active {
  overflow: hidden;
}

.matchmaking-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 5% 0%, rgba(251, 191, 36, 0.18), transparent 60%),
    radial-gradient(circle at 100% 10%, rgba(244, 63, 94, 0.25), transparent 55%),
    radial-gradient(circle at 0% 100%, rgba(56, 189, 248, 0.26), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(129, 140, 248, 0.3), transparent 55%),
    #020617;
  background-size: 180% 180%;
  animation: mmAurora 18s ease-in-out infinite;
  backdrop-filter: blur(28px) saturate(1.45);
  -webkit-backdrop-filter: blur(28px) saturate(1.45);
}

/* Soft animated “nebula” over the whole screen */
.matchmaking-overlay::before {
  content: '';
  position: absolute;
  inset: -25%;
  background:
    conic-gradient(
      from 120deg,
      rgba(251, 191, 36, 0.02),
      rgba(249, 115, 22, 0.12),
      rgba(236, 72, 153, 0.16),
      rgba(59, 130, 246, 0.12),
      rgba(52, 211, 153, 0.12),
      rgba(251, 191, 36, 0.02)
    );
  mix-blend-mode: screen;
  opacity: 0.75;
  filter: blur(40px);
  pointer-events: none;
  animation: mmAuroraShift 22s linear infinite;
}

.matchmaking-overlay.is-visible {
  display: flex;
}

/* Core matchmaking card */
.matchmaking-panel {
  position: relative;
  max-width: 480px;
  width: 100%;
  padding: 24px 24px 18px;
  border-radius: 26px;
  background:
    radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.08), transparent 60%),
    radial-gradient(circle at 100% 0, rgba(251, 191, 36, 0.12), transparent 65%),
    rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.65);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 28px 90px rgba(15, 23, 42, 0.98),
    0 0 60px rgba(56, 189, 248, 0.30);
  color: #e5edff;
  overflow: hidden;
}

/* Animated gradient ring behind the panel content */
.matchmaking-panel::before {
  content: '';
  position: absolute;
  inset: -40%;
  background:
    conic-gradient(
      from 240deg,
      rgba(251, 191, 36, 0.0),
      rgba(251, 191, 36, 0.35),
      rgba(236, 72, 153, 0.38),
      rgba(59, 130, 246, 0.4),
      rgba(52, 211, 153, 0.35),
      rgba(251, 191, 36, 0.0)
    );
  opacity: 0.45;
  filter: blur(40px);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: mmOrbitSlow 26s linear infinite;
}

/* Subtle inner border & gloss */
.matchmaking-panel::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(148, 163, 184, 0.6);
  box-shadow:
    inset 0 1px 0 rgba(248, 250, 252, 0.12),
    inset 0 -14px 30px rgba(15, 23, 42, 0.95);
  pointer-events: none;
}

/* Spinning orbit accent in top-right */
.matchmaking-orbit {
  position: absolute;
  width: 260px;
  height: 260px;
  right: -90px;
  top: -120px;
  border-radius: 999px;
  border: 2px solid rgba(148, 163, 184, 0.35);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 0 40px rgba(248, 250, 252, 0.08);
  background:
    radial-gradient(circle at 30% 10%, rgba(251, 191, 36, 0.35), transparent 65%),
    radial-gradient(circle at 70% 80%, rgba(236, 72, 153, 0.3), transparent 65%),
    radial-gradient(circle at 20% 70%, rgba(56, 189, 248, 0.3), transparent 65%);
  opacity: 0.8;
  filter: blur(0.5px);
  pointer-events: none;
  animation: mmOrbitSpin 14s linear infinite;
}

.matchmaking-overlay .matchmaking-header,
.matchmaking-overlay .matchmaking-body,
.matchmaking-overlay .matchmaking-footer {
  position: relative;
  z-index: 1;
}

/* Header / title */
.matchmaking-eyebrow {
  margin: 0 0 4px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  opacity: 0.95;
  background: linear-gradient(120deg, #facc15, #f97316, #ec4899, #38bdf8);
  background-size: 220% 220%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: mmEyebrowGlow 9s ease-in-out infinite;
}

.matchmaking-header h2 {
  margin: 0;
  font-size: 1.28rem;
  letter-spacing: 0.02em;
}

/* Body layout */
.matchmaking-body {
  margin-top: 16px;
}

.matchmaking-players {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

/* Small “pill” chip label */
.matchmaking-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.14), transparent 70%);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.9);
  opacity: 0.96;
}

/* Mono counter 1/2 → 2/2 */
.matchmaking-count {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 1.45rem;
}

.matchmaking-count-divider {
  opacity: 0.7;
}

.matchmaking-count-total {
  opacity: 0.8;
}

/* Active player count bubble */
.matchmaking-count-current {
  position: relative;
  padding-inline: 8px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 0 0, rgba(249, 115, 22, 0.55), transparent 70%),
    radial-gradient(circle at 100% 100%, rgba(236, 72, 153, 0.5), transparent 75%);
  box-shadow:
    0 0 0 1px rgba(248, 250, 252, 0.24),
    0 0 18px rgba(236, 72, 153, 0.65);
  animation: mmPulse 1.4s ease-in-out infinite;
  font-weight: 700;
}

/* When we’re at 2/2 and locked-in */
.matchmaking-overlay.is-locked .matchmaking-count-current {
  background:
    radial-gradient(circle at 0 0, rgba(52, 211, 153, 0.8), transparent 70%),
    radial-gradient(circle at 100% 100%, rgba(34, 197, 94, 0.8), transparent 70%);
  box-shadow:
    0 0 0 1px rgba(187, 247, 208, 0.85),
    0 0 24px rgba(16, 185, 129, 0.9),
    0 0 0 10px rgba(34, 197, 94, 0.25);
  animation: mmLockedPulse 1.3s ease-in-out infinite;
}

/* Sub copy */
.matchmaking-sub {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: #cbd5f5;
}

/* Timer badge */
.matchmaking-timer {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(34, 197, 94, 0.2)),
    rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(45, 212, 191, 0.7);
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.9rem;
  color: #e5edff;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow:
    0 10px 28px rgba(15, 23, 42, 0.9),
    0 0 20px rgba(45, 212, 191, 0.55);
}

.matchmaking-timer.is-hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.matchmaking-timer-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  opacity: 0.9;
}

.matchmaking-timer-value {
  font-weight: 700;
  font-size: 1.25rem;
  animation: mmTimerPulse 1s ease-in-out infinite;
}

.matchmaking-timer-unit {
  font-size: 0.8rem;
  opacity: 0.8;
}

/* Footer */
.matchmaking-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.mm-cancel {
  font-size: 0.8rem;
  padding-inline: 16px;
  background: radial-gradient(circle at 0 0, rgba(148, 163, 184, 0.3), transparent 70%);
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.85);
  box-shadow:
    0 8px 18px rgba(15, 23, 42, 0.9),
    0 0 0 1px rgba(15, 23, 42, 1);
}

.mm-cancel:hover:not(:disabled) {
  background:
    radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.3), transparent 70%),
    rgba(15, 23, 42, 0.96);
}

.mm-cancel.is-hidden {
  display: none;
}

/* Mode-specific tint (optional but fun) */
.matchmaking-overlay[data-mode="lightning"] .matchmaking-panel {
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 32px 90px rgba(124, 58, 237, 0.95),
    0 0 60px rgba(249, 115, 22, 0.65);
}

.matchmaking-overlay[data-mode="castle_takedown"] .matchmaking-panel,
.matchmaking-overlay[data-mode="castle-takedown"] .matchmaking-panel {
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 32px 90px rgba(56, 189, 248, 0.95),
    0 0 60px rgba(34, 197, 94, 0.65);
}

/* ─── Animations ─────────────────────────────────────────── */

@keyframes mmAurora {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes mmAuroraShift {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.05);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@keyframes mmOrbitSlow {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(-360deg);
  }
}

@keyframes mmOrbitSpin {
  0% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(180deg) scale(1.02);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes mmEyebrowGlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Existing pulse refined to feel more “alive” */
@keyframes mmPulse {
  0% {
    transform: scale(1);
    box-shadow:
      0 0 0 0 rgba(236, 72, 153, 0.65),
      0 0 0 0 rgba(249, 115, 22, 0.5);
  }
  70% {
    transform: scale(1.06);
    box-shadow:
      0 0 0 10px rgba(236, 72, 153, 0),
      0 0 0 18px rgba(249, 115, 22, 0);
  }
  100% {
    transform: scale(1);
    box-shadow:
      0 0 0 0 rgba(236, 72, 153, 0),
      0 0 0 0 rgba(249, 115, 22, 0);
  }
}

/* Extra pulse once match is locked */
@keyframes mmLockedPulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.07);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes mmTimerPulse {
  0% {
    transform: translateY(0);
    text-shadow: 0 0 0 rgba(34, 197, 94, 0.0);
  }
  50% {
    transform: translateY(-1px);
    text-shadow: 0 0 14px rgba(34, 197, 94, 0.8);
  }
  100% {
    transform: translateY(0);
    text-shadow: 0 0 0 rgba(34, 197, 94, 0.0);
  }
}

/* small-screen tweaks for overlay */
@media (max-width: 640px) {
  .matchmaking-overlay {
    padding: 16px;
  }

  .matchmaking-panel {
    padding: 20px 18px 16px;
    border-radius: 22px;
  }

  .matchmaking-count {
    font-size: 1.3rem;
  }
}

/* ───────────────────────────────────────────────────────────
   Lightning Round full‑screen game UI
   ─────────────────────────────────────────────────────────── */
.lightning-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  background:
   radial-gradient(circle at 12% 18%, rgba(59, 130, 246, 0.22), transparent 52%),
    radial-gradient(circle at 88% 22%, rgba(236, 72, 153, 0.18), transparent 46%),
    radial-gradient(circle at 80% 88%, rgba(56, 189, 248, 0.2), transparent 55%),
    #020617;

  /* IMPORTANT: no blur here – this is part of what trips Safari */
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}


/* --- SAFARI PATCH: disable the blur there to avoid 3D + backdrop-filter bug --- */
@supports (-webkit-backdrop-filter: blur(0px)) {
  .lightning-overlay {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.lightning-overlay.is-visible {
  display: flex;
}

.lightning-shell {
  width: 100%;
  height: 100vh;
  max-width: none;
  max-height: none;
  display: grid;
  grid-template-rows: auto 1fr auto;  /* header / main / footer */
  padding: 20px 32px 20px;
  border-radius: 0;
  background:
    radial-gradient(circle at 18% 15%, rgba(59, 130, 246, 0.35), transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(244, 114, 182, 0.25), transparent 45%),
    radial-gradient(circle at 90% 88%, rgba(56, 189, 248, 0.28), transparent 50%),
    rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(15, 23, 42, 0.95);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 30px 80px rgba(2, 6, 23, 0.55);  color: #e5edff;
  overflow: hidden;
}


/* Header: scores + timer */

.lightning-header {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
}

.lightning-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lightning-player {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.lightning-player-opponent {
  align-items: flex-end;
  text-align: right;
}

.lightning-player-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  opacity: 0.85;
}

.lightning-player-name {
  font-size: 0.95rem;
  font-weight: 600;
}

.lightning-player-score {
  margin-top: 2px;
  font-size: 1.4rem;
  font-weight: 700;
}

.lightning-player-me .lightning-player-score {
  color: #facc15;
}

.lightning-player-opponent .lightning-player-score {
  color: #38bdf8;
}

.lightning-timer {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(45, 212, 191, 0.7);
  background:
    linear-gradient(135deg, rgba(45, 212, 191, 0.22), rgba(56, 189, 248, 0.18)),
    rgba(15, 23, 42, 0.98);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  box-shadow:
    0 10px 24px rgba(15, 23, 42, 0.95),
    0 0 18px rgba(45, 212, 191, 0.6);
}

.lightning-timer-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  opacity: 0.9;
}

.lightning-timer-value {
  font-weight: 700;
  font-size: 1.2rem;
}

.lightning-timer-unit {
  font-size: 0.8rem;
  opacity: 0.85;
}

.lightning-status {
  margin: 8px 0 2px;
  font-size: 0.86rem;
  color: #cbd5f5;
}

/* Main split columns */

.lightning-main {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr);
  gap: 32px;
  margin-top: 16px;
  /* don't clip the tall flashcard; let it define its height */
  overflow: visible;
}

.lightning-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.lightning-column-me {
  align-items: center;  /* center big flashcard */
  padding: 12px 10px 16px;
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(30, 64, 175, 0.18), rgba(15, 23, 42, 0.2));
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.25);
}

.lightning-column-opponent {
  justify-content: center;
  padding: 20px 18px;
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: inset 0 0 0 1px rgba(30, 64, 175, 0.2);
}


.lightning-column-title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.9;
}
.lightning-column-me .lightning-column-title {
  color: #fde68a;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.lightning-column-opponent .lightning-column-title {
  color: #94a3b8;
}


.lightning-questions {
  flex: 1 1 auto;
  /* make sure there's always space for the card */
  min-height: min(68vh, 600px);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0 18px;
}

/* Question cards */

.lightning-question-card {
  position: relative;
  width: 100%;
  max-width: 760px;
  min-height: min(68vh, 640px);
  border-radius: 28px;
  padding: 0;
  perspective: 1600px;
  background: transparent;
}

.lightning-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background:
    radial-gradient(circle at 12% 8%, rgba(30, 64, 175, 0.75), transparent 48%),
    radial-gradient(circle at 100% 100%, rgba(37, 99, 235, 0.55), transparent 60%),
    rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.75);
  box-shadow:
    0 24px 70px rgba(2, 6, 23, 0.95),
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 0 40px rgba(56, 189, 248, 0.18);
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.33, 1, 0.68, 1);
}

.lightning-question-card.is-flipped .lightning-card-inner {
  transform: rotateY(180deg);
}

.lightning-card-face {
  position: absolute;
  inset: 0;
  padding: 20px 22px 18px;
  border-radius: inherit;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
}

.lightning-card-front {
  justify-content: space-between;
}

.lightning-card-back {
  transform: rotateY(180deg);
  align-items: center;
  justify-content: center;
}
/* --- SAFARI PATCH: turn the 3D flip into a simple fade --- */
@supports (-webkit-backdrop-filter: blur(0px)) {
  /* Remove 3D context */
  .lightning-question-card {
    perspective: none;
  }

  .lightning-card-inner {
    transform-style: flat;
    transform: none !important;
  }

  .lightning-question-card.is-flipped .lightning-card-inner {
    transform: none;
  }

  .lightning-card-face {
    backface-visibility: visible;
    transition: opacity 0.2s ease;
  }

  /* Default: show front, hide back */
  .lightning-card-front {
    opacity: 1;
    z-index: 2;
  }

  .lightning-card-back {
    opacity: 0;
    z-index: 1;
  }

  /* When answered, fade to the back (✓ / ✕) face */
  .lightning-question-card.is-answered .lightning-card-front {
    opacity: 0;
  }

  .lightning-question-card.is-answered .lightning-card-back {
    opacity: 1;
  }
}

/* Big check / X */
.lightning-flash-result {
  font-size: clamp(5rem, 12vw, 7rem);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 0 40px rgba(15, 23, 42, 0.85);
}

.lightning-question-card.is-correct .lightning-flash-result {
  color: #22c55e;
}

.lightning-question-card.is-incorrect .lightning-flash-result {
  color: #f97373;
}

.lightning-question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  margin-bottom: 8px;
  opacity: 0.9;
}

.lightning-question-text {
  margin: 6px 0 12px;
  font-size: 1.15rem;
  line-height: 1.6;
}

.lightning-choices {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}


.lightning-choice {
  width: 100%;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.9);
  color: #e5edff;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.08s ease,
    box-shadow 0.15s ease;
}

/* Nice color bands per option */
.lightning-choice:nth-child(1) {
  background: linear-gradient(
    135deg,
    rgba(129, 140, 248, 0.22),
    rgba(15, 23, 42, 0.98)
  );
}
.lightning-choice:nth-child(2) {
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.22),
    rgba(15, 23, 42, 0.98)
  );
}
.lightning-choice:nth-child(3) {
  background: linear-gradient(
    135deg,
    rgba(52, 211, 153, 0.22),
    rgba(15, 23, 42, 0.98)
  );
}
.lightning-choice:nth-child(4) {
  background: linear-gradient(
    135deg,
    rgba(249, 115, 22, 0.22),
    rgba(15, 23, 42, 0.98)
  );
}

.lightning-choice:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.9);
  border-color: rgba(248, 250, 252, 0.9);
}

.lightning-choice:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Answer state */

.lightning-question-card.is-answered {
  border-color: rgba(148, 163, 184, 0.9);
}

.lightning-question-card.is-correct {
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.8),
    0 0 22px rgba(34, 197, 94, 0.8);
}

.lightning-question-card.is-incorrect {
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.85),
    0 0 22px rgba(248, 113, 113, 0.9);
}

.lightning-choice.is-correct {
  background: rgba(22, 163, 74, 0.92);
  border-color: rgba(187, 247, 208, 0.95);
}

.lightning-choice.is-incorrect {
  background: rgba(185, 28, 28, 0.95);
  border-color: rgba(254, 202, 202, 0.95);
}

/* Opponent side */

.lightning-opponent-hint {
  margin: 0 0 8px;
  font-size: 0.84rem;
  color: #cbd5f5;
}

.lightning-opponent-meta {
  margin-top: 2px;
  font-size: 0.82rem;
  color: #e5edff;
}

/* Footer */

.lightning-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  display: flex;
  justify-content: flex-end;
}

/* Responsive tweaks */

@media (max-width: 768px) {
  .lightning-shell {
    padding: 16px 14px;
    grid-template-rows: auto 1fr auto;
  }

  .lightning-main {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .lightning-question-card {
    max-width: 100%;
    min-height: 60vh;
  }

  .lightning-column-opponent {
    border-top: 1px solid rgba(148, 163, 184, 0.3);
    padding-top: 8px;
  }
}

.lightning-player-score-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.lightning-opponent-trend {
  font-size: 1.6rem;
  line-height: 1;
  margin-top: 2px;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.lightning-opponent-trend[data-trend="up"] {
  color: #22c55e;
  text-shadow: 0 0 18px rgba(34, 197, 94, 0.9);
  opacity: 1;
  transform: scale(1.05);
}

.lightning-opponent-trend[data-trend="down"] {
  color: #f97373;
  text-shadow: 0 0 18px rgba(248, 113, 113, 0.9);
  opacity: 1;
  transform: scale(1.05);
}

.lightning-opponent-trend[data-trend=""] {
  color: #64748b;
  opacity: 0.6;
  transform: scale(1);
}

/* ───────────────────────────────────────────────────────────
   Lightning card – Safari‑safe override (no 3D / backface)
   ─────────────────────────────────────────────────────────── */

/* Make sure the main area can grow and actually show content */
.lightning-main {
  overflow: visible;
}

/* Center the question card vertically */
.lightning-questions {
  flex: 1 1 auto;
  min-height: min(68vh, 600px);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0 18px;
}

/* Flattened “card” shell – no perspective */
.lightning-question-card {
  position: relative;
  width: 100%;
  max-width: 760px;
  min-height: min(68vh, 640px);
  border-radius: 28px;
  padding: 24px 26px 22px;

  background:
    radial-gradient(circle at 12% 8%, rgba(30, 64, 175, 0.75), transparent 48%),
    radial-gradient(circle at 100% 100%, rgba(37, 99, 235, 0.55), transparent 60%),
    rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.75);
  box-shadow:
 0 24px 70px rgba(2, 6, 23, 0.95),
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 0 40px rgba(56, 189, 248, 0.18);
  overflow: hidden;

  /* kill perspective in case earlier rule is still in effect */
  perspective: none !important;
}

.lightning-card-inner {
  position: static;
  width: 100%;
  height: auto;
  transform: none !important;
  transform-style: flat !important;
}

/* Stop using backface + absolute stacking for the faces */
.lightning-card-face {
  position: static;
  inset: auto;
  padding: 0;
  border-radius: 0;
  backface-visibility: visible !important;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Back face becomes a simple overlay for the ✓ / ✕ result */
.lightning-card-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

/* When answered, fade the overlay in and dim the front a bit */
.lightning-question-card.is-answered .lightning-card-back {
  opacity: 1;
}

.lightning-question-card.is-answered .lightning-card-front {
  opacity: 0.25;
}

/* Belt-and-suspenders: never rotate the inner card anywhere */
.lightning-question-card.is-flipped .lightning-card-inner {
  transform: none !important;
}
/* ───────────────────────────────────────────────────────────
   Multiplayer mode-select overlay (Lightning vs Castle)
   ─────────────────────────────────────────────────────────── */

.multiplayer-overlay {
  position: fixed;
  inset: 0;
  z-index: 998; /* below Lightning (1000) and matchmaking (999) */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 0 0, rgba(148, 163, 184, 0.25), transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(56, 189, 248, 0.20), transparent 60%),
    #020617;
}

.multiplayer-overlay.is-visible {
  display: flex;
}

.multiplayer-shell {
  position: relative;
  max-width: 900px;
  width: 100%;
  border-radius: 26px;
  padding: 20px 22px 16px;
  background:
    radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.08), transparent 60%),
    radial-gradient(circle at 100% 0, rgba(251, 191, 36, 0.18), transparent 65%),
    rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.7);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.95),
    0 24px 80px rgba(15, 23, 42, 0.98);
  color: #e5edff;
  display: flex;
  flex-direction: column;
}

.multiplayer-header h2 {
  margin: 0 0 10px;
  font-size: 1.25rem;
}

.multiplayer-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 10px;
}

.multiplayer-column {
  border-radius: 18px;
  padding: 14px 14px 12px;
  background:
    radial-gradient(circle at 0 0, rgba(15, 23, 42, 0.96), transparent 60%),
    rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(51, 65, 85, 0.9);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.multiplayer-column--lightning {
  box-shadow:
    0 0 0 1px rgba(129, 140, 248, 0.75),
    0 16px 40px rgba(79, 70, 229, 0.8);
}

.multiplayer-column--castle {
  box-shadow:
    0 0 0 1px rgba(56, 189, 248, 0.75),
    0 16px 40px rgba(6, 182, 212, 0.8);
}

.multiplayer-column-title {
  margin: 0 0 4px;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.9;
}

.multiplayer-column-body {
  flex: 1 1 auto;
  font-size: 0.86rem;
  color: #cbd5f5;
}

.multiplayer-column-actions {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.multiplayer-footer {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

/* Slightly lighter secondary CTA for "Play With Friends" / Back */
.dash-cta--ghost {
  background: rgba(15, 23, 42, 0.96);
  border-color: rgba(148, 163, 184, 0.7);
  color: #e5edff;
}

.dash-cta--ghost:hover:not(:disabled) {
  background:
    radial-gradient(circle at 0 0, rgba(148, 163, 184, 0.5), transparent 70%),
    rgba(15, 23, 42, 0.98);
  border-color: rgba(248, 250, 252, 0.9);
}
/* ───────────────────────────────────────────────────────────
   Castle Takedown full-screen game UI
   ─────────────────────────────────────────────────────────── */

.castle-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.86);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.castle-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.castle-shell {
  width: min(1200px, 96vw);
  max-height: 92vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 0%, rgba(59, 130, 246, 0.2), transparent 60%),
    radial-gradient(circle at 90% 100%, rgba(251, 191, 36, 0.15), transparent 55%),
    rgba(15, 23, 42, 0.98);
  border-radius: 26px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.95);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
}

.castle-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 20px 26px 10px;
}

.castle-team-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
}

.castle-team-summary--enemy {
  text-align: right;
}

.castle-team-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  opacity: 0.7;
}

.castle-team-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.castle-team-members {
  font-size: 0.78rem;
  color: #cbd5f5;
}

.castle-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.8rem;
}

.castle-timer-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fef3c7;
}

.castle-status {
  margin: 0 26px 14px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 0.86rem;
  color: #e2e8f0;
  min-height: 1.4em;
}

.castle-status.is-success {
  color: #bbf7d0;
}

.castle-status.is-error {
  color: #fecaca;
}

.castle-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 0 26px 18px;
  overflow: auto;
}

.castle-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(30, 41, 59, 0.9);
  min-height: 0;
}

.castle-side-title {
  margin: 0;
  font-size: 1.05rem;
}

.castle-cards {
  display: grid;
  gap: 12px;
}

.castle-card {
  background: rgba(30, 41, 59, 0.7);
  border-radius: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(71, 85, 105, 0.8);
}

.castle-card-title {
  margin: 0 0 8px;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #cbd5f5;
}

.castle-hearts {
  display: flex;
  gap: 6px;
}

.castle-heart {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: #f87171;
  box-shadow: 0 0 6px rgba(248, 113, 113, 0.6);
}

.castle-heart.is-empty {
  background: rgba(148, 163, 184, 0.25);
  box-shadow: none;
}

.castle-towers {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.castle-tower {
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(135deg, #f8fafc, #94a3b8);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.4);
}

.castle-tower.is-destroyed {
  background: rgba(71, 85, 105, 0.35);
  box-shadow: inset 0 0 0 1px rgba(30, 41, 59, 0.6);
}

.castle-actions {
  display: grid;
  gap: 12px;
}

.castle-action-group {
  padding: 12px;
  border-radius: 14px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(51, 65, 85, 0.8);
  display: grid;
  gap: 8px;
}

.castle-action-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: #e2e8f0;
}

.castle-action-count {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fef3c7;
}

.castle-action-buttons {
  display: grid;
  gap: 8px;
}

.castle-question {
  flex: 1;
  overflow: auto;
  padding: 14px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(51, 65, 85, 0.9);
}

.castle-question-card {
  display: grid;
  gap: 10px;
}

.castle-question-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #cbd5f5;
}

.castle-question-text {
  font-size: 0.98rem;
  font-weight: 600;
  color: #f8fafc;
}

.castle-choices {
  display: grid;
  gap: 8px;
}

.castle-choice {
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(71, 85, 105, 0.8);
  color: #e2e8f0;
  cursor: pointer;
  font-size: 0.86rem;
}

.castle-choice:hover:not(:disabled) {
  border-color: rgba(248, 250, 252, 0.9);
  background: rgba(59, 130, 246, 0.25);
}

.castle-choice[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.castle-choice.is-correct {
  border-color: rgba(34, 197, 94, 0.9);
  background: rgba(34, 197, 94, 0.25);
}

.castle-choice.is-incorrect {
  border-color: rgba(239, 68, 68, 0.9);
  background: rgba(239, 68, 68, 0.2);
}

.castle-team-list {
  padding: 12px;
  border-radius: 16px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(51, 65, 85, 0.8);
}

.castle-team-members-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  color: #e2e8f0;
}

.castle-footer {
  padding: 16px 26px 22px;
  display: flex;
  justify-content: flex-end;
}

.castle-exit {
  margin-top: 0;
}

@media (max-width: 768px) {
  .multiplayer-overlay {
    padding: 16px;
  }

  .multiplayer-shell {
    padding: 18px 16px 14px;
    border-radius: 22px;
  }

  .multiplayer-main {
    grid-template-columns: 1fr;
  }
     .castle-overlay {
    padding: 16px;
  }

  .castle-shell {
    max-height: 95vh;
  }

  .castle-header {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .castle-team-summary--enemy {
    text-align: center;
  }

  .castle-main {
    grid-template-columns: 1fr;
  }
}
