/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --accent:        #F07820;   /* orange from the stag badge */
  --accent-dark:   #d4681a;
  --hero-bg:       #111111;
  --bg:            #f2f2f7;
  --surface:       #ffffff;
  --surface-2:     #e8e8ed;
  --text:          #1c1c1e;
  --text-secondary:#6c6c70;
  --text-tertiary: #aeaeb2;
  --border:        #d1d1d6;
  --radius:        16px;
  --radius-sm:     10px;
  --shadow:        0 2px 8px rgba(0,0,0,.08);
}

/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure the HTML hidden attribute always wins over CSS display rules */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.event-hero {
  background: #ffffff;
  border-bottom: 1px solid #d1d1d6;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: max(20px, calc(env(safe-area-inset-top) + 8px)) 16px 20px;
}


.stag-logo {
  width: min(220px, 65vw);
  height: auto;
  display: block;
}

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 16px;
}

/* ── Soundboard grid ─────────────────────────────────────────────────────── */
.soundboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

/* ── Sound button ────────────────────────────────────────────────────────── */
.sound-btn {
  appearance: none;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 100px;
  width: 100%;
  box-shadow: var(--shadow);
  transition:
    background .18s ease,
    border-color .18s ease,
    color .18s ease,
    transform .12s ease,
    box-shadow .18s ease;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.sound-btn:active {
  transform: scale(0.96);
}

.sound-btn.playing {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(240,120,32,.4);
  transform: scale(1.02);
}

.btn-icon {
  font-size: 24px;
  line-height: 1;
  display: block;
}

.btn-label {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 24px;
  text-align: center;
}

.empty-icon {
  font-size: 56px;
  line-height: 1;
  opacity: .3;
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
}

.empty-sub {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.empty-sub code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  background: var(--surface-2);
  padding: 2px 5px;
  border-radius: 4px;
}

/* ── Sponsors footer ─────────────────────────────────────────────────────── */
.sponsors {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.sponsors-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.sponsors-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px 24px;
}

.sponsors-logos img {
  height: 36px;
  width: auto;
  object-fit: contain;
}

/* ── Tablet / wider screens ──────────────────────────────────────────────── */
@media (min-width: 600px) {
  .soundboard-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .stag-logo {
    width: min(360px, 60vw);
  }
}

@media (min-width: 900px) {
  .main-content { max-width: 800px; margin: 0 auto; padding: 20px; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}

/* ── Tab bar ─────────────────────────────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  /* viewport-fit=cover is set in HTML; max() provides a fallback floor */
  padding-bottom: max(env(safe-area-inset-bottom), 10px);
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text-secondary);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s ease;
  touch-action: manipulation;
}

.tab-item.active { color: var(--accent); }

.tab-icon {
  font-size: 26px;
  line-height: 1;
}

/* Push content above the fixed tab bar */
.main-content {
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

/* ── Sponsors (now inside the sounds tab panel) ──────────────────────────── */
.sponsors {
  margin-top: 24px;
}

/* ── Map tab ─────────────────────────────────────────────────────────────── */
.map-container {
  width: 100%;
  height: 340px;
  background: var(--surface-2);
}

.map-notice {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 10px 16px;
  text-align: center;
}

.map-notice code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 4px;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}

/* ── Strava auth (connect / connected-as — always visible) ──────────────── */
.strava-auth-section {
  padding: 16px 16px 0;
}
.strava-auth-connected {
  display: flex;
  align-items: center;
  gap: 12px;
}
.strava-auth-connected .strava-athlete-info {
  margin: 0;
}

/* ── Countdown widget ────────────────────────────────────────────────────── */
.strava-countdown-section {
  padding: 20px 16px 8px;
  text-align: center;
}
.countdown-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.countdown-display {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
}
.countdown-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
}
.countdown-num {
  font-size: 44px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}
.countdown-sep {
  font-size: 36px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  padding: 4px 2px 0;
}
.countdown-sub {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-top: 5px;
}

/* Pre-event leaderboard placeholder */
.strava-pre-event {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  text-align: center;
}

/* ── Club event card ─────────────────────────────────────────────────────── */
.strava-event-section {
  padding: 12px 16px 0;
}

.strava-event-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-left: 4px solid #FC4C02;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.strava-event-type-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #FC4C02;
  background: rgba(252, 76, 2, 0.1);
  padding: 3px 8px;
  border-radius: 99px;
}

.strava-event-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
}

