/* =========================================================
   浅仪式之墓
   全站 UI 对齐 原始图.jpg：半透明白框 + 白字硬黑描边 + 雨夜墓园
   ========================================================= */

/* 严肃明朝系 —— 对齐原作白字黑边，绝不用圆体/可爱体 */
@import url("https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@600;700&family=Noto+Serif+SC:wght@600;700&display=swap");

:root {
  /* 恐怖 AVG / 寒蝉系：暗、低对比，不要亮白描边闪瞎眼 */
  --ink: rgba(228, 222, 210, 0.92);
  --ink-soft: rgba(200, 194, 180, 0.72);
  --ink-dim: rgba(170, 165, 152, 0.48);
  --frame: rgba(160, 155, 140, 0.22);
  --frame-mid: rgba(160, 155, 140, 0.32);
  --frame-dim: rgba(120, 115, 105, 0.18);
  --fill: rgba(6, 8, 6, 0.45);
  --fill-deep: rgba(4, 6, 4, 0.78);
  --fill-hover: rgba(12, 14, 10, 0.62);
  --font-ui: "Noto Serif JP", "Noto Serif SC", "Yu Mincho", "Hiragino Mincho ProN",
    "MS Mincho", "Songti SC", "SimSun", serif;
  /* 字影：只压黑底，不要白描边感 */
  --outline:
    0 1px 2px rgba(0, 0, 0, 0.95),
    0 0 8px rgba(0, 0, 0, 0.55);
  --outline-soft:
    0 1px 3px rgba(0, 0, 0, 0.9);
  --panel-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    inset 0 0 48px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

html,
body {
  width: 100%;
  min-height: 100%;
  min-height: 100dvh;
  background: #000;
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body.is-title,
body.is-app {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

/* ========== 场景 ========== */
#scene {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

body.is-title #scene,
body.is-app #scene {
  height: 100%;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
}

#bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: #0a0c0a;
  background-image: url("bg.png");
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
}

body:not(.is-title):not(.is-app) #bg {
  position: fixed;
}

#rain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

body:not(.is-title) #rain {
  position: fixed;
}

#vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(
    ellipse 75% 70% at 50% 48%,
    transparent 35%,
    rgba(0, 0, 0, 0.35) 100%
  );
}

body:not(.is-title) #vignette {
  position: fixed;
  background: rgba(0, 0, 0, 0.42);
}

/* ========== 原作按钮（图片） ========== */
.menu-btn,
.img-btn {
  pointer-events: auto;
  position: relative;
  display: block;
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: none;
  line-height: 0;
  --tx: 0px;
  --ty: 0px;
  --sc: 1;
  transform: translate(var(--tx), var(--ty)) scale(var(--sc));
  transform-origin: center center;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7));
  transition: filter 0.15s ease, opacity 0.15s ease;
  will-change: transform, filter;
}

.menu-btn img,
.img-btn img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.menu-btn.dim {
  opacity: 0.88;
}

.menu-btn:hover,
.menu-btn:focus-visible,
.img-btn:hover,
.img-btn:focus-visible {
  outline: none;
  z-index: 8;
  --sc: 1.06;
  opacity: 1;
  filter:
    drop-shadow(0 0 8px rgba(255, 255, 255, 0.28))
    drop-shadow(0 2px 4px rgba(0, 0, 0, 0.75))
    brightness(1.18);
}

.menu-btn:active,
.img-btn:active {
  --sc: 0.94;
  filter: brightness(0.9);
  transition-duration: 0.05s;
}

.menu-btn.is-press,
.img-btn.is-press,
.ui-btn.is-press,
.dialog-btn.is-press {
  animation: btn-press 0.14s ease-out forwards;
  z-index: 9;
}

.menu-btn.is-flash::after,
.img-btn.is-flash::after {
  content: "";
  position: absolute;
  inset: 10% 5%;
  background: rgba(255, 255, 255, 0.2);
  pointer-events: none;
  animation: btn-flash 0.26s ease-out forwards;
}

.menu-btn.is-selected,
.img-btn.is-selected {
  --sc: 1.04;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.4)) brightness(1.22);
}

@keyframes btn-press {
  0% {
    transform: translate(var(--tx), var(--ty)) scale(1.06);
  }
  40% {
    transform: translate(var(--tx), var(--ty)) scale(0.91);
    filter: brightness(1.3);
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(1);
  }
}

@keyframes btn-flash {
  from {
    opacity: 0.5;
  }
  to {
    opacity: 0;
  }
}

