/* ORBIT — HUD styles (Rae Lindqvist)
 * ============================================================================
 * The interface that floats over the planet. Register: Stripe / Linear / Apple
 * product-surface — dark, restrained, confident hierarchy, real type, nothing
 * decorative. The globe is the hero; this layer frames it and gets out of its
 * way. Two real faces: a desktop layout that spends the width, and a phone
 * layout that fits the thumb. No stock UI kit, no neon-gamer chrome.
 * ============================================================================ */

:root {
  /* --- ink & ground (harmonised with the engine shell) --- */
  --o-ink:        #f3f6ff;   /* primary text, high contrast on dark */
  --o-ink-soft:   #c3ccdf;   /* secondary text */
  --o-ink-dim:    #7b86a1;   /* labels, eyebrows */
  --o-ink-faint:  #525d78;   /* hairlines, disabled */

  --o-accent:     #63e6ff;   /* cyan — the engine's marker colour, our primary accent */
  --o-accent-deep:#2ea6cc;
  --o-gold:       #ffd166;   /* the guess arc colour — reveal / points */
  --o-good:       #7ef0b0;   /* streak / bullseye */

  /* --- glass panels: dark, low-saturation, high blur --- */
  --o-glass:      rgba(9, 13, 22, 0.62);
  --o-glass-hi:   rgba(16, 22, 36, 0.78);
  --o-stroke:     rgba(255, 255, 255, 0.09);
  --o-stroke-hi:  rgba(255, 255, 255, 0.16);
  --o-shadow:     0 18px 50px -18px rgba(0, 0, 0, 0.7);

  /* --- type: a confident system stack set with care; offline-safe, no fetch --- */
  --o-sans: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont,
            "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --o-num:  "SF Pro Display", -apple-system, "Segoe UI", Roboto, sans-serif;

  --o-r:    16px;    /* panel radius */
  --o-r-sm: 11px;
  --o-ease: cubic-bezier(.16, 1, .3, 1);
}

/* ==========================================================================
   LAYER — #hud is fixed full-screen, pointer-events off; children opt in.
   ========================================================================== */
#hud {
  font-family: var(--o-sans);
  color: var(--o-ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#hud button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}
#hud [class^="o-"] { pointer-events: none; }        /* panels transparent to the globe */
/* Re-enable the real interactive controls. Each selector below is id+class
 * (0,1,1,0) so it TIES the base [class^="o-"] rule (also 0,1,1,0); the tie is
 * broken by source order — this rule comes after, so it wins. The controls
 * whose own class begins "o-" (.o-start, .o-explore-link, .o-mode, .o-next,
 * .o-again) must be named directly: re-enabling only their containers left the
 * children pointer-events:none and every click fell through to the canvas. */
#hud button,
#hud .o-start, #hud .o-explore-link, #hud .o-mode,
#hud .o-next, #hud .o-again,
#hud .o-modes, #hud .o-reveal, #hud .o-over,
#hud .o-intro__cta { pointer-events: auto; }         /* controls catch the finger */

/* shared panel look */
.o-panel, .o-scores, .o-prompt, .o-reveal, .o-fact, .o-over, .o-modes {
  background: var(--o-glass);
  border: 1px solid var(--o-stroke);
  border-radius: var(--o-r);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  box-shadow: var(--o-shadow);
}

/* number rendering — tabular so scores don't jitter as they count */
.o-score__value, .o-timer__num, .o-reveal__v, .o-over__score, .o-streak__n {
  font-family: var(--o-num);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   SCORE CLUSTER — the always-on state. High score is the anchor (client's
   hard requirement): it sits first, largest label, always legible.
   Desktop: top-right. Phone: a slim top band.
   ========================================================================== */
.o-scores {
  position: fixed;
  top: 20px; right: 22px;
  display: flex; align-items: stretch; gap: 2px;
  padding: 4px;
  transition: opacity .6s var(--o-ease), transform .6s var(--o-ease);
}
.o-scores[data-dim="true"] { opacity: 0; transform: translateY(-8px); pointer-events: none; }
/* Explore mode has no score to chase — quiet the live score + streak so only
   the persistent High Score reads. Keeps the calm register the brief asks for. */
.o-scores[data-explore="true"] .o-score--live { opacity: 0; }
.o-scores[data-explore="true"] .o-score--live::before { opacity: 0; }
.o-scores[data-explore="true"] .o-streak { opacity: 0 !important; }

.o-score {
  display: flex; flex-direction: column; align-items: flex-end;
  justify-content: center;
  padding: 8px 16px 9px;
  min-width: 92px;
  border-radius: 12px;
  position: relative;
}
.o-score--high { order: 0; }
.o-score--live::before {          /* hairline divider between the two scores */
  content: ""; position: absolute; left: 0; top: 22%; bottom: 22%;
  width: 1px; background: var(--o-stroke);
}
.o-score__label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--o-ink-dim);
  margin-bottom: 3px;
}
.o-score--high .o-score__label { color: var(--o-accent); opacity: 0.85; }
.o-score__value { font-size: 26px; font-weight: 600; line-height: 1; }
.o-score--high .o-score__value { color: var(--o-ink); }
.o-score--live .o-score__value { color: var(--o-ink); }

