/* Shared overlays: toasts, the in-match popup card, the unread-chat pill. */
.copy-toast { position: absolute; top: 100%; right: 0; margin-top: 4px; background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); padding: 4px 12px; border-radius: 4px; font-size: 0.75rem; white-space: nowrap; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 9999; }
.copy-toast.show { opacity: 1; }

.coin-toast-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding-bottom: 10vh; background: rgba(0,0,0,0.5); z-index: 10000; opacity: 0; transition: opacity 0.3s; }
.coin-toast-overlay.show { opacity: 1; }

.notification-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translate(-50%, -120%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  /* Solid dark backdrop + white text for contrast in BOTH themes (bg-card washed out in light). */
  background: rgba(22, 20, 17, 0.97);
  border: 1px solid color-mix(in srgb, var(--accent-green) 65%, rgba(255, 255, 255, 0.2));
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 10001;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.2s ease;
  max-width: calc(100vw - 32px);
}
.notification-toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}
.notification-toast.toast-info  { border-color: color-mix(in srgb, var(--lapis-2) 70%, rgba(255, 255, 255, 0.2)); }
.notification-toast.toast-warn  { border-color: color-mix(in srgb, var(--gold) 70%, rgba(255, 255, 255, 0.2)); }
.notification-toast.toast-error { border-color: color-mix(in srgb, var(--porphyry-2) 80%, rgba(255, 255, 255, 0.2)); }
.notification-toast.app-toast .notification-toast-msg { white-space: normal; }
.notification-toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-green);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  flex: 0 0 auto;
}
.notification-toast-msg {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (prefers-reduced-motion: reduce) {
  .notification-toast { transition: opacity 0.2s ease; transform: translate(-50%, 0); }
}
.coin-toast-card { background: var(--bg-card); border: 2px solid var(--accent-green); border-radius: 12px; padding: 28px 48px; text-align: center; }
.coin-toast-icon { font-size: 2.5rem; margin-bottom: 8px; }
.coin-toast-msg { font-size: 1.3rem; color: var(--text-primary); font-weight: 600; }

/* position:fixed so it isn't clipped by .app-content overflow-x:hidden. The z scale, low to
   high: sidebar/nav/user-menu < popup-overlay(1100) < focus-exit(1200) < dm-dock mobile(1300)
   < chat-unread(1310) < modal-overlay(1400) < coin-toast(10000) < notification-toast(10001). */
.popup-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 1100; }
.popup-card { background: var(--bg-1); border: 2px solid var(--bronze); border-radius: var(--radius-l); padding: 18px 24px; min-width: 340px; max-width: 420px; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,0.4); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.popup-drag-handle { font-size: 0.7rem; color: var(--text-muted); cursor: move; text-align: left; margin-bottom: 8px; user-select: none; padding: 2px 0; letter-spacing: 0.08em; opacity: 0.6; }
.popup-drag-handle:hover { opacity: 1; color: var(--accent-gold); }
.popup-card h3 { color: var(--accent-gold); margin-bottom: 10px; font-size: 1.1rem; }
.popup-card p { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 6px; }
.defend-table { width: 100%; border-collapse: collapse; background: rgba(0,0,0,0.2); border-radius: 6px; margin: 8px 0; font-size: 0.85rem; }
.defend-table td { padding: 5px 10px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.defend-table tr:last-child td { border-bottom: none; }
.defend-table td:first-child { color: var(--text-secondary); text-align: left; }
.defend-table td:nth-child(2) { text-align: right; color: var(--text-primary); }
/* Unread chat. Shown at EVERY width: collapsing the right panel hides the log on desktop too,
   which is the same silence this exists to break. z-index clears the DM dock (1300) so a docked
   conversation bar cannot bury it; syncUnread withholds it while a response popup is up.
   The bottom bar is 64px and takes no safe-area inset, so neither does this. */
.chat-unread {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 74px;
  z-index: 1310;
  padding: 5px 14px; border-radius: 999px;
  background: var(--bronze-gradient); color: var(--on-bronze);
  border: 1px solid var(--bronze-2); box-shadow: var(--shadow-2);
  font: inherit; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em;
  cursor: pointer; white-space: nowrap;
}
.chat-unread:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
/* No bottom bar above 640px, so it sits at the viewport edge instead. */
@media (min-width: 641px) { .chat-unread { bottom: 18px; } }
/* A unit pip standing in for its name in popup prose. */
.popup-unit { display: inline-flex; align-items: center; vertical-align: -0.18em; margin: 0 1px; }
.popup-unit .unit-pip { width: 1em; height: 1em; border-width: 1px; }
.popup-buttons { display: flex; gap: 8px; margin-top: 14px; justify-content: center; flex-wrap: wrap; }
/* Cost tables collapse so the popup leads with the decision; the buttons already carry the cost. */
.popup-details-toggle {
  all: unset;
  box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-top: 12px; padding: 6px 8px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-m);
  font: inherit; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3); transition: color 0.12s, border-color 0.12s;
}
.popup-details-toggle:hover { color: var(--ink); border-color: var(--bronze-2); }
/* all:unset strips the native focus ring — restore a keyboard indicator. */
.popup-details-toggle:focus-visible { outline: 2px solid var(--bronze-2); outline-offset: 2px; }
.pd-arrow { font-size: 0.75em; line-height: 1; }
.popup-details { display: none; }
.popup-details.is-open { display: block; }