/* 标题六键环绕 */
body.is-title #menu,
body.is-app #menu {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

body.is-title .menu-btn,
body.is-app .menu-btn {
  position: absolute;
  width: min(26vw, 300px);
  pointer-events: auto;
}

/* 子视图：同场景切换，雨声/雨动画不断 */
.view {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

.view[hidden],
[hidden] {
  display: none !important;
}

.sheet {
  width: min(100%, 28rem);
  max-height: min(88dvh, 640px);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.sheet-fit {
  max-height: min(86dvh, 560px);
}

.sheet-box {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.text-back {
  align-self: flex-start;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-dim);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  cursor: pointer;
  text-shadow: var(--outline-soft);
  padding: 0.2rem 0;
}

.text-back:hover {
  color: var(--ink-soft);
}

.fit-box {
  gap: 0.75rem;
}

.fit-head {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.fit-date {
  font-size: 0.8rem;
  color: var(--ink-dim);
  letter-spacing: 0.15em;
}

.fit-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--ink);
  text-shadow: var(--outline);
  flex: 1;
}

.fit-pos {
  font-size: 0.75rem;
  color: var(--ink-dim);
  letter-spacing: 0.1em;
}

.fit-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.fit-body p {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.85;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-shadow: var(--outline-soft);
  margin-bottom: 0.75em;
}

.fit-body p:last-child {
  margin-bottom: 0;
}

.fit-nav {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.fit-half {
  flex: 1;
  font-size: 0.9rem !important;
  padding: 0.55em 0.5em !important;
}

/* 手记列表按钮行 */
.diary-list .row {
  width: 100%;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}
.diary-list .diary-open {
  appearance: none;
  background: transparent;
  border: none;
  display: block;
  padding: 0.75rem 0.2rem;
}
.diary-list .diary-open:hover {
  background: rgba(255, 255, 255, 0.04);
}
.short-body p {
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 0.65em;
  color: var(--ink);
  text-shadow: var(--outline-soft);
  font-weight: 600;
}
.paper-date {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  margin-bottom: 0.25rem;
}
.paper-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--ink);
  text-shadow: var(--outline);
  margin-bottom: 0.75rem;
}
.paper-body {
  flex: 1;
  min-height: 0;
}

/* 抓狂案例：卡片网格，不像日记目录 */
.sheet-cases {
  width: min(100%, 36rem);
  max-height: min(88dvh, 620px);
}
.case-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  overflow: auto;
  max-height: min(58dvh, 420px);
  padding: 0.15rem 0;
}
.case-card {
  appearance: none;
  text-align: left;
  border: 1px solid var(--frame-mid);
  background: rgba(0, 0, 0, 0.4);
  color: var(--ink);
  font-family: var(--font-ui);
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 4.2rem;
  transition: border-color 0.15s, background 0.15s;
}
.case-card:hover:not(:disabled) {
  border-color: rgba(200, 160, 120, 0.4);
  background: rgba(20, 14, 8, 0.55);
}
.case-card strong {
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  font-weight: 700;
}
.case-card em {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--ink-dim);
}
.case-card.is-lock {
  opacity: 0.4;
  cursor: not-allowed;
}
.case-tag {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: rgba(200, 150, 100, 0.75);
}
.case-detail .case-body {
  white-space: normal;
  line-height: 1.85;
}
@media (max-width: 520px) {
  .case-grid {
    grid-template-columns: 1fr;
  }
}

.novel-box {
  min-height: 12rem;
}

.novel-box .novel-text {
  min-height: 4.5em;
  font-size: 1rem;
}