/* record flourish: the cluster lifts + the high value glows when you pass it */
.o-scores.is-record { border-color: var(--o-accent); }
.o-scores.is-record .o-score--high .o-score__value {
  color: var(--o-accent);
  text-shadow: 0 0 22px rgba(99, 230, 255, 0.55);
}

/* streak chip — appears at 2+, sits under the scores */
.o-streak {
  position: absolute; top: calc(100% + 8px); right: 4px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px 5px 9px; border-radius: 999px;
  background: rgba(126, 240, 176, 0.10);
  border: 1px solid rgba(126, 240, 176, 0.24);
  opacity: 0; transform: translateY(-4px) scale(0.96);
  transition: opacity .35s var(--o-ease), transform .35s var(--o-ease);
}
.o-streak[data-on="true"] { opacity: 1; transform: none; }
.o-streak__flame {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--o-good); box-shadow: 0 0 10px var(--o-good);
}
.o-streak__n { font-size: 13px; font-weight: 700; color: var(--o-good); }
.o-streak__label {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(126, 240, 176, 0.7);
}

/* ==========================================================================
   MODE TOGGLE — Guess (default) / Explore. A quiet segmented control.
   Desktop: bottom-left. Phone: centered bottom bar.
   ========================================================================== */
.o-modes {
  position: fixed;
  left: 22px; bottom: 22px;
  display: inline-flex; gap: 2px; padding: 4px;
  border-radius: 999px;
  transition: opacity .6s var(--o-ease), transform .6s var(--o-ease);
}
.o-modes[data-dim="true"] { opacity: 0; transform: translateY(8px); pointer-events: none; }
.o-mode {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; letter-spacing: 0.01em;
  color: var(--o-ink-dim);
  transition: color .25s var(--o-ease), background .25s var(--o-ease);
}
.o-mode__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--o-ink-faint);
  transition: background .25s var(--o-ease), box-shadow .25s var(--o-ease);
}
.o-mode:hover { color: var(--o-ink-soft); }
.o-mode.is-active {
  color: var(--o-ink);
  background: rgba(255, 255, 255, 0.08);
}
.o-mode.is-active .o-mode__dot {
  background: var(--o-accent); box-shadow: 0 0 10px var(--o-accent);
}

/* ==========================================================================
   PROMPT + TIMER — the round's ask, top-center. Reads instantly as the thing
   to do, distinct from the score. The timer ring tightens visually as it runs.
   ========================================================================== */
.o-prompt {
  position: fixed;
  top: 20px; left: 50%; transform: translateX(-50%) translateY(-14px);
  display: flex; align-items: center; gap: 16px;
  padding: 12px 22px 12px 14px;
  opacity: 0; pointer-events: none;
  transition: opacity .4s var(--o-ease), transform .4s var(--o-ease);
}
.o-prompt[data-show="true"] { opacity: 1; transform: translateX(-50%); }

