/* =====================================================================
   Our World — UI stylesheet
   Pastel, chunky, playful. Thick chocolate outlines, rounded everything.
   ===================================================================== */

:root {
  --cream: #fff6e5;
  --cream-2: #fff0d2;
  --pink: #ffb7c5;
  --pink-2: #ff8fa8;
  --mint: #b8f1d0;
  --mint-2: #7fd8a8;
  --sky: #bfe6ff;
  --sky-2: #8fd0ff;
  --sun: #ffd166;
  --choc: #5a3a22;
  --ink: #3b2314;
  --text: #3b2314;
  --muted: #8a6b55;
  --plum: #7b3f61;
  --radius: 18px;
  --outline: 3px solid var(--choc);
  --shadow-chunk: 0 6px 0 var(--choc);
  --shadow-soft: 0 12px 32px rgba(59, 35, 20, .28);
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  /* the touch stick (Minecraft-style, fixed bottom-left): base and knob size, the gap to the screen's corner */
  --joy-size: 128px;
  --knob-size: 56px;
  --joy-gap-x: 40px;
  --joy-gap-y: 40px;
  --font: 'Fredoka', 'Nunito', 'Quicksand', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --hand: 'Caveat', 'Bradley Hand', 'Segoe Print', 'Comic Sans MS', cursive;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  background: #bfe6ff;
}
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.3;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
#game {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #bfe6ff;
  overflow: hidden;
}
#game canvas { display: block; touch-action: none; outline: none; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
img { -webkit-user-drag: none; user-select: none; }
[hidden] { display: none !important; }
.scroll { touch-action: pan-y; -webkit-overflow-scrolling: touch; }

/* ---------- shared bits ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--cream);
  border: var(--outline);
  border-radius: 999px;
  padding: 5px 16px 5px 8px;
  box-shadow: 0 5px 0 var(--choc);
  font-weight: 600;
  font-size: 22px;
  line-height: 1;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 26px;
  border: var(--outline);
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 5px 0 var(--choc);
  transition: transform .08s ease, box-shadow .08s ease, background .2s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--choc); }
.btn-primary { background: var(--pink); }
.btn-small { min-height: 40px; padding: 6px 16px; font-size: 15px; box-shadow: 0 3px 0 var(--choc); }
.btn-danger { background: #ffd5d5; }
.link {
  background: none;
  border: 0;
  padding: 10px 8px;
  min-height: 44px;
  color: var(--choc);
  font-weight: 600;
  font-size: 15px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.key {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  background: #fff;
  border: 2px solid var(--choc);
  border-bottom-width: 4px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  color: var(--ink);
}

/* ---------- vignette ---------- */
#vignette {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 32%, var(--vig-color, #000) 100%);
  transition: opacity .9s ease;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  z-index: 13;   /* above the touch layer (12): the Vault strip at the top centre must win over the look zone */
  pointer-events: none;
  transition: opacity .7s ease;
}
#hud.hud-hidden, #prompt.hud-hidden, #companion-bubble.hud-hidden { opacity: 0 !important; }
/* one HUD piece at a time (ui.setHudElementVisible): the museum hands them out one by one */
.hud-el-off { display: none !important; }
.hud-pop { animation: hudPop .8s cubic-bezier(.2, 1.6, .4, 1) both; }
#minimap-wrap.mm-glow { animation: mmGlow 1.1s ease-in-out 4; }
/* invisible HUD must not be clickable/tappable (Empty Life); the P / M shortcuts still work */
#hud.hud-hidden, #hud.hud-hidden *, #companion-bubble.hud-hidden, #companion-bubble.hud-hidden * { pointer-events: none !important; }
.hud-left {
  position: absolute;
  left: calc(12px + var(--sal));
  top: calc(12px + var(--sat));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.hud-right {
  position: absolute;
  right: calc(12px + var(--sar));
  top: calc(74px + var(--sat));   /* under the corner buttons (sound + settings) */
}
#bliss { pointer-events: none; }
.bliss-icon { width: 36px; height: 36px; flex: none; }
.bliss-num { display: inline-flex; align-items: baseline; gap: 4px; padding-top: 2px; }
.bliss-sep { font-size: .75em; color: var(--muted); }
#bliss-total { font-size: .85em; color: var(--muted); }
.golden-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
  padding: 2px 9px 2px 7px;
  background: var(--sun);
  border: 2px solid var(--choc);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
#bliss.pop .bliss-icon { animation: pop .55s cubic-bezier(.2, 1.7, .4, 1); }
#bliss.pop #bliss-count { display: inline-block; animation: numpop .45s cubic-bezier(.2, 1.7, .4, 1); }
#golden.pop { animation: pop .55s cubic-bezier(.2, 1.7, .4, 1); }
.hud-buttons { display: flex; gap: 8px; }
.hud-btn {
  position: relative;
  width: 52px;
  height: 52px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--cream);
  border: var(--outline);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--choc);
  pointer-events: auto;
  transition: transform .08s, box-shadow .08s;
}
.hud-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--choc); }
.hud-btn svg { width: 34px; height: 34px; }
.hud-btn.wiggle { animation: wiggle .8s ease; }
.hud-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  background: var(--pink-2);
  border: 2px solid var(--choc);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
#btn-companion img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 12%;
  background: var(--sky);
  border: 2px solid var(--choc);
  transition: filter .3s, opacity .3s;
}
#btn-companion .zz {
  display: none;
  position: absolute;
  right: 2px;
  top: 0;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 17px;
  color: var(--plum);
  transform: rotate(10deg);
}
#btn-companion.off img { filter: grayscale(1); opacity: .5; }
#btn-companion.off .zz { display: block; }
#btn-mute .muted-x { display: none; }
#btn-mute.is-muted .wave { display: none; }
#btn-mute.is-muted .muted-x { display: block; }
#minimap-wrap {
  position: relative;
  width: 128px;
  height: 128px;
  border: var(--outline);
  border-radius: 30px;
  overflow: hidden;
  background: #79c7ee;
  box-shadow: 0 4px 0 var(--choc);
  pointer-events: none;
}
#minimap { display: block; width: 100%; height: 100%; }
.compass {
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 0 var(--choc), 0 0 4px rgba(59, 35, 20, .5);
}

/* ---------- prompt pill (desktop) ---------- */
#prompt {
  position: fixed;
  left: 50%;
  bottom: calc(30px + var(--sab));
  z-index: 11;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 8px 10px;
  background: var(--cream);
  border: var(--outline);
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--choc);
  font-weight: 600;
  font-size: 19px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 16px) scale(.9);
  transition: opacity .18s ease, transform .22s cubic-bezier(.2, 1.4, .4, 1);
}
#prompt.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
body.touch #prompt { display: none; }
body.modal-open #prompt { opacity: 0; }