.novel-box .novel-choices.is-show,
.novel-box .novel-end.is-show {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

/* 六键明显靠向中央墓碑（左右对称略错落） */
body.is-title .pos-tl,
body.is-app .pos-tl {
  top: 7.5%;
  left: 18%;
  width: min(24vw, 280px);
}
body.is-title .pos-tr,
body.is-app .pos-tr {
  top: 11%;
  right: 17%;
  width: min(23vw, 270px);
}
body.is-title .pos-ml,
body.is-app .pos-ml {
  top: 36%;
  left: 15%;
  width: min(25vw, 290px);
  --ty: -50%;
}
body.is-title .pos-mr,
body.is-app .pos-mr {
  top: 41%;
  right: 14.5%;
  width: min(25vw, 290px);
  --ty: -50%;
}
body.is-title .pos-bl,
body.is-app .pos-bl {
  bottom: 12%;
  left: 19%;
  width: min(24vw, 280px);
}
body.is-title .pos-br,
body.is-app .pos-br {
  bottom: 14%;
  right: 16%;
  width: min(26vw, 300px);
}

/* ========== 文字 UI：暗幕面板（AVG 消息窗感，无亮白框） ========== */

.ui-box {
  position: relative;
  border: 1px solid var(--frame);
  background:
    linear-gradient(180deg, rgba(18, 20, 16, 0.55) 0%, rgba(4, 6, 4, 0.82) 100%);
  box-shadow: var(--panel-shadow);
  padding: 1.25rem 1.3rem 1.35rem;
  backdrop-filter: blur(2px);
}

/* 极淡内缘，模拟旧作窗体层次，不是高亮描边 */
.ui-box::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.ui-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: clamp(1.15rem, 2.6vw, 1.45rem);
  letter-spacing: 0.16em;
  color: var(--ink);
  text-shadow: var(--outline);
  margin-bottom: 0.4rem;
  line-height: 1.35;
}

.ui-meta {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-shadow: var(--outline-soft);
  margin-bottom: 1.15rem;
  line-height: 1.65;
}

.ui-note {
  margin-top: 1rem;
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  text-shadow: var(--outline-soft);
  line-height: 1.6;
}

/* 选项键：暗底 + 细弱边，hover 只是略亮 */
.ui-btn {
  appearance: none;
  display: block;
  width: 100%;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: clamp(0.98rem, 2.1vw, 1.12rem);
  letter-spacing: 0.12em;
  line-height: 1.3;
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  text-shadow: var(--outline);
  border: 1px solid var(--frame-mid);
  background: var(--fill);
  padding: 0.72em 1.05em 0.78em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.1s ease;
}

.ui-btn:hover:not(:disabled),
.ui-btn:focus-visible:not(:disabled) {
  outline: none;
  border-color: rgba(200, 195, 180, 0.38);
  background: var(--fill-hover);
  color: rgba(240, 236, 226, 0.96);
}

.ui-btn:active:not(:disabled) {
  transform: scale(0.985);
  background: rgba(0, 0, 0, 0.55);
}

.ui-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--frame-dim);
}

.ui-btn .sub {
  display: block;
  margin-top: 0.28em;
  font-size: 0.72em;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-shadow: var(--outline-soft);
}

.ui-btn.ui-btn-left {
  text-align: left;
}

.ui-btn-row {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* ========== 子页布局 ========== */
.content {
  position: relative;
  z-index: 5;
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.35rem 1rem 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.back-btn {
  width: min(34vw, 148px);
  flex-shrink: 0;
}

/* 列表项：无现代卡片，只有分割线 + 原作字 */
.list {
  list-style: none;
}

.list-item {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.list-item:last-child {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.list-item a,
.list-item .row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.95rem 0.15rem;
  color: inherit;
  text-decoration: none;
  background: transparent;
  border: none;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.12s ease;
}

.list-item a:hover,
.list-item button.row:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
}

.list-item .date {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  text-shadow: var(--outline-soft);
  margin-bottom: 0.2rem;
}

.list-item .title {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink);
  text-shadow: var(--outline);
}

.list-item .hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  text-shadow: var(--outline-soft);
  line-height: 1.5;
}

.list-item.is-locked {
  opacity: 0.4;
  pointer-events: none;
}

/* 回想格子 */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.cell {
  aspect-ratio: 16 / 10;
  border: 1px solid var(--frame-dim);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.7rem;
  text-align: center;
  cursor: default;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.cell.is-open {
  cursor: pointer;
  border-color: var(--frame-mid);
}

.cell.is-open:hover {
  background: rgba(0, 0, 0, 0.55);
  border-color: rgba(200, 195, 180, 0.35);
}

.cell .cell-title {
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 0.98rem;
  text-shadow: var(--outline);
}

.cell .cell-desc {
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  text-shadow: var(--outline-soft);
  line-height: 1.45;
}

.cell.is-locked {
  opacity: 0.4;
  border-style: solid;
}

/* 音乐 */
.track {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.track:last-of-type {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.play-btn {
  appearance: none;
  width: 2.7rem;
  height: 2.7rem;
  flex-shrink: 0;
  border: 1px solid var(--frame-mid);
  background: var(--fill);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-shadow: var(--outline);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.play-btn:hover:not(:disabled) {
  background: var(--fill-hover);
  border-color: rgba(200, 195, 180, 0.35);
}

.play-btn.is-playing {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(200, 195, 180, 0.4);
}

.play-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--frame-dim);
}

.track strong {
  display: block;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-shadow: var(--outline);
}

.track em {
  display: block;
  font-style: normal;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-soft);
  text-shadow: var(--outline-soft);
  margin-top: 0.15rem;
  letter-spacing: 0.06em;
}

/* ========== 对话框：同框体 ========== */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 1rem;
}

