/* ═══════════════════════════════════════════════
   PRESENCE MODAL (overlay, periodic human check-in)
   Independent from wellness — same visual language,
   distinct accent colors per challenge level.
   ═══════════════════════════════════════════════ */

#presence-modal-container:empty { display: none; }

/* ── Overlay & backdrop ── */

.presence-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.presence-modal-overlay.presence-modal-visible {
  opacity: 1;
  pointer-events: auto;
}

.presence-modal-overlay.presence-modal-out {
  opacity: 0;
  transition: opacity 0.22s ease;
}

.presence-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 20, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ── Card ── */

.presence-modal-card {
  --pm-accent: #10b981;
  --pm-accent-soft: rgba(16, 185, 129, 0.10);
  --pm-accent-glow: rgba(16, 185, 129, 0.25);

  position: relative;
  z-index: 9302;
  background: #ffffff;
  border-radius: 20px;
  max-width: 440px;
  width: 100%;
  overflow: hidden;
  margin: auto;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.06),
    0 20px 60px rgba(0, 0, 0, 0.18),
    0 4px 16px rgba(0, 0, 0, 0.08);
  transform: scale(0.86) translateY(20px);
  opacity: 0;
  transition:
    transform 0.44s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity   0.28s ease;
}

.presence-modal-card--easy {
  --pm-accent: #10b981;
  --pm-accent-soft: rgba(16, 185, 129, 0.10);
  --pm-accent-glow: rgba(16, 185, 129, 0.25);
}

.presence-modal-card--medium {
  --pm-accent: #f59e0b;
  --pm-accent-soft: rgba(245, 158, 11, 0.10);
  --pm-accent-glow: rgba(245, 158, 11, 0.25);
}

.presence-modal-card--hard {
  --pm-accent: #6366f1;
  --pm-accent-soft: rgba(99, 102, 241, 0.10);
  --pm-accent-glow: rgba(99, 102, 241, 0.25);
}

.presence-modal-card--manual {
  --pm-accent: #25D366;
  --pm-accent-soft: rgba(37, 211, 102, 0.12);
  --pm-accent-glow: rgba(37, 211, 102, 0.28);
}

.presence-modal-card--penalty {
  --pm-accent: #f59e0b;
  --pm-accent-soft: rgba(245, 158, 11, 0.12);
  --pm-accent-glow: rgba(245, 158, 11, 0.28);
}

/* View-Once: violet accent — distinct from the other levels so the modal
   visually signals "different mechanic" (image in WhatsApp) at a glance. */
.presence-modal-card--view-once {
  /* violet-600 (#7c3aed) for the actionable foreground — clears 4.5:1 on
     white. The lighter violet-500 is reserved for soft/glow backgrounds. */
  --pm-accent: #7c3aed;
  --pm-accent-soft: rgba(139, 92, 246, 0.12);
  --pm-accent-glow: rgba(139, 92, 246, 0.28);
}

/* Tic-Tac-Toe: teal accent — distinct "puzzle game" vibe vs the warmer
   Penalty amber and the cooler Hard indigo. teal-600 #0d9488 clears the
   WCAG 4.5:1 bar against the warm off-white background. */
.presence-modal-card--tic-tac-toe {
  --pm-accent: #0d9488;
  --pm-accent-soft: rgba(13, 148, 136, 0.10);
  --pm-accent-glow: rgba(13, 148, 136, 0.25);
}

.presence-modal-view-once-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--pm-accent-soft);
  border-left: 3px solid var(--pm-accent);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.45;
  color: #1f2937;
}

[data-theme="dark"] .presence-modal-view-once-warning {
  color: #e2e8f0; /* slate-200 — readable on the dark card */
  background: rgba(139, 92, 246, 0.18);
}

.presence-modal-view-once-warning svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--pm-accent);
}

[data-theme="dark"] .presence-modal-view-once-warning svg {
  color: #a78bfa; /* violet-400 — brighter against dark background */
}

