/* Type: PP Editorial New for latin (names, dates, taglines) and SVN-Gilroy for body — both from
   Long & Hạnh's own kit. Vietnamese headings use Newsreader, an editorial serif close to PP Editorial
   that carries the full Vietnamese set (PP Editorial lacks it). UTM Diana is kept for the logo only. */
@font-face { font-family: 'Editorial'; src: url('assets/fonts/PPEditorialNew-Regular.otf') format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Editorial'; src: url('assets/fonts/PPEditorialNew-UltralightItalic.otf') format('opentype'); font-weight: 200; font-style: italic; font-display: swap; }
@font-face { font-family: 'Gilroy'; src: url('assets/fonts/SVN-Gilroy-Regular.otf') format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Gilroy'; src: url('assets/fonts/SVN-Gilroy-Medium.otf') format('opentype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Gilroy'; src: url('assets/fonts/SVN-Gilroy-Italic.otf') format('opentype'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Gilroy'; src: url('assets/fonts/SVN-Gilroy-Bold.otf') format('opentype'); font-weight: 700; font-display: swap; }

:root {
  --coral: #ec6248;
  --cream: #f6ede3;
  --muted: rgba(246, 237, 227, 0.64);
  --line: rgba(246, 237, 227, 0.18);
  --glass: rgba(14, 9, 9, 0.68);
  --display: 'Newsreader', 'Times New Roman', serif;
  --latin: 'Editorial', 'Times New Roman', serif;
  --body: 'Gilroy', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--cream);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }

.btn {
  appearance: none;
  border: 1px solid var(--coral);
  background: var(--coral);
  color: #fff;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, opacity 0.2s, color 0.2s;
}
.btn:hover:not(:disabled) { background: #f0745c; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--cream); }
.btn-ghost:hover:not(:disabled) { background: rgba(246, 237, 227, 0.1); }
.btn-lg { padding: 14px 36px; font-size: 16px; }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 20px 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s 0.6s;
}
body.entered .hud { opacity: 1; }
.hud > * { pointer-events: auto; }
.hud-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hud-mono { width: 44px; height: auto; opacity: 0.92; }
.hud-actions { display: flex; gap: 8px; flex-shrink: 0; }
.hud-actions .btn-ghost { background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#btn-music.muted { opacity: 0.55; }

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 62px);
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--glass);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.8s;
  pointer-events: none;
}
body.entered .hint.show { opacity: 1; }