.dialog.is-open {
  opacity: 1;
}

.dialog[hidden] {
  display: none !important;
}

.dialog-panel {
  position: relative;
  text-align: center;
  width: min(92vw, 24rem);
  border: 1px solid var(--frame);
  background:
    linear-gradient(180deg, rgba(16, 18, 14, 0.72) 0%, rgba(4, 6, 4, 0.9) 100%);
  box-shadow: var(--panel-shadow);
  padding: 1.5rem 1.4rem 1.25rem;
  transform: scale(0.96);
  transition: transform 0.2s ease;
}

.dialog-panel::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.dialog.is-open .dialog-panel {
  transform: scale(1);
}

.dialog-panel p {
  font-family: var(--font-ui);
  font-size: clamp(1.02rem, 2.3vw, 1.2rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1.75;
  margin-bottom: 1.15rem;
  color: var(--ink);
  text-shadow: var(--outline);
  white-space: pre-line;
}

.dialog-row {
  display: flex;
  gap: 1.2rem;
  justify-content: center;
  align-items: center;
}

.dialog-btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  width: min(30vw, 132px);
  line-height: 0;
  transition: filter 0.12s ease, transform 0.12s ease;
}

.dialog-btn img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.dialog-btn:hover,
.dialog-btn:focus-visible {
  outline: none;
  filter: brightness(1.15);
  transform: scale(1.06);
}

.dialog-btn:active {
  transform: scale(0.94);
  filter: brightness(0.92);
}

/* ========== 游戏 / 小说窗（AVG 对话框） ========== */
.novel-wrap {
  /* 底部消息窗感觉 */
}

.novel {
  min-height: 11rem;
  outline: none;
}

.novel-speaker {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  margin-bottom: 0.55rem;
  color: rgba(230, 220, 200, 0.9);
  text-shadow: var(--outline);
  min-height: 1.25em;
}

.novel-text {
  font-size: clamp(1.02rem, 2.2vw, 1.12rem);
  font-weight: 600;
  line-height: 1.95;
  letter-spacing: 0.06em;
  color: var(--ink);
  text-shadow: var(--outline-soft);
  min-height: 5em;
  white-space: pre-wrap;
}

.novel-hint {
  margin-top: 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  text-shadow: var(--outline-soft);
  animation: blink 1.35s ease-in-out infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.95;
  }
}

.novel-choices,
.novel-end {
  margin-top: 1.1rem;
  display: none;
  flex-direction: column;
  gap: 0.65rem;
}

.novel-choices.is-show,
.novel-end.is-show {
  display: flex;
}

/* 日记正文 */
.entry-body p {
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.95;
  letter-spacing: 0.05em;
  margin-bottom: 0.95em;
  color: var(--ink);
  text-shadow: var(--outline-soft);
}

.entry-body p:last-child {
  margin-bottom: 0;
}

.hidden {
  display: none !important;
}

/* 回想浮层 */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.58);
  padding: 1.1rem;
}

.overlay[hidden] {
  display: none !important;
}

.overlay-panel {
  position: relative;
  width: min(100%, 28rem);
  border: 1px solid var(--frame);
  background:
    linear-gradient(180deg, rgba(16, 18, 14, 0.72) 0%, rgba(4, 6, 4, 0.9) 100%);
  box-shadow: var(--panel-shadow);
  padding: 1.35rem 1.25rem 1.15rem;
}

.overlay-panel::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.overlay-panel h2 {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  margin-bottom: 0.75rem;
  color: var(--ink);
  text-shadow: var(--outline);
}

.overlay-panel p {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.85;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-shadow: var(--outline-soft);
  margin-bottom: 1.15rem;
}

.overlay-close {
  display: block;
  width: 100%;
}

/* 兼容旧 class 名 → 映射到新 UI */
.panel {
  border: 1px solid var(--frame);
  background:
    linear-gradient(180deg, rgba(18, 20, 16, 0.55) 0%, rgba(4, 6, 4, 0.82) 100%);
  box-shadow: var(--panel-shadow);
  padding: 1.2rem 1.25rem 1.3rem;
}