/* ---------- companion bubble ---------- */
#companion-bubble {
  position: fixed;
  left: calc(14px + var(--sal));
  bottom: calc(14px + var(--sab));
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
  transition: opacity .6s;
}
.companion-face {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: var(--outline);
  object-fit: cover;
  object-position: 50% 10%;
  background: var(--sky);
  box-shadow: 0 3px 0 var(--choc);
  animation: floaty 3.2s ease-in-out infinite;
  transition: opacity .3s, filter .3s;
}
#companion-bubble.off .companion-face { opacity: 0; }
.bubble {
  position: relative;
  margin-left: 22px;
  max-width: min(280px, 62vw);
  padding: 9px 14px;
  background: #fff;
  border: var(--outline);
  border-radius: 18px;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.25;
  box-shadow: 0 4px 0 var(--choc);
  opacity: 0;
  transform: scale(.5) translateY(12px);
  transform-origin: 12% 110%;
  transition: opacity .2s ease, transform .3s cubic-bezier(.2, 1.5, .4, 1);
}
.bubble::before, .bubble::after {
  content: '';
  position: absolute;
  left: 8px;
  bottom: -14px;
  border-style: solid;
  border-width: 14px 12px 0 0;
  border-color: var(--choc) transparent transparent transparent;
}
.bubble::after { bottom: -9px; left: 11px; border-width: 10px 8px 0 0; border-color: #fff transparent transparent transparent; }
#companion-bubble.say .bubble { opacity: 1; transform: none; }
body.touch #companion-bubble { bottom: calc(196px + var(--sab)); }
body.modal-open #companion-bubble { opacity: 0; }
body.touch #companion-bubble .companion-face { width: 48px; height: 48px; }

/* ---------- hint ---------- */
#hint {
  position: fixed;
  left: 50%;
  top: 62%;
  z-index: 12;
  max-width: 90vw;
  padding: 9px 18px;
  background: rgba(59, 35, 20, .78);
  color: #fff;
  border-radius: 999px;
  font-weight: 500;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity .3s, transform .3s;
}
#hint.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- zone banner ---------- */
#banner {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(17% + var(--sat));
  z-index: 14;
  display: flex;
  justify-content: center;
  padding: 0 16px;
  pointer-events: none;
}
.banner-card {
  position: relative;
  max-width: min(92vw, 760px);
  padding: 16px 44px 18px;
  background: var(--cream);
  border: var(--outline);
  border-radius: 30px;
  box-shadow: 0 7px 0 var(--choc), var(--shadow-soft);
  text-align: center;
  opacity: 0;
}
#banner.show .banner-card { animation: bannerIn .65s cubic-bezier(.2, 1.4, .4, 1) forwards; }
#banner.hide .banner-card { animation: bannerOut .5s ease forwards; }
.banner-title {
  font-size: clamp(30px, 6.2vw, 60px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: .5px;
  color: var(--ink);
}
.banner-title span { display: inline-block; opacity: 0; white-space: pre; }
#banner.show .banner-title span { animation: letterPop .55s cubic-bezier(.2, 1.7, .4, 1) forwards; animation-delay: calc(var(--i) * 42ms + .18s); }
.banner-sub {
  margin-top: 4px;
  font-family: var(--hand);
  font-size: clamp(20px, 3.4vw, 32px);
  font-weight: 600;
  color: var(--plum);
  opacity: 0;
}
#banner.show .banner-sub { animation: fadeUp .6s ease forwards; animation-delay: .5s; }
/* the text fades out WITH the card (dropping .show would otherwise snap it back to opacity 0: an empty card) */
#banner.hide .banner-title span, #banner.hide .banner-sub { opacity: 1; }
.banner-deco {
  position: absolute;
  top: 50%;
  width: 26px;
  height: 26px;
  margin-top: -13px;
  background: var(--pink);
  clip-path: polygon(50% 100%, 0 45%, 6% 20%, 25% 5%, 50% 20%, 75% 5%, 94% 20%, 100% 45%);
}
.banner-deco-l { left: 12px; transform: rotate(-14deg); }
.banner-deco-r { right: 12px; transform: rotate(14deg); background: var(--mint-2); }

/* ---------- toasts ---------- */
#toasts {
  position: fixed;
  left: 50%;
  top: calc(112px + var(--sat));   /* under the objective line + Vault strip */
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(92vw, 540px);
  transform: translateX(-50%);
  pointer-events: none;
  transition: top .3s ease;
}
/* while a zone banner shows, toasts stack under its card instead of covering the title (ui.zoneBanner sets both) */
body.banner-on #toasts { top: var(--banner-bottom, calc(17% + 140px + var(--sat))); }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 8px 18px 8px 10px;
  background: var(--cream);
  border: var(--outline);
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--choc);
  font-weight: 600;
  font-size: 17px;
  animation: toastIn .55s cubic-bezier(.2, 1.5, .4, 1);
}
.toast.out { animation: toastOut .4s ease forwards; }
.toast-icon { width: 30px; height: 30px; flex: none; display: grid; place-items: center; font-size: 22px; line-height: 1; }
.toast-icon svg { width: 30px; height: 30px; }
.toast-text { overflow: hidden; text-overflow: ellipsis; }
/* tablet portrait: a full-width toast would cover the HUD columns (left buttons, minimap), so toasts start below them */
@media (min-width: 641px) and (max-width: 980px) {
  #toasts { top: calc(156px + var(--sat)); }
}
@media (max-width: 640px) {
  #toasts { top: calc(240px + var(--sat)); }
  body.banner-on #toasts { top: var(--banner-bottom, calc(27% + 118px + var(--sat))); }
  #banner { top: calc(27% + var(--sat)); }
  body.touch #companion-bubble { bottom: calc(214px + var(--sab)); }
  body.touch .bubble { max-width: 58vw; }
  #hint { top: 50%; }
}

/* ---------- touch controls ---------- */
#touch { position: fixed; inset: 0; z-index: 12; display: none; pointer-events: none; }
body.touch #touch { display: block; }
body.modal-open #touch { visibility: hidden; }
#look-zone {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  pointer-events: auto;
  touch-action: none;
}
/* the stick: fixed bottom-left (Minecraft Bedrock's spot), always there, faint until a thumb is on it; the knob sits
   inside the base and follows the thumb (controls.js measures the base, so its size and spot live only here) */
#joy-base {
  position: absolute;
  left: calc(var(--joy-gap-x) + var(--sal));
  bottom: calc(var(--joy-gap-y) + var(--sab));
  width: var(--joy-size);
  height: var(--joy-size);
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  border: 3px solid rgba(255, 255, 255, .85);
  box-shadow: inset 0 0 0 5px rgba(90, 58, 34, .12), 0 4px 18px rgba(0, 0, 0, .18);
  pointer-events: none;
  opacity: .5;
  transition: opacity .35s ease;
}
#joy-base::before {
  content: '';
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, .6);
}
#joy-base.active { opacity: 1; transition-duration: .08s; }
/* floating (a possible setting): hidden until a thumb lands, centred on it */
#joy-base.floating { display: none; bottom: auto; margin: calc(var(--joy-size) / -2) 0 0 calc(var(--joy-size) / -2); }
#joy-base.floating.active { display: block; }
#joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--knob-size);
  height: var(--knob-size);
  margin: calc(var(--knob-size) / -2) 0 0 calc(var(--knob-size) / -2);
  border-radius: 50%;
  background: var(--cream);
  border: var(--outline);
  box-shadow: 0 4px 0 var(--choc);
  pointer-events: none;
}
#joy-base:not(.active) #joy-knob { transition: transform .12s ease-out; }
#joy-knob.run { background: var(--pink); }
#joy-knob::after {
  content: '';
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: var(--pink);
  border: 2px solid var(--choc);
}
#joy-knob.run::after { background: var(--pink-2); }

