/* ===== Ambient backdrop ===== */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 50% at 20% 10%, color-mix(in oklab, var(--accent) 14%, transparent), transparent 70%),
    radial-gradient(50% 50% at 85% 90%, color-mix(in oklab, var(--gold) 12%, transparent), transparent 70%);
  filter: blur(20px);
  opacity: 0.8;
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1.05); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.12); }
}

/* ===== Top bar ===== */
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) clamp(var(--space-4), 4vw, var(--space-10));
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: var(--space-3); }
.logo { width: 38px; height: 38px; color: var(--color-text); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
}
.brand-sub { font-size: var(--text-xs); color: var(--color-text-muted); }

.controls { display: flex; align-items: center; gap: var(--space-3); }

.seg {
  display: inline-flex;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px;
}
.seg-btn {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.seg-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #04140c;
  font-weight: 700;
  box-shadow: var(--glow);
}
.seg-btn:not([aria-pressed="true"]):hover { color: var(--color-text); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Layout ===== */
.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-4);
  height: calc(100dvh - 84px);
  padding: 0 clamp(var(--space-4), 4vw, var(--space-10)) var(--space-6);
}

/* ===== Globe stage ===== */
/* The globe is an immersive space scene — keep the stage dark in both themes
   so the 3D sphere and hero text stay legible. */