.presence-modal-view-once-input {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.presence-modal-view-once-reissue {
  margin: 10px 0 4px;
  background: transparent;
  border: 1px solid var(--pm-accent);
  color: var(--pm-accent);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.15s ease;
}

.presence-modal-view-once-reissue:hover {
  background: var(--pm-accent-soft);
}

[data-theme="dark"] .presence-modal-view-once-reissue {
  color: #a78bfa;
  border-color: #a78bfa;
}

.presence-modal-view-once-reissue-count {
  font-size: 11px;
  opacity: 0.75;
}

.presence-modal-card.presence-modal-card-in {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.presence-modal-card.presence-modal-card-out {
  transform: scale(0.9) translateY(10px);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

/* ── Close button (top-right) ── */

.presence-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  z-index: 10;
}

.presence-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #111827;
}

[data-theme="dark"] .presence-modal-close {
  color: #6b7280;
}

[data-theme="dark"] .presence-modal-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f9fafb;
}

/* ── Support link (WhatsApp) ── */

.presence-modal-support-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  align-self: center;
  font-size: 0.75rem;
  color: #25D366;
  text-decoration: none;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  border: 1px solid rgba(37, 211, 102, 0.3);
  border-radius: 999px;
  background: rgba(37, 211, 102, 0.05);
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  margin-top: 0.25rem;
  margin-bottom: 0.85rem;
  position: relative;
}

/* Soft divider after the support link to break it away from the next
 * challenge block (Turnstile, hold button, word canvas, OTP input). */
.presence-modal-support-link::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.55rem;
  width: 32px;
  height: 1px;
  background: #e5e7eb;
  transform: translateX(-50%);
}

.presence-modal-support-link:hover {
  background: rgba(37, 211, 102, 0.12);
  border-color: rgba(37, 211, 102, 0.55);
}

[data-theme="dark"] .presence-modal-support-link {
  background: rgba(37, 211, 102, 0.08);
  border-color: rgba(37, 211, 102, 0.35);
}

[data-theme="dark"] .presence-modal-support-link::after {
  background: rgba(255, 255, 255, 0.08);
}

/* ── "Gerar novo desafio" secondary button ── */

.presence-modal-reissue {
  align-self: center;
  margin-top: 0.25rem;
  background: transparent;
  border: 1px solid #e5e7eb;
  color: #6b7280;
  padding: 0.42rem 0.95rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.presence-modal-reissue:hover {
  border-color: var(--pm-accent);
  color: var(--pm-accent);
  background: var(--pm-accent-soft);
}

.presence-modal-reissue:disabled {
  opacity: 0.55;
  cursor: default;
}

[data-theme="dark"] .presence-modal-reissue {
  border-color: #374151;
  color: #9ca3af;
}

/* ── Identity zone ── */

.presence-modal-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1.75rem 1.5rem;
  background: var(--pm-accent-soft);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  position: relative;
}

.presence-modal-identity::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--pm-accent);
  border-radius: 0 0 3px 3px;
}

.presence-modal-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--pm-accent);
  color: #ffffff;
  margin-bottom: 1rem;
  box-shadow: 0 4px 16px var(--pm-accent-glow);
}

.presence-modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: #111827;
  margin: 0 0 0.45rem;
  letter-spacing: -0.01em;
}

.presence-modal-desc {
  font-size: 0.85rem;
  color: #6b7280;
  line-height: 1.65;
  margin: 0;
  max-width: 320px;
}

.presence-modal-level-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.9rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--pm-accent);
  background: #ffffff;
  border: 1px solid var(--pm-accent-glow);
  letter-spacing: 0.06em;
}

/* ── Action zone ── */

.presence-modal-action {
  padding: 1.5rem 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.presence-modal-otp {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.presence-modal-manual {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-items: stretch;
}

.presence-modal-manual-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  background: #25D366;
  color: #ffffff;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.9rem 1.1rem;
  border: none;
  border-radius: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04), 0 4px 12px rgba(37, 211, 102, 0.25);
  letter-spacing: 0.01em;
}

.presence-modal-manual-btn:hover {
  background: #1eb959;
}

.presence-modal-manual-btn:active {
  transform: translateY(1px);
}

.presence-modal-manual-divider {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.65rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0.15rem 0 0.05rem;
}

.presence-modal-manual-divider::before,
.presence-modal-manual-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

.presence-modal-manual-qr {
  align-self: center;
  padding: 0.5rem;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  line-height: 0;
}

.presence-modal-manual-qr svg {
  display: block;
}