/* the centre dot: first person on touch (and under desktop pointer lock); never under a card, the letter or the ending */
#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 11;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 0 0 1.5px rgba(59, 35, 20, .55), 0 0 6px rgba(0, 0, 0, .25);
  pointer-events: none;
  display: none;
}
body.crosshair-on #crosshair { display: block; }
body.modal-open #crosshair, body.start-on #crosshair, body.letter-open #crosshair, body.ending-on #crosshair { display: none; }
/* phones upright: a slightly smaller stick (TALK and JUMP keep the right corner) */
@media (max-width: 640px) {
  :root { --joy-size: 116px; --knob-size: 52px; --joy-gap-x: 26px; --joy-gap-y: 34px; }
}

.touch-buttons {
  position: absolute;
  right: calc(16px + var(--sar));
  bottom: calc(20px + var(--sab));
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
.tbtn {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  border-radius: 50%;
  border: var(--outline);
  background: var(--cream);
  box-shadow: 0 5px 0 var(--choc);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .6px;
  color: var(--ink);
  touch-action: none;
  transition: transform .06s, box-shadow .06s, background .25s;
}
.tbtn:active, .tbtn.pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--choc); }
.tbtn-label { line-height: 1; margin-top: -2px; }
.tbtn-label.long { font-size: 11px; letter-spacing: 0; }
#interact-wrap { position: relative; display: flex; flex-direction: column; align-items: center; margin-bottom: 44px; }
#btn-interact { width: 86px; height: 86px; background: var(--mint); }
#btn-interact svg { width: 36px; height: 36px; }
#btn-interact.active { background: var(--sun); animation: pulse 1.3s ease-in-out infinite; }
#btn-jump { width: 70px; height: 70px; background: var(--sky); }
#btn-jump svg { width: 30px; height: 30px; }
#interact-label {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 10px;
  width: max-content;
  max-width: min(calc(100vw - 130px - var(--sal) - var(--sar)), 340px);
  padding: 5px 13px;
  background: var(--cream);
  border: var(--outline);
  border-radius: 16px;
  box-shadow: 0 3px 0 var(--choc);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.15;
  text-align: right;
  white-space: normal;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .25s cubic-bezier(.2, 1.4, .4, 1);
}
#interact-wrap.active #interact-label { opacity: 1; transform: none; }

