/* TrackAScore shared UI: overlay, share sheet, room pill, toast, banner.
   The --tas-* tokens are defined as aliases in brand.css (load it first). */

.tas-hidden { display: none !important; }

.tas-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  /* NOTE: deliberately NO backdrop-filter. A full-screen blur over the board's
     continuously-animating at-bat indicator forces a per-frame re-blur of the
     whole viewport, which pegs laptop GPUs and freezes the page. Use a solid
     scrim instead. */
  background: rgba(8, 10, 14, 0.88);
  padding: calc(env(safe-area-inset-top) + 1rem) 1rem calc(env(safe-area-inset-bottom) + 1.5rem);
}
.tas-card {
  background: var(--tas-card); color: var(--tas-fg); border-radius: var(--ta-radius-xl); padding: 1.5rem 1.4rem;
  width: min(92vw, 420px); text-align: center; box-shadow: var(--ta-shadow-3); position: relative;
  margin: auto;  /* re-centers on tall viewports; collapses to top + scrolls when content overflows */
}
.tas-card h2 { margin: 0 0 .8rem; font-size: 1.3rem; }
.tas-x { position: absolute; top: .5rem; right: .7rem; background: none; border: 0; color: var(--tas-muted); font-size: 1.6rem; cursor: pointer; line-height: 1; }

.tas-code {
  font-family: var(--ta-font-mono); font-size: clamp(2rem, 9vw, 3.2rem);
  font-weight: 700; letter-spacing: .08em; padding: .3em .2em; cursor: pointer; user-select: all;
}
.tas-qr { display: block; margin: .4rem auto 1rem; background: #fff; border-radius: 12px; max-width: 100%; height: auto; }

/* Players / Observers segmented toggle (share sheet) */
.tas-seg { display: flex; gap: 4px; background: var(--ta-surface-2); border-radius: 12px; padding: 4px; margin: .8rem 0 .2rem; }
.tas-seg-btn { flex: 1 1 0; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--tas-fg); font-size: .98rem; font-weight: 600; cursor: pointer; }
.tas-seg-btn.on { background: var(--tas-accent); color: var(--ta-on-primary); }

.tas-btn { display: block; width: 100%; min-height: 48px; border: 0; border-radius: 12px; padding: .85rem 1rem; font-size: 1.05rem; font-weight: 600; cursor: pointer; margin: .4rem 0; }
.tas-btn.tas-sm { width: auto; display: inline-block; padding: .45rem .8rem; font-size: .9rem; margin: 0 .25rem; }
.tas-primary { background: var(--tas-accent); color: var(--ta-on-primary); }
.tas-secondary { background: var(--ta-surface-2); color: var(--tas-fg); }
.tas-danger { background: var(--ta-color-danger); color: #fff; }
/* Confirm dialog sits above the settings sheet / share sheet (same base z-index). */
#tas-confirm-overlay { z-index: 90; }
.tas-caption { color: var(--tas-fg); margin: .8rem 0 .2rem; font-size: .95rem; }
.tas-card .tas-link { display: flex; align-items: center; justify-content: center; min-height: 44px; margin-top: .8rem; padding: .4rem .6rem; color: var(--ta-color-primary); text-decoration: none; }
.tas-card .tas-back { display: flex; align-items: center; justify-content: center; min-height: 44px; margin-top: .6rem; padding: .4rem .6rem; color: var(--ta-muted); text-decoration: none; font-size: .9rem; }
.tas-card .tas-back:hover { color: var(--ta-fg); }
.tas-card .tas-err { color: var(--ta-color-danger); font-size: .85rem; margin-top: .6rem; }
.tas-subcaption { color: var(--tas-muted); margin: 0; font-size: .8rem; }

/* Room pill */
#tas-room-pill {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 40;
  display: flex; align-items: center; gap: .5rem; background: var(--ta-surface); color: var(--tas-fg);
  border-radius: 999px; padding: .45rem .9rem; font-family: var(--ta-font-mono); font-weight: 700;
  letter-spacing: .06em; cursor: pointer; box-shadow: var(--ta-shadow-2); border: 1px solid var(--ta-border);
}
#tas-room-pill.reconnecting { animation: tas-pulse 1.2s ease-in-out infinite; }
@keyframes tas-pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.tas-pill-dots { display: inline-flex; gap: 4px; align-items: center; }
.tas-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ta-muted); display: inline-block; }
.tas-dot.host { width: 11px; height: 11px; border: 2px solid var(--tas-gold); }
.tas-dot.spectator { background: transparent !important; border: 1.5px solid var(--tas-muted); }
.tas-overflow { font-size: .75rem; color: var(--tas-muted); }

