/* Manrope, SIL Open Font License: assets/fonts/OFL.txt. Bundled so the game works offline. */
@font-face {
  font-family: "Manrope";
  src: url("../assets/fonts/manrope-latin-wght.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #0b1220;
  --panel: #0f1829;
  --raise: #16223a;
  --ink: #e9eef6;
  --muted: #8d9bb1;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #f5c542;
  --accent-ink: #1a1405;
  --good: #5ad17a;
  --bad: #ff6b5a;
  --radius: 14px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* The screens size themselves to this; without a height the title screen can't scroll. */
#app {
  height: 100%;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

/* ---- Buttons ------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 46px;
  padding: 10px 20px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--raise);
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.28);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible,
.mode-pill:focus-visible,
.level:focus-visible,
.site-head a:focus-visible,
.hud-btn:focus-visible,
.seed-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.btn.primary:hover:not(:disabled) {
  background: #ffd45e;
}

.btn:disabled,
.btn.primary:disabled {
  background: var(--raise);
  color: var(--muted);
  border-color: var(--line);
  cursor: default;
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  min-height: 38px;
  padding: 6px 14px;
}

.btn-sub {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.75;
}

/* ---- Title --------------------------------------------------------------------------- */

.screen.title {
  position: relative;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

.title-bg {
  position: fixed;
  inset: -10%;
  display: grid;
  place-items: center;
  opacity: 0.16;
  pointer-events: none;
  mask-image: radial-gradient(closest-side, #000 45%, transparent);
  -webkit-mask-image: radial-gradient(closest-side, #000 45%, transparent);
}

.title-bg canvas {
  width: max(110vw, 110vh);
  height: max(110vw, 110vh);
  transform: rotate(-8deg);
}

.site-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 24px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.logo {
  display: block;
  width: 72px;
  height: auto;
}

.wordmark {
  color: #f3efe4;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  transform: translateY(-2px);
}

.site-head nav {
  display: flex;
  gap: 32px;
}

.site-head nav a {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.site-head nav a:first-child,
.site-head nav a:hover {
  color: var(--ink);
}

.title-inner {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 56px;
}

.title-inner > section {
  width: 100%;
  scroll-margin-top: 24px;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 36px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 56px);
  text-wrap: balance;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.lede {
  margin: 14px 0 0;
  max-width: 640px;
  color: #b8c3d3;
  font-size: clamp(15px, 2vw, 18px);
}

.hero-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 32px;
}

.btn.big {
  min-width: 240px;
  min-height: 56px;
  border-radius: 14px;
  font-size: 17px;
}

.btn.outline {
  background: rgba(15, 24, 41, 0.6);
  border: 1.5px solid rgba(160, 180, 210, 0.35);
}

.btn.outline:hover:not(:disabled) {
  border-color: rgba(200, 215, 235, 0.65);
}

.hero-figure {
  position: relative;
  width: 100%;
  max-width: 970px;
  aspect-ratio: 970 / 310;
  margin: 44px 0 0;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(160, 185, 220, 0.28);
  background: #101a2a;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.hero-map-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.hero-map-svg path {
  vector-effect: non-scaling-stroke;
}

.hero-grid path {
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 1;
}

.hero-map-svg .minor {
  stroke: rgba(232, 238, 245, 0.5);
  stroke-width: 1;
}

.hero-map-svg .index {
  stroke: rgba(232, 238, 245, 0.95);
  stroke-width: 2.2;
}

.hero-map-svg .water {
  fill: rgb(30, 62, 98);
  stroke: #7fb4e6;
  stroke-width: 1.4;
}

.hero-pin-drop path {
  fill: #c8ef9b;
}

.hero-pin-drop circle {
  fill: #101a2a;
}

.hero-ripple {
  fill: none;
  stroke: #c8ef9b;
  stroke-width: 2;
  opacity: 0;
}

.hero-view-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  clip-path: polygon(0 0, 57% 0, 45% 100%, 0 100%);
}

.hero-view {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The diagonal seam between the view and the map, along the edge of the view's clip-path. */
.hero-seam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hero-seam line {
  stroke: rgba(235, 242, 250, 0.9);
  stroke-width: 1.5;
}

.viewfinder {
  position: absolute;
  left: 21%;
  top: 34%;
  width: 7.5%;
  aspect-ratio: 64 / 52;
  color: rgba(255, 255, 255, 0.9);
  pointer-events: none;
}

.viewfinder svg {
  width: 100%;
  height: 100%;
}

.steps ol {
  list-style: none;
  max-width: 1020px;
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

.step {
  position: relative;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step + .step::before {
  content: "";
  position: absolute;
  left: -27px;
  top: 26px;
  width: 22px;
  height: 1px;
  background: rgba(160, 180, 210, 0.35);
}

.step-icon {
  flex: none;
  width: 50px;
  height: 50px;
  color: var(--accent);
}

.step-icon svg {
  width: 100%;
  height: 100%;
}

.step h3 {
  margin: 2px 0 6px;
  font-size: 19px;
  font-weight: 750;
}

.step p {
  margin: 0;
  color: #a8b4c6;
  font-size: 14.5px;
}

.section-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  flex-wrap: wrap;
}

.section-rule > span:first-child {
  display: flex;
  align-items: center;
  gap: 16px;
}

.section-rule > span:first-child::before,
.section-rule > span:first-child::after {
  content: "";
  width: 72px;
  height: 1px;
  background: rgba(160, 180, 210, 0.3);
}

.rule-note {
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--accent);
  font-weight: 700;
}

/* ---- Motion --------------------------------------------------------------------------- */
/* Everything that moves lives here, and only for people who haven't asked for less motion. */

:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Snappy presses everywhere, kept even with reduced motion: they are feedback, not decoration. */
.btn,
.mode-pill,
.level {
  transition: transform 0.09s ease-out, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:active:not(:disabled),
.mode-pill:active,
.level:active:not(:disabled) {
  transform: translateY(2px) scale(0.98);
}

@media (prefers-reduced-motion: no-preference) {
  .btn:hover:not(:disabled),
  .mode-pill:hover,
  .level:hover:not(:disabled) {
    transform: translateY(-2px);
  }

  .btn.primary:hover:not(:disabled) {
    box-shadow: 0 10px 28px rgba(245, 197, 66, 0.28);
  }

  /* Arrival: the page rises into place. */
  .site-head {
    animation: fade-down 0.6s var(--ease-out) both;
  }

  .hero h1 {
    animation: rise 0.7s var(--ease-out) both;
  }

  .lede {
    animation: rise 0.7s var(--ease-out) 0.08s both;
  }

  .hero-actions {
    animation: rise 0.7s var(--ease-out) 0.16s both;
  }

  .hero-figure {
    animation: rise-in 0.9s var(--ease-out) 0.24s both;
  }

  /* The map draws itself from low ground up, then the pin drops onto the summit. */
  .hero-map-svg .minor,
  .hero-map-svg .index {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: draw 1.1s var(--ease-out) calc(0.6s + var(--d)) forwards;
  }

  .hero-map-svg .water {
    animation: fade-in 1s ease-out 0.6s both;
  }

  .hero-pin-drop {
    animation: pin-drop 0.75s var(--ease-out) 2.2s both;
  }

  .hero-ripple {
    transform-box: fill-box;
    transform-origin: center;
    animation: ripple 2.8s ease-out 2.75s infinite;
  }

  /* The camera locks on as the pin lands; both are timed from the map's arrival. */
  .hero-figure:not(.map-ready) .viewfinder {
    opacity: 0;
  }

  .map-ready .viewfinder {
    animation: lock-on 0.55s var(--ease-spring) 2.55s both;
  }

  /* The scene never quite stands still. */
  .hero-view {
    animation: drift 28s ease-in-out infinite alternate;
  }

  .title-bg canvas {
    animation: contour-drift 70s ease-in-out infinite alternate;
  }

  /* The main button catches the light now and then. */
  .btn.big {
    position: relative;
    overflow: hidden;
  }

  .btn.primary.big::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.5) 50%, transparent 65%);
    transform: translateX(-120%);
    animation: shine 5.5s ease-in-out 3.4s infinite;
    pointer-events: none;
  }

  /* Sections slide in as they scroll into view; their contents follow one by one. */
  .reveal:not(.in) {
    opacity: 0;
    transform: translateY(22px);
  }

  .reveal {
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
  }

  .steps.in .step {
    animation: rise 0.6s var(--ease-out) calc(var(--i) * 0.09s) both;
  }

  .trail-section.in .level {
    animation: pop 0.45s var(--ease-spring) calc(0.1s + var(--i) * 0.02s) both;
  }

  .trail-section.in .level.current {
    animation: pop 0.45s var(--ease-spring) calc(0.1s + var(--i) * 0.02s) both, beckon 2.4s ease-in-out 1.2s infinite;
  }

  .mode-pill.selected {
    animation: pop 0.35s var(--ease-spring);
  }

  .mode-chips li {
    animation: rise 0.35s var(--ease-out) calc(var(--i) * 0.03s) both;
  }

  @keyframes fade-down {
    from {
      opacity: 0;
      transform: translateY(-12px);
    }
  }

  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(18px);
    }
  }

  @keyframes rise-in {
    from {
      opacity: 0;
      transform: translateY(30px) scale(0.97);
    }
  }

  @keyframes fade-in {
    from {
      opacity: 0;
    }
  }

  @keyframes draw {
    to {
      stroke-dashoffset: 0;
    }
  }

  @keyframes pin-drop {
    0% {
      opacity: 0;
      transform: translateY(-90px);
    }
    55% {
      opacity: 1;
      transform: translateY(0);
    }
    72% {
      transform: translateY(-14px);
    }
    86% {
      transform: translateY(0);
    }
    93% {
      transform: translateY(-4px);
    }
    100% {
      transform: translateY(0);
    }
  }

  @keyframes ripple {
    0% {
      opacity: 0.85;
      transform: scale(0.6);
    }
    100% {
      opacity: 0;
      transform: scale(4.2);
    }
  }

  @keyframes lock-on {
    from {
      opacity: 0;
      transform: scale(1.45);
    }
  }

  @keyframes drift {
    from {
      transform: scale(1.02) translate(0, 0);
    }
    to {
      transform: scale(1.1) translate(-2%, -1.5%);
    }
  }

  @keyframes contour-drift {
    from {
      transform: rotate(-8deg) translate(0, 0);
    }
    to {
      transform: rotate(-5deg) translate(-3%, -2%);
    }
  }

  @keyframes shine {
    0%,
    70% {
      transform: translateX(-120%);
    }
    100% {
      transform: translateX(120%);
    }
  }

  @keyframes pop {
    0% {
      opacity: 0;
      transform: scale(0.7);
    }
    100% {
      opacity: 1;
      transform: scale(1);
    }
  }

  @keyframes beckon {
    0%,
    100% {
      box-shadow: 0 0 0 3px rgba(245, 197, 66, 0.15);
    }
    50% {
      box-shadow: 0 0 0 7px rgba(245, 197, 66, 0.05), 0 0 18px rgba(245, 197, 66, 0.25);
    }
  }
}

/* ---- Trail ---------------------------------------------------------------------------- */

.trail {
  padding: 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(15, 24, 41, 0.78);
  backdrop-filter: blur(6px);
}

.trail-chapters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 22px;
}