/* ---------- dialogue ---------- */
#dialogue {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;     /* centred on every screen (characters; signs and plaques use #card) */
  justify-content: center;
  padding: calc(60px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  background: rgba(59, 35, 20, .18);
  pointer-events: auto;
  opacity: 0;
  transition: opacity .22s ease;
}
#dialogue.open { opacity: 1; }
.dlg-card {
  position: relative;
  width: min(100%, 640px);
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 18px;
  padding: 18px 26px 22px 18px;
  min-height: 132px;
  background: var(--cream);
  border: var(--outline);
  border-radius: 26px;
  box-shadow: 0 7px 0 var(--choc), var(--shadow-soft);
  transform: translateY(40px) scale(.96);
  transition: transform .32s cubic-bezier(.2, 1.4, .4, 1);
}
#dialogue.open .dlg-card { transform: none; }
.dlg-card.no-portrait { grid-template-columns: 1fr; padding-left: 26px; }
.dlg-card.no-portrait .dlg-portrait { display: none; }
.dlg-portrait {
  width: 116px;
  height: 128px;
  margin-top: -52px;
  align-self: start;
  border-radius: 22px;
  background: linear-gradient(160deg, var(--sky) 0%, var(--mint) 100%);
  border: var(--outline);
  box-shadow: 0 4px 0 var(--choc);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.dlg-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0%;
  display: block;
  filter: drop-shadow(1.5px 0 0 #fff) drop-shadow(-1.5px 0 0 #fff) drop-shadow(0 1.5px 0 #fff) drop-shadow(0 -1.5px 0 #fff);
  transform-origin: 50% 100%;
}
.dlg-portrait img.in { animation: portraitIn .45s cubic-bezier(.2, 1.6, .4, 1); }
.dlg-right { display: flex; flex-direction: column; min-width: 0; }
.dlg-name {
  align-self: flex-start;
  margin-top: -34px;
  padding: 5px 16px;
  background: var(--pink);
  border: var(--outline);
  border-radius: 999px;
  font-weight: 700;
  font-size: 17px;
  box-shadow: 0 3px 0 var(--choc);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dlg-name.alt { background: var(--mint); }
.dlg-name.empty { visibility: hidden; }
.dlg-text {
  white-space: pre-wrap;
  margin-top: 10px;
  font-size: 21px;
  font-weight: 500;
  line-height: 1.35;
  min-height: 2.7em;
  padding-right: 18px;
  overflow-wrap: anywhere;
}
.dlg-cue {
  position: absolute;
  right: 18px;
  bottom: 10px;
  font-size: 24px;
  line-height: 1;
  color: var(--choc);
  opacity: 0;
}
.dlg-card.done .dlg-cue { opacity: 1; animation: blink 1s steps(2, start) infinite; }
@media (max-width: 640px) {
  .dlg-card { grid-template-columns: 84px 1fr; gap: 12px; padding: 14px 18px 18px 12px; min-height: 110px; }
  .dlg-portrait { width: 84px; height: 96px; margin-top: -40px; border-radius: 18px; }
  .dlg-name { margin-top: -30px; font-size: 15px; padding: 4px 12px; }
  .dlg-text { font-size: 18px; margin-top: 8px; padding-right: 10px; }
}

/* ---------- modals (passport, vault) ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(10px + var(--sat)) calc(10px + var(--sar)) calc(10px + var(--sab)) calc(10px + var(--sal));
  pointer-events: auto;
  opacity: 0;
  transition: opacity .25s ease;
}
.modal.open { opacity: 1; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(59, 35, 20, .55); }
.modal-close {
  position: absolute;
  top: calc(12px + var(--sat));
  right: calc(12px + var(--sar));
  z-index: 3;
  width: 50px;
  height: 50px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: var(--outline);
  background: var(--cream);
  box-shadow: 0 4px 0 var(--choc);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}
.modal-close:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--choc); }
.modal-body {
  position: relative;
  width: min(100%, 860px);
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 30px 8px 16px;
  scrollbar-width: thin;
  transform: scale(.92) translateY(24px);
  transition: transform .4s cubic-bezier(.2, 1.4, .4, 1);
}
.modal.open .modal-body { transform: none; }

/* passport booklet */
.passport-book {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  max-width: 740px;
  margin: 0 auto;
  padding: 14px;
  background: #6b2d4e;
  background-image: radial-gradient(circle at 12% 18%, rgba(255, 255, 255, .08), transparent 40%);
  border: var(--outline);
  border-radius: 22px;
  box-shadow: var(--shadow-soft), inset 0 0 0 2px rgba(255, 209, 102, .35);
}
.passport-book.shake { animation: shake .45s ease; }
.pp-page {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 384px;
  padding: 16px 16px 14px;
  background-color: #fffaf0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(123, 63, 97, .06) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 60%, rgba(123, 63, 97, .05) 0 2px, transparent 3px),
    repeating-linear-gradient(0deg, rgba(90, 58, 34, .035) 0 1px, transparent 1px 9px);
  background-size: 120px 120px, 160px 160px, auto;
}
.pp-left { border-radius: 14px 3px 3px 14px; box-shadow: inset -14px 0 22px -16px rgba(0, 0, 0, .45); }
.pp-right { border-radius: 3px 14px 14px 3px; box-shadow: inset 14px 0 22px -16px rgba(0, 0, 0, .45); }
.pp-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(123, 63, 97, .25);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--plum);
}
.pp-emblem { font-size: 16px; }
.pp-photo {
  width: 124px;
  height: 154px;
  margin: 0 auto 14px;
  border: 3px solid var(--choc);
  border-radius: 8px;
  background: #d9c7a8;
  box-shadow: 0 3px 0 var(--choc);
  overflow: hidden;
  transform: rotate(-1.5deg);
}
.pp-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; filter: sepia(.22) contrast(1.05); display: block; }
.pp-fields { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; }
.pp-fields dt { align-self: end; font-size: 9.5px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--plum); padding-bottom: 3px; }
.pp-fields dd { margin: 0; font-family: var(--hand); font-size: 21px; font-weight: 600; line-height: 1.05; color: var(--ink); overflow-wrap: anywhere; }
.pp-mrz {
  margin-top: auto;
  padding-top: 12px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 1.2px;
  line-height: 1.5;
  color: #8a6b55;
  word-break: break-all;
}
.pp-stamps { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pp-slot {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 2px dashed rgba(123, 63, 97, .35);
  border-radius: 14px;
  display: grid;
  place-items: center;
  overflow: visible;
}
.pp-slot-label { font-family: var(--hand); font-size: 19px; font-weight: 600; color: rgba(123, 63, 97, .5); text-align: center; padding: 6px; }
.pp-slot.stamped { border-color: transparent; }
.pp-slot.stamped .pp-slot-label { display: none; }
.pp-stamp {
  position: absolute;
  inset: 3%;
  transform: rotate(var(--rot, -6deg));
  mix-blend-mode: multiply;
  opacity: .92;
}
.pp-stamp svg { width: 100%; height: 100%; display: block; }
.pp-stamp.slam { animation: slam .6s cubic-bezier(.25, 1.3, .4, 1) forwards; }
.pp-footer { margin-top: auto; padding-top: 12px; font-family: var(--hand); font-size: 18px; color: var(--plum); text-align: center; }
.pp-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 740px; margin: 14px auto 0; }
.pp-extra section { background: var(--cream); border: var(--outline); border-radius: 18px; padding: 10px 14px; box-shadow: 0 4px 0 var(--choc); min-width: 0; }
.pp-extra h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--plum); }
.pp-extra ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pp-extra li { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; background: #fff; border: 2px solid var(--choc); border-radius: 999px; font-size: 14px; font-weight: 600; max-width: 100%; }
.pp-extra li .star { color: #e3a008; }
.pp-extra li.empty { border-style: dashed; color: var(--muted); font-weight: 500; background: transparent; }
.pp-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 20px; margin-top: 12px; }
.pp-actions .link { color: var(--cream); }
@media (max-width: 600px) {
  .passport-book { grid-template-columns: 1fr; gap: 10px; padding: 10px; }
  .pp-page { min-height: 0; }
  .pp-left { border-radius: 14px 14px 3px 3px; box-shadow: inset 0 -14px 22px -16px rgba(0, 0, 0, .45); }
  .pp-right { border-radius: 3px 3px 14px 14px; box-shadow: inset 0 14px 22px -16px rgba(0, 0, 0, .45); }
  .pp-photo { width: 104px; height: 128px; }
  .pp-extra { grid-template-columns: 1fr; }
  .modal-body { padding-top: 56px; }
}

/* stamp ghost flying to the HUD button */
.stamp-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 150px;
  height: 150px;
  z-index: 16;
  pointer-events: none;
  mix-blend-mode: multiply;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .25));
}
.stamp-ghost svg { width: 100%; height: 100%; }

/* vault */
#vault { z-index: 45; }
.vault-backdrop { background: radial-gradient(ellipse at center, rgba(123, 63, 97, .78) 0%, rgba(44, 20, 34, .94) 100%); }
.hearts-rain { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.hearts-rain .fh {
  position: absolute;
  top: -12vh;
  left: var(--x);
  width: var(--s);
  height: var(--s);
  animation: fall var(--d) linear var(--delay) infinite;
  opacity: .92;
}
.hearts-rain .fh i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--c);
  clip-path: polygon(50% 100%, 0 45%, 6% 20%, 25% 5%, 50% 20%, 75% 5%, 94% 20%, 100% 45%);
  animation: sway var(--sd) ease-in-out infinite alternate;
}
.vault-wrap { padding-top: 48px; }
.letter {
  position: relative;
  max-width: 640px;
  margin: 18px auto 0;
  padding: 36px 34px 30px;
  background-color: #fff9ec;
  background-image: repeating-linear-gradient(rgba(90, 58, 34, .14) 0 1px, transparent 1px 34px);
  background-position: 0 112px;
  border: var(--outline);
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
  transform: rotate(-1deg);
}
.letter.no-title { background-position: 0 68px; }
.tape {
  position: absolute;
  top: -15px;
  left: 50%;
  width: 130px;
  height: 32px;
  background: rgba(255, 214, 102, .78);
  border: 2px dashed rgba(90, 58, 34, .3);
  transform: translateX(-50%) rotate(2deg);
}
#vault-title { margin: 0 0 10px; font-size: 30px; font-weight: 700; color: var(--plum); line-height: 34px; }
.letter-body {
  min-height: 102px;
  font-family: var(--hand);
  font-size: 27px;
  line-height: 34px;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.letter-body .caret { display: inline-block; width: 2px; height: .9em; margin-left: 1px; background: var(--choc); vertical-align: -.12em; animation: blink 1s steps(2, start) infinite; }
.letter.done .caret { display: none; }
.photo-strip { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; max-width: 760px; margin: 28px auto 0; }
.polaroid {
  width: 150px;
  margin: 0;
  padding: 8px 8px 10px;
  background: #fff;
  border: 2px solid var(--choc);
  box-shadow: var(--shadow-soft);
  transform: rotate(var(--r, 0deg));
  animation: polaroidIn .6s cubic-bezier(.2, 1.4, .4, 1) both;
  animation-delay: var(--delay, 0s);
}
.polaroid img { display: block; width: 100%; height: 128px; object-fit: cover; object-position: 50% 15%; background: var(--sky); }
.polaroid figcaption { margin-top: 6px; font-family: var(--hand); font-size: 18px; font-weight: 600; text-align: center; color: var(--ink); min-height: 1.2em; }
.vault-actions { display: flex; justify-content: center; margin-top: 22px; }
@media (max-width: 600px) {
  .letter { padding: 30px 20px 22px; }
  .letter-body { font-size: 24px; line-height: 34px; }
  .polaroid { width: 128px; }
  .polaroid img { height: 108px; }
}

/* video (ui.openVideo): a portrait 9:16 player in a cream card */
#video { z-index: 46; }
#video .modal-close { width: 52px; height: 52px; }
.video-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  max-height: 100%;
  padding: 14px 16px 18px;
  background: var(--cream);
  border: var(--outline);
  border-radius: 26px;
  box-shadow: 0 6px 0 var(--choc), var(--shadow-soft);
  transform: scale(.92) translateY(24px);
  transition: transform .4s cubic-bezier(.2, 1.4, .4, 1);
}
#video.open .video-card { transform: none; }
.video-title { max-width: 100%; font-size: 22px; font-weight: 700; text-align: center; line-height: 1.15; }
.video-frame {
  position: relative;
  flex: none;
  height: min(calc(100vh - 250px - var(--sat) - var(--sab)), calc((100vw - 64px) * 16 / 9), 720px);
  height: min(calc(100dvh - 250px - var(--sat) - var(--sab)), calc((100vw - 64px) * 16 / 9), 720px);
  aspect-ratio: 9 / 16;
  border: var(--outline);
  border-radius: 18px;
  overflow: hidden;
  background: #1b1b1b;
}
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-note { position: absolute; inset: 0; display: grid; place-items: center; padding: 18px; color: var(--cream); font-size: 17px; font-weight: 600; text-align: center; }
.video-caption { max-width: min(80vw, 380px); font-family: var(--hand); font-size: 22px; font-weight: 600; line-height: 1.15; text-align: center; }
@media (max-height: 480px) {
  .video-card { flex-direction: row; gap: 14px; padding: 10px 14px; }
  .video-title, .video-caption { display: none; }
  .video-frame { height: calc(100vh - 60px - var(--sat) - var(--sab)); height: calc(100dvh - 60px - var(--sat) - var(--sab)); }
}

