
:root {
  --bg: #070913;
  --paper: #f7ecd6;
  --paper-dark: #cfb68f;
  --ink: #352719;
  --gold: #f0c979;
  --gold-2: #bb8150;
  --panel: rgba(7, 9, 17, .84);
  --panel-strong: rgba(7, 9, 17, .94);
  --shadow: rgba(0,0,0,.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); }
body {
  color: var(--paper);
  font-family: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif CJK SC", "PingFang SC", serif;
  touch-action: manipulation;
  user-select: none;
}

#game {
  width: 100vw;
  height: 100dvh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 12%, rgba(185,204,255,.12), transparent 30rem),
    linear-gradient(180deg, #060812, #121827);
}

#stage {
  position: relative;
  width: min(100vw, 520px);
  height: 100dvh;
  max-height: 960px;
  overflow: hidden;
  background: #090b14;
  box-shadow: 0 0 60px rgba(0,0,0,.55);
}

#scene-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
  transform: scale(1.012);
  transition: opacity .75s ease, transform 6s ease;
}

#darken {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 44%, transparent 0 34%, rgba(0,0,0,.20) 76%),
    linear-gradient(180deg, rgba(0,0,0,.24), rgba(0,0,0,.03) 20%, rgba(0,0,0,.24));
  z-index: 1;
}

#particles {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: .55;
  background-image:
    radial-gradient(circle, rgba(255,230,166,.95) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(255,255,255,.8) 0 1px, transparent 1.5px);
  background-size: 83px 91px, 127px 139px;
  animation: drift 18s linear infinite;
  mix-blend-mode: screen;
}

.panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  transition: opacity .45s ease, transform .45s ease, filter .45s ease;
}

.panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  filter: blur(2px);
}

#title-screen {
  z-index: 10;
  align-items: center;
  justify-content: flex-end;
  padding: 0 24px max(70px, env(safe-area-inset-bottom) + 42px);
}

.title-spacer { flex: 1; }

.primary-btn, .secondary-btn {
  border: 0;
  border-radius: 999px;
  min-height: 46px;
  padding: 0 28px;
  color: #3a2718;
  background:
    linear-gradient(180deg, #fff3c6, #f1c16c 58%, #c98747);
  box-shadow:
    0 12px 30px rgba(0,0,0,.30),
    inset 0 1px 0 rgba(255,255,255,.55);
  font-size: 15px;
  letter-spacing: .22em;
  font-family: inherit;
}

.secondary-btn {
  color: #eee0c7;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
}

.tiny-tip {
  margin: 14px 0 0;
  color: rgba(247,236,214,.72);
  font-size: 12px;
  letter-spacing: .08em;
  text-shadow: 0 2px 8px #000;
}

.topbar {
  position: absolute;
  left: 14px;
  right: 14px;
  top: max(14px, env(safe-area-inset-top));
  z-index: 7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(10,14,26,.72), rgba(10,13,22,.42));
  backdrop-filter: blur(7px);
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
}

.chapter {
  color: #fff5dd;
  font-size: 16px;
  letter-spacing: .10em;
}

#progress {
  margin-top: 4px;
  color: rgba(247,236,214,.70);
  font-size: 12px;
}

.round-btn {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  color: var(--gold);
  font-size: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

.round-btn.muted { color: rgba(255,255,255,.45); }

.hotspot {
  position: absolute;
  z-index: 6;
  width: 54px;
  height: 54px;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,236,176,.95) 0 12%, rgba(255,215,134,.40) 28%, rgba(255,215,134,.10) 54%, transparent 70%);
  color: var(--paper);
  font-size: 0;
  opacity: .35;
  pointer-events: none;
  filter: grayscale(.55);
}

.hotspot span {
  position: absolute;
  left: 50%;
  top: calc(100% - 2px);
  transform: translateX(-50%);
  min-width: 56px;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(10,11,18,.78);
  color: #ffe6aa;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: .08em;
  box-shadow: 0 6px 16px rgba(0,0,0,.24);
}

.hotspot.active {
  pointer-events: auto;
  opacity: 1;
  filter: none;
  animation: pulse 1.9s ease-in-out infinite;
}

.hotspot.done {
  opacity: .75;
  filter: none;
  background: radial-gradient(circle, rgba(190,245,220,.90) 0 12%, rgba(132,206,174,.28) 32%, transparent 70%);
}

.hint {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom) + 12px);
  transform: translateX(-50%);
  width: min(86%, 380px);
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid rgba(240,201,121,.25);
  background: rgba(9,11,18,.70);
  color: #f9e4b7;
  font-size: 12px;
  text-align: center;
  letter-spacing: .06em;
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 28px rgba(0,0,0,.24);
}