.stage {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: radial-gradient(120% 120% at 50% 0%, #0d1a15, #07100d 70%);
  border: 1px solid var(--color-border);
  color-scheme: dark;
}
.stage .next-label { color: #8fae9f; }
.stage .next-city { color: #e7f3ec; }
.stage .hint { color: #5a7568; }
#globe { width: 100%; height: 100%; cursor: grab; }
#globe:active { cursor: grabbing; }

.next-hero {
  position: absolute;
  left: 50%;
  bottom: var(--space-8);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}
.next-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-text-muted);
}
.next-city {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-xl);
  margin-top: var(--space-1);
}
.next-count {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-2xl);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.next-when {
  font-size: var(--text-sm);
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.hint {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  pointer-events: none;
}
.recenter {
  position: absolute;
  right: var(--space-4);
  bottom: var(--space-4);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #b9d6c6;
  background: rgba(13, 26, 21, 0.72);
  border: 1px solid #1f3b30;
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.recenter:hover { color: var(--accent); border-color: var(--accent); }

/* ===== Live layer: blaze button + shared counter chip ===== */
.blaze-btn {
  pointer-events: auto;
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 700;
  color: #8fae9f;
  background: rgba(13, 26, 21, 0.72);
  border: 1px solid #1f3b30;
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: default;
}
.blaze-btn.ready {
  cursor: pointer;
  color: #04140c;
  background: linear-gradient(100deg, var(--gold), #ff9f43);
  border-color: transparent;
  box-shadow: 0 0 28px rgba(255, 200, 96, 0.5);
  animation: blazePulse 1.4s ease-in-out infinite;
}
.blaze-btn.ready:hover { transform: translateY(-1px) scale(1.03); }
.blaze-btn.done {
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 55%, transparent);
}
@keyframes blazePulse {
  0%, 100% { box-shadow: 0 0 18px rgba(255, 200, 96, 0.4); }
  50% { box-shadow: 0 0 36px rgba(255, 200, 96, 0.75); }
}
.live-chip {
  position: absolute;
  left: var(--space-4);
  bottom: var(--space-4);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #b9d6c6;
  background: rgba(13, 26, 21, 0.72);
  border: 1px solid #1f3b30;
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  max-width: min(360px, calc(50% - 2rem));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.secret-on .blaze-btn,
body.secret-on .live-chip { display: none; }
.live-chip { pointer-events: auto; cursor: pointer; }
.live-chip:hover { border-color: var(--gold); color: #ffe6b3; }

/* ===== Blaze board (daily leaderboard) ===== */
.board-modal {
  width: min(480px, 92vw);
  max-height: min(80dvh, 620px);
  padding: var(--space-6);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
}
.board-modal::backdrop {
  background: rgba(4, 10, 8, 0.6);
  backdrop-filter: blur(6px);
}
.board-sub {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}
.board-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.board-row {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3) calc(var(--space-2) + 5px);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.board-row.mine {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 12%, var(--color-surface-2));
}
.board-rank { font-size: var(--text-base); text-align: center; }
.board-row:nth-child(n + 4) .board-rank {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-faint);
}
.board-name {
  font-size: var(--text-sm);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-count {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.board-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  border-radius: 0 2px 2px 0;
  opacity: 0.85;
}
.board-gap {
  list-style: none;
  text-align: center;
  color: var(--color-text-faint);
  line-height: 1;
}
.board-empty {
  padding: var(--space-6) var(--space-2);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.board-foot {
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: center;
}

/* ===== Side panel ===== */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}
.panel-head {
  padding: var(--space-5) var(--space-5) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}
.panel-head h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
}
.panel-sub { font-size: var(--text-xs); color: var(--color-text-muted); display: block; }
.search {
  margin-top: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.search::placeholder { color: var(--color-text-faint); }
.search:focus-visible { border-color: var(--accent); outline: none; }
.no-results {
  padding: var(--space-6);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.city-list {
  overflow-y: auto;
  flex: 1;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
}
.city-row[hidden] { display: none !important; }
.city-row {
  display: grid;
  grid-template-columns: 22px 1fr auto 28px;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.city-row:hover { background: var(--color-surface-2); }
.city-row.active {
  background: color-mix(in oklab, var(--accent) 14%, transparent);
}
.city-row.blazing {
  background: color-mix(in oklab, var(--gold) 22%, transparent);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  50% { background: color-mix(in oklab, var(--gold) 38%, transparent); }
}
.rank {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.city-meta { min-width: 0; }
.city-name {
  font-weight: 700;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.city-info {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.city-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cc-time {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--accent);
}
.cc-when {
  font-size: 0.7rem;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.blazing .cc-time, .blazing .cc-when { color: var(--gold); }
.blazing .cc-when::after { content: " · blaze it"; }

/* Bell toggle: arm an audible alert for this zone's 4:20 */
.bell {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  color: var(--color-text-faint);
  opacity: 0.45;
}
.city-row:hover .bell,
.bell:focus-visible { opacity: 1; }
.bell:hover { color: var(--color-text); background: var(--color-surface); }
.bell.on {
  opacity: 1;
  color: var(--gold);
}
.bell.on svg { filter: drop-shadow(0 0 5px color-mix(in oklab, var(--gold) 70%, transparent)); }
body.secret-on .bell { visibility: hidden; }

/* Alerts status chip under the search box */
.alerts-chip {
  margin-top: var(--space-2);
  display: flex;
  align-items: stretch;
  gap: var(--space-1);
}
.alerts-chip button {
  font-size: var(--text-xs);
  color: var(--gold);
  background: color-mix(in oklab, var(--gold) 12%, transparent);
  border: 1px solid color-mix(in oklab, var(--gold) 35%, transparent);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
}
.alerts-chip button:hover { border-color: var(--gold); }
.alerts-chip #alertsChip { flex: 1; text-align: left; }
.alerts-chip #alertsClear { flex: 0 0 auto; }

/* ===== Responsive ===== */
@media (max-width: 880px) {
  body { overflow: auto; }
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .stage { height: 56vh; min-height: 360px; }
  .panel { max-height: 60vh; }
  .city-list { max-height: 48vh; }
}
@media (max-width: 520px) {
  .brand-sub { display: none; }
  .seg-btn { padding: var(--space-2) var(--space-3); }
}

/* ---------------- Secret easter-egg mode ---------------- */
body.secret-on .next-count {
  background: linear-gradient(90deg, var(--gold), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: secretPulse 1.6s ease-in-out infinite;
}
body.secret-on .stage {
  box-shadow: inset 0 0 120px rgba(255, 200, 96, 0.18);
}
@keyframes secretPulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 200, 96, 0.35)); }
  50% { filter: drop-shadow(0 0 18px rgba(255, 200, 96, 0.7)); }
}

/* ===== Pill button (Trivia) ===== */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.pill-btn:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 700;
  color: #04140c;
  background: var(--accent);
  border-radius: var(--radius-full);
  box-shadow: var(--glow);
}
.btn-primary:hover { transform: translateY(-1px); }

/* ===== Fact card (appears while a city blazes) ===== */
.fact-card {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  max-width: min(340px, calc(100% - 2rem));
  padding: var(--space-3) var(--space-4);
  background: color-mix(in oklab, #0d1a15 82%, transparent);
  border: 1px solid color-mix(in oklab, var(--gold) 45%, transparent);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  animation: factIn 420ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes factIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fact-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.fact-where {
  flex: 1;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
}
.fact-close {
  font-size: var(--text-xs);
  color: #8fae9f;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.fact-close:hover { color: #e7f3ec; }
.fact-text {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: #e7f3ec;
}

/* ===== Alert toast (top of the globe stage) ===== */
.alert-toast {
  position: absolute;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: min(420px, calc(100% - 2rem));
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 700;
  color: #ffe6b3;
  background: color-mix(in oklab, #0d1a15 85%, transparent);
  border: 1px solid var(--gold);
  border-radius: var(--radius-full);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 24px rgba(255, 200, 96, 0.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: toastIn 420ms cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 3;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.alert-toast button {
  color: #8fae9f;
  font-size: var(--text-xs);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.alert-toast button:hover { color: #e7f3ec; }
/* If a toast and a fact card show at once, stack instead of colliding. */
.stage:has(.alert-toast:not([hidden])) .fact-card { top: calc(var(--space-4) + 48px); }

/* ===== Did-you-know ticker ===== */
.ticker {
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.ticker-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
  white-space: nowrap;
}
.ticker-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.45;
  transition: opacity 400ms ease;
}
.ticker-text.ticker-fade { opacity: 0; }
.ticker-privacy {
  margin-left: auto;
  align-self: center;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-faint);
  text-decoration: none;
  white-space: nowrap;
}
.ticker-privacy:hover { color: var(--color-text-muted); }

/* ===== Quiz modal ===== */
.quiz-modal {
  width: min(540px, 92vw);
  max-height: min(80dvh, 640px);
  padding: var(--space-6);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
}
.quiz-modal::backdrop {
  background: rgba(4, 10, 8, 0.6);
  backdrop-filter: blur(6px);
}
.quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.quiz-head h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
}
.quiz-meta {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
.quiz-q {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--space-4);
}
.quiz-opts {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.quiz-opt {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.quiz-opt:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateX(2px);
}
.quiz-opt:disabled { cursor: default; opacity: 0.75; }
.quiz-opt.correct {
  opacity: 1;
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 18%, transparent);
  font-weight: 700;
}
.quiz-opt.wrong {
  opacity: 1;
  border-color: #e5484d;
  background: color-mix(in oklab, #e5484d 14%, transparent);
}
.quiz-explain {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-left: 3px solid #e5484d;
  border-radius: var(--radius-sm);
}
.quiz-explain.is-right { border-left-color: var(--accent); }
.quiz-next { margin-top: var(--space-4); }

.quiz-results { text-align: center; padding: var(--space-6) 0 var(--space-2); }
.quiz-results-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-text-muted);
}
.quiz-score {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-2xl);
  color: var(--accent);
  line-height: 1.1;
}
.quiz-title-line {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--gold);
  margin-bottom: var(--space-5);
}
.quiz-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

@media (max-width: 520px) {
  .pill-btn span { display: none; }
  .recenter span { display: none; }
  .fact-card { max-width: calc(100% - 2rem); }
  .quiz-modal { padding: var(--space-4); }
}