/* ---------- start screen ---------- */
#start {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  background: linear-gradient(180deg, #8fd0ff 0%, #bfe6ff 48%, #fff6e5 100%);
  overflow: hidden auto;
  touch-action: pan-y;
  transition: opacity .75s ease, visibility .75s;
}
#start.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.float-shapes { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.shape {
  position: absolute;
  left: var(--x);
  bottom: -14vh;
  width: var(--s);
  height: var(--s);
  opacity: .85;
  animation: floatUp var(--d) linear var(--delay) infinite;
  will-change: transform;
}
.shape.heart { background: var(--c); clip-path: polygon(50% 100%, 0 45%, 6% 20%, 25% 5%, 50% 20%, 75% 5%, 94% 20%, 100% 45%); }
.shape.tri { background: var(--c); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.shape.gem { background: var(--c); clip-path: polygon(50% 0, 100% 40%, 80% 100%, 20% 100%, 0 40%); }
.shape.ball {
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 60%, #fff6e5 0 9%, transparent 10%),
    radial-gradient(circle at 66% 34%, #fff6e5 0 8%, transparent 9%),
    radial-gradient(circle at 62% 74%, #fff6e5 0 7%, transparent 8%),
    radial-gradient(circle at 36% 30%, #8a5a3a, #5a3a22 62%);
  box-shadow: inset -3px -4px 0 rgba(0, 0, 0, .18);
}
.shape.cloud { height: calc(var(--s) * .55); background: #fff; border-radius: 999px; opacity: .9; }
.shape.cloud::before, .shape.cloud::after {
  content: '';
  position: absolute;
  bottom: 30%;
  background: #fff;
  border-radius: 50%;
}
.shape.cloud::before { left: 18%; width: 45%; height: 110%; }
.shape.cloud::after { left: 48%; width: 38%; height: 85%; }
.start-card {
  position: relative;
  z-index: 1;   /* over the floating shapes */
  width: 100%;
  max-width: 680px;
  text-align: center;
}
.title-top {
  margin: 0 0 2px;
  font-family: var(--hand);
  font-size: clamp(30px, 6.5vw, 48px);
  font-weight: 700;
  color: var(--choc);
  transform: rotate(-3deg);
}
.title-main {
  margin: 0;
  font-size: clamp(56px, 14vw, 118px);
  font-weight: 700;
  line-height: .95;
  letter-spacing: 1px;
  color: #fff;
  -webkit-text-stroke: 3px var(--choc);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--choc), 0 12px 24px rgba(59, 35, 20, .25);
}
.title-main span { display: inline-block; white-space: pre; animation: bounceLetter 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * 95ms); }
.title-main span:nth-child(5n+1) { color: var(--pink); }
.title-main span:nth-child(5n+2) { color: var(--mint); }
.title-main span:nth-child(5n+3) { color: var(--sun); }
.title-main span:nth-child(5n+4) { color: var(--sky); }
.title-main span:nth-child(5n+5) { color: #fff; }
.subtitle { margin: 14px 0 22px; font-size: clamp(16px, 3vw, 22px); font-weight: 500; color: var(--choc); }
.loading { width: min(100%, 380px); max-height: 120px; margin: 0 auto 16px; overflow: hidden; transition: opacity .45s ease, max-height .5s ease .1s, margin .5s ease .1s; }
.loading.done { opacity: 0; max-height: 0; margin-bottom: 0; }
.loading-bar { height: 24px; border: var(--outline); border-radius: 999px; background: #fff; overflow: hidden; box-shadow: 0 4px 0 var(--choc); }
.loading-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: repeating-linear-gradient(135deg, var(--pink) 0 14px, var(--pink-2) 14px 28px);
  background-size: 40px 40px;
  animation: stripes 1s linear infinite;
  transition: width .35s ease;
}
.loading-label { margin-top: 8px; min-height: 1.3em; font-size: 15px; font-weight: 600; color: var(--choc); }
.loading-quip { min-height: 1.25em; font-family: var(--hand); font-size: 19px; color: var(--muted); }
.btn-start {
  min-height: 66px;
  padding: 16px 44px;
  border: var(--outline);
  border-radius: 999px;
  background: var(--pink);
  color: var(--ink);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: .5px;
  box-shadow: 0 8px 0 var(--choc), 0 14px 30px rgba(59, 35, 20, .25);
  transition: transform .1s, box-shadow .1s, background .3s, color .3s;
  animation: breathe 2.2s ease-in-out infinite;
}
.btn-start:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--choc); }
.btn-start:disabled { background: #efe4cf; color: var(--muted); animation: none; cursor: default; box-shadow: 0 6px 0 var(--choc); }
.ctrl { display: inline-flex; align-items: center; gap: 10px; }
.ctrl .keys { display: inline-flex; gap: 3px; flex: none; }
.ctrl svg { width: 34px; height: 34px; flex: none; }
.confirm {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 14px;
  background: #fff;
  border: var(--outline);
  border-radius: 16px;
  font-weight: 600;
  box-shadow: 0 4px 0 var(--choc);
}
.start-error {
  display: none;
  margin: 12px auto 0;
  max-width: 520px;
  padding: 8px 12px;
  background: #fff;
  border: 2px solid #b3261e;
  border-radius: 12px;
  color: #b3261e;
  font-weight: 600;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.start-error.show { display: block; }
@media (max-height: 560px) {
  #start { justify-content: flex-start; }
  .title-top { font-size: 26px; }
  .title-main { font-size: clamp(44px, 9vw, 64px); text-shadow: 0 4px 0 var(--choc); }
  .subtitle { margin: 6px 0 12px; font-size: 15px; }
  .loading { margin-bottom: 10px; }
  .loading-quip { display: none; }
  .btn-start { min-height: 54px; padding: 10px 30px; font-size: 22px; }
}
@media (max-height: 480px) {
  #minimap-wrap { width: 92px; height: 92px; border-radius: 22px; }
  .hud-right { top: calc(66px + var(--sat)); }
  #toasts { top: calc(96px + var(--sat)); }
  #objective { font-size: 15px; padding: 4px 12px 4px 6px; }
  .obj-pin { width: 26px; height: 26px; }
  .vs-dot, .vs-lock { width: 26px; height: 26px; }
  .pill { font-size: 18px; padding: 4px 12px 4px 6px; }
  .bliss-icon { width: 28px; height: 28px; }
  .hud-btn { width: 46px; height: 46px; border-radius: 14px; }
  .hud-btn svg { width: 30px; height: 30px; }
  #btn-companion img { width: 34px; height: 34px; }
  .dlg-card { min-height: 100px; padding-top: 12px; padding-bottom: 14px; }
  .dlg-portrait { width: 84px; height: 92px; margin-top: -36px; }
  .dlg-text { font-size: 18px; min-height: 2.2em; }
  #banner { top: calc(8% + var(--sat)); }
  /* landscape phone: the banner sits high, so toasts move to the free bottom-centre lane (joystick left, TALK/JUMP right) */
  body.touch #toasts { top: auto; bottom: calc(14px + var(--sab)); flex-direction: column-reverse; max-width: min(60vw, 460px); gap: 6px; }
  body.touch .toast { font-size: 14px; padding: 5px 12px 5px 8px; gap: 8px; }
  body.touch .toast-icon, body.touch .toast-icon svg { width: 22px; height: 22px; font-size: 17px; }
  .banner-card { padding: 10px 40px 12px; }
  .banner-title { font-size: 34px; }
  .banner-sub { font-size: 20px; }
  .modal-body { padding-top: 10px; }
  .modal-close { width: 44px; height: 44px; }
  #interact-wrap { margin-bottom: 20px; }
  body.touch #companion-bubble { bottom: calc(96px + var(--sab)); left: calc(168px + var(--sal)); }

  #btn-interact { width: 72px; height: 72px; }
  #btn-jump { width: 64px; height: 64px; }
  /* landscape phone: a smaller stick, closer to the corner */
  :root { --joy-size: 112px; --knob-size: 50px; --joy-gap-x: 24px; --joy-gap-y: 18px; }
}



/* ---------- top-right corner: sound + settings (always visible; above the start screen while it is up) ---------- */
#corner {
  position: fixed;
  top: calc(12px + var(--sat));
  right: calc(12px + var(--sar));
  z-index: 13;
  display: flex;
  gap: 8px;
  transition: opacity .5s ease;
}
body.start-on #corner { z-index: 51; }
body.start-on #btn-mute { display: none; }
body.letter-open #corner, body.ending-on:not(.epilogue) #corner { opacity: 0; visibility: hidden; pointer-events: none; }
#btn-settings svg { transition: transform .5s cubic-bezier(.2, 1.4, .4, 1); }
#btn-settings:active svg { transform: rotate(60deg); }

/* ---------- top centre: objective line + Vault strip ---------- */
#topstack {
  position: absolute;
  left: 50%;
  top: calc(12px + var(--sat));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(460px, calc(100vw - 380px - var(--sal) - var(--sar)));
  transition: top .6s ease;
}
body.skyline-on #topstack { top: calc(68px + var(--sat)); }
#objective {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 16px 6px 8px;
  background: var(--cream);
  border: var(--outline);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--choc);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.15;
  color: var(--ink);
}
#objective.obj-pop { animation: objPop .6s cubic-bezier(.2, 1.6, .4, 1); }
.obj-pin {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--choc);
  transition: transform .25s ease-out, opacity .4s;
}
.obj-pin svg { width: 20px; height: 20px; }
.obj-pin.near { opacity: .45; }
.obj-text { min-width: 0; overflow-wrap: anywhere; }
.obj-progress {
  flex: none;
  padding: 2px 8px;
  background: var(--mint);
  border: 2px solid var(--choc);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}
