:root {
  --bg: #080d18;
  --surface: #111827;
  --surface-alt: #1a2438;
  --border: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --muted: #94a3b8;
  --crimson: #e53935;
  --cyan: #00e5ff;
  --gold: #ffd54f;
  --emerald: #00e676;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top right, #152238 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 14px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}

.brand-title {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0.06em;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-name {
  font-size: 0.9rem;
  color: var(--muted);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-centered {
  align-items: center;
  padding-top: 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
}

.auth-card {
  max-width: 460px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 22px;
}

.auth-card h2,
.join-card h2 {
  margin: 0;
  font-size: 1.35rem;
}

.muted {
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--surface-alt);
  color: var(--text);
}

.pill-cyan {
  background: rgba(0, 229, 255, 0.14);
  color: var(--cyan);
  border: 1px solid rgba(0, 229, 255, 0.35);
}

.pending-code {
  background: rgba(0, 230, 118, 0.12);
  border: 1px solid rgba(0, 230, 118, 0.35);
  color: #a7f3d0;
  padding: 10px 14px;
  border-radius: 12px;
  width: 100%;
}

.error-text {
  color: #ff8a80;
  font-size: 0.9rem;
  margin: 0;
}

/* Buttons */
.btn {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
  color: var(--text);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-lg {
  min-height: 54px;
  font-size: 1rem;
  padding: 0 22px;
}

.btn-square {
  width: 48px;
  min-width: 48px;
  padding: 0;
  font-size: 1.35rem;
}

.btn-primary {
  background: var(--crimson);
  color: #fff;
}

.btn-emerald {
  background: var(--emerald);
  color: #06130b;
}

.btn-gold {
  background: var(--gold);
  color: #0a0f1a;
}

.btn-tonal {
  background: var(--surface-alt);
  border-color: var(--border);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
}

.btn-full {
  width: 100%;
}

.code-signin-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.code-signin-form .code-input {
  flex: none;
  width: 100%;
  text-align: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Lobby */
.join-form {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.code-input {
  flex: 1 1 220px;
  min-height: 54px;
  border-radius: 12px;
  border: 1px solid rgba(0, 229, 255, 0.4);
  background: #0a1020;
  color: var(--text);
  padding: 0 16px;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.session-item-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.session-code-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  color: var(--cyan);
  margin-right: 8px;
}

/* Controller Toolbar */
.ctrl-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.ctrl-toolbar-left,
.ctrl-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.room-chip {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid rgba(0, 229, 255, 0.45);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.sync-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--emerald);
}

.sync-dot.ended {
  background: var(--crimson);
}

.mono-bold {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

.chip-action {
  font-size: 0.78rem;
  color: var(--cyan);
  font-weight: 700;
}

.ended-banner {
  background: rgba(229, 57, 53, 0.16);
  border: 1px solid rgba(229, 57, 53, 0.5);
  color: #ffcdd2;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
}

/* HUD Preview */
.hud-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hud-preview {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(8, 13, 24, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-wrap: wrap;
  justify-content: center;
}

.hud-live-pill {
  background: var(--crimson);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.08em;
}

.hud-team {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hud-bar {
  width: 5px;
  height: 22px;
  border-radius: 3px;
}

.hud-abbr {
  font-weight: 800;
  letter-spacing: 0.04em;
}

.hud-score {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  font-weight: 800;
}

.hud-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}

.hud-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-left: 6px;
  border-left: 1px solid var(--border);
}

.hud-period {
  color: var(--gold);
  font-weight: 800;
}

.hud-clock {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--cyan);
}

.last-action {
  font-size: 0.85rem;
  text-align: center;
}

/* Chips */
.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.chip.selected {
  background: rgba(0, 229, 255, 0.16);
  border-color: var(--cyan);
  color: var(--cyan);
}

/* Clock Card */
.clock-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.clock-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.clock-display-btn {
  background: transparent;
  border: none;
  padding: 4px 6px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.caption {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.clock-big {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 2.3rem;
  font-weight: 800;
  line-height: 1.1;
}

.clock-big.running {
  color: var(--cyan);
}

.period-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-badge {
  min-width: 72px;
  text-align: center;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--gold);
  font-weight: 800;
  font-size: 1.1rem;
}

.clock-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.clock-controls #clock-toggle-btn {
  flex: 1.5 1 160px;
}

.clock-controls #clock-reset-btn {
  flex: 1 1 110px;
}

.clock-controls #clock-ot-btn {
  flex: 0.8 1 92px;
}

.possession-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Team Scoring Cards */
.teams-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 560px) {
  .teams-grid {
    gap: 8px;
  }
}

.team-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border-width: 1.5px;
}

.team-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.team-stripe {
  width: 6px;
  height: 28px;
  border-radius: 3px;
  flex-shrink: 0;
}

.team-title {
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-big {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 3.1rem;
  font-weight: 800;
  line-height: 1;
}

.score-btn-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.score-btn-full {
  grid-column: span 2;
}

/* Telemetry Deck */
.telemetry-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.telemetry-card h3 {
  margin: 0;
  font-size: 1rem;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 600px) {
  .telemetry-grid {
    grid-template-columns: 1fr;
  }
}

.counter-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-alt);
}

.counter-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  font-weight: 800;
}

.counter-actions {
  display: flex;
  gap: 6px;
}

.baseball-outs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.outs-dots {
  display: flex;
  align-items: center;
  gap: 10px;
}

.out-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface-alt);
  cursor: pointer;
}

.out-dot.active {
  background: var(--gold);
  border-color: var(--gold);
}

.baseball-count-row,
.football-down-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.baseball-count-row .btn,
.football-down-row .btn {
  flex: 1 1 110px;
}

/* Modals */
.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 440px;
  width: calc(100% - 28px);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-body h3 {
  margin: 0;
}

.field-row {
  display: flex;
  gap: 10px;
}

.field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.field-sm {
  flex: 0 0 100px;
}

.field input {
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0a1020;
  color: var(--text);
  padding: 0 12px;
  font-size: 1rem;
}

.swatch-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--cyan);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  border: 1px solid rgba(0, 229, 255, 0.4);
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  z-index: 100;
  max-width: calc(100% - 32px);
  text-align: center;
}

/* Footer & Legal / Account Deletion Pages */
.site-footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 600;
}

.site-footer a:hover {
  text-decoration: underline;
}

.info-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.info-list strong {
  color: var(--text);
}

.account-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.danger-card {
  border-color: rgba(229, 57, 53, 0.55);
}

.success-box {
  background: rgba(0, 230, 118, 0.12);
  border: 1px solid rgba(0, 230, 118, 0.4);
  border-radius: 12px;
  padding: 14px;
  color: #a7f3d0;
  line-height: 1.5;
}

.warn-box {
  background: rgba(255, 213, 79, 0.12);
  border: 1px solid rgba(255, 213, 79, 0.4);
  border-radius: 12px;
  padding: 14px;
  color: #fde68a;
  line-height: 1.5;
}

.text-input {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0a1020;
  color: var(--text);
  padding: 0 14px;
  font-size: 1rem;
}

.text-input:focus {
  outline: 2px solid var(--cyan);
  border-color: var(--cyan);
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

