@font-face { font-family: "Reunion Round"; font-style: normal; font-weight: 400; font-display: swap; src: url("./media/reunion-round-400.woff2") format("woff2"); }
@font-face { font-family: "Reunion Round"; font-style: normal; font-weight: 700; font-display: swap; src: url("./media/reunion-round-700.woff2") format("woff2"); }
@font-face { font-family: "Reunion Letter"; font-style: normal; font-weight: 400; font-display: swap; src: url("./media/reunion-letter.woff2") format("woff2"); }
:root {
  color-scheme: light;
  --paper: #faf1e3;
  --paper-panel: #fffaf0;
  --paper-shade: #f8ead7;
  --page-warmth: #f0d9c6;
  --ink: #392a25;
  --subtle: #654c3f;
  --accent: #923e32;
  --accent-hover: #793329;
  --line: #ddc7b5;
  --letter-rule: #b9765333;
  --shadow: #673b2520;
  --dialog-shadow: #3b271e59;
  --control-fill: #fff6e7;
  --control-hover: #f4e5d4;
  --control-line: #c7a58d;
  --selected-fill: #f1dace;
  --selected-hover: #ebcdbd;
  --selected-line: #ad745d;
  --focus-ring: var(--accent);
  --round: "Reunion Round", "YouYuan", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --hand: "Reunion Letter", KaiTi, "STKaiti", var(--round);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  min-width: 300px;
  min-height: 100%;
  background:
    radial-gradient(ellipse at 94% 1%, var(--page-warmth) 0, transparent 35rem),
    radial-gradient(ellipse at 14% 84%, var(--paper-shade) 0, transparent 34rem),
    var(--paper);
  background-repeat: no-repeat;
}
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--round);
  font-size: 16px;
}
button { font: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 4px; }
h1:focus { outline: none; }
.page { margin-inline: auto; max-width: 1090px; padding: 0 clamp(20px, 5.2vw, 68px) 32px; }
.site-header {
  height: 82px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); gap: 12px;
}
.wordmark, .music-button { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); }
.wordmark {
  padding: 0; border: 0; background: transparent; font: 700 1.05rem var(--round); letter-spacing: .03em;
}
.seal {
  width: 39px; height: 39px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--control-fill); border: 1px solid var(--line);
}
.seal canvas { display: block; width: 32px; height: 32px; }
.music-button {
  min-height: 44px; padding: 7px 13px; border: 1px solid var(--control-line); border-radius: 24px;
  background: var(--control-fill); color: var(--subtle); font-size: .88rem;
}
.music-icon { color: var(--accent); font: bold 18px Georgia, serif; }
.music-button[aria-pressed="true"] { background: var(--selected-fill); border-color: var(--selected-line); }
.experience {
  display: grid; grid-template-columns: minmax(0, 1fr);
  gap: 14px; padding: clamp(15px, 2.3vw, 27px) 0 17px;
}
.letter {
  margin: 0; padding: clamp(15px, 2.25vw, 25px);
  position: relative; border: 1px solid var(--line); border-radius: 6px 14px 6px 6px;
  background: linear-gradient(155deg, var(--paper-panel), var(--paper-shade) 95%);
  box-shadow: 0 3px 10px var(--shadow);
  color: var(--ink); font-family: var(--hand);
}
.letter-heading {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line); margin-bottom: 8px; padding-bottom: 5px;
}
.letter-heading h2 { margin: 0; color: var(--accent); font-size: 1.03rem; font-weight: 400; letter-spacing: .12em; }
.letter-heading canvas { display: block; width: 32px; height: 32px; transform: rotate(10deg); }
.letter-body {
  margin: 0; font-size: clamp(1.19rem, 2.05vw, 1.52rem); line-height: 1.77;
  background: repeating-linear-gradient(to bottom, transparent 0 calc(1.77em - 1px), var(--letter-rule) calc(1.77em - 1px) 1.77em);
}
.actions { display: flex; align-items: center; gap: clamp(6px, 1.5vw, 12px); }
.experience[data-view="chapter"] .actions { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.experience[data-view="chapter"] #previous { justify-self: start; }
.actions #next { margin-inline-start: auto; }
.actions button {
  min-height: 44px; border-radius: 10px; padding: 8px clamp(8px, 1.9vw, 19px);
  font-size: clamp(.84rem, 2.5vw, 1rem); font-weight: 700; white-space: nowrap;
}
.primary { background: var(--accent); border: 1px solid var(--accent); color: var(--paper-panel); }
.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.secondary { background: var(--control-fill); color: var(--subtle); border: 1px solid var(--control-line); }
.secondary:hover, .music-button:hover { background-color: var(--control-hover); }
.stage {
  --scene-ink: var(--ink); --scene-hint: #47352c;
  --scene-center: 46% 29%; --scene-midpoint: 68%;
  --scene-light: #fff2d8; --scene-mid: #efc2a9; --scene-edge: #dda994;
  margin: 0; min-width: 0;
}
:is(.stage, .memory)[data-scene="graduation"] {
  --scene-center: 47% 24%; --scene-midpoint: 70%;
  --scene-light: #fbefd9; --scene-mid: #e7d7bd; --scene-edge: #cbb79f;
}
:is(.stage, .memory)[data-scene="dinner"] {
  --scene-center: 50% 25%; --scene-midpoint: 70%;
  --scene-light: #fff0d2; --scene-mid: #f1c7a6; --scene-edge: #d9a88c;
}
:is(.stage, .memory)[data-scene="bridge"] {
  --scene-center: 50% 26%;
  --scene-light: #f9efd5; --scene-mid: #d6ddc0; --scene-edge: #b9c9ac;
}
.stage[data-scene="ending"] {
  --scene-center: 50% 26%;
  --scene-light: #fff1d7; --scene-mid: #f0c6af; --scene-edge: #dca78e;
}
.stage[data-weather="rain"] {
  --scene-center: 50% 30%; --scene-midpoint: 74%;
  --scene-light: #565d74; --scene-mid: #3c435c; --scene-edge: #30374e;
  --scene-ink: #fff1db; --scene-hint: #e1d9cf; --focus-ring: var(--paper-panel);
}
.stage[data-candle-lit] {
  --scene-center: 48% 42%;
  --scene-light: #f9d9ac; --scene-mid: #e4b68f; --scene-edge: #c99b80;
}
.stage-window {
  display: grid; grid-template-rows: minmax(74px, auto) minmax(0, 1fr) 54px;
  overflow: hidden; width: 100%; height: clamp(366px, 83vw, 550px);
  border-radius: 21px; border: 1px solid var(--line); box-shadow: 0 10px 28px var(--shadow);
  background: radial-gradient(ellipse at var(--scene-center), var(--scene-light), var(--scene-mid) var(--scene-midpoint), var(--scene-edge));
}
.scene-heading {
  align-self: start; min-width: 0; padding: clamp(11px, 2.35vw, 20px) 14px 0;
  color: var(--scene-ink); text-align: center;
}
.scene-title { display: flex; justify-content: center; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; }
.scene-title h1 {
  margin: 0; font: 700 clamp(1.34rem, 3.2vw, 1.94rem)/1.22 var(--round);
  letter-spacing: -.045em;
}
.title-period { color: var(--accent); }
.scene-caption { font-size: .88rem; }
.setting { margin: 4px 0 0; font-size: clamp(.91rem, 2.15vw, 1rem); line-height: 1.45; }
.stage[data-scene="ending"] .setting {
  margin-top: 8px; font-size: clamp(1.125rem, 2.6vw, 1.5rem); letter-spacing: .04em;
}
.stage-art { position: relative; min-height: 0; }
.stage-controls {
  display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  grid-template-areas: "left right"; align-items: center;
  padding: 0 clamp(10px, 3vw, 24px) 6px;
}
.stage[data-scene="cover"] .stage-window {
  grid-template-rows: minmax(0, 1fr) 54px;
}
.stage[data-scene="cover"] .stage-art { grid-area: 1 / 1; }
.stage[data-scene="cover"] .scene-heading {
  grid-area: 2 / 1; align-self: center; padding: 0 14px 6px;
}
.stage[data-scene="cover"] .scene-title h1 {
  color: var(--scene-hint); font-size: clamp(1.03rem, 2.6vw, 1.27rem); font-weight: 400;
  letter-spacing: .045em;
}
.stage[data-scene="cover"] .stage-controls { display: none; }
.canvas-host { position: absolute; inset: 0; touch-action: pan-y; cursor: grab; }
.canvas-host:active { cursor: grabbing; }
.canvas-host canvas { display: block; width: 100%; height: 100%; }
.stage-fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.envelope-control { position: absolute; inset: 0; padding: 0; border: 0; background: transparent; }
.envelope-control:focus-visible { outline-offset: -4px; border-radius: 12px; }
.canvas-host:not([hidden]) ~ .envelope-control { pointer-events: none; }
.stage-action {
  grid-area: right; justify-self: end; padding: 7px 12px; border-radius: 10px;
  background: var(--control-fill); color: var(--subtle); border: 1px solid var(--control-line);
  font-size: .83rem; min-height: 44px; font-weight: 700;
}
.stage-action:hover { background: var(--control-hover); }
.stage-action[aria-pressed="true"] { background: var(--selected-fill); color: var(--accent); border-color: var(--selected-line); }
.stage-hint {
  grid-area: left; justify-self: start; white-space: nowrap;
  color: var(--scene-hint); font-size: .75rem; font-weight: 400; line-height: 1.4;
}
.photo-button {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--selected-fill); border: 1px solid var(--selected-line); color: var(--accent);
}
.photo-button:hover, .stage-action[aria-pressed="true"]:hover, .music-button[aria-pressed="true"]:hover { background: var(--selected-hover); }
.camera-icon { position: relative; width: 16px; height: 12px; border: 1.5px solid currentColor; border-radius: 3px; }
.camera-icon::before, .camera-icon::after { content: ""; position: absolute; background: currentColor; }
.camera-icon::before { top: -4px; left: 2px; width: 5px; height: 3px; border-radius: 1px 1px 0 0; }
.camera-icon::after { width: 6px; height: 6px; inset: 1.5px 0 0; margin-inline: auto; border-radius: 50%; }
.memories { border-top: 1px solid var(--line); padding-top: 15px; }
.memory-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.memory {
  display: grid; justify-items: center; min-width: 0; gap: 6px; padding: 5px 5px 8px;
  border: 1px solid var(--line); border-radius: 10px;
  text-align: center; background: var(--paper-panel); color: var(--ink);
}
.memory:hover { background: var(--control-hover); }
.memory[aria-current="true"] { border-color: var(--selected-line); background: var(--selected-fill); }
.memory[aria-current="true"]:hover { background: var(--selected-hover); }
.memory-art {
  display: block; width: 100%; height: clamp(48px, 10vw, 84px); object-fit: contain;
  border-radius: 6px;
  background: radial-gradient(ellipse at 50% 24%, var(--scene-light), var(--scene-mid) 66%, var(--scene-edge));
}
.memory strong { font-size: .97rem; }
.photo-dialog {
  border: 0; border-radius: 16px; background: var(--paper-panel); color: var(--ink);
  max-width: min(92vw, 900px); max-height: 92dvh; padding: 0; box-shadow: 0 18px 70px var(--dialog-shadow);
}
.photo-dialog::backdrop { background: #34231bda; }
.photo-card { padding: 0 10px 10px; }
.photo-card header { min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding-left: 5px; gap: 12px; }
.photo-card h2 { font: 700 1.1rem var(--round); margin: 4px 0; }
.photo-card button { border: 0; background: transparent; color: var(--accent); font-size: 1.9rem; min-width: 44px; min-height: 44px; }
.photo-card img { display: block; max-width: 100%; max-height: calc(90dvh - 62px); width: auto; height: auto; margin-inline: auto; object-fit: contain; border-radius: 6px; }
.live-status { position: fixed; bottom: 12px; left: 12px; margin: 0; max-width: calc(100% - 24px); padding: 10px 13px; color: var(--ink); background: var(--paper-panel); border: 1px solid var(--line); border-radius: 8px; }
@media (max-width: 780px) {
  .site-header { height: 64px; }
  .stage-window { border-radius: 15px; }
  .memory-list { gap: 7px; }
}
@media (max-width: 350px) { .camera-icon { display: none; } }
@media (min-width: 781px), (orientation: landscape) and (min-width: 650px) {
  .page { max-width: 1360px; }
  .experience[data-view="chapter"] {
    grid-template-columns: minmax(0, 1fr) clamp(195px, 29%, 355px);
    column-gap: clamp(14px, 2.35vw, 32px);
    align-items: center;
  }
  .experience[data-view="chapter"] .stage { align-self: start; }
  .experience[data-view="chapter"] .actions { grid-column: 1 / -1; }
  .stage[data-scene="ending"] .stage-window {
    grid-template-columns: minmax(0, 30%) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 54px;
    grid-template-areas: "greeting artwork" "greeting controls";
  }
  .stage[data-scene="ending"] .scene-heading {
    grid-area: greeting;
    align-self: center;
    padding: 0 0 0 clamp(15px, 2.2vw, 32px);
  }
  .stage[data-scene="ending"] .stage-art { grid-area: artwork; }
  .stage[data-scene="ending"] .stage-controls { grid-area: controls; }
}
@media (orientation: landscape) and (min-width: 650px) and (max-height: 520px) {
  .stage-window { height: clamp(285px, calc(100dvh - 95px), 425px); }
}