#vault-strip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  background: rgba(255, 246, 229, .92);
  border: var(--outline);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--choc);
  touch-action: manipulation;
}
#vault-strip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--choc); }
.vs-dots { display: inline-flex; gap: 5px; }
.vs-dot {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px dashed rgba(90, 58, 34, .45);
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #fff;
}
.vs-dot svg { width: 34px; height: 24px; flex: none; filter: grayscale(.75); opacity: .42; }
.vs-dot.on { border: 2.5px solid var(--choc); }
.vs-dot.on svg { filter: none; opacity: 1; }
.vs-check {
  position: absolute;
  right: -1px;
  bottom: -2px;
  display: none;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--mint-2);
  border-radius: 50%;
  width: 14px;
  height: 14px;
  line-height: 14px;
  text-align: center;
}
.vs-dot.on .vs-check { display: block; }
.vs-dot.vs-pop { animation: pop .7s cubic-bezier(.2, 1.7, .4, 1); }
.vs-arrow { font-size: 22px; font-weight: 700; color: var(--muted); line-height: 1; margin: 0 -1px; }
.vs-lock { width: 30px; height: 30px; display: grid; place-items: center; }
.vs-lock svg { width: 28px; height: 28px; overflow: visible; }
.vs-lock .shackle { transition: transform .6s cubic-bezier(.2, 1.6, .4, 1); transform-origin: 22px 15px; }
.vs-lock.open .shackle { transform: translateY(-3.5px) rotate(28deg); }
.vs-lock.vs-unlock { animation: unlock 1.2s ease 2; }
#vault-strip.complete { background: #fff1c9; }

/* ---------- the night's sky line ---------- */
#skyline {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(14px + var(--sat));
  z-index: 13;
  padding: 0 140px;
  text-align: center;
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(28px, 4.2vw, 44px);
  line-height: 1.1;
  color: #fff;
  text-shadow: 0 0 18px rgba(170, 160, 255, .55), 0 2px 8px rgba(15, 18, 48, .7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.6s ease;
}
#skyline.show { opacity: 1; }