.panel h1 {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: clamp(1.15rem, 2.6vw, 1.45rem);
  letter-spacing: 0.16em;
  color: var(--ink);
  text-shadow: var(--outline);
  margin-bottom: 0.35rem;
}

.panel .meta {
  font-weight: 500;
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-shadow: var(--outline-soft);
  margin-bottom: 1.1rem;
  line-height: 1.65;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.choice-btn {
  appearance: none;
  display: block;
  width: 100%;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: clamp(0.98rem, 2.1vw, 1.1rem);
  letter-spacing: 0.12em;
  line-height: 1.3;
  color: var(--ink);
  text-align: left;
  text-shadow: var(--outline);
  border: 1px solid var(--frame-mid);
  background: var(--fill);
  padding: 0.72em 1em 0.78em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.choice-btn:hover:not(:disabled),
.choice-btn:focus-visible:not(:disabled) {
  outline: none;
  border-color: rgba(200, 195, 180, 0.38);
  background: var(--fill-hover);
}

.choice-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.choice-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--frame-dim);
}

.choice-btn span,
.choice-btn .sub {
  display: block;
  margin-top: 0.28em;
  font-size: 0.75em;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  text-shadow: var(--outline-soft);
}

.note {
  margin-top: 1rem;
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  text-shadow: var(--outline-soft);
  line-height: 1.6;
}

.page-label {
  display: none;
}

/* ========== 窄屏 ========== */
@media (max-width: 720px) {
  body.is-title .menu-btn,
  body.is-app .menu-btn {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    --ty: 0px !important;
    width: min(78vw, 300px) !important;
  }

  body.is-title .menu-btn:nth-child(odd),
  body.is-app .menu-btn:nth-child(odd) {
    --tx: -3vw;
  }
  body.is-title .menu-btn:nth-child(even),
  body.is-app .menu-btn:nth-child(even) {
    --tx: 3vw;
  }

  body.is-title #menu:not([hidden]),
  body.is-app #menu:not([hidden]) {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 14vh 1rem 8vh;
    background: linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.5) 0%,
      transparent 28%,
      transparent 55%,
      rgba(0, 0, 0, 0.55) 100%
    );
    pointer-events: auto;
    overflow-y: auto;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .sheet {
    max-height: 90dvh;
  }
}

/* 雨音开关：极低调，不抢画面 */
.rain-mute-btn {
  position: fixed;
  right: 0.85rem;
  bottom: 0.85rem;
  z-index: 60;
  appearance: none;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
  text-shadow: var(--outline-soft);
  border: 1px solid var(--frame-dim);
  background: rgba(0, 0, 0, 0.45);
  padding: 0.4em 0.75em;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.rain-mute-btn:hover {
  color: var(--ink-soft);
  border-color: var(--frame-mid);
  background: rgba(0, 0, 0, 0.6);
}

.rain-mute-btn[aria-pressed="true"] {
  opacity: 0.55;
  color: var(--ink-dim);
}

@media (prefers-reduced-motion: reduce) {
  .menu-btn,
  .img-btn,
  .ui-btn,
  .dialog,
  .dialog-panel,
  .novel-hint {
    transition: none !important;
    animation: none !important;
  }
}

/* ========== 完整面板 UI（单页子视图） ========== */
.farewell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: #000;
  color: #666;
  font-family: "Noto Serif SC", "Yu Mincho", serif;
  letter-spacing: 0.35em;
}

.view {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.42);
}

.view[hidden] { display: none !important; }

.panel {
  width: min(100%, 26rem);
  max-height: min(86dvh, 560px);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.15rem 1.2rem 1.2rem;
  border: 1px solid rgba(140, 130, 115, 0.2);
  background: linear-gradient(180deg, rgba(14, 16, 12, 0.72), rgba(4, 6, 4, 0.9));
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), inset 0 0 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.panel-story { max-height: min(80dvh, 480px); }
.panel-echo { width: min(100%, 28rem); }
.panel-read { width: min(100%, 24rem); }

.panel-head h1,
.panel > h1,
.panel-read h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: rgba(228, 222, 210, 0.92);
  text-shadow: 0 1px 3px #000;
  margin: 0 0 0.3rem;
}

.panel-head p {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: rgba(180, 172, 158, 0.55);
  line-height: 1.5;
}

