/* ==========================================================================
   Ball Knowledge — design tokens
   Themed around the flame/smoke logo artwork: black canvas, fire gradient
   accents (orange/red/blue/green), bold condensed display type.
   ========================================================================== */
:root {
  --bg: #050505;
  --surface: #131313;
  --surface-line: rgba(245, 245, 245, 0.12);
  --white: #f5f5f5;
  --dim: #a8a8a8;
  --flame-orange: #ff7a2e;
  --flame-red: #ef3c3c;
  --flame-blue: #35b3e0;
  --flame-green: #38c977;
  --correct: #38c977;
  --wrong: #ef3c3c;
  --radius: 10px;
  --max-width: 960px;
  --font-display: 'Jersey 15', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(5, 5, 5, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--surface-line);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
}
.brand img {
  height: 34px;
  width: auto;
}
.site-nav {
  display: flex;
  gap: 22px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.site-nav a { color: var(--dim); transition: color 0.15s; }
.site-nav a:hover, .site-nav a.active { color: var(--flame-orange); }
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 22px;
  cursor: pointer;
}

.nav-dropdown { position: relative; }
.nav-dropdown-btn {
  background: none;
  border: none;
  color: var(--dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  transition: color 0.15s;
}
.nav-dropdown-btn:hover { color: var(--flame-orange); }
.nav-dropdown-arrow { font-size: 10px; }
.nav-dropdown-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  padding: 6px;
  display: none;
  flex-direction: column;
  min-width: 190px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.5);
  z-index: 90;
}
.nav-dropdown-panel.open { display: flex; }
.nav-dropdown-panel a {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 5px;
  white-space: nowrap;
}
.nav-dropdown-panel a:hover { background: rgba(255,122,46,0.1); }

@media (max-width: 640px) {
  .site-nav {
    position: fixed;
    top: 58px;
    left: 0;
    right: 0;
    background: var(--surface);
    flex-direction: column;
    gap: 0;
    padding: 6px 0;
    border-bottom: 1px solid var(--surface-line);
    transform: translateY(-140%);
    transition: transform 0.2s ease;
  }
  .site-nav.open { transform: translateY(0); }
  .site-nav > a { padding: 12px 20px; border-top: 1px solid var(--surface-line); }
  .nav-toggle { display: block; }

  /* On mobile, the dropdown is always expanded inline as part of the
     vertical menu — no separate click needed, matching the existing
     "everything in one list" mobile pattern. */
  .nav-dropdown-btn {
    padding: 12px 20px;
    border-top: 1px solid var(--surface-line);
    width: 100%;
    color: var(--dim);
    pointer-events: none;
  }
  .nav-dropdown-arrow { display: none; }
  .nav-dropdown-panel {
    display: flex !important;
    position: static;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0;
    min-width: 0;
  }
  .nav-dropdown-panel a { padding: 12px 20px 12px 32px; border-top: 1px solid var(--surface-line); border-radius: 0; }
}

/* ---------- Hero ---------- */
.hero {
  padding: 40px 0 30px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,122,46,0.16), transparent 60%);
  border-bottom: 1px solid var(--surface-line);
}
.hero img.hero-logo {
  max-width: 320px;
  width: 80%;
  margin: 0 auto 16px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--flame-orange);
  margin: 0 auto 10px;
}
.hero p {
  color: var(--dim);
  font-size: 15px;
  max-width: 46ch;
  line-height: 1.5;
  margin: 0 auto;
}

/* ---------- Game grid ---------- */
.section-label {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: 0.06em;
  color: var(--flame-orange);
  margin: 36px 0 14px;
}
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding-bottom: 8px;
}
.game-card {
  background: var(--surface);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
}
.game-card:hover {
  border-color: var(--flame-orange);
  transform: translateY(-2px);
}
.game-card .thumb {
  aspect-ratio: 2 / 1;
  overflow: hidden;
  background: #000;
}
.game-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.game-card .body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.game-card .tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--flame-orange);
}
.game-card p {
  font-size: 13px;
  color: var(--dim);
  margin: 0;
  line-height: 1.4;
}
.game-card .play {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #050505;
  background: var(--flame-orange);
  padding: 7px 12px;
  border-radius: 6px;
  width: fit-content;
}
.game-card.soon {
  opacity: 0.5;
}
.game-card.soon .thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  color: var(--dim);
  font-size: 15px;
}
.game-card.soon .play {
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--surface-line);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--surface-line);
  margin-top: 50px;
  padding: 24px 0 40px;
  color: var(--dim);
  font-size: 12px;
}
.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.footer-legal-links {
  width: 100%;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--surface-line);
}
.footer-legal-links a { color: var(--dim); }
.footer-legal-links a:hover { color: var(--flame-orange); }