/* ---------- reading card (signs, plaques, photo captions) ---------- */
#card {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  background: rgba(59, 35, 20, .32);
  pointer-events: auto;
  opacity: 0;
  transition: opacity .2s ease;
}
#card.open { opacity: 1; }
.card-paper {
  position: relative;
  width: min(100%, 600px);
  max-height: 100%;
  overflow-y: auto;
  padding: 24px 30px 18px;
  background-color: #fff9ec;
  background-image: radial-gradient(circle at 12% 10%, rgba(255, 183, 197, .18), transparent 40%);
  border: var(--outline);
  border-radius: 24px;
  box-shadow: 0 7px 0 var(--choc), var(--shadow-soft);
  text-align: center;
  transform: translateY(26px) scale(.95);
  transition: transform .32s cubic-bezier(.2, 1.4, .4, 1);
}
#card.open .card-paper { transform: none; }
.card-photo { margin: 0 auto 14px; }
.card-photo img {
  display: block;
  max-width: 100%;
  max-height: min(46vh, 420px);
  margin: 0 auto;
  border: 3px solid var(--choc);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 0 var(--choc);
  transform: rotate(-1.2deg);
}
.card-title { margin: 0 0 8px; font-size: 30px; font-weight: 700; line-height: 1.1; color: var(--plum); overflow-wrap: anywhere; }
.card-text { white-space: pre-wrap; font-size: 23px; font-weight: 500; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere; }
.card-text.in { animation: fadeUp .35s ease; }
.card-paper.short .card-text { font-size: 28px; }
.card-paper.long .card-text { font-size: 19px; text-align: left; }
.card-paper.has-photo .card-text { font-family: var(--hand); font-size: 27px; font-weight: 600; line-height: 1.2; }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; min-height: 22px; font-size: 14px; font-weight: 600; color: var(--muted); }
.card-cue { font-size: 22px; color: var(--choc); animation: blink 1s steps(2, start) infinite; }
@media (max-width: 640px) {
  .card-paper { padding: 18px 18px 14px; }
  .card-title { font-size: 25px; }
  .card-text { font-size: 19px; }
  .card-paper.short .card-text { font-size: 23px; }
  .card-paper.long .card-text { font-size: 17px; }
}

/* ---------- settings ---------- */
#settings { z-index: 55; }
.settings-wrap { width: min(100%, 560px); padding-top: 10px; }
.settings-card {
  position: relative;
  padding: 22px 24px 20px;
  background: var(--cream);
  border: var(--outline);
  border-radius: 26px;
  box-shadow: 0 7px 0 var(--choc), var(--shadow-soft);
}
.settings-card .modal-close { position: absolute; top: 12px; right: 12px; width: 46px; height: 46px; }
.settings-title { margin: 0 56px 14px 0; font-size: 30px; font-weight: 700; color: var(--plum); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 14px; border-bottom: 2px dashed rgba(90, 58, 34, .2); }
.set-label { font-size: 21px; font-weight: 600; }
.set-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 104px;
  height: 48px;
  padding: 0 14px;
  border: var(--outline);
  border-radius: 999px;
  background: #e8dcc8;
  box-shadow: 0 4px 0 var(--choc);
  font-weight: 700;
  font-size: 17px;
  transition: background .2s;
}
.set-toggle .knob { position: absolute; left: 5px; top: 5px; width: 32px; height: 32px; border-radius: 50%; background: #fff; border: 2px solid var(--choc); transition: transform .25s cubic-bezier(.2, 1.4, .4, 1); }
.set-toggle.on { background: var(--mint); justify-content: flex-start; }
.set-toggle.on .knob { transform: translateX(54px); }
.set-section { padding: 14px 0 6px; }
.set-section h3 { margin: 0 0 10px; font-size: 14px; letter-spacing: 2px; text-transform: uppercase; color: var(--plum); }
.set-controls { display: grid; gap: 10px; font-size: 18px; font-weight: 500; }
.set-actions { display: flex; flex-direction: column; gap: 12px; padding: 14px 0 4px; border-top: 2px dashed rgba(90, 58, 34, .2); }
.set-actions .btn { width: 100%; }
.btn-soft-danger { background: #ffe3e3; }
.set-confirm { display: flex; margin-top: 12px; text-align: center; }
.set-confirm-btns { display: inline-flex; gap: 10px; }
.set-done { display: flex; justify-content: center; margin-top: 16px; }
@media (max-width: 480px) {
  .settings-card { padding: 18px 16px 16px; }
  .set-controls { font-size: 16px; }
}

/* ---------- stand up (after the ending) ---------- */
#standup {
  position: fixed;
  left: 50%;
  bottom: calc(26px + var(--sab));
  z-index: 47;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 8px 26px 8px 10px;
  border: 3px solid rgba(90, 58, 34, .85);
  border-radius: 999px;
  background: rgba(255, 246, 229, .86);
  color: var(--choc);
  font-size: 22px;
  font-weight: 600;
  box-shadow: 0 4px 0 rgba(90, 58, 34, .35);
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 1.4s ease, transform 1.4s ease;
  touch-action: manipulation;
}
#standup.show { opacity: .8; transform: translate(-50%, 0); }
#standup.show.ready { opacity: 1; animation: standBreathe 2.6s ease-in-out infinite; }
#standup:disabled { cursor: default; }
.su-ring { width: 44px; height: 44px; transform: rotate(-90deg); flex: none; }
.su-track { fill: none; stroke: rgba(90, 58, 34, .18); stroke-width: 4; }
.su-fill { fill: none; stroke: var(--pink-2); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: 113.1; }
#standup.ready .su-fill { stroke: var(--mint-2); }

@keyframes objPop { 0% { transform: scale(.85); } 60% { transform: scale(1.06); } 100% { transform: none; } }
@keyframes unlock { 0%, 100% { transform: none; } 20% { transform: rotate(-12deg) scale(1.2); } 40% { transform: rotate(10deg) scale(1.25); } 60% { transform: rotate(-6deg) scale(1.15); } }

/* phones: the top lane belongs to the HUD columns; the objective + strip sit under the left column */
@media (max-width: 640px) {
  #topstack { left: calc(12px + var(--sal)); right: calc(12px + var(--sar)); top: calc(212px + var(--sat)); transform: none; width: auto; max-width: none; }
  body.skyline-on #topstack { top: calc(262px + var(--sat)); }
  #objective { font-size: 16px; }
  #skyline { top: calc(208px + var(--sat)); padding: 0 16px; }
  #toasts { top: calc(316px + var(--sat)); }
  #banner { top: calc(318px + var(--sat)); }
}
/* tablets / small laptops: a little less room between the columns */
@media (min-width: 641px) and (max-width: 900px) {
  #topstack { max-width: calc(100vw - 340px - var(--sal) - var(--sar)); }
  #objective { font-size: 17px; }
}

/* ---------- fatal panels ---------- */
.fatal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #8fd0ff, #fff6e5);
}
html.no-webgl #nowebgl, .fatal.show, .fatal-noscript { display: flex; }
.fatal-card {
  max-width: 460px;
  padding: 24px 28px;
  background: var(--cream);
  border: var(--outline);
  border-radius: 24px;
  box-shadow: var(--shadow-chunk);
  text-align: center;
}
.fatal-card h2 { margin: 0 0 8px; font-size: 26px; }
.fatal-card p { margin: 0; font-size: 16px; font-weight: 500; }