.presence-modal-manual-hint {
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.45;
}

.presence-modal-manual-hint--error {
  color: #c53030;
}

.presence-modal-manual-phone {
  margin: 0;
  text-align: center;
  font-size: 0.7rem;
  color: #94a3b8;
}

.presence-modal-manual-phone a {
  color: #25D366;
  font-weight: 600;
  text-decoration: none;
}

.presence-modal-manual-phone a:hover {
  text-decoration: underline;
}

[data-theme="dark"] .presence-modal-manual-hint,
[data-theme="dark"] .presence-modal-manual-phone {
  color: rgba(255, 255, 255, 0.45);
}

[data-theme="dark"] .presence-modal-manual-divider::before,
[data-theme="dark"] .presence-modal-manual-divider::after {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .presence-modal-manual-qr {
  background: #ffffff; /* keep white — QR scanners need contrast */
  border-color: rgba(255, 255, 255, 0.1);
}

/* Compact the manual modal on small viewports so the QR + phone + button
 * + hint all fit without overflow. */
@media (max-width: 420px) {
  .presence-modal-manual { gap: 0.4rem; }
  .presence-modal-manual-btn { padding: 0.7rem 1rem; font-size: 0.92rem; }
  .presence-modal-manual-qr { padding: 0.35rem; }
  .presence-modal-manual-qr svg { width: 96px; height: 96px; }
  .presence-modal-manual-divider { font-size: 0.6rem; margin: 0.05rem 0 0; }

  /* Manual is the tallest card (icon + QR + button + hint stack);
   * trim padding and shrink the icon so it fits on small screens. */
  .presence-modal-card--manual .presence-modal-identity {
    padding: 1.15rem 1.4rem 0.95rem;
  }
  .presence-modal-card--manual .presence-modal-icon-wrap {
    width: 46px;
    height: 46px;
    margin-bottom: 0.55rem;
  }
  .presence-modal-card--manual .presence-modal-icon-wrap svg {
    width: 22px;
    height: 22px;
  }
  .presence-modal-card--manual .presence-modal-title {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
  }
  .presence-modal-card--manual .presence-modal-desc {
    font-size: 0.78rem;
    line-height: 1.5;
  }
  .presence-modal-card--manual .presence-modal-level-badge {
    margin-top: 0.55rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.65rem;
  }
  .presence-modal-card--manual .presence-modal-action {
    padding: 0.95rem 1.4rem 1.15rem;
    gap: 0.6rem;
  }

  /* Hard is the second-tallest card (Turnstile + 3x3 canvas + status + reissue);
   * compress identity zone and shrink the canvas so the whole challenge fits
   * without forcing the user to scroll while a ball is flashing. */
  .presence-modal-card--hard .presence-modal-identity {
    padding: 1.15rem 1.4rem 0.95rem;
  }
  .presence-modal-card--hard .presence-modal-icon-wrap {
    width: 46px;
    height: 46px;
    margin-bottom: 0.55rem;
  }
  .presence-modal-card--hard .presence-modal-icon-wrap svg {
    width: 22px;
    height: 22px;
  }
  .presence-modal-card--hard .presence-modal-title {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
  }
  .presence-modal-card--hard .presence-modal-desc {
    font-size: 0.78rem;
    line-height: 1.5;
  }
  .presence-modal-card--hard .presence-modal-level-badge {
    margin-top: 0.55rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.65rem;
  }
  .presence-modal-card--hard .presence-modal-action {
    padding: 0.95rem 1.4rem 1.15rem;
    gap: 0.55rem;
  }
  .presence-modal-card--hard .presence-modal-sequence {
    gap: 0.5rem;
  }
  .presence-modal-card--hard .presence-modal-sequence-canvas {
    max-width: 240px;
  }
  .presence-modal-card--hard .presence-modal-sequence-turnstile {
    min-height: 0;
    transform: scale(0.85);
    transform-origin: center top;
    margin-bottom: -0.4rem;
  }

  /* Penalty card: tall portrait canvas needs the same compression treatment
   * as Hard so the goal/ball pair fits without forcing scroll. */
  .presence-modal-card--penalty .presence-modal-identity {
    padding: 1.15rem 1.4rem 0.95rem;
  }
  .presence-modal-card--penalty .presence-modal-icon-wrap {
    width: 46px;
    height: 46px;
    margin-bottom: 0.55rem;
  }
  .presence-modal-card--penalty .presence-modal-icon-wrap svg {
    width: 22px;
    height: 22px;
  }
  .presence-modal-card--penalty .presence-modal-title {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
  }
  .presence-modal-card--penalty .presence-modal-desc {
    font-size: 0.78rem;
    line-height: 1.5;
  }
  .presence-modal-card--penalty .presence-modal-level-badge {
    margin-top: 0.55rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.65rem;
  }
  .presence-modal-card--penalty .presence-modal-action {
    padding: 0.95rem 1.4rem 1.15rem;
    gap: 0.55rem;
  }
  .presence-modal-card--penalty .presence-modal-penalty-canvas {
    max-width: 220px;
  }
  .presence-modal-card--penalty .presence-modal-penalty-turnstile {
    min-height: 0;
    transform: scale(0.85);
    transform-origin: center top;
    margin-bottom: -0.4rem;
  }
}

.presence-modal-otp-hint {
  margin: 0.25rem 0 0;
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.45;
}

[data-theme="dark"] .presence-modal-otp-hint {
  color: rgba(255, 255, 255, 0.45);
}

.presence-modal-flash {
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font-size: 0.78rem;
  line-height: 1.5;
}

.presence-modal-flash--error {
  background: #fff5f5;
  color: #c53030;
  border: 1px solid #fed7d7;
}

.presence-modal-flash--success {
  background: #f0fff4;
  color: #276749;
  border: 1px solid #c6f6d5;
}

/* ── Hold-to-Play (Easy) ── */

.presence-modal-hold {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
}

.presence-modal-hold-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 1rem 1.5rem;
  background: #f3f4f6;
  color: var(--pm-accent);
  border: 2px solid var(--pm-accent);
  border-radius: 14px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow: hidden;
  letter-spacing: 0.02em;
  transition: transform 0.1s ease;
}

