/* Top bar, toasts, confirm dialog. */

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: calc(6px + var(--safe-t)) max(10px, var(--safe-r)) 6px max(10px, var(--safe-l));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  z-index: 5;
}
.topbar-side { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; min-width: 0; }
.topbar-side-end { justify-content: flex-end; }

.chip-btn {
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(9, 11, 28, 0.66);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--c-text);
  font-family: var(--font-display);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: border-color 0.15s ease, transform 0.08s ease;
}
.chip-btn:hover { border-color: var(--c-cyan); }
.chip-btn > [aria-hidden] { font-size: 1.05rem; line-height: 1; }
.chip-btn:active { transform: scale(0.94); }
.topbar-quit { color: var(--c-red); border-color: rgba(255, 51, 85, 0.4); }

.round-pill, .conn-pill {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(9, 11, 28, 0.7);
  border: 1px solid rgba(0, 240, 255, 0.35);
  font-family: var(--font-display);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--c-cyan);
}
.round-pill.is-final { color: var(--c-yellow); border-color: rgba(255, 204, 0, 0.6); box-shadow: 0 0 16px rgba(255, 204, 0, 0.35); }
.conn-pill { color: var(--c-yellow); border-color: rgba(255, 204, 0, 0.45); }
.conn-pill .pulse-dot { background: var(--c-yellow); box-shadow: 0 0 10px var(--c-yellow); }

.topbar-core {
  flex: 1 1 auto;
  max-width: 220px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(9, 11, 28, 0.7);
  border: 1px solid rgba(255, 0, 110, 0.4);
  --core: var(--c-pink);
}
.topbar-core[data-state="mid"] { --core: var(--c-yellow); }
.topbar-core[data-state="low"], .topbar-core[data-state="dead"] { --core: var(--c-green); }
.topbar-core-icon { font-size: 0.95rem; }
.topbar-core-bar { flex: 1; min-width: 28px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.topbar-core-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--core);
  box-shadow: 0 0 10px var(--core);
  transform-origin: 0 50%;
  transition: transform 0.6s cubic-bezier(0.3, 1.4, 0.5, 1), background 0.4s ease;
}
.topbar-core-value { font-family: var(--font-display); font-size: 0.56rem; font-weight: 700; color: var(--c-dim); white-space: nowrap; }

/* Phone landscape with the keyboard up: ~200 px of height left, the answer dock needs all of it. */
@media (orientation: landscape) and (max-height: 500px) {
  .hud.kb-open .topbar { display: none; }
}

/* Narrow phones: the round pill and the meter share the space between the corner buttons. */
@media (max-width: 420px) {
  .round-pill { padding: 0 8px; font-size: 0.5rem; }
  .topbar-core { padding: 0 8px; gap: 4px; }
  .topbar-core-icon { display: none; }
}

/* Spectator badge: under the bar, centred — the one place a mid-game joiner learns why nothing is theirs yet. */
.watch-badge {
  position: absolute;
  top: calc(var(--topbar-h) + var(--safe-t) + 2px);
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(9, 11, 28, 0.85);
  border: 1px solid rgba(238, 243, 255, 0.3);
  font-family: var(--font-display);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 4;
  animation: toast-in 0.3s ease both;
}
.watch-badge-eye { font-size: 0.9rem; }
.hud.kb-open .watch-badge { display: none; }

/* ── Toasts ────────────────────────────────────────────────────────── */

.toasts {
  position: absolute;
  top: calc(var(--topbar-h) + var(--safe-t) + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 420px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 50;
}
.toast {
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--glass-strong);
  border: 1px solid rgba(0, 240, 255, 0.4);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.8);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  animation: toast-in 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
.toast-error { border-color: var(--c-red); color: #ffd9df; }
.toast-warn { border-color: var(--c-yellow); color: #fff2c2; }
.toast-ok { border-color: var(--c-green); color: #d5ffe9; }
.toast.is-sticky {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  pointer-events: auto;
}
.toast-actions { display: inline-flex; gap: 6px; }
.toast.is-leaving { opacity: 0; transform: translateY(-8px); transition: opacity 0.25s ease, transform 0.25s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(0.94); } }

/* ── Modal scaffolding (dialog here, settings sheet in settings.css) ─ */

.sheet-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: auto;
  z-index: 40;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 3, 10, 0.62);
  animation: fade-in 0.2s ease both;
}
@keyframes fade-in { from { opacity: 0; } }

.dialog-wrap { align-items: center; padding: 20px; }
.dialog {
  position: relative;
  width: min(100%, 380px);
  padding: 22px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  animation: pop-in 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
.dialog-text { color: var(--c-dim); font-size: 0.95rem; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
@keyframes pop-in { from { opacity: 0; transform: scale(0.9); } }