/* ---------- keyframes ---------- */
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.45) rotate(-10deg); } 100% { transform: scale(1); } }
@keyframes numpop { 0% { transform: scale(1); } 40% { transform: scale(1.5); color: var(--pink-2); } 100% { transform: scale(1); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(-14deg) scale(1.1); } 30% { transform: rotate(12deg) scale(1.12); } 45% { transform: rotate(-9deg) scale(1.08); } 60% { transform: rotate(6deg); } 75% { transform: rotate(-3deg); } }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(3deg); } }
@keyframes bannerIn { 0% { opacity: 0; transform: translateY(-26px) scale(.8); } 100% { opacity: 1; transform: none; } }
@keyframes bannerOut { 0% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-18px) scale(.95); } }
@keyframes letterPop { 0% { opacity: 0; transform: translateY(18px) scale(.4) rotate(-8deg); } 100% { opacity: 1; transform: none; } }
@keyframes fadeUp { 0% { opacity: 0; transform: translateY(8px); } 100% { opacity: 1; transform: none; } }
@keyframes toastIn { 0% { opacity: 0; transform: translateY(-24px) scale(.8); } 100% { opacity: 1; transform: none; } }
@keyframes toastOut { 0% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-14px) scale(.9); } }
@keyframes blink { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes portraitIn { 0% { transform: translateY(30px) scale(.6); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes slam { 0% { transform: rotate(var(--rot, -6deg)) scale(2.8); opacity: 0; } 55% { transform: rotate(var(--rot, -6deg)) scale(.92); opacity: .95; } 75% { transform: rotate(var(--rot, -6deg)) scale(1.05); } 100% { transform: rotate(var(--rot, -6deg)) scale(1); opacity: .92; } }
@keyframes shake { 0%, 100% { transform: translate(0, 0); } 20% { transform: translate(-5px, 2px) rotate(-.6deg); } 40% { transform: translate(5px, -2px) rotate(.6deg); } 60% { transform: translate(-3px, 1px); } 80% { transform: translate(3px, -1px); } }
@keyframes fall { 0% { transform: translateY(0) rotate(0); } 100% { transform: translateY(125vh) rotate(300deg); } }
@keyframes sway { 0% { transform: translateX(-18px); } 100% { transform: translateX(18px); } }
@keyframes floatUp { 0% { transform: translateY(0) rotate(0); } 100% { transform: translateY(-125vh) rotate(var(--spin, 180deg)); } }
@keyframes bounceLetter { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-7px) rotate(2deg); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.045); } }
/* the Stand up button breathes around its own centre (it is centred with a translate, which the scale must keep) */
@keyframes standBreathe { 0%, 100% { transform: translate(-50%, 0) scale(1); } 50% { transform: translate(-50%, 0) scale(1.045); } }
@keyframes stripes { 0% { background-position: 0 0; } 100% { background-position: 40px 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes hudPop { 0% { transform: scale(.1) rotate(-14deg); opacity: 0; } 60% { transform: scale(1.22) rotate(4deg); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes mmGlow { 0%, 100% { box-shadow: 0 4px 0 var(--choc), 0 0 0 0 rgba(255, 209, 102, 0); } 50% { box-shadow: 0 4px 0 var(--choc), 0 0 0 9px rgba(255, 209, 102, .9); } }
@keyframes polaroidIn { 0% { opacity: 0; transform: translateY(30px) rotate(var(--r, 0deg)) scale(.7); } 100% { opacity: 1; transform: rotate(var(--r, 0deg)); } }

@media (prefers-reduced-motion: reduce) {
  .shape, .hearts-rain .fh, .hearts-rain .fh i, .title-main span, .companion-face, .btn-start, #btn-interact.active, .loading-fill, .hud-pop, #standup.show.ready, .vs-lock.vs-unlock, #objective.obj-pop { animation: none !important; }
  .banner-title span { animation-duration: .01ms !important; animation-delay: 0s !important; }
  .polaroid { animation: none; opacity: 1; }
}

/* ═══════════ the reveal over the bench ("I'm coming to Slovenia.", FINAL PASS §4): bigger, grander, slower ═══════════
   ending.js builds #ending-reveal (.r1 the big line, .r2 the date) and toggles its classes on its own clock:
   .r1.in (zooms in, slow), .r1.shine (the first shine), .r1.shine2 (a second shine a few seconds later),
   .r1.grand (a slow, tiny breathing while it holds), #ending-reveal.out (fades). The selectors carry `html body` so these
   rules win over the style ending.js injects for itself. */
html body #ending-reveal { gap: clamp(10px, 2.2vh, 24px); transition: opacity 2s ease; }
html body #ending-reveal::before { width: min(1400px, 140vw); height: 92%;
  background: radial-gradient(closest-side, rgba(74, 30, 66, .26), rgba(74, 30, 66, .08) 55%, rgba(74, 30, 66, 0)); }
html body #ending-reveal .r1 {
  font-size: clamp(44px, 7.4vw, 100px);   /* ~100 px on a desktop, one line on an iPad (either way up) */
  max-width: none; white-space: nowrap; letter-spacing: .01em;
  text-shadow: 0 0 18px rgba(255, 183, 197, .7), 0 0 60px rgba(255, 110, 150, .45), 0 4px 22px rgba(74, 30, 66, .6), 0 1px 3px rgba(74, 30, 66, .75);
  transform: scale(2.1); filter: blur(10px);
  transition: opacity 1.6s ease, transform 3.2s cubic-bezier(.12, .8, .22, 1), filter 2.2s ease;
}
html body #ending-reveal .r1.in { opacity: 1; transform: none; filter: none; }
html body #ending-reveal .r1.in.grand { animation: reveal-breathe 5.5s ease-in-out infinite; }
html body #ending-reveal .r1.shine2::after { animation: ending-shine-2 1.9s ease-in-out forwards; }
html body #ending-reveal .r2 { font-size: clamp(24px, 3.4vw, 44px); letter-spacing: .03em; transition: opacity 1.6s ease, transform 1.8s ease; }
@keyframes ending-shine-2 { 0% { background-position: 100% 0; opacity: 1; } 88% { opacity: 1; } 100% { background-position: 0% 0; opacity: 0; } }
@keyframes reveal-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }
/* a phone held upright: two balanced lines instead of one */
@media (max-width: 600px) {
  html body #ending-reveal .r1 { white-space: normal; max-width: 8.5em; font-size: clamp(40px, 12vw, 64px); text-wrap: balance; }
}
@media (prefers-reduced-motion: reduce) {
  html body #ending-reveal .r1 { transform: none; filter: none; transition: opacity 1.2s ease; }
  html body #ending-reveal .r1.in.grand { animation: none; }
  html body #ending-reveal .r1.shine2::after { display: none; }
}