.nav-home {
  align-self: flex-start;
  appearance: none;
  border: none;
  background: none;
  color: rgba(170, 162, 148, 0.5);
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  cursor: pointer;
  padding: 0;
}
.nav-home:hover { color: rgba(220, 214, 200, 0.85); }

.stack { display: flex; flex-direction: column; gap: 0.5rem; }
.story-choices,
.story-ending {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}
.panel-story .btn {
  pointer-events: auto;
  position: relative;
  z-index: 3;
}

.btn {
  appearance: none;
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgba(228, 222, 210, 0.9);
  text-shadow: 0 1px 2px #000;
  border: 1px solid rgba(150, 140, 120, 0.28);
  background: rgba(0, 0, 0, 0.4);
  padding: 0.7em 0.9em;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover:not(:disabled) {
  background: rgba(20, 18, 12, 0.65);
  border-color: rgba(180, 160, 130, 0.4);
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-ghost { background: transparent; color: rgba(180, 172, 158, 0.55); }

.entry-list { list-style: none; overflow: auto; flex: 1; min-height: 0; }
.entry {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  color: rgba(220, 214, 200, 0.88);
}
.entry:last-child { border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.entry:hover:not(.is-lock) { background: rgba(255, 255, 255, 0.03); }
.entry.is-lock { opacity: 0.35; cursor: default; }
.entry .muted, .muted { color: rgba(160, 152, 140, 0.45); }

.read-date {
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  color: rgba(160, 152, 140, 0.5);
  margin: 0 0 0.2rem;
}
.read-body {
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.read-body p {
  font-size: 0.95rem;
  line-height: 1.85;
  letter-spacing: 0.04em;
  color: rgba(228, 222, 210, 0.9);
  margin: 0 0 0.7em;
  text-shadow: 0 1px 2px #000;
}

.story { flex: 1; min-height: 10rem; cursor: pointer; }
.story-sp {
  min-height: 1.2em;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  color: rgba(210, 190, 160, 0.75);
  margin-bottom: 0.5rem;
}
.story-tx {
  min-height: 5em;
  font-size: 1rem;
  line-height: 1.9;
  letter-spacing: 0.05em;
  color: rgba(228, 222, 210, 0.92);
  white-space: pre-wrap;
  text-shadow: 0 1px 2px #000;
}
.story-hint {
  margin-top: 0.75rem;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: rgba(160, 152, 140, 0.4);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.tab {
  appearance: none;
  border: 1px solid rgba(140, 130, 115, 0.22);
  background: rgba(0, 0, 0, 0.35);
  color: rgba(170, 162, 148, 0.55);
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  padding: 0.35em 0.6em;
  cursor: pointer;
}
.tab.is-on {
  color: rgba(230, 200, 160, 0.9);
  border-color: rgba(180, 130, 70, 0.4);
  background: rgba(40, 28, 12, 0.5);
}
.tab.is-lock { opacity: 0.3; cursor: not-allowed; }

.echo-card {
  flex: 1;
  min-height: 8rem;
  padding: 1.1rem 0.25rem 0.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.echo-card h2 {
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  margin: 0 0 0.75rem;
  color: rgba(228, 222, 210, 0.92);
}
.echo-card p {
  font-size: 0.95rem;
  line-height: 1.9;
  letter-spacing: 0.05em;
  color: rgba(200, 194, 180, 0.8);
  margin: 0;
}

.track-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.track-row b {
  display: block;
  font-size: 0.95rem;
  letter-spacing: 0.1em;
}
.track-row i {
  font-style: normal;
  font-size: 0.72rem;
  color: rgba(160, 152, 140, 0.45);
}
.btn-icon {
  width: 2.4rem;
  height: 2.4rem;
  appearance: none;
  border: 1px solid rgba(150, 140, 120, 0.28);
  background: rgba(0, 0, 0, 0.4);
  color: rgba(228, 222, 210, 0.85);
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-icon:disabled { opacity: 0.35; cursor: not-allowed; }
.note {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: rgba(160, 152, 140, 0.45);
  letter-spacing: 0.08em;
}

.rain-mute-btn {
  position: fixed;
  right: 0.85rem;
  bottom: 0.85rem;
  z-index: 60;
  appearance: none;
  font-family: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: rgba(160, 152, 140, 0.45);
  border: 1px solid rgba(120, 115, 100, 0.2);
  background: rgba(0, 0, 0, 0.4);
  padding: 0.4em 0.7em;
  cursor: pointer;
}
.rain-mute-btn:hover {
  color: rgba(200, 194, 180, 0.75);
}
