/* Lights out: the poster sits in the dark and a torch follows the pointer. Same palette and type as the home page. */
:root {
  --night: #122C2D; --night-deep: #0D2223; --panel: #1A3A3B; --panel-line: #2F5556;
  --cream: #FCF8F0; --sand: #F3E5C6; --salmon: #E0876A; --leaf: #BBD0C2; --torch: #FFD45C;
  --ink: #1E3B3D; --soft: #B9CCC8;
  --display: "Bagel Fat One", system-ui, sans-serif;
  --body: "Nunito", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; height: auto; display: block; }
body {
  background-color: var(--night); color: var(--cream); font-family: var(--body); font-size: 17px; line-height: 1.55;
  background-image: radial-gradient(rgba(252,248,240,.75) 1px, transparent 1.6px), radial-gradient(rgba(252,248,240,.4) 1px, transparent 1.6px);
  background-size: 140px 140px, 90px 90px; background-position: 10px 20px, 55px 70px;
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.05; letter-spacing: -.005em; }
.wrap { max-width: 1240px; margin: 0 auto; padding-inline: max(20px, env(safe-area-inset-left, 0px)); }
:focus-visible { outline: 3px solid var(--torch); outline-offset: 3px; }

/* nav (same as home, on dark) */
.nav { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px 24px; padding-block: 20px; }
.logo { text-decoration: none; font-family: var(--display); font-size: 2.4rem; line-height: 1; }
.logo span { color: var(--leaf); }
.nav-links { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; font-weight: 800; margin-left: auto; }
.nav-links a { text-decoration: none; }
.nav-links a:hover, .nav-links a[aria-current] { color: var(--sand); text-decoration: underline; text-underline-offset: 5px; }
.nav-cta { display: flex; align-items: center; gap: 14px; font-weight: 800; }
.nav-cta .pill { text-decoration: none; background: var(--sand); color: var(--ink); padding: 11px 20px; border-radius: 999px; white-space: nowrap; }
@media (max-width: 1000px) {
  .nav { gap: 14px 12px; padding-block: 16px; }
  .logo { font-size: 2.1rem; }
  .nav-cta { order: 1; margin-left: auto; gap: 10px; }
  .nav-links { order: 2; flex-basis: 100%; margin-left: 0; gap: 6px 20px; font-size: .95rem; }
}
@media (max-width: 560px) {
  /* phones: only the page links; "The route" is a section further down the home page */
  .nav-links { flex-wrap: nowrap; white-space: nowrap; gap: 24px; font-size: 1rem; }
  .nav-links a[href$="#route"], .nav-links a[href$="#eco"] { display: none; }
  .nav-cta .pill { padding: 9px 15px; font-size: .88rem; }
  .nav-cta .lang a { min-width: 0; padding: 7px 10px; }
}
@media (max-width: 359px) { .nav-cta .pill { display: none; } }

/* intro */
.intro { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 18px 40px; padding-block: 28px 30px; }
.kicker { display: inline-block; font-weight: 900; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--leaf); border: 2px solid var(--leaf); border-radius: 999px; padding: 5px 14px; margin-bottom: 16px; }
.intro h1 { font-size: clamp(3rem, 8vw, 6rem); color: var(--sand); }
.intro p { font-size: 1.2rem; color: var(--soft); max-width: 460px; }
.intro .hand { font-family: "Caveat", cursive; font-weight: 700; font-size: 1.6rem; color: var(--salmon); display: block; transform: rotate(-2deg); margin-top: 6px; }

/* main grid */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; padding-bottom: 72px; }
@media (max-width: 880px) { .game { grid-template-columns: minmax(0, 1fr); } }

.stage-col { display: grid; gap: 14px; min-width: 0; }
.stage-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.city-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-weight: 800; font-size: .95rem; min-height: 44px;
  border: 2px solid var(--panel-line); background: var(--panel); color: var(--cream);
  border-radius: 999px; padding: 6px 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.chip:hover { border-color: var(--soft); }
.chip[aria-current="true"] { background: var(--sand); border-color: var(--sand); color: var(--ink); }
.chip.found::after { content: "✓"; color: var(--leaf); font-weight: 900; }
.chip[aria-current="true"].found::after { color: var(--ink); }
.chip:disabled { opacity: .6; cursor: default; border-style: dashed; background: transparent; }
.chip .dots { font-size: .6rem; letter-spacing: 1px; opacity: .75; }