/* the dot in the middle while the mouse is held by the game: a click acts on what's under it */
.crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.45), 0 0 10px rgba(255, 220, 190, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
body.locked .crosshair { opacity: 0.85; }
body.locked .hud { opacity: 0.55; }

/* the touch joystick, appearing wherever the left thumb lands */
.stick {
  position: fixed;
  width: 132px;
  height: 132px;
  margin: -66px 0 0 -66px;
  border-radius: 50%;
  border: 1.5px solid rgba(246, 237, 227, 0.35);
  background: rgba(20, 14, 12, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.stick.on { opacity: 1; }
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(246, 237, 227, 0.75);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

/* ---------- card ---------- */
.card {
  position: fixed;
  left: 28px;
  bottom: 28px;
  width: min(390px, calc(100vw - 32px));
  padding: 24px 26px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 0.45s, transform 0.45s;
}
.card.open { opacity: 1; transform: none; pointer-events: auto; }
.card-close {
  position: absolute; top: 10px; right: 12px;
  width: 34px; height: 34px;
  border: 0; background: transparent;
  font-size: 24px; line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.card-close:hover { color: var(--cream); }
.card-label { margin: 0 0 6px; font-size: 12px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--coral); }
.card-title { margin: 0 0 10px; font-family: var(--display); font-weight: 300; font-size: 34px; line-height: 1.12; letter-spacing: -0.01em; }
.card[data-kind='finale'] .card-title { font-size: 44px; }
.card-text { margin: 0 0 16px; font-size: 15px; line-height: 1.65; color: var(--muted); }
.card[data-kind='chapter'] .card-text, .card[data-kind='finale'] .card-text { font-style: italic; }
.card-view { margin-bottom: 16px; }

/* ---------- the keepsakes viewer ---------- */
body.viewer-open .hud, body.viewer-open .nav, body.viewer-open .card, body.viewer-open .hint { opacity: 0; pointer-events: none; }
.viewer {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 20, 14, 0.82), rgba(6, 3, 3, 0.95) 70%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.5s ease;
}
.viewer.open { opacity: 1; }
.viewer[hidden] { display: none; }
.v-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) 20px 10px;
}
.v-mono { width: 40px; opacity: 0.9; }
.v-tabs { flex: 1; display: flex; justify-content: center; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.v-tab {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
}
.v-tab:hover { color: var(--cream); }
.v-tab.active { background: rgba(236, 98, 72, 0.22); color: var(--cream); }
.v-tab.locked { opacity: 0.45; cursor: default; }
.v-tab.locked:hover { color: var(--muted); }
.v-pane {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 20px max(20px, env(safe-area-inset-bottom));
}
.v-pane.active { display: flex; animation: paneIn 0.6s ease both; }
@keyframes paneIn { from { opacity: 0; transform: translateY(12px) scale(0.985); } to { opacity: 1; transform: none; } }

/* the book */
.book-chapter { margin: 0; font-family: var(--display); font-weight: 300; font-style: italic; font-size: 24px; color: var(--cream); min-height: 1.3em; text-align: center; }
.book {
  position: relative;
  width: min(94vw, calc((100vh - 250px) * 2.8));
  aspect-ratio: 2.8;
  perspective: 2600px;
  cursor: pointer;
  user-select: none;
  touch-action: pan-y;
  transition: opacity 0.25s, transform 0.9s cubic-bezier(0.45, 0.05, 0.25, 1);
  filter: drop-shadow(0 24px 50px rgba(0, 0, 0, 0.55));
}
.book.fading { opacity: 0; }
/* closed: only the cover (the right half) shows, so slide the book to centre it */
.book.closed { transform: translateX(-25%); }
.page, .flipper .face {
  position: absolute;
  top: 0;
  bottom: 0;
  background-color: #f4efe8;
  background-repeat: no-repeat;
}
.page { width: 50%; }
.pl { left: 0; border-radius: 3px 0 0 3px; }
.pr { left: 50%; border-radius: 0 3px 3px 0; }
.page.blank { background-color: transparent; }
.book.closed .pl { visibility: hidden; }
.book.closed .pr { border-radius: 3px; }
/* the gutter: a soft fold where the pages meet */
.book:not(.single):not(.closed)::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 7%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.16) 45%, rgba(0, 0, 0, 0.22) 50%, rgba(0, 0, 0, 0.16) 55%, transparent);
  pointer-events: none;
  z-index: 3;
}
.flipper {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.45, 0.05, 0.25, 1);
  z-index: 4;
}
.flipper[hidden] { display: none; }
.flipper.right { left: 50%; transform-origin: left center; }
.flipper.left { left: 0; transform-origin: right center; }
.flipper .face { inset: 0; width: auto; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flipper .back { transform: rotateY(180deg); }
.flipper .face.blank { background-color: #efe8df; }
/* the inside of the cover */
.page.endpaper, .face.endpaper {
  background: radial-gradient(ellipse at 50% 45%, #f6f0e7, #e9dfd1);
  display: grid;
  place-items: center;
}
.page.endpaper::before, .face.endpaper::before {
  content: 'Long & Hạnh · 08.11.2025';
  font-family: var(--latin);
  font-style: italic;
  font-weight: 200;
  font-size: clamp(11px, 1.6vw, 22px);
  letter-spacing: 0.06em;
  color: #a8907a;
}
/* light sliding across the turning page */
.flipper .face::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 18%, transparent 80%, rgba(255, 255, 255, 0.08));
  pointer-events: none;
}
.book-bar { display: flex; align-items: center; gap: 14px; }
.book-bar .btn { width: 44px; height: 44px; padding: 0; font-size: 18px; }
.book-bar .btn:disabled { opacity: 0.25; }
.book-page { min-width: 150px; text-align: center; font-family: var(--latin); font-size: 16px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 900px; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s;
}
.chip:hover { color: var(--cream); }
.chip.active { border-color: var(--coral); color: var(--cream); background: rgba(236, 98, 72, 0.15); }
.book-rotate { margin: 0; font-size: 13px; color: var(--muted); }
.book-rotate[hidden] { display: none; }
/* short landscape screens (a phone turned sideways): give the book all the height there is */
@media (max-height: 520px) {
  .v-head { padding-top: 8px; padding-bottom: 4px; }
  .v-pane { gap: 8px; padding-bottom: 8px; }
  .book { width: min(94vw, calc((100vh - 120px) * 2.8)); }
  .book-chapter { font-size: 17px; }
  .chips { display: none; }
  .book-bar .btn { width: 36px; height: 36px; }
}

/* wedding photos */
.w-grid {
  width: min(1100px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 4px;
}
/* the columns live inside the scroller: on the scroller itself a height limit makes them overflow sideways */
.w-cols { columns: 2 320px; column-gap: 14px; }
.shot {
  display: block;
  width: 100%;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  cursor: zoom-in;
  background: #1a1110;
  break-inside: avoid;
}
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.6s ease; }
.shot:hover img { transform: scale(1.03); }
.shot[hidden] { display: none; }
/* the honeymoon: a chip for each city above a denser grid, since there are nearly five hundred */
#hm-chips { margin: 0 0 12px; }
#hm-grid { columns: 4 200px; column-gap: 10px; }
#hm-grid .shot { margin-bottom: 10px; }
/* the wedding day: nearly a thousand photos, so the same denser grid under a chip for each part of the day */
#w-chips { margin: 0 0 12px; }
#w-grid { columns: 4 200px; column-gap: 10px; }
#w-grid .shot { margin-bottom: 10px; }
.empty { color: var(--muted); font-style: italic; }
.zoom {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: rgba(4, 2, 2, 0.94);
}
.zoom[hidden] { display: none; }
.zoom img {
  max-width: 92vw;
  max-height: 84vh;
  border-radius: 4px;
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 0.4s ease, transform 0.6s ease;
}
.zoom.open img { opacity: 1; transform: none; }
.zoom .btn { position: absolute; }
.zoom-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.zoom-next { right: 16px; top: 50%; transform: translateY(-50%); }
.zoom-close { top: max(16px, env(safe-area-inset-top)); right: 16px; }

/* invitation */
.inv-strip {
  display: flex;
  gap: 22px;
  width: 100%;
  max-width: 1300px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding: 10px max(20px, 8vw);
  align-items: center;
}
.inv-strip::-webkit-scrollbar { display: none; }
.inv-card {
  flex: 0 0 auto;
  height: min(64vh, 520px);
  margin: 0;
  scroll-snap-align: center;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.inv-card img { height: 100%; width: 100%; object-fit: cover; display: block; }

/* ---------- stars, toast, map, surprise ---------- */
.btn-stars { font-family: var(--latin); letter-spacing: 0.04em; }
.btn-stars.done { border-color: var(--coral); color: #fff; background: rgba(236, 98, 72, 0.35); }
.toast {
  position: fixed;
  left: 50%;
  top: calc(max(16px, env(safe-area-inset-top)) + 58px);
  transform: translate(-50%, -8px);
  max-width: min(520px, calc(100vw - 32px));
  margin: 0;
  padding: 10px 18px;
  border-radius: 14px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s, transform 0.4s;
  z-index: 4;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.mapview {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 2, 2, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.35s;
}
.mapview.open { opacity: 1; }
.mapview[hidden] { display: none; }
.map-card {
  width: min(620px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 20px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(14, 9, 9, 0.85);
}
.map-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.map-kicker { margin: 0; font-family: var(--display); font-weight: 300; font-size: 26px; }
.map-count { margin: 2px 0 0; font-family: var(--latin); color: var(--coral); font-size: 15px; }
.map-svg { width: 100%; height: min(62vh, 520px); }
.map-svg.teleport { cursor: crosshair; }
.map-foot { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }
.m-bridge { stroke: #ffc890; stroke-width: 1.4; stroke-dasharray: 2 2; opacity: 0.8; }
.m-runway { stroke: rgba(246, 237, 227, 0.35); stroke-width: 4; }
.m-sun { fill: #ec6248; opacity: 0.85; }
.m-island[role="button"] { cursor: pointer; }
.m-island circle { fill: rgba(246, 237, 227, 0.05); stroke: rgba(246, 237, 227, 0.35); stroke-width: 0.6; transition: fill 0.3s, stroke 0.3s; }
.m-island[role="button"]:hover circle, .m-island:focus circle { fill: rgba(236, 98, 72, 0.18); stroke: var(--coral); }
.m-island:focus { outline: none; }
.m-name { fill: var(--cream); font-family: var(--display); font-size: 6px; text-anchor: middle; }
.m-sub { fill: var(--muted); font-family: var(--body); font-size: 3.4px; text-anchor: middle; }
.m-me { fill: #fff; stroke: var(--coral); stroke-width: 1; }
.m-star { fill: #ffd79a; font-size: 5px; text-anchor: middle; }

.surprise {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at center, rgba(40, 18, 12, 0.85), rgba(3, 2, 2, 0.97) 70%);
  opacity: 0;
  transition: opacity 1.2s;
}
.surprise.open { opacity: 1; }
.surprise[hidden] { display: none; }
.sp-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; width: min(900px, 100%); text-align: center; }
.sp-mono { width: 72px; }
.sp-title { margin: 0; font-family: var(--display); font-weight: 300; font-style: italic; font-size: clamp(32px, 6vw, 52px); }
.sp-video { width: 100%; max-height: 64vh; border-radius: 10px; background: #000; box-shadow: 0 30px 80px rgba(236, 98, 72, 0.2); }
.sp-video[hidden] { display: none; }
.sp-wait { margin: 0; color: var(--muted); font-style: italic; }

/* ---------- intro, in the invitation's coral ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--coral);
  color: #fff;
  transition: opacity 1.6s, visibility 1.6s;
}
body.entered .intro { opacity: 0; visibility: hidden; }
.intro-inner { text-align: center; max-width: 620px; }
.intro-sun { width: 132px; height: auto; margin-bottom: 26px; animation: rise 2.4s ease-out both; }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
.intro-kicker { margin: 0 0 14px; font-family: var(--latin); font-size: 18px; letter-spacing: 0.24em; }
/* set like the invitation's name page: "Phi Long — and — Hong Hanh" */
.intro-names { margin: 0; font-family: var(--latin); font-weight: 400; font-size: clamp(46px, 10vw, 84px); line-height: 1; }
.intro-names span { display: block; }
.intro-names em { display: block; font-style: italic; font-weight: 200; font-size: 0.38em; margin: 0.15em 0 0.1em; }
.intro-dates { margin: 18px 0 34px; font-family: var(--latin); font-size: 22px; letter-spacing: 0.08em; }
.intro .btn { background: #fff; border-color: #fff; color: var(--coral); }
.intro .btn:hover:not(:disabled) { background: var(--cream); }
.intro .btn[hidden], .intro-choose[hidden] { display: none; }
/* whom to walk as: two buttons side by side, like the two names above */
.intro-ask { margin: 0 0 14px; font-family: var(--latin); font-style: italic; font-size: 20px; }
.intro-who { display: flex; justify-content: center; gap: 14px; }
.intro-who .btn { min-width: 132px; font-family: var(--latin); font-size: 22px; }
.intro-tag { margin: 30px 0 0; font-family: var(--latin); font-style: italic; font-weight: 200; font-size: 20px; opacity: 0.9; }

@media (max-width: 720px) {
  .hud { padding-left: 14px; padding-right: 14px; }
  .hud-mono { width: 34px; }
  .hud-actions .btn { padding: 7px 13px; font-size: 13px; }
  .card {
    left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom));
    width: auto; max-height: 42vh; overflow-y: auto;
    padding: 18px 20px 14px;
  }
  .card-title { font-size: 28px; }
  .card[data-kind='finale'] .card-title { font-size: 34px; }
  .card-text { font-size: 14px; margin-bottom: 12px; }
  #btn-pubs, #btn-map, #btn-stars { padding-left: 10px; padding-right: 10px; }
  .hud-actions { gap: 5px; }
  .v-head { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .v-mono { display: none; }
  .v-tab { padding: 7px 10px; font-size: 13px; }
  .v-pane { padding-left: 12px; padding-right: 12px; }
  .book-chapter { font-size: 20px; }
  .chips { gap: 4px; }
  .chip { padding: 5px 9px; font-size: 12px; }
  .inv-card { height: min(58vh, 460px); }
}

/* ---------- mini-games (js/games) ---------- */
.m-star-todo { fill: rgba(255, 215, 154, 0.35); }
.g-prompt {
  position: fixed;
  left: 50%;
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + 64px);
  transform: translateX(-50%);
  z-index: 5;
  box-shadow: 0 10px 30px rgba(236, 98, 72, 0.35);
  animation: g-pulse 1.6s ease-in-out infinite;
}
.g-prompt kbd {
  font: inherit;
  font-size: 12px;
  padding: 1px 7px;
  margin-right: 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.22);
}
.g-done { opacity: 0.75; font-size: 12px; margin-left: 6px; }
@keyframes g-pulse { 50% { transform: translateX(-50%) scale(1.04); } }
body.gaming .hud, body.gaming .hint, body.gaming .card, body.gaming .crosshair { opacity: 0; pointer-events: none; }
body.gaming #scene { cursor: crosshair; }

.g-fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.35s; z-index: 9; }
.g-fade.on { opacity: 1; }

.game { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.game > * { pointer-events: auto; }
.g-top {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  padding: 12px 18px 12px;
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  text-align: center;
  pointer-events: none;
}
.g-place { margin: 0; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--coral); }
.g-title { margin: 2px 0 4px; font-family: var(--display); font-weight: 400; font-size: 26px; }
.g-how { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.g-status { margin: 8px 0 0; font-size: 15px; font-variant-numeric: tabular-nums; }
.g-status:empty { display: none; }
.g-meter { display: inline-block; vertical-align: middle; width: 90px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.15); overflow: hidden; margin: 0 4px; }
.g-meter i { display: block; height: 100%; background: var(--muted); transition: width 0.15s; }
.g-meter i.ok { background: #7ad88a; }
.g-meter.fog i { background: #e6eaee; }
.g-exit { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); }
.g-pad {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
}
.claw-pad { display: flex; align-items: center; gap: 10px; }
.claw-ud { display: flex; flex-direction: column; gap: 8px; }
.g-key {
  width: 54px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(8px);
  font-size: 18px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}
.g-key:active { background: rgba(236, 98, 72, 0.5); }
.g-grab { padding: 16px 26px; font-size: 18px; font-weight: 700; margin-left: 8px; touch-action: none; }
.g-shutter { padding: 14px 26px; font-size: 17px; }
.g-pad.ready .g-shutter, .ready > .g-shutter { box-shadow: 0 0 0 4px rgba(122, 216, 138, 0.7); }

/* Fansipan's beat: a ring closing on a dot */
.beat { position: relative; width: 110px; height: 110px; display: grid; place-items: center; cursor: pointer; touch-action: none; }
.beat-core { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--coral); font-size: 22px; color: #fff; }
.beat-ring { position: absolute; width: 58px; height: 58px; border-radius: 50%; border: 3px solid #fff; opacity: 0.85; }
.g-judge { position: absolute; bottom: 118px; left: 50%; transform: translateX(-50%); margin: 0; font-weight: 700; font-size: 20px; white-space: nowrap; animation: g-rise 0.6s ease-out forwards; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); }
.g-judge.good { color: #ffe08a; }
.g-judge.ok { color: #fff; }
.g-judge.bad { color: #ff8a7a; }
@keyframes g-rise { to { transform: translate(-50%, -26px); opacity: 0; } }
.g-mist { position: fixed; inset: 0; pointer-events: none; z-index: 4; background: radial-gradient(ellipse at center, rgba(230, 234, 238, 0.55), rgba(230, 234, 238, 1) 75%); opacity: 0; }

/* the Bund's viewfinder */
.g-finder {
  position: fixed;
  z-index: 4;
  pointer-events: none;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28);
}
.g-finder::before, .g-finder::after { content: ''; position: absolute; left: 50%; top: 50%; background: rgba(255, 255, 255, 0.8); }
.g-finder::before { width: 18px; height: 2px; transform: translate(-50%, -50%); }
.g-finder::after { width: 2px; height: 18px; transform: translate(-50%, -50%); }
.g-finder.flash { background: rgba(255, 255, 255, 0.85); }

/* snow on the lens */
.g-splat { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }

.g-bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.g-bubble {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  padding: 7px 13px;
  border-radius: 14px;
  background: #fff;
  color: #2a1d17;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.g-bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 6px solid transparent; border-bottom: 0; border-top-color: #fff; }

/* the result: a Polaroid when there's a picture, and what next */
.g-result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  text-align: center;
  z-index: 6;
}
.g-photo {
  margin: 0;
  padding: 12px 12px 0;
  background: #fbf8f2;
  border-radius: 4px;
  transform: rotate(-3deg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  max-width: min(420px, 86vw);
  animation: g-drop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.g-photo img { display: block; width: 100%; max-height: 50vh; object-fit: cover; }
.g-photo figcaption { padding: 14px 6px 16px; color: #2a1d17; font-family: 'Comic Sans MS', 'Chalkboard SE', var(--body); font-weight: 700; font-size: 22px; }
@keyframes g-drop { from { transform: translateY(-40px) rotate(6deg); opacity: 0; } }
.g-msg { margin: 0; max-width: 460px; font-size: 17px; line-height: 1.5; }
.g-gain { color: #ffd79a; font-family: var(--latin); font-size: 22px; margin-right: 4px; }
.g-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.game.won .g-result { background: radial-gradient(circle at center, rgba(236, 98, 72, 0.35), rgba(0, 0, 0, 0.6)); }

@media (max-width: 600px) {
  .g-title { font-size: 21px; }
  .g-how { font-size: 11.5px; }
  .g-exit { bottom: auto; top: calc(max(14px, env(safe-area-inset-top)) + 150px); }
}
.g-pad[hidden], .g-result[hidden], .g-photo[hidden], .game[hidden] { display: none; }

/* the music switch on the intro, top right */
.intro-music {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: transparent;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.intro-music.muted { opacity: 0.45; text-decoration: line-through; }
.m-unknown circle { fill: none; stroke-dasharray: 2 2; opacity: 0.5; }
.m-unknown text { opacity: 0.55; }

/* a new place: its name in the middle of the screen as it appears, then gone */
.area-title {
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  z-index: 4;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.7);
  width: min(720px, calc(100vw - 32px));
}
.area-title.show { animation: area-in 3.8s ease forwards; }
.area-kicker { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: #ffd7a0; }
.area-name { margin: 0; font-family: var(--display); font-weight: 300; font-size: clamp(34px, 6vw, 64px); color: #fff4e6; }
.area-sub { margin: 6px 0 0; font-size: 15px; color: rgba(246, 237, 227, 0.8); }
@keyframes area-in {
  0% { opacity: 0; transform: translate(-50%, -40%); letter-spacing: 0.08em; }
  18% { opacity: 1; transform: translate(-50%, -50%); letter-spacing: 0; }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -56%); }
}

/* ---------- the quest board: what to do on the island you're on (js/quest.js) ---------- */
.quest {
  position: fixed;
  left: 20px;
  top: calc(max(16px, env(safe-area-inset-top)) + 64px);
  z-index: 4;
  width: min(320px, calc(100vw - 32px));
  opacity: 0;
  transform: translateX(-12px);
  pointer-events: none;
  transition: opacity 0.5s, transform 0.5s;
}
.quest.shown { opacity: 1; transform: none; pointer-events: auto; }
body.gaming .quest, body.viewer-open .quest { opacity: 0; pointer-events: none; }
.quest-head {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 215, 160, 0.35);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--cream);
  font: inherit;
  cursor: pointer;
}
.quest-kicker { font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: #ffd7a0; }
.quest-count { font-size: 12px; color: var(--muted); }
.quest-count:empty { display: none; }
.quest-body {
  margin-top: 8px;
  padding: 16px 18px 14px;
  border: 1px solid rgba(255, 215, 160, 0.28);
  border-radius: 16px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 0 24px rgba(255, 190, 120, 0.06);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
  transition: max-height 0.45s ease, opacity 0.35s, padding 0.45s;
}
.quest.open .quest-body { max-height: 320px; opacity: 1; padding-top: 14px; padding-bottom: 12px; }
.quest-title { margin: 0 0 10px; font-family: var(--display); font-weight: 400; font-size: 21px; color: #fff4e6; }
.quest-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.quest-list li { position: relative; padding-left: 24px; font-size: 14px; line-height: 1.4; color: rgba(246, 237, 227, 0.88); }
.quest-list li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 3px;
  width: 12px;
  height: 12px;
  border: 1.5px solid rgba(255, 215, 160, 0.7);
  border-radius: 4px;
}
.quest-list li.done { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(246, 237, 227, 0.35); }
.quest-list li.done::before { content: '✓'; border-color: var(--coral); background: var(--coral); color: #fff; font-size: 10px; line-height: 12px; text-align: center; }