.o-timer { position: relative; width: 44px; height: 44px; flex: 0 0 auto; }
.o-timer__svg { width: 100%; height: 100%; display: block; }
.o-timer__track { fill: none; stroke: rgba(255,255,255,0.10); stroke-width: 3; }
.o-timer__arc {
  fill: none; stroke: var(--o-accent); stroke-width: 3; stroke-linecap: round;
  transition: stroke-dashoffset .25s linear, stroke .4s var(--o-ease);
}
.o-timer[data-low="true"] .o-timer__arc { stroke: var(--o-gold); }
.o-timer[data-low="true"] { animation: o-pulse 1s ease-in-out infinite; }
@keyframes o-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.o-timer__num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 15px; font-weight: 600; color: var(--o-ink);
}

.o-prompt__body { display: flex; flex-direction: column; line-height: 1.05; }
.o-prompt__kicker {
  font-size: 11px; font-weight: 600; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--o-ink-dim); margin-bottom: 3px;
}
.o-prompt__name {
  font-size: 25px; font-weight: 600; letter-spacing: -0.015em; color: var(--o-ink);
}
.o-prompt__sub {
  font-size: 12.5px; font-weight: 500; color: var(--o-ink-dim);
  margin-top: 3px; text-transform: capitalize;
}

/* ==========================================================================
   REVEAL CARD — the result. Bottom-center, big satisfying numbers. The points
   read as the reward; the distance reads as the honest measure.
   ========================================================================== */
.o-reveal {
  position: fixed;
  left: 50%; bottom: 26px; transform: translateX(-50%) translateY(16px);
  width: min(92vw, 420px);
  padding: 20px 22px 16px;
  opacity: 0; pointer-events: none;
  transition: opacity .4s var(--o-ease), transform .45s var(--o-ease);
}
.o-reveal[data-show="true"] { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.o-reveal__head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.o-reveal__place { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.o-reveal__country { font-size: 13px; font-weight: 500; color: var(--o-ink-dim); }

.o-reveal__stats { display: flex; gap: 10px; margin-bottom: 16px; }
.o-reveal__stat {
  flex: 1; padding: 11px 14px; border-radius: var(--o-r-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--o-stroke);
}
.o-reveal__k {
  display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--o-ink-dim); margin-bottom: 5px;
}
.o-reveal__v { font-size: 21px; font-weight: 600; color: var(--o-ink); }
.o-reveal__stat--pts .o-reveal__v { color: var(--o-gold); }
/* a near-perfect guess / inside the border: celebrate it */
.o-reveal[data-bull="true"] .o-reveal__stat--pts {
  background: rgba(126, 240, 176, 0.10); border-color: rgba(126, 240, 176, 0.28);
}
.o-reveal[data-bull="true"] .o-reveal__stat--pts .o-reveal__v { color: var(--o-good); }

.o-next {
  width: 100%; padding: 13px; border-radius: var(--o-r-sm);
  background: var(--o-ink); color: #0a0e17;
  font-size: 14.5px; font-weight: 600; letter-spacing: 0.01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .2s var(--o-ease), filter .2s var(--o-ease);
}
.o-next:hover { filter: brightness(1.08); transform: translateY(-1px); }
.o-next:active { transform: translateY(0); }
.o-next__key {
  font-size: 11px; font-weight: 600; opacity: 0.5;
  border: 1px solid rgba(0,0,0,0.25); border-radius: 5px;
  padding: 1px 6px; line-height: 1.4;
}

/* ==========================================================================
   EXPLORE FACT CARD — the calm, learn-something register. Different mood from
   the scored HUD: no numbers, generous line-height, quiet. Bottom-center.
   ========================================================================== */
.o-fact {
  position: fixed;
  left: 50%; bottom: 26px; transform: translateX(-50%) translateY(16px);
  width: min(94vw, 460px);
  padding: 22px 24px 20px;
  opacity: 0; pointer-events: none;
  background: var(--o-glass-hi);
  transition: opacity .5s var(--o-ease), transform .5s var(--o-ease);
}
.o-fact[data-show="true"] { opacity: 1; transform: translateX(-50%); }
.o-fact__eyebrow {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--o-accent); opacity: 0.9;
}
.o-fact__place {
  display: block; font-size: 24px; font-weight: 600;
  letter-spacing: -0.015em; margin: 7px 0 11px;
}
.o-fact__text {
  font-size: 15.5px; line-height: 1.55; font-weight: 400; color: var(--o-ink-soft);
  letter-spacing: 0.002em;
}
.o-fact__hint {
  display: block; margin-top: 15px;
  font-size: 11px; letter-spacing: 0.06em; color: var(--o-ink-faint);
}