/* Toast */
#tas-toast-root { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.tas-toast { background: var(--ta-surface); color: var(--ta-fg); padding: .6rem 1rem; border-radius: var(--ta-radius-sm); font-size: .95rem; box-shadow: var(--ta-shadow-2); opacity: 0; transform: translateY(-8px); transition: opacity .18s, transform .18s; max-width: 90vw; }
.tas-toast.show { opacity: 1; transform: translateY(0); }

/* Resume banner */
#tas-resume-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 70; background: var(--tas-gold); color: var(--ta-on-accent);
  display: flex; align-items: center; justify-content: center; gap: .6rem; flex-wrap: wrap;
  padding: .6rem 1rem; font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.3);
}
#tas-resume-banner .tas-primary { background: var(--ta-on-accent); color: #fff; }
#tas-resume-banner .tas-secondary { background: rgba(0,0,0,.12); color: var(--ta-on-accent); }

/* Connection banners (host/joiner disconnect) */
.tas-conn-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 65; text-align: center; padding: .5rem; font-weight: 600; color: #fff; }
.tas-conn-bar.reconnecting { background: var(--ta-color-danger-strong); }
.tas-conn-bar.host-paused { background: var(--ta-color-warn-strong); }

/* Spectating tag */
.tas-spectating-tag { display: inline-block; background: var(--ta-surface-2); color: var(--tas-muted); border-radius: 999px; padding: .15rem .6rem; font-size: .8rem; font-weight: 600; }

/* =========================================================================
 * Shared team/player setup ("how many players are playing")
 * ONE design used by every game (current + future). Built by boardApp.js
 * ensureEntryUI(); do NOT redefine .ta-cfg per game. Spaced-out card per
 * team/player with a +/- count stepper.
 * ========================================================================= */
#config-rows { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 18px; }
/* Team-config card: cap to the viewport so the Save CTA is ALWAYS reachable;
   the rows list scrolls internally while header + buttons stay pinned. */
#team-config .tas-card {
  display: flex; flex-direction: column;
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 2.5rem);
}
#team-config #config-rows {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  flex: 1 1 auto; min-height: 0;  /* min-height:0 is mandatory or the inner scroll never engages */
}
.ta-cfg {
  background: var(--ta-surface-2); border: 1px solid var(--ta-border);
  border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 14px;
}
.ta-cfg__main { display: flex; align-items: center; gap: 12px; }
.ta-cfg__swatch {
  position: relative; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px;
  overflow: hidden; border: 1px solid var(--ta-border); cursor: pointer;
}
.ta-cfg__swatch input[type=color] {
  position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px);
  border: 0; padding: 0; background: none; cursor: pointer;
}
.ta-cfg__name {
  flex: 1 1 auto; min-width: 0; background: var(--ta-bg-deep);
  border: 1px solid var(--ta-border); color: var(--ta-fg);
  border-radius: 10px; padding: .7rem .8rem; font-size: 1.05rem; font-weight: 600; font-family: inherit;
}
.ta-cfg__name:focus { outline: none; border-color: var(--ta-color-primary); }
.ta-cfg__rm {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px; border: 0;
  background: var(--ta-bg-deep); color: var(--ta-color-danger);
  font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.ta-cfg__rm:hover { background: var(--ta-color-danger-soft); }
.ta-cfg__cap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ta-cfg__cap-label { color: var(--ta-muted); font-size: .95rem; font-weight: 600; }
.ta-cfg__step {
  display: flex; align-items: center; background: var(--ta-bg-deep);
  border: 1px solid var(--ta-border); border-radius: 10px; overflow: hidden;
}
.ta-cfg__step-btn {
  width: 46px; height: 46px; border: 0; background: none; color: var(--ta-fg);
  font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.ta-cfg__step-btn:hover { background: var(--ta-surface-2); }
.ta-cfg__num {
  width: 52px; text-align: center; background: none; border: 0;
  border-left: 1px solid var(--ta-border); border-right: 1px solid var(--ta-border);
  color: var(--ta-fg); font-size: 1.2rem; font-weight: 700; font-family: inherit;
  padding: .65rem 0; -moz-appearance: textfield; appearance: textfield;
}
.ta-cfg__num::-webkit-outer-spin-button, .ta-cfg__num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