.strava-event-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.strava-event-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.strava-event-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.strava-event-athletes {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.strava-section {
  padding: 16px;
}

.strava-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.5;
}

.strava-hint--warn {
  color: #b45309;
}

.strava-hint code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 4px;
}

.strava-connect-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #FC4C02;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.strava-connect-btn:active { opacity: .85; }

.strava-athlete-info {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* Leaderboard */
.leaderboard { margin-bottom: 12px; }

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.lb-medal { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }
.lb-name  { flex: 1; font-size: 14px; font-weight: 600; }
.lb-dist  { font-size: 14px; font-weight: 700; color: var(--accent); }

.lb-loading, .lb-empty {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 12px 0;
  text-align: center;
}

.text-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Crawl tracker ───────────────────────────────────────────────────────── */
.crawl-progress-wrap {
  padding: 14px 0 10px;
  margin-bottom: 8px;
}

.crawl-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.crawl-progress-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.crawl-progress-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}

.crawl-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .4s ease;
  width: 0%;
}

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

.crawl-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: border-color .15s, opacity .15s;
}

.crawl-item--done {
  border-color: var(--accent);
  opacity: .65;
}

.crawl-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.crawl-item--done .crawl-num {
  background: var(--accent);
  color: #fff;
}

.crawl-info { flex: 1; min-width: 0; }
.crawl-name { font-size: 14px; font-weight: 600; }
.crawl-challenge {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}

.crawl-check-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, color .15s;
  touch-action: manipulation;
}

.crawl-item--done .crawl-check-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Bingo ───────────────────────────────────────────────────────────────── */
.bingo-name-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px 24px;
  text-align: center;
}

.bingo-name-title {
  font-size: 22px;
  font-weight: 800;
}

.bingo-name-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: -8px;
}

.bingo-name-input {
  width: 100%;
  max-width: 260px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 16px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}

.bingo-name-input:focus { border-color: var(--accent); }

.bingo-name-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 32px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.bingo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 4px;
}

.bingo-player-label { font-size: 13px; color: var(--text-secondary); }

.bingo-letters {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 0 8px;
}

.bingo-letters span {
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
  padding: 4px 0;
}

.bingo-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 4px 8px 8px;
}

.bingo-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(7px, 1.9vw, 10px);
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  line-height: 1.25;
  padding: 4px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  word-break: break-word;
  transition: background .15s, border-color .15s, color .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.bingo-cell:active { transform: scale(0.94); }

.bingo-cell--marked {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Dares ───────────────────────────────────────────────────────────────── */
.dares-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 8px 0;
}

.dares-top-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dares-counter {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.dare-card {
  width: 100%;
  min-height: 220px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 28px 20px;
  text-align: center;
}


.dare-text {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

.dare-next-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 40px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  touch-action: manipulation;
  transition: background .15s;
}

.dare-next-btn:active { background: var(--accent-dark); }

@media (min-width: 600px) {
  .map-container { height: 420px; }
  .dare-card { min-height: 260px; }
}

/* ── AI styles ───────────────────────────────────────────────────────────── */

/* Bingo: loading state while AI generates */
.bingo-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 24px;
  text-align: center;
}

.bingo-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: #7c3aed;
  border-radius: 50%;
  animation: ai-spin 0.75s linear infinite;
}

@keyframes ai-spin { to { transform: rotate(360deg); } }

.bingo-loading-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Bingo: error state */
.bingo-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 24px;
  text-align: center;
}

.bingo-error-msg {
  font-size: 14px;
  color: #b45309;
  line-height: 1.5;
}

/* Dares: loading state inside dare card */
.dare-card-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.dare-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ai-spin 0.75s linear infinite;
}

.dare-loading-label {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Person picker ───────────────────────────────────────────────────────────── */

.person-pick-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 20px 24px;
  text-align: center;
}

.person-pick-title {
  font-size: 22px;
  font-weight: 800;
}

.person-pick-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: -8px;
}

.person-pick-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.person-pick-btn {
  width: 100%;
  padding: 15px 20px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  touch-action: manipulation;
  transition: border-color .15s, background .15s;
}

.person-pick-btn:active {
  background: var(--surface-2);
}

.person-pick-btn--stag {
  border-color: var(--accent);
}

.person-stag-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--accent);
  background: rgba(240, 120, 32, 0.12);
  padding: 3px 8px;
  border-radius: 99px;
}

/* Bingo: header buttons row */
.bingo-header-btns {
  display: flex;
  gap: 10px;
  align-items: center;
}