.presence-modal-hold-btn:active {
  transform: scale(0.98);
}

.presence-modal-hold-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--pm-accent);
  transform-origin: left center;
  transform: scaleX(var(--pm-hold-progress, 0));
  pointer-events: none;
  z-index: 0;
  transition: transform 0.06s linear;
}

.presence-modal-hold-btn[data-armed="true"] {
  color: #ffffff;
}

.presence-modal-hold-btn span {
  position: relative;
  z-index: 1;
  mix-blend-mode: difference;
  color: #ffffff;
}

.presence-modal-hold-hint {
  font-size: 0.72rem;
  color: #6b7280;
  text-align: center;
  margin: 0;
}

/* ── Word distorted SVG (Medium) ── */

.presence-modal-word {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.presence-modal-word-canvas {
  background: #fafafa;
  border: 2px dashed #e5e7eb;
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 110px;
}

.presence-modal-word-canvas svg,
.presence-modal-word-canvas img {
  max-width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
  user-select: none;
  -webkit-user-select: none;
}

.presence-modal-word-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.presence-modal-word-input {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.68rem 0.6rem;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  background: #fafafa;
  color: #111827;
  outline: none;
  text-transform: lowercase;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.presence-modal-word-input:focus {
  border-color: var(--pm-accent);
  box-shadow: 0 0 0 3px var(--pm-accent-glow);
  background: #ffffff;
}

/* ── Sequence memory (Hard) ── */

.presence-modal-sequence {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: center;
}

.presence-modal-sequence-turnstile {
  display: flex;
  justify-content: center;
  min-height: 65px;
}

.presence-modal-sequence-canvas {
  display: block;
  width: 100%;
  max-width: 320px;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  background: #0f172a;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.presence-modal-sequence-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1 / 1;
}

.presence-modal-sequence-cell {
  background: #f3f4f6;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  color: transparent;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.18s ease, border-color 0.18s ease;
  user-select: none;
}

.presence-modal-sequence-cell.is-flashing {
  background: var(--pm-accent);
  border-color: var(--pm-accent);
  color: #ffffff;
  transform: scale(1.04);
}

.presence-modal-sequence-cell.is-tapped {
  background: var(--pm-accent-soft);
  border-color: var(--pm-accent);
  color: var(--pm-accent);
}

.presence-modal-sequence-cell:active {
  transform: scale(0.97);
}

.presence-modal-sequence-status {
  font-size: 0.75rem;
  color: #6b7280;
  text-align: center;
  margin: 0;
  font-weight: 600;
}

/* ── Penalty (Drag) ── */

.presence-modal-penalty {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: center;
}

.presence-modal-penalty-turnstile {
  display: flex;
  justify-content: center;
  min-height: 65px;
}

.presence-modal-penalty-status {
  font-size: 0.75rem;
  color: #6b7280;
  text-align: center;
  margin: 0;
  font-weight: 600;
}

.presence-modal-penalty-canvas {
  display: block;
  width: 100%;
  max-width: 260px;
  height: auto;
  aspect-ratio: 330 / 440;
  border-radius: 14px;
  background: #155724;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  cursor: grab;
}

.presence-modal-penalty-canvas:active {
  cursor: grabbing;
}

[data-theme="dark"] .presence-modal-penalty-status {
  color: rgba(255, 255, 255, 0.55);
}

/* ── Common button ── */

.presence-modal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.78rem 1.5rem;
  background: var(--pm-accent);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
  letter-spacing: 0.01em;
}

.presence-modal-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.presence-modal-btn:active { transform: scale(0.98); }
.presence-modal-btn:disabled { opacity: 0.55; cursor: default; transform: none; }

/* ── Dark mode ── */

[data-theme="dark"] .presence-modal-card {
  background: #17202e;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 20px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .presence-modal-identity {
  border-bottom-color: rgba(255, 255, 255, 0.07);
}

[data-theme="dark"] .presence-modal-title { color: #f9fafb; }
[data-theme="dark"] .presence-modal-desc  { color: #9ca3af; }

[data-theme="dark"] .presence-modal-hold-btn {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .presence-modal-word-canvas {
  background: rgba(255, 255, 255, 0.04);
  border-color: #374151;
}

[data-theme="dark"] .presence-modal-word-input {
  background: #1f2937;
  border-color: #374151;
  color: #f9fafb;
}

[data-theme="dark"] .presence-modal-sequence-cell {
  background: rgba(255, 255, 255, 0.05);
  border-color: #374151;
}

[data-theme="dark"] .presence-modal-level-badge {
  background: rgba(255, 255, 255, 0.06);
}

/* ── Presence blocked banner (ABANDON_COOLDOWN persistent indicator) ──
   Sits above the fixed game bar. Mirrors the geometry of .game-bar-countdown
   (1240px content well, font-display, tabular-nums timer) so it reads as
   part of the same notification layer — not a third-party alert. The
   countdown is the hero; the verb is supporting copy. */

.presence-blocked-banner {
  background: #fdf5d9;
  border-top: 1px solid rgba(180, 83, 9, 0.18);
  border-bottom: 1px solid rgba(180, 83, 9, 0.22);
  position: relative;
  overflow: hidden;
}

.presence-blocked-banner-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.45rem max(2rem, calc((100vw - 1240px) / 2 + 2rem));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-display);
}

/* Hourglass icon + timer act as one visual block — the hierarchy hero.
   Aligning baselines on the timer prevents the icon from drifting. */
.presence-blocked-banner-meter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.presence-blocked-banner-icon {
  color: #b45309;
  display: inline-flex;
}

.presence-blocked-banner-timer {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.01em;
  color: #78350f;
  line-height: 1;
}

.presence-blocked-banner-message {
  font-size: 0.78rem;
  font-weight: 500;
  color: #92400e;
  line-height: 1.3;
}

.presence-blocked-banner-message strong {
  font-weight: 600;
  color: #78350f;
}

/* Slim progress strip at the bottom — visually communicates that time IS
   passing without forcing the user to stare at the digits. Animated via
   CSS only; duration is set inline from blocked_until - now. */
.presence-blocked-banner-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, #d97706, #f59e0b);
  transform-origin: left center;
  animation: presence-blocked-shrink linear forwards;
}

@keyframes presence-blocked-shrink {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* Dark theme: opaque dark base so the banner reads as a layout element,
   not a translucent wash over page content. Amber is reserved for the
   timer + icon — the hierarchy carriers — not the surface. */
[data-theme="dark"] .presence-blocked-banner {
  background: #1f1605;
  border-top-color: rgba(251, 191, 36, 0.22);
  border-bottom-color: rgba(251, 191, 36, 0.28);
}

[data-theme="dark"] .presence-blocked-banner-icon {
  color: #fbbf24;
}

[data-theme="dark"] .presence-blocked-banner-timer {
  color: #fde68a;
}

[data-theme="dark"] .presence-blocked-banner-message {
  color: rgba(254, 243, 199, 0.78);
}

[data-theme="dark"] .presence-blocked-banner-message strong {
  color: #fef3c7;
}

@media (max-width: 640px) {
  .presence-blocked-banner-inner {
    padding: 0.45rem 0.95rem;
    gap: 0.6rem;
  }
  .presence-blocked-banner-timer {
    font-size: 0.95rem;
  }
  .presence-blocked-banner-message {
    font-size: 0.72rem;
    line-height: 1.25;
  }
  /* On narrow screens, drop the verb — keep only the timer + concise caption. */
  .presence-blocked-banner-message-long {
    display: none;
  }
}

@media (min-width: 641px) {
  .presence-blocked-banner-message-short {
    display: none;
  }
}

/* ── Tic-Tac-Toe (admin-triggered, in test) ── */

.presence-modal-ttt {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.6rem;
}

.presence-modal-ttt-instruction {
  margin: 0;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #334155;
}

[data-theme="dark"] .presence-modal-ttt-instruction {
  color: #e2e8f0;
}

/* Glyph (× or ○) — inline SVG, ~1.5× the cap height of the surrounding
   text so it reads clearly for low-vision users. Stroke is server-rendered
   at width 3.5 (sturdy at 22px). Inherits teal via currentColor. */
.presence-modal-ttt-instruction .presence-modal-ttt-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--pm-accent);
  vertical-align: -0.32em;
  margin: 0 2px;
}

