:root {
  --bg: #0a0e17;
  --panel: #121826;
  --panel-border: #232c40;
  --accent: #4fd1c5;
  --accent-2: #f6ad55;
  --text: #e6ebf5;
  --text-dim: #8a96ab;
  --danger: #f56565;
  --good: #48bb78;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

/* body is a flex column of [topbar, main-content] so #game/#not-ready/#results-screen can fill
   whatever space remains via flex: 1 instead of a hardcoded calc(100% - 54px) — the old fixed
   54px assumed the topbar always stays exactly one line tall, which breaks the instant the
   topbar wraps onto multiple lines (e.g. daily mode's extra HUD pills on a narrow viewport). See
   SKILL.md's mobile-layout fix note for the bug this replaced. */
body {
  display: flex;
  flex-direction: column;
}

#topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  row-gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

#brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

#hud {
  display: flex;
  flex-wrap: wrap;
  row-gap: 0.4rem;
  gap: 1.25rem;
  font-size: 0.95rem;
  color: var(--text-dim);
}

#hud span {
  background: rgba(255, 255, 255, 0.04);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
}

#game-label {
  color: var(--accent-2);
  font-weight: 600;
}

#score-indicator {
  color: var(--accent-2);
  font-weight: 600;
}

/* #mode-menu: a single dropdown ("Modes ▾") replacing the earlier inline-links pattern
   (#mode-link/.mode-nav-link) once a 4th mode made 3-4 inline topbar links a real mobile-layout
   problem (wrapping to multiple rows even with the flex-wrap fix). Built on native <details>/
   <summary> — no JS needed for open/close, keyboard-accessible (Enter/Space toggles it, same as
   any other button) for free. See nav.js for how each page's link list is populated. */
/* margin-left: auto keeps #mode-menu pinned to the topbar's right edge even when #topbar wraps
   onto multiple rows on mobile (flex-wrap causes #mode-menu to otherwise fall to the start of
   whichever row it wraps onto, at the far LEFT — which broke #mode-menu-list's right:0 anchoring
   below, since "flush with #mode-menu's right edge" then meant "flush with the left side of the
   screen," pushing the list off-screen. Found via a real mobile screenshot, reproduced with
   Playwright: #mode-menu-list.x was -108px, entirely outside the 390px viewport.) */
#mode-menu {
  position: relative;
  margin-left: auto;
}

#mode-menu summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

#mode-menu summary::-webkit-details-marker {
  display: none;
}

#mode-menu summary:hover,
#mode-menu summary:focus-visible,
#mode-menu[open] summary {
  color: var(--accent);
  border-color: var(--accent);
}

#mode-menu-list {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  max-width: calc(100vw - 2rem);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 0.4rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

#mode-menu-list a {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}

#mode-menu-list a:hover,
#mode-menu-list a:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent);
}

#not-ready {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

#not-ready.hidden {
  display: none;
}

#not-ready h1 {
  color: var(--accent);
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
}

#not-ready p {
  color: var(--text-dim);
  margin: 0;
  max-width: 32rem;
}

#game {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* #prompt-panel used to be a full-width banner above the globe holding the logo tile + instruction
   text; removed per explicit user direction so the globe gets that vertical space back. It's now
   a floating overlay pinned to the top-left of #globe-wrap (same positioning technique as
   #result-banner, which already floats over the globe) — see #globe-wrap/#result-banner below.
   The per-question instruction caption that used to live here was removed once the one-time
   onboarding dialog (#onboarding-dialog, see onboarding.js) took over teaching the mechanics —
   #prompt-panel now wraps just the logo tile. */
#prompt-panel {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 10;
}

#logo-wrap {
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  padding: 0.35rem;
  margin: 0;
  border-radius: 12px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid var(--panel-border);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  transition: transform 0.1s ease, border-color 0.15s ease;
}

#logo-wrap:hover,
#logo-wrap:focus-visible {
  border-color: var(--accent);
  transform: translateY(-1px);
}

#logo-wrap:active {
  transform: translateY(0);
}

#team-logo {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