#dialog-ui {
  justify-content: flex-end;
  padding: 0 12px max(12px, env(safe-area-inset-bottom) + 8px);
}

.dialog-card {
  min-height: 176px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,.11);
  background:
    radial-gradient(circle at 16% 0%, rgba(243,207,132,.10), transparent 34%),
    linear-gradient(180deg, rgba(9,11,20,.90), rgba(5,7,13,.97));
  box-shadow: 0 18px 45px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.06);
  padding: 16px 16px 12px;
  backdrop-filter: blur(7px);
}

.speaker-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(180deg, #ae8c62, #634a35);
  color: #fff3d8;
  box-shadow: inset 0 -8px 16px rgba(0,0,0,.20), 0 10px 18px rgba(0,0,0,.22);
  font-size: 16px;
}

.speaker {
  font-size: 17px;
  color: #fff7df;
  letter-spacing: .06em;
}

.speaker-sub {
  margin-top: 2px;
  color: rgba(247,236,214,.54);
  font-size: 11px;
  letter-spacing: .06em;
}

#dialog-text {
  min-height: 5.4em;
  margin: 13px 0 0;
  color: #fff2dc;
  font-size: 17px;
  line-height: 1.88;
  letter-spacing: .02em;
  text-shadow: 0 2px 12px #000;
  white-space: pre-line;
}

.dialog-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: rgba(247,236,214,.55);
  font-size: 11px;
  letter-spacing: .08em;
}

#next-tip {
  color: var(--gold);
  opacity: .85;
  animation: breathe 1.5s ease-in-out infinite;
}

#memory-ui {
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(4px);
}

.memory-card {
  width: min(86vw, 360px);
  padding: 28px 22px 22px;
  border-radius: 26px;
  border: 1px solid rgba(255,255,255,.12);
  background:
    radial-gradient(circle at 50% 0%, rgba(240,201,121,.16), transparent 36%),
    linear-gradient(180deg, rgba(247,236,214,.94), rgba(222,198,160,.96));
  color: var(--ink);
  text-align: center;
  box-shadow: 0 26px 70px rgba(0,0,0,.42);
}

.memory-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  color: #5a341d;
  background:
    radial-gradient(circle at 34% 28%, #fff8d6, #f0c979 48%, #bc8150);
  box-shadow: 0 10px 28px rgba(154,95,45,.22), inset 0 1px 0 rgba(255,255,255,.6);
  font-size: 30px;
}

.memory-card h2 {
  margin: 0;
  font-weight: 500;
  font-size: 26px;
  letter-spacing: .08em;
}

.memory-card p {
  margin: 12px 0 20px;
  color: #5b4432;
  font-size: 15px;
  line-height: 1.8;
}

#final-ui {
  overflow-y: auto;
  padding: max(30px, env(safe-area-inset-top) + 18px) 18px max(32px, env(safe-area-inset-bottom) + 20px);
  justify-content: flex-end;
  background: linear-gradient(180deg, rgba(0,0,0,.04), rgba(0,0,0,.20) 38%, rgba(0,0,0,.56));
}

.letter {
  width: min(100%, 420px);
  margin: auto auto 0;
  padding: 20px 18px 18px;
  border-radius: 24px;
  background: rgba(247,236,214,.92);
  color: var(--ink);
  box-shadow: 0 26px 65px rgba(0,0,0,.36);
  border: 1px solid rgba(255,255,255,.5);
}

.final-photo-wrap {
  width: 54%;
  max-width: 210px;
  margin: -58px auto 12px;
  padding: 8px 8px 28px;
  border-radius: 6px;
  background: #f4eadb;
  transform: rotate(-2deg);
  box-shadow: 0 14px 34px rgba(0,0,0,.32);
}

.final-photo-wrap img { display: block; width: 100%; border-radius: 3px; }

.letter h1 {
  margin: 4px 0 10px;
  text-align: center;
  font-weight: 500;
  font-size: 27px;
  letter-spacing: .08em;
}

.letter p {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.85;
}

.letter .sign { text-align: right; color: #75563a; }

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(.92); }
  50% { transform: translate(-50%, -50%) scale(1.12); }
}

@keyframes breathe {
  0%,100% { opacity: .45; }
  50% { opacity: 1; }
}

@keyframes drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 83px -91px, -127px -139px; }
}

@media (min-width: 720px) {
  #stage { border-radius: 28px; height: min(100dvh, 920px); }
}

@media (max-height: 700px) {
  .dialog-card { min-height: 150px; }
  #dialog-text { font-size: 15px; line-height: 1.72; min-height: 4.4em; }
  .letter p { font-size: 15px; line-height: 1.72; }
}