.chase-coords { font-size: 0.7rem; opacity: 0.75; background: rgba(0,0,0,0.3); border-radius: 3px; padding: 1px 4px; font-family: monospace; }

.popup-waiting {
  position: absolute;
  top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  background: color-mix(in srgb, var(--bg-0) 93%, transparent);
  border: 1px solid var(--bronze);
  border-radius: var(--radius-l);
  padding: 10px 16px;
  z-index: 50;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  min-width: 280px;
  max-width: calc(100% - 32px);
}
.popup-waiting-spinner {
  width: 22px; height: 22px;
  border: 2px solid color-mix(in srgb, var(--accent-gold) 25%, transparent);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: battlefield-spin 0.9s linear infinite;
  flex-shrink: 0;
}
.popup-waiting-text { text-align: left; font-size: 0.85rem; color: var(--text-primary); line-height: 1.35; }
.popup-waiting-text strong { color: var(--accent-gold); }
.popup-waiting-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
@media (prefers-reduced-motion: reduce) {
  .popup-waiting-spinner { animation: none; border-top-color: var(--accent-gold); }
}

@media (max-width: 640px) {
  /* Mobile: fixed full-viewport, z above bottom-nav(500), below focus-exit(1200). */
  .popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.78);
    border-radius: 0;
    padding: 16px;
  }
  .popup-card {
    position: static;
    transform: none;
    top: auto; right: auto; left: auto;
    min-width: 0;
    width: 100%;
    max-width: 420px;
    padding: 16px 18px;
  }
  .popup-buttons { flex-direction: column; gap: 6px; }
  .popup-buttons .btn { width: 100%; }
  .defend-table td { padding: 4px 6px; font-size: 0.8rem; }
  .ai-confirm-prompt { margin-left: 0; width: 100%; justify-content: space-between; }
  .coin-toast-card { padding: 20px 28px; }
  .coin-toast-icon { font-size: 2rem; }
  .coin-toast-msg { font-size: 1.1rem; }
}

/* Mobile + portrait-tablet popup and toast overrides (the panel stack they once followed lives in play/play-panels.css).
   768, not 600: at 600–768 play-panels' 1440 block's `flex: 1; min-width: 200px` still fits two panel cards
   side by side, which is how a large phone got the unit card and the actions card in one row. */
@media (max-width: 768px) {
  .popup-card { min-width: 0; width: 90%; max-width: calc(100% - 16px); }
}