#logo-dialog {
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: #fff;
  padding: 1.5rem;
  width: min(90vw, 640px);
  max-width: 90vw;
  max-height: 85vh;
}

#logo-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

#logo-dialog-img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: calc(85vh - 3rem);
  object-fit: contain;
}

/* #help-btn: small persistent "?" button in the topbar that reopens #onboarding-dialog on demand.
   Sits next to #mode-menu (not inside #brand/#hud) so it stays visible and reachable regardless of
   how many HUD pills a given mode has. */
#help-btn {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 700;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
  box-shadow: none;
  flex-shrink: 0;
}

#help-btn:hover,
#help-btn:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  transform: none;
}

#onboarding-dialog {
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  padding: 1.75rem;
  width: min(90vw, 460px);
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
}

#onboarding-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

#onboarding-dialog h2 {
  color: var(--accent);
  margin: 0 0 1rem;
  font-size: 1.3rem;
}

#onboarding-dialog ol {
  margin: 0 0 1.25rem;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#onboarding-dialog li {
  line-height: 1.4;
}

#onboarding-dialog li strong {
  color: var(--text);
}

.onboarding-dont-show-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.onboarding-dont-show-row input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.onboarding-dont-show-row label {
  cursor: pointer;
}

#onboarding-close-btn {
  width: 100%;
}

#globe-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

#globeViz {
  position: absolute;
  inset: 0;
}

#result-banner {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 24, 38, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 0.9rem 1.5rem;
  text-align: center;
  backdrop-filter: blur(6px);
  min-width: 240px;
}

#result-banner.hidden {
  display: none;
}

#result-team {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

#result-distance {
  color: var(--text-dim);
  font-size: 0.9rem;
}

#result-points {
  color: var(--accent-2);
  font-weight: 700;
  font-size: 1.1rem;
  margin-top: 0.25rem;
}

/* #action-bar used to be a full-width banner below the globe holding Submit/Next; removed per
   explicit user direction so the globe gets that vertical space back. Now floats directly over
   the bottom of #globe-wrap with no background bar — the buttons themselves already have a solid
   fill + shadow, so they stay legible over any terrain without a bar behind them. */
#action-bar {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.7rem 1.8rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: #06201c;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  transition: transform 0.1s ease, opacity 0.15s ease, background 0.15s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#next-btn {
  background: var(--accent-2);
}

#next-btn.hidden,
#submit-btn.hidden {
  display: none;
}

#results-screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2.5rem 1.5rem;
  overflow-y: auto;
}

#results-screen.hidden {
  display: none;
}

#play-again-btn.hidden {
  display: none;
}

#streak-indicator {
  color: var(--accent-2);
}

#streak-indicator.hidden {
  display: none;
}

#share-btn {
  background: var(--accent-2);
  margin-bottom: 0.75rem;
}

#share-btn.hidden {
  display: none;
}

#share-feedback {
  display: block;
  color: var(--good);
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: -0.5rem;
  margin-bottom: 0.75rem;
}

#share-feedback.hidden {
  display: none;
}

#results-screen h1 {
  color: var(--accent);
  margin: 0 0 0.5rem;
}

#final-score {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-2);
  margin-bottom: 1.75rem;
}

#breakdown {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 2rem;
}

.breakdown-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.6rem 1rem;
}

.breakdown-row img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  flex-shrink: 0;
}

.breakdown-info {
  flex: 1;
  min-width: 0;
}

.breakdown-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breakdown-meta {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.breakdown-points {
  font-weight: 700;
  color: var(--accent-2);
  white-space: nowrap;
}

@media (max-width: 640px) {
  #hud {
    gap: 0.5rem;
    font-size: 0.8rem;
  }

  #hud span {
    padding: 0.25rem 0.5rem;
  }

  #brand {
    font-size: 1rem;
  }

  #mode-menu summary {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
  }

  #prompt-panel {
    top: 0.6rem;
    left: 0.6rem;
  }

  #logo-wrap {
    width: 64px;
    height: 64px;
    padding: 0.25rem;
  }

  button {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }

  #result-banner {
    min-width: 200px;
    padding: 0.7rem 1rem;
  }
}