.presence-modal-ttt-instruction .presence-modal-ttt-glyph svg {
  width: 1.6em;
  height: 1.6em;
  display: block;
}

/* Stake verb ("vencer" / "impedir a derrota") — bold + slightly larger so
   the consequence of the action pops. */
.presence-modal-ttt-instruction .presence-modal-ttt-stake {
  font-weight: 800;
  font-size: 1.08em;
  color: var(--pm-accent);
}

/* The board container holds the PNG as a background-image and a 3×3 grid
   of invisible buttons on top. Aspect-ratio + max-width keep it square
   without forcing a fixed pixel size — adapts cleanly to narrow viewports. */
.presence-modal-ttt-board {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  background-color: #faf9f5;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  overflow: hidden;
}

[data-theme="dark"] .presence-modal-ttt-board {
  background-color: #1f2937;
  border-color: #374151;
}

.presence-modal-ttt-cell {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  outline: none;
  transition: background-color 0.12s ease;
}

.presence-modal-ttt-cell:hover:not(:disabled) {
  background: var(--pm-accent-soft);
}

.presence-modal-ttt-cell:focus-visible {
  background: var(--pm-accent-soft);
  box-shadow: inset 0 0 0 2px var(--pm-accent);
}

.presence-modal-ttt-cell:disabled {
  cursor: wait;
}

@media (max-width: 480px) {
  .presence-modal-card--tic-tac-toe .presence-modal-identity {
    padding: 1.15rem 1.4rem 0.9rem;
  }
  .presence-modal-card--tic-tac-toe .presence-modal-icon-wrap {
    width: 46px;
    height: 46px;
    margin-bottom: 0.55rem;
  }
  .presence-modal-card--tic-tac-toe .presence-modal-icon-wrap svg {
    width: 22px;
    height: 22px;
  }
  .presence-modal-card--tic-tac-toe .presence-modal-title {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
  }
  .presence-modal-card--tic-tac-toe .presence-modal-desc {
    font-size: 0.78rem;
    line-height: 1.5;
  }
  .presence-modal-card--tic-tac-toe .presence-modal-action {
    padding: 0.95rem 1.4rem 1.15rem;
    gap: 0.55rem;
  }
  .presence-modal-card--tic-tac-toe .presence-modal-ttt-board {
    max-width: 260px;
  }
}