/* ---------- Generic page ---------- */
.page-header {
  padding: 24px 0 12px;
  text-align: center;
}
.page-header img.page-logo {
  max-width: 280px;
  width: 75%;
  margin: 0 auto 10px;
}
.page-header h1.visual-h1 {
  font-family: var(--font-display);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  margin: 0 0 10px;
  font-weight: normal;
}
.page-header .meta {
  font-size: 13px;
  color: var(--dim);
  line-height: 1.5;
}
.back-link {
  font-size: 12px;
  color: var(--dim);
  display: inline-block;
  margin-bottom: 10px;
}
.back-link:hover { color: var(--flame-orange); }

.coming-soon-box {
  text-align: center;
  padding: 60px 16px;
  color: var(--dim);
}

/* ---------- Autocomplete (shared across games) ---------- */
.bk-ac-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
}
.bk-ac-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 2px 0 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--surface-line);
  border-radius: 6px;
  max-height: 170px;
  overflow-y: auto;
  z-index: 80;
  display: none;
  box-shadow: 0 6px 16px rgba(0,0,0,0.5);
}
.bk-ac-list.open { display: block; }
.bk-ac-item {
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--white);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bk-ac-item.active,
.bk-ac-item:hover {
  background: var(--flame-orange);
  color: #050505;
}

/* ---------- Leaderboard (shared across games) ---------- */
.bk-lb {
  max-width: 420px;
  margin: 16px auto 0;
}
.bk-lb-title {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--flame-orange);
  text-align: center;
  margin-bottom: 10px;
}
.bk-lb-submit-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.bk-lb-submit-row input {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid rgba(245,245,245,0.3);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--white);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
}
.bk-lb-submit-row input:focus { border-color: var(--flame-orange); }
.bk-lb-submit-row button {
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 7px;
  border: none;
  background: var(--flame-orange);
  color: #050505;
  cursor: pointer;
  white-space: nowrap;
}
.bk-lb-submit-row button:disabled { opacity: 0.5; cursor: not-allowed; }
.bk-lb-status {
  font-size: 11px;
  color: var(--dim);
  margin-bottom: 10px;
  min-height: 14px;
}
.bk-lb-status.error { color: var(--wrong); }
.bk-lb-status.success { color: var(--correct); }
.bk-lb-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.bk-lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--surface-line);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  transition: transform 0.1s;
}
.bk-lb-row.rank-1 {
  border-color: #d4af37;
  background: linear-gradient(90deg, rgba(212,175,55,0.14), rgba(212,175,55,0.03));
}
.bk-lb-row.rank-2 {
  border-color: #c7c9cc;
  background: linear-gradient(90deg, rgba(199,201,204,0.13), rgba(199,201,204,0.03));
}
.bk-lb-row.rank-3 {
  border-color: #cd7f32;
  background: linear-gradient(90deg, rgba(205,127,50,0.13), rgba(205,127,50,0.03));
}
.bk-lb-medal {
  font-size: 18px;
  width: 24px;
  flex-shrink: 0;
  text-align: center;
}
.bk-lb-rank {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--dim);
  width: 24px;
  flex-shrink: 0;
  text-align: center;
}
.bk-lb-name {
  flex: 1;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bk-lb-time {
  font-size: 11px;
  color: var(--dim);
  flex-shrink: 0;
}
.bk-lb-score {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--flame-orange);
  flex-shrink: 0;
  min-width: 24px;
  text-align: right;
}
.bk-lb-row.rank-1 .bk-lb-score { color: #e8c874; }
.bk-lb-empty {
  text-align: center;
  font-size: 12px;
  color: var(--dim);
  padding: 12px;
}

/* ---------- Homepage leaderboards ---------- */
.hp-lb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  padding-bottom: 30px;
}
.hp-lb-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--surface-line);
  border-radius: 10px;
  padding: 14px;
  transition: border-color 0.15s, transform 0.15s;
}
.hp-lb-card:hover {
  border-color: var(--flame-orange);
  transform: translateY(-2px);
}
.hp-lb-card-title {
  font-family: var(--font-display);
  font-size: 17px;
  text-transform: uppercase;
  color: var(--flame-orange);
  margin-bottom: 8px;
}
.hp-lb-card .bk-lb-list { margin-bottom: 8px; }
.hp-lb-card-play {
  font-size: 11px;
  font-weight: 700;
  color: var(--dim);
}
.hp-lb-card:hover .hp-lb-card-play { color: var(--flame-orange); }