/* ==========================================================================
   GAME OVER — run summary + play again.
   ========================================================================== */
.o-over {
  position: fixed;
  left: 50%; top: 50%; transform: translate(-50%, -46%);
  width: min(88vw, 340px);
  padding: 32px 28px 26px;
  text-align: center;
  opacity: 0; pointer-events: none;
  background: var(--o-glass-hi);
  transition: opacity .5s var(--o-ease), transform .5s var(--o-ease);
}
.o-over[data-show="true"] { opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; }
.o-over__eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--o-ink-dim);
}
.o-over[data-best="true"] .o-over__eyebrow { color: var(--o-accent); }
.o-over__score {
  display: block; font-size: 62px; font-weight: 700; line-height: 1;
  margin: 12px 0 2px; letter-spacing: -0.02em;
}
.o-over[data-best="true"] .o-over__score {
  color: var(--o-accent); text-shadow: 0 0 34px rgba(99,230,255,0.4);
}
.o-over__label {
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--o-ink-dim);
}
.o-over__best { margin: 16px 0 22px; font-size: 13.5px; color: var(--o-ink-soft); }
.o-again {
  width: 100%; padding: 14px; border-radius: var(--o-r-sm);
  background: var(--o-ink); color: #0a0e17;
  font-size: 15px; font-weight: 600;
  transition: transform .2s var(--o-ease), filter .2s var(--o-ease);
}
.o-again:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ==========================================================================
   INTRO INVITATION — the first-touch moment. The planet must breathe; this
   sits low and quiet so the globe is the hero, inviting the grab, not walling
   it. Fades away entirely once play begins.
   ========================================================================== */
.o-intro {
  position: fixed; inset: 0;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 24px 44px;
  opacity: 0; pointer-events: none;
  transition: opacity .7s var(--o-ease);
}
.o-intro[data-show="true"] { opacity: 1; }
.o-intro__inner {
  max-width: 560px; text-align: center;
  pointer-events: auto;
  animation: o-rise .9s var(--o-ease) both;
  animation-delay: .15s;
}
@keyframes o-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.o-intro__eyebrow {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--o-ink-dim);
}
.o-intro__title {
  font-size: clamp(30px, 5vw, 46px); font-weight: 600; line-height: 1.06;
  letter-spacing: -0.025em; margin: 14px 0 14px; color: var(--o-ink);
}
.o-intro__title em {
  font-style: italic; font-weight: 500; color: var(--o-accent);
}
.o-intro__lede {
  font-size: 15.5px; line-height: 1.55; color: var(--o-ink-soft);
  max-width: 440px; margin: 0 auto 24px;
}
.o-intro__cta { display: inline-flex; align-items: center; gap: 18px; }
.o-start {
  padding: 14px 30px; border-radius: 999px;
  background: var(--o-ink); color: #0a0e17;
  font-size: 15px; font-weight: 600;
  box-shadow: 0 10px 30px -8px rgba(99, 230, 255, 0.35);
  transition: transform .2s var(--o-ease), filter .2s var(--o-ease), box-shadow .3s var(--o-ease);
}
.o-start:hover {
  filter: brightness(1.06); transform: translateY(-2px);
  box-shadow: 0 16px 40px -10px rgba(99, 230, 255, 0.5);
}
.o-start:active { transform: translateY(0); }
.o-explore-link {
  font-size: 14px; font-weight: 500; color: var(--o-ink-dim);
  text-decoration: none; position: relative;
  transition: color .2s var(--o-ease);
}
.o-explore-link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 1px;
  background: currentColor; opacity: 0.3; transform: scaleX(0.7);
  transition: opacity .2s var(--o-ease), transform .2s var(--o-ease);
}
.o-explore-link:hover { color: var(--o-ink-soft); }
.o-explore-link:hover::after { opacity: 0.6; transform: scaleX(1); }

/* ==========================================================================
   HIGH-SCORE BEAT — the small satisfying flourish when you pass your best.
   A band that sweeps across, then leaves.
   ========================================================================== */