.tools { display: flex; gap: 8px; }
.icon-btn {
  font: inherit; font-weight: 800; font-size: .95rem; min-height: 44px;
  border: 2px solid var(--cream); background: transparent; color: var(--cream);
  border-radius: 999px; padding: 6px 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.icon-btn[aria-pressed="true"] { background: var(--torch); border-color: var(--torch); color: var(--ink); }

.frame {
  position: relative; background: var(--night-deep); border: 3px solid var(--cream); border-radius: 22px; padding: 10px;
  box-shadow: 0 40px 80px -30px rgba(0,0,0,.75), 0 0 0 10px rgba(255,212,92,.08);
}
.scroller { overflow: auto; border-radius: 14px; max-height: min(80vh, 920px); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.stage { position: relative; display: block; width: 100%; margin: 0 auto; cursor: crosshair; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.zoomed .stage { width: 200%; max-width: none; }
.stage img { display: block; width: 100%; height: auto; max-width: none; pointer-events: none; border-radius: 8px; }

/* the torch */
.torch {
  position: absolute; inset: 0; z-index: 1; pointer-events: none; border-radius: 8px; overflow: hidden;
  transition: opacity .7s ease;
}
/* An oversized dark layer with the light at its centre, moved with a GPU transform (no repaint per move). */
.torch i {
  position: absolute; left: 0; top: 0; width: 200%; height: 200%; will-change: transform;
  background: radial-gradient(circle at 50% 50%, rgba(9,24,25,0) 0, rgba(9,24,25,0) 80px, rgba(9,24,25,.93) 145px);
}
/* While the torch is on, dragging on the poster moves the light instead of scrolling the page. */
.stage:not(.lit) { touch-action: none; }
.zoomed .stage { touch-action: manipulation; }
.stage.lit .torch { opacity: 0; }
.ring, .hint-glow, .puff { z-index: 2; }

.puff {
  position: absolute; transform: translate(-50%, -50%);
  background: var(--cream); color: var(--ink); border: 2px solid var(--ink);
  font-weight: 800; font-size: .9rem; padding: 4px 12px; border-radius: 999px;
  white-space: nowrap; pointer-events: none; animation: puff 1.1s ease-out forwards;
}
@keyframes puff { 0% { opacity: 0; margin-top: 0; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -34px; } }
.ring {
  position: absolute; transform: translate(-50%, -50%); border-radius: 50%; border: 5px solid var(--torch);
  box-shadow: 0 0 0 5px var(--night), 0 0 30px rgba(255,212,92,.9), 0 0 0 9999px rgba(9,24,25,.4);
  pointer-events: none; animation: ring .7s cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes ring { from { transform: translate(-50%, -50%) scale(2.4); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
.hint-glow {
  position: absolute; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle, rgba(255,212,92,.6) 0%, rgba(255,212,92,0) 70%);
  pointer-events: none; animation: glow 1.6s ease-in-out infinite; mix-blend-mode: screen;
}
@keyframes glow { 50% { opacity: .45; } }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.confetti i { position: absolute; width: 9px; height: 14px; border-radius: 2px; top: -16px; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: .2; } }
.note { font-size: .9rem; color: var(--soft); text-align: center; font-weight: 600; }

/* side panel */
.side { display: grid; gap: 16px; min-width: 0; }
.card { background: var(--panel); border: 2px solid var(--panel-line); border-radius: 22px; padding: 18px 20px; }
.who { display: grid; grid-template-columns: 76px minmax(0,1fr); gap: 14px; align-items: center; }
.who img { width: 76px; border-radius: 16px; background: var(--cream); padding: 4px; }
.who h2 { font-size: 1.35rem; margin-bottom: 4px; color: var(--sand); }
.who p { font-size: .95rem; color: var(--soft); }
.status h2, .journal h2 { font-size: 1.45rem; margin-bottom: 8px; text-wrap: balance; }
.status { background: var(--cream); color: var(--ink); border-color: var(--cream); }
.status p { font-size: 1rem; }
.status .level { margin-bottom: 4px; font-size: .8rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: #4E6264; }
.status .mission { font-weight: 800; }
.status .tries { font-size: .9rem; color: #4E6264; margin-top: 8px; font-variant-numeric: tabular-nums; font-weight: 700; }
.status .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn {
  font: inherit; font-weight: 900; font-size: 1rem; text-decoration: none; min-height: 46px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 999px; padding: 10px 20px; cursor: pointer; border: 2.5px solid var(--ink);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-primary { background: var(--ink); color: var(--cream); box-shadow: 4px 4px 0 var(--salmon); }
.btn-primary:hover { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 var(--salmon); }
.btn-ghost { background: transparent; color: var(--ink); }
.finale .btn-ghost { color: var(--cream); border-color: var(--cream); }
.fact { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--sand); font-size: .95rem; }
.fact b { color: #A24F33; }

.journal { position: relative; }
.journal .sub { margin-bottom: 14px; font-size: .9rem; color: var(--soft); font-weight: 700; }
.stamps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stamp {
  aspect-ratio: 1; border-radius: 50%; border: 2px dashed rgba(252,248,240,.35);
  display: grid; place-items: center; text-align: center; padding: 4px;
  font-family: var(--display); font-size: .85rem; line-height: 1.05; color: rgba(252,248,240,.5);
}
.stamp.on { border: 3px double var(--torch); color: var(--torch); transform: rotate(-8deg); animation: stampin .45s cubic-bezier(.2,1.5,.4,1); }
.stamp.on:nth-child(2n) { transform: rotate(6deg); }
.stamp.long { font-size: .7rem; }
.stamp small { display: block; font-family: var(--body); font-weight: 800; font-size: .6rem; letter-spacing: .08em; text-transform: uppercase; }
@keyframes stampin { from { transform: scale(1.8) rotate(-20deg); opacity: 0; } }

/* finale */
.finale {
  background: var(--salmon); color: var(--ink); border: 3px solid var(--cream); border-radius: 24px;
  padding: 22px 24px; margin-bottom: 24px; display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 20px; align-items: center;
}
.finale img { width: 96px; border-radius: 16px; background: var(--cream); padding: 4px; }
.finale h2 { margin-bottom: 6px; font-size: clamp(1.5rem, 4vw, 2.2rem); text-wrap: balance; }
.finale p { margin-bottom: 14px; max-width: 60ch; font-weight: 600; }
.finale .actions { display: flex; flex-wrap: wrap; gap: 10px; }
.finale .btn-ghost { color: var(--ink); border-color: var(--ink); }
@media (max-width: 480px) { .finale { grid-template-columns: minmax(0,1fr); } }

footer { background: var(--night-deep); color: var(--soft); padding-block: 32px; border-top: 2px solid var(--panel-line); }
footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; align-items: center; }
footer strong { font-family: var(--display); font-weight: 400; color: var(--cream); font-size: 1.5rem; }
footer nav { display: flex; flex-wrap: wrap; gap: 20px; font-weight: 800; color: var(--cream); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .confetti { display: none; }
}

/* language switch */
.lang { display: inline-flex; border: 2px solid var(--cream); border-radius: 999px; overflow: hidden; font-weight: 900; font-size: .9rem; }
.lang a { text-decoration: none; padding: 9px 13px; min-width: 44px; text-align: center; color: var(--cream); }
.lang a[aria-current="true"] { background: var(--cream); color: var(--ink); }
.lang a:not([aria-current="true"]):hover { background: rgba(252,248,240,.14); text-decoration: none; }

/* phones: keep it simple, just the poster and the torch */
@media (max-width: 700px) {
  .city-tabs, #zoom { display: none; }
  .stage-bar { justify-content: flex-end; }
  .note { display: none; }
}

/* stacked layout: Vivi and the mission come first, then the poster, then the journal */
@media (max-width: 880px) {
  .game { display: flex; flex-direction: column; gap: 12px; }
  .side { display: contents; }
  .who { order: 1; } .status { order: 2; } .stage-col { order: 3; margin-top: 4px; } .journal { order: 4; margin-top: 8px; }
  .who { grid-template-columns: 48px minmax(0, 1fr); gap: 12px; padding: 12px 14px; }
  .who img { width: 48px; border-radius: 12px; padding: 2px; }
  .who h2 { font-size: 1.1rem; margin-bottom: 0; }
  .who p { font-size: .88rem; line-height: 1.35; }
  .status { padding: 14px 16px; }
  .status .level { margin-bottom: 2px; }
  .status h2 { font-size: 1.3rem; margin-bottom: 4px; }
  .status p { font-size: .95rem; }
  .status .tries { margin-top: 4px; }
  .status .actions { margin-top: 10px; }
  .status .btn { min-height: 42px; padding: 8px 16px; font-size: .95rem; }
  .status .fact { margin-top: 8px; padding: 10px 12px; font-size: .9rem; }
}

/* success card over the poster */
.win {
  position: absolute; left: 22px; right: 22px; bottom: 22px; z-index: 4;
  background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 20px;
  padding: 16px 18px; box-shadow: 0 18px 40px rgba(0,0,0,.45); animation: winin .45s cubic-bezier(.2,1.3,.4,1) both;
}
.win.top { top: 22px; bottom: auto; }
.win h2 { font-size: 1.35rem; margin: 0 40px 4px 0; text-wrap: balance; }
.win p { font-size: .98rem; }
.win .fact { margin-top: 10px; }
.win .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.win-close { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink); font-size: 1.8rem; line-height: 1; cursor: pointer; border-radius: 50%; }
.win-close:hover { background: rgba(30,59,61,.08); }
@keyframes winin { from { opacity: 0; transform: translateY(16px) scale(.97); } }
@media (max-width: 560px) {
  .win { left: 12px; right: 12px; bottom: 12px; padding: 14px; }
  .win.top { top: 12px; }
  .win h2 { font-size: 1.15rem; }
  .win p, .win .fact { font-size: .9rem; }
}

/* keyboard play: a visible aim ring that follows the arrow keys */
.kcursor { display: none; position: absolute; z-index: 3; width: 36px; height: 36px; transform: translate(-50%, -50%); border-radius: 50%; border: 3px solid var(--torch); box-shadow: 0 0 0 3px var(--night); pointer-events: none; }
.kcursor::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--torch); }
.stage:focus-visible .kcursor, .stage.kbd .kcursor { display: block; }
.kbd-tip { display: none; }
@media (hover: hover) and (pointer: fine) { .kbd-tip { display: inline; } }