/* ---------- FAQ section (shared across game pages) ---------- */
.faq-section {
  max-width: 480px;
  margin: 30px auto 40px;
}
.faq-section h2 {
  font-family: var(--font-display);
  font-size: 20px;
  text-transform: uppercase;
  color: var(--flame-orange);
  margin-bottom: 12px;
}
.faq-item {
  background: var(--surface);
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.faq-item h3 {
  font-size: 14px;
  margin: 0 0 6px;
  color: var(--white);
}
.faq-item p {
  font-size: 13px;
  color: var(--dim);
  margin: 0;
  line-height: 1.5;
}

/* ---------- How to Play modal ---------- */
.bk-htp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.bk-htp-modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--surface-line);
  border-radius: 12px;
  padding: 24px 20px 20px;
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
.bk-htp-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--dim);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.bk-htp-close:hover { color: var(--white); }
.bk-htp-title {
  font-family: var(--font-display);
  font-size: 22px;
  text-transform: uppercase;
  color: var(--flame-orange);
  margin-bottom: 10px;
  padding-right: 20px;
}
.bk-htp-body { font-size: 13px; color: var(--white); line-height: 1.6; }
.bk-htp-body p { margin: 0 0 10px; }
.bk-htp-body ul { margin: 0 0 10px; padding-left: 18px; }
.bk-htp-body li { margin-bottom: 4px; }
.bk-htp-got-it { width: 100%; margin-top: 12px; }

.bk-htp-reopen {
  position: fixed;
  bottom: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--flame-orange);
  color: var(--flame-orange);
  font-family: var(--font-display);
  font-size: 18px;
  cursor: pointer;
  z-index: 60;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* ---------- Cookie consent banner ---------- */
.bk-cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1.5px solid var(--flame-orange);
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 300;
  box-shadow: 0 -6px 20px rgba(0,0,0,0.5);
}
.bk-cookie-text {
  font-size: 12px;
  color: var(--dim);
  max-width: 560px;
  line-height: 1.5;
  text-align: center;
}
.bk-cookie-text a { color: var(--flame-orange); }
.bk-cookie-buttons { display: flex; gap: 8px; flex-shrink: 0; }
.bk-cookie-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  padding: 9px 16px;
  border-radius: 6px;
  cursor: pointer;
  border: 1.5px solid rgba(245,245,245,0.3);
}
.bk-cookie-btn.reject { background: transparent; color: var(--white); }
.bk-cookie-btn.accept { background: var(--flame-orange); color: #050505; border-color: var(--flame-orange); }

/* ---------- Legal pages ---------- */
.legal-content { max-width: 680px; margin: 0 auto 50px; font-size: 14px; line-height: 1.7; color: var(--white); }
.legal-content h2 { font-family: var(--font-display); font-size: 20px; color: var(--flame-orange); margin: 28px 0 10px; text-transform: uppercase; }
.legal-content h2:first-child { margin-top: 0; }
.legal-content p { margin: 0 0 12px; color: var(--dim); }
.legal-content ul { margin: 0 0 12px; padding-left: 20px; color: var(--dim); }
.legal-content li { margin-bottom: 6px; }
.legal-content a { color: var(--flame-orange); }
.legal-updated { font-size: 11px; color: var(--dim); margin-bottom: 24px; }



/* ---------- Daily Circuit Progression ---------- */
.circuit-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--surface-line);
  font-family: var(--font-body);
  padding: 12px 16px;
  position: sticky;
  top: 58px; /* sits right under the header */
  z-index: 40;
}
.circuit-wrap {
  max-width: var(--max-width);
  margin: 0 auto;
}
.circuit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.circuit-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.circuit-season {
  background: rgba(255,122,46,0.15);
  color: var(--flame-orange);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
}
.circuit-xp {
  font-size: 13px;
  color: var(--dim);
  font-weight: 600;
}
.circuit-xp .xp-val {
  color: var(--flame-orange);
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.03em;
}
.circuit-games {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.circuit-game-item {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--surface-line);
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.circuit-game-item::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-line);
}
.circuit-game-item.status-done {
  color: var(--white);
  border-color: rgba(56,201,119,0.3);
  background: rgba(56,201,119,0.05);
}
.circuit-game-item.status-done::before {
  background: var(--correct);
  box-shadow: 0 0 6px var(--correct);
}


/* --- Mobile UI Fixes --- */
@media (max-width: 640px) {
  /* 1. Hide individual circuit games to save sticky header space */
  .circuit-games {
    display: none !important;
  }
  .circuit-header {
    margin-bottom: 0 !important;
  }
  .circuit-bar {
    padding: 8px 16px !important;
  }
  
  /* 3. Prevent iOS Safari auto-zoom by enforcing 16px font-size on inputs */
  input[type="text"], 
  input[type="number"],
  .bk-lb-submit-row input,
  .gf-guess-row input,
  .cp-form input,
  .wai-input-row input,
  .ttw-guess-row input,
  .nt-form input {
    font-size: 16px !important;
  }
}