.o-beat {
  position: fixed; left: 50%; top: 34%;
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0; pointer-events: none; z-index: 30;
}
.o-beat.is-live { animation: o-beat 1.6s var(--o-ease) both; }
@keyframes o-beat {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  18%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  72%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1.02); }
}
.o-beat__text {
  font-size: 13px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--o-accent);
  padding: 9px 20px; border-radius: 999px;
  background: rgba(9, 13, 22, 0.72);
  border: 1px solid rgba(99, 230, 255, 0.4);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 0 40px -6px rgba(99, 230, 255, 0.5);
}

/* guess-feedback flash — a soft ring pulse at the moment of a click/guess */
.o-guessflash {
  position: fixed; inset: 0; pointer-events: none; z-index: 25;
  background: radial-gradient(circle at 50% 55%,
              rgba(99, 230, 255, 0.10) 0%, rgba(99, 230, 255, 0) 42%);
  opacity: 0;
}
.o-guessflash.is-live { animation: o-flash .5s ease-out both; }
@keyframes o-flash { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }

/* entrance micro-animation applied when a panel first appears */
.o-reveal.is-in, .o-fact.is-in, .o-over.is-in, .o-prompt.is-in {
  animation: o-panel-in .5s var(--o-ease) both;
}
@keyframes o-panel-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ==========================================================================
   PHONE FACE — a real touch layout, not a squeezed desktop. The globe fills
   the screen; the HUD sits in reachable bands. Score reads as a slim top strip;
   the mode toggle is a thumb-height bottom bar; cards are full-width sheets.
   ========================================================================== */
@media (max-width: 640px) {
  .o-scores {
    top: 12px; right: 12px; left: 12px;
    justify-content: flex-end; gap: 0;
    padding: 3px;
  }
  .o-score { padding: 7px 13px 8px; min-width: 78px; }
  .o-score__value { font-size: 22px; }
  .o-score__label { font-size: 9px; }
  .o-streak { top: calc(100% + 7px); }

  /* prompt: keep it top-center but a touch smaller, below the score strip */
  .o-prompt {
    top: 66px; padding: 10px 18px 10px 12px; gap: 13px;
    width: min(92vw, 380px);
  }
  .o-prompt[data-show="true"] { transform: translateX(-50%); }
  .o-timer { width: 40px; height: 40px; }
  .o-prompt__name { font-size: 21px; }

  /* mode toggle: centered bottom bar, thumb-reachable */
  .o-modes {
    left: 50%; bottom: 18px; transform: translateX(-50%);
    padding: 4px;
  }
  .o-modes[data-dim="true"] { transform: translateX(-50%) translateY(8px); }
  .o-mode { padding: 11px 22px; font-size: 14px; }

  /* cards become full-width bottom sheets, clear of the mode bar */
  .o-reveal, .o-fact {
    left: 12px; right: 12px; width: auto; transform: translateY(16px);
    bottom: 82px;
  }
  .o-reveal[data-show="true"], .o-fact[data-show="true"] { transform: none; }
  .o-reveal__place { font-size: 20px; }
  .o-fact__text { font-size: 15px; }

  .o-over { width: min(90vw, 330px); padding: 28px 24px 24px; }
  .o-over__score { font-size: 54px; }

  .o-intro { padding: 0 20px 30px; align-items: flex-end; }
  .o-intro__title { font-size: clamp(28px, 8vw, 38px); }
  .o-intro__lede { font-size: 14.5px; }
  .o-intro__cta { flex-direction: column; gap: 14px; }
  .o-start { width: 100%; max-width: 320px; padding: 15px 30px; }
}

/* very short landscape phones: pull the intro up so the CTA never clips */
@media (max-height: 520px) {
  .o-intro { align-items: center; padding-bottom: 0; }
  .o-intro__lede { margin-bottom: 18px; }
}

/* respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .o-scores, .o-modes, .o-prompt, .o-reveal, .o-fact, .o-over, .o-intro,
  .o-intro__inner, .o-beat, .o-timer[data-low="true"] {
    animation: none !important;
    transition-duration: .12s !important;
  }
}