.chapter-name {
  margin: 0 0 6px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
}

.chapter-levels {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.level {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 52px;
  padding: 4px 0;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--raise);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.level:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.3);
}

.level.current {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 197, 66, 0.15);
}

.level:disabled {
  background: transparent;
  color: rgba(141, 155, 177, 0.55);
  cursor: default;
}

.level-stars {
  font-size: 10.5px;
  line-height: 1.2;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.level:disabled .level-stars {
  color: inherit;
}

/* ---- Open play ------------------------------------------------------------------------ */

.modes {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mode-pills {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.mode-pill {
  min-width: 118px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 13px;
  border: 1.5px solid rgba(160, 180, 210, 0.25);
  background: rgba(15, 24, 41, 0.78);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mode-pill:hover {
  border-color: rgba(200, 215, 235, 0.5);
}

.mode-pill.selected {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 197, 66, 0.14);
}

.mode-detail {
  width: min(640px, 100%);
  margin-top: 20px;
  padding: 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(15, 24, 41, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.mode-tag {
  margin: 0;
  color: #c6d0de;
}

.mode-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.mode-chips li {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 99px;
  background: rgba(90, 209, 122, 0.12);
  color: #a9e8b9;
}

.mode-chips li.hard {
  background: rgba(255, 107, 90, 0.12);
  color: #ffb3a8;
}

.mode-best {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mode-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.free-go {
  min-width: 240px;
}

.seed-form {
  display: flex;
  gap: 8px;
  width: min(440px, 100%);
}

.seed-input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.8);
  color: var(--ink);
  font: inherit;
}

.about {
  max-width: 640px;
  text-align: center;
  color: #c6d0de;
}

.about p {
  margin: 0 0 8px;
}

/* ---- Your progress, and the achievement pop-up --------------------------------------- */

.progress-tiles {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.progress-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(15, 24, 41, 0.78);
  text-align: center;
}

.progress-tile strong {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.progress-tile span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}

.badges {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(15, 24, 41, 0.6);
  text-align: center;
}

.badge-icon {
  font-size: 30px;
  line-height: 1.1;
  filter: grayscale(1);
  opacity: 0.35;
}

.badge strong {
  font-size: 13.5px;
  color: var(--muted);
}

.badge-how {
  font-size: 11.5px;
  line-height: 1.3;
  color: rgba(141, 155, 177, 0.75);
}

.badge.earned {
  border-color: rgba(200, 239, 155, 0.45);
  background: rgba(200, 239, 155, 0.07);
}

.badge.earned .badge-icon {
  filter: none;
  opacity: 1;
}

.badge.earned strong {
  color: var(--ink);
}

.achievement-stack {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  z-index: 40;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.achievement-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(200, 239, 155, 0.5);
  background: rgba(15, 24, 41, 0.96);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 0 0 4px rgba(200, 239, 155, 0.08);
  pointer-events: auto;
  cursor: pointer;
}

.achievement-toast.leaving {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.achievement-icon {
  font-size: 28px;
}

.achievement-text {
  display: flex;
  flex-direction: column;
}

.achievement-eyebrow {
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c8ef9b;
}

.achievement-text strong {
  font-size: 16px;
}

@media (max-width: 860px) {
  .progress-tiles {
    grid-template-columns: repeat(3, 1fr);
  }
  .badges {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 600px) {
  .progress-tiles {
    grid-template-columns: repeat(2, 1fr);
  }
  .badges {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .achievement-toast {
    animation: toast-in 0.6s var(--ease-spring) calc(var(--i) * 0.35s) both;
  }

  .achievement-toast .achievement-icon {
    display: inline-block;
    animation: icon-wiggle 0.7s ease-in-out calc(0.35s + var(--i) * 0.35s) both;
  }

  .progress-section.in .badge,
  .progress-section.in .progress-tile {
    animation: pop 0.45s var(--ease-spring) calc(0.05s + var(--i, 0) * 0.04s) both;
  }

  .badge.earned:hover .badge-icon {
    animation: icon-wiggle 0.6s ease-in-out;
  }

  @keyframes toast-in {
    from {
      opacity: 0;
      transform: translateY(-24px) scale(0.85);
    }
  }

  @keyframes icon-wiggle {
    0%,
    100% {
      transform: rotate(0) scale(1);
    }
    30% {
      transform: rotate(-14deg) scale(1.25);
    }
    60% {
      transform: rotate(10deg) scale(1.15);
    }
  }
}

/* ---- FAQ, and the plain page shown before the game loads ----------------------------- */

.faq {
  max-width: 680px;
}

.faq-item {
  border-top: 1px solid var(--line);
  padding: 12px 4px;
}

.faq-item:last-child {
  border-bottom: 1px solid var(--line);
}

.faq-item summary {
  cursor: pointer;
  font-weight: 700;
}

.faq-item p {
  margin: 8px 0 2px;
  color: #c6d0de;
}

.static-page {
  max-width: 720px;
  height: 100%;
  overflow-y: auto;
  margin: 0 auto;
  padding: 48px 20px;
  color: #c6d0de;
  line-height: 1.6;
}

.static-page h1,
.static-page h2,
.static-page h3 {
  color: var(--ink);
}

.static-page a {
  color: #c8ef9b;
}

/* ---- Footer, consent banner and the privacy and terms pages --------------------------- */

.site-foot {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
  padding: 0 16px max(28px, env(safe-area-inset-bottom));
  font-size: 13.5px;
}

.site-foot a,
.doc-foot a,
.consent a {
  color: #c6d0de;
}

.consent {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 24px));
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px 18px;
  flex-wrap: wrap;
  border-radius: 14px;
  border: 1px solid rgba(160, 185, 220, 0.28);
  background: rgba(15, 24, 41, 0.97);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  font-size: 14px;
}

.consent p {
  flex: 1 1 320px;
  margin: 0;
  color: #c6d0de;
}

.consent-actions {
  display: flex;
  gap: 10px;
}

/* The game locks page scrolling; the text pages scroll inside their own body instead. */
.doc-page {
  height: 100%;
  overflow-y: auto;
}

.doc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 760px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 20px 0;
}

.doc-back {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.doc {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 24px;
  color: #c6d0de;
  line-height: 1.6;
}

.doc h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
}

.doc h2 {
  margin: 30px 0 8px;
  color: var(--ink);
  font-size: 19px;
}

.doc a {
  color: #c8ef9b;
}

.doc-date {
  color: var(--muted);
  font-size: 13.5px;
}

.doc-choice {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(15, 24, 41, 0.8);
}

.doc-choice p {
  margin: 0 0 10px;
}

.doc-foot {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 20px 40px;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---- Shared with the results screens and the game ----------------------------------- */

.stars-big {
  font-size: 46px;
  line-height: 1.1;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.stars-big .off {
  color: rgba(255, 255, 255, 0.16);
}

.prompt-hint {
  font-weight: 450;
  font-size: 12.5px;
  color: var(--muted);
}

.prompt-hint.intro {
  font-size: 14px;
  line-height: 1.35;
  color: var(--accent);
}

.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 860px) {
  .trail-chapters {
    grid-template-columns: repeat(2, 1fr);
  }
  .steps ol {
    grid-template-columns: 1fr;
    gap: 22px;
    max-width: 460px;
    margin: 0 auto;
  }
  .step + .step::before {
    display: none;
  }
}

@media (max-width: 600px) {
  .site-head {
    padding: max(14px, env(safe-area-inset-top)) 16px 4px;
  }
  .logo {
    width: 54px;
  }
  .wordmark {
    font-size: 24px;
  }
  .site-head nav {
    gap: 14px;
    font-size: 13.5px;
  }
  .site-head nav a:not(:first-child) {
    display: none;
  }
  .title-inner {
    padding: 0 16px 48px;
    gap: 44px;
  }
  .hero {
    padding-top: 20px;
  }
  .hero-actions {
    flex-direction: column;
    align-self: stretch;
  }
  .btn.big {
    min-width: 0;
  }
  .hero-figure {
    aspect-ratio: 16 / 9;
    margin-top: 32px;
  }
  .viewfinder {
    left: 16%;
    width: 11%;
  }
  .trail {
    padding: 14px;
  }
  .trail-chapters {
    grid-template-columns: 1fr;
  }
  .mode-pills {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 10px;
  }
  .mode-pill {
    min-width: 0;
  }
  .section-rule > span:first-child::before,
  .section-rule > span:first-child::after {
    width: 32px;
  }
}

/* ---- Game layout --------------------------------------------------------------------- */

.screen.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(46vw, calc(100dvh - 120px));
  height: 100dvh;
}

.view {
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: #1c2a3a;
}

canvas.world {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

canvas.world.dragging {
  cursor: grabbing;
}

canvas.world.locked {
  cursor: default;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  min-width: 0;
  padding: 12px 14px max(12px, env(safe-area-inset-bottom));
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-prompt {
  display: flex;
  flex-direction: column;
  font-weight: 700;
  font-size: 16px;
}

.panel-prompt .muted {
  font-weight: 450;
  font-size: 12.5px;
}

.quit,
.panel-back,
.sound-toggle {
  flex: none;
  min-height: 34px;
  width: 34px;
  padding: 0;
  font-size: 16px;
}

.sound-toggle {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.sound-toggle[aria-pressed="true"] {
  color: var(--ink);
}

.panel-back {
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
}

.panel-prompt {
  flex: 1;
  min-width: 0;
}

.map-host {
  position: relative;
  flex: 1;
  min-height: 0;
}

.map-canvas {
  position: absolute;
  inset: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.panel-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-caption {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

.guess {
  width: 100%;
  font-size: 16px;
}

.result {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.result-text {
  display: flex;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
}

.result-text strong {
  font-size: 17px;
}

.result .btn {
  flex: 0 0 auto;
}

@media (max-width: 899px) {
  .screen.game {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(200px, 40dvh) minmax(0, 1fr);
  }
  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

/* ---- HUD ----------------------------------------------------------------------------- */

.hud-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

.hud-chip,
.hud-heading,
.compass {
  background: rgba(8, 13, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  backdrop-filter: blur(6px);
}

.hud-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-weight: 650;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.hud-chip .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
}

.hud-score {
  display: inline-block;
  color: var(--accent);
}

.hud-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 14px;
  min-width: 120px;
}

.hud-heading-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 650;
}

.hud-heading-value {
  display: grid;
  justify-items: center;
  font-size: 19px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* An invisible copy of the widest reading shares the text's grid cell, so the box keeps one width
   as you turn instead of jumping between "LEFT 5°" and "RIGHT 128°". */
.hud-heading-value::after {
  content: "RIGHT 188°";
  grid-area: 1 / 1;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}

.compass {
  position: relative;
  width: 230px;
  height: 42px;
  overflow: hidden;
}

.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.compass.attention {
  border-color: var(--accent);
  animation: point-out 1.2s ease-in-out 5;
}

@keyframes point-out {
  50% {
    box-shadow: 0 0 0 5px rgba(245, 197, 66, 0.35);
  }
}

.compass-tip {
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12.5px;
  font-weight: 700;
}

.compass-strip {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  will-change: transform;
}

.compass .tick {
  position: absolute;
  bottom: 6px;
  width: 1px;
  height: 7px;
  background: rgba(255, 255, 255, 0.4);
  font-size: 0;
}

.compass .tick.major {
  height: auto;
  width: auto;
  bottom: 8px;
  background: none;
  transform: translateX(-50%);
  font-size: 15px;
  font-weight: 800;
  color: #e7edf5;
}

.compass-needle {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 9px;
  margin-left: -1px;
  background: var(--accent);
}

.hud-timer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: rgba(0, 0, 0, 0.35);
}

.hud-timer-bar {
  height: 100%;
  background: var(--accent);
  transform-origin: left;
}

.hud-timer.urgent .hud-timer-bar {
  background: var(--bad);
}

.hud-btn {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(8, 13, 24, 0.72);
  backdrop-filter: blur(6px);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.hud-btn.on {
  background: var(--accent);
  color: var(--accent-ink);
}

.hud-zoom {
  position: absolute;
  right: 12px;
  bottom: 18px;
}

.hud-pad {
  position: absolute;
  left: 12px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-walk {
  position: absolute;
  left: 66px;
  bottom: 22px;
  font-size: 12px;
  color: #dfe6ef;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

.hud-hint {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 99px;
  background: rgba(8, 13, 24, 0.72);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.hud-hint.fade {
  opacity: 0;
}

@media (max-width: 560px) {
  .compass {
    width: 160px;
  }
  .hud-heading {
    min-width: 0;
    padding: 4px 10px;
  }
  .hud-heading-value {
    font-size: 16px;
  }
  .hud-hint {
    white-space: normal;
    width: max-content;
    max-width: calc(100% - 140px);
    text-align: center;
  }
}

/* ---- Overlays ------------------------------------------------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(6, 10, 18, 0.72);
  backdrop-filter: blur(3px);
}

.overlay.loading {
  align-content: center;
  gap: 14px;
}

.overlay.loading p {
  margin: 0;
  color: #c6d0de;
}

/* Surveying: contour rings around a summit. */
.survey {
  position: relative;
  width: 64px;
  height: 64px;
}

.survey span {
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  border-radius: 47% 53% 44% 56% / 55% 45% 55% 45%;
}

.survey span:nth-child(2) {
  inset: 12px;
  opacity: 0.7;
}

.survey span:nth-child(3) {
  inset: 23px;
  opacity: 0.45;
}

.summary .card {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.rank {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
}

.total {
  font-variant-numeric: tabular-nums;
}

.total-num {
  font-size: 46px;
  font-weight: 850;
  color: var(--accent);
}

.total-max {
  color: var(--muted);
  font-size: 18px;
}

.tiles {
  font-size: 26px;
  letter-spacing: 0.08em;
}

.breakdown {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

.breakdown td {
  padding: 7px 6px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.breakdown td.num {
  text-align: right;
  font-weight: 700;
}

.summary .actions {
  width: 100%;
}

.summary .actions .btn {
  flex: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Each round opens in haze; hidden unless there is motion to show it. */
.mist,
.round-intro {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .mist {
    display: block;
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 55%, color-mix(in srgb, var(--haze, #b9cadb) 70%, white), var(--haze, #b9cadb) 75%);
    backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
  }

  .mist.play {
    animation: mist-lift 0.9s ease-in both;
  }

  .round-intro {
    display: flex;
    position: absolute;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #0f1829;
    opacity: 0;
    pointer-events: none;
  }

  .round-intro.play {
    animation: round-intro 1.15s var(--ease-out) both;
  }

  .round-intro-eyebrow {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    opacity: 0.7;
  }

  .round-intro strong {
    font-size: clamp(26px, 4.4vw, 44px);
    font-weight: 800;
    letter-spacing: -0.01em;
  }

  /* Surveying: the rings spread out like contours from a summit. */
  .survey span {
    animation: survey 1.6s var(--ease-out) infinite;
  }

  .survey span:nth-child(2) {
    animation-delay: -0.53s;
  }

  .survey span:nth-child(3) {
    animation-delay: -1.06s;
  }

  /* The result rises in; its tile lands with the pin on the map. */
  .result:not([hidden]) {
    animation: rise 0.4s var(--ease-out) both;
  }

  .result-tile {
    display: inline-block;
    animation: pop 0.5s var(--ease-spring) var(--land, 0s) both;
  }

  /* The last ten seconds: the clock bar throbs. */
  .hud-timer.urgent .hud-timer-bar {
    animation: urgent 0.5s ease-in-out infinite alternate;
  }

  /* Results: the card rises, the rank stamps down, tiles and rows follow one by one. */
  .summary {
    animation: fade-in 0.3s ease-out both;
  }

  .summary .card {
    animation: rise-in 0.55s var(--ease-out) both;
  }

  .summary .rank {
    animation: stamp 0.5s var(--ease-spring) 0.2s both;
  }

  .summary .tiles span {
    display: inline-block;
    animation: pop 0.4s var(--ease-spring) calc(0.5s + var(--i) * 0.09s) both;
  }

  .summary .breakdown tr {
    animation: rise 0.4s var(--ease-out) calc(0.55s + var(--i) * 0.06s) both;
  }

  .summary .actions {
    animation: rise 0.45s var(--ease-out) 0.85s both;
  }

  /* Trail stars stamp down one after another (their chimes are timed in trailPanel.js). */
  .stars-big .star {
    display: inline-block;
    animation: stamp 0.45s var(--ease-spring) calc(0.45s + var(--i) * 0.28s) both;
  }

  .stars-big .star:not(.off) {
    text-shadow: 0 0 18px rgba(245, 197, 66, 0.45);
  }

  @keyframes mist-lift {
    0%,
    25% {
      opacity: 1;
    }
    100% {
      opacity: 0;
    }
  }

  @keyframes round-intro {
    0% {
      opacity: 0;
      transform: scale(0.88);
    }
    22% {
      opacity: 1;
      transform: scale(1);
    }
    58% {
      opacity: 1;
      transform: translateY(0);
    }
    100% {
      opacity: 0;
      transform: translateY(-28px);
    }
  }

  @keyframes survey {
    0% {
      opacity: 0;
      transform: scale(0.3) rotate(0deg);
    }
    35% {
      opacity: 1;
    }
    100% {
      opacity: 0;
      transform: scale(1.15) rotate(40deg);
    }
  }

  @keyframes urgent {
    to {
      opacity: 0.55;
    }
  }

  @keyframes stamp {
    0% {
      opacity: 0;
      transform: scale(2.1) rotate(-10deg);
    }
    100% {
      opacity: 1;
      transform: none;
    }
  }
}

.fatal {
  display: grid;
  place-items: center;
  align-content: center;
  height: 100%;
  padding: 16px;
  text-align: center;
}
