/* 深宫谋 · 竖屏宫斗 */
:root {
  --night: #12080a;
  --night-2: #1c0b0d;
  --wine: #3a1116;
  --wine-2: #5a1d23;
  --gold: #e7bd6c;
  --gold-2: #b9853a;
  --gold-3: #ffe6b8;
  --cream: #f8ecd6;
  --cream-2: #efd9b5;
  --orange: #ff8a3d;
  --orange-2: #e46f25;
  --ink: #3f1c11;
  --muted: rgba(255, 231, 196, .58);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: #0a0506;
  color: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(80% 50% at 50% 0%, #2a1013 0%, #12080a 58%, #070304 100%);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.game {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--night);
  box-shadow: 0 0 80px rgba(0, 0, 0, .7);
  isolation: isolate;
}

/* ---------- 背景画面 ---------- */
.art {
  position: absolute;
  inset: -2px;
  z-index: 0;
  background: #1b0b0d url("assets/palace.jpg") center top / cover no-repeat;
  transform: scale(1.02);
  animation: artBreathe 28s ease-in-out infinite alternate;
  filter: saturate(1.06) contrast(1.01);
}

@keyframes artBreathe {
  from { transform: scale(1.02) translateY(0); }
  to { transform: scale(1.055) translateY(-7px); }
}

.veil {
  position: absolute;
  left: 0;
  right: 0;
  top: 30%;
  bottom: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg,
    rgba(16, 7, 9, 0) 0%,
    rgba(16, 7, 9, .28) 8%,
    rgba(16, 7, 9, .62) 16%,
    rgba(16, 7, 9, .88) 23%,
    rgba(16, 7, 9, .96) 29%,
    rgba(16, 7, 9, .995) 39%,
    #12080a 56%,
    #12080a 100%);
}

.veil::after {
  content: "";
  position: absolute;
  inset: 0;
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 32%, #000 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 32%, #000 100%);
}

.petals {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 44%;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.petal {
  position: absolute;
  top: -24px;
  width: 9px;
  height: 13px;
  border-radius: 62% 38% 62% 38%;
  background: linear-gradient(135deg, #ffd0d0 0%, #f39aa8 48%, #d96d82 100%);
  opacity: .45;
  filter: blur(.15px);
  animation-name: petalFall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  will-change: transform;
}

@keyframes petalFall {
  0% { transform: translate3d(0, -24px, 0) rotate(0deg); opacity: 0; }
  8% { opacity: .55; }
  85% { opacity: .4; }
  100% { transform: translate3d(var(--sway, 34px), 128vh, 0) rotate(560deg); opacity: 0; }
}

/* ---------- 顶部状态栏 ---------- */
.hud {
  position: relative;
  z-index: 6;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(var(--safe-top) + 10px) 14px 12px;
  border-bottom: 1px solid rgba(231, 189, 108, .18);
  background: linear-gradient(180deg, #15090b 0%, #12080a 58%, #1b0c0f 100%);
  box-shadow: 0 7px 20px rgba(0, 0, 0, .34);
}

.chapter-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 11px 6px 6px;
  border: 1px solid rgba(231, 189, 108, .52);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(91, 31, 36, .82) 0%, rgba(40, 14, 17, .94) 100%);
  box-shadow:
    0 5px 16px rgba(0, 0, 0, .36),
    inset 0 1px 0 rgba(255, 230, 180, .16),
    inset 0 0 0 1px rgba(255, 224, 170, .05);
}

.chapter-chip::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(231, 189, 108, .18);
  border-radius: 7px;
  pointer-events: none;
}

.chapter-seal {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #4a1c08;
  background:
    radial-gradient(circle at 32% 24%, #fff0c9 0%, #f4c77c 28%, #cf8f3e 62%, #8f5a1e 100%);
  box-shadow:
    0 0 0 1px rgba(255, 240, 205, .75),
    0 0 12px rgba(255, 162, 72, .3),
    inset 0 -2px 4px rgba(90, 45, 8, .35);
}

.chapter-seal .mp-icon {
  width: 16px;
  height: 16px;
}

.chapter-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.05;
}

.chapter-copy em {
  font-style: normal;
  font-size: 9px;
  letter-spacing: .2em;
  color: rgba(255, 228, 178, .6);
  transform: scale(.96);
  transform-origin: left center;
}

.chapter-copy strong {
  margin-top: 3px;
  max-width: 96px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .1em;
  color: #ffe6b8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .65);
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.stat {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid rgba(231, 189, 108, .34);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(54, 19, 23, .78), rgba(20, 8, 10, .84));
  box-shadow: inset 0 1px 0 rgba(255, 230, 180, .08), 0 3px 10px rgba(0, 0, 0, .25);
}

.stat .mp-icon {
  width: 16px;
  height: 16px;
  color: #ffc06e;
  filter: drop-shadow(0 0 4px rgba(255, 155, 64, .4));
}

#favorStat .mp-icon {
  color: #ffa08b;
  filter: drop-shadow(0 0 4px rgba(255, 114, 96, .36));
}

.stat-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.stat-copy em {
  font-style: normal;
  font-size: 8px;
  letter-spacing: .1em;
  color: rgba(255, 231, 196, .55);
}

.stat-copy b {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 700;
  color: #ffe7bb;
  font-variant-numeric: tabular-nums;
  transform-origin: center bottom;
}

.stat-copy b.stat-pop {
  animation: statPop .4s cubic-bezier(.2, .9, .3, 1.4);
}

@keyframes statPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.35); color: #fff3d0; }
  100% { transform: scale(1); }
}

.sound-btn {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(231, 189, 108, .34);
  border-radius: 50%;
  color: var(--gold);
  background: linear-gradient(180deg, rgba(54, 19, 23, .78), rgba(20, 8, 10, .84));
  box-shadow: inset 0 1px 0 rgba(255, 230, 180, .08);
  transition: transform .12s ease, color .2s ease;
}

.sound-btn:active {
  transform: scale(.92);
}

.sound-btn .mp-icon {
  width: 16px;
  height: 16px;
}

.sound-btn.is-off {
  color: rgba(255, 231, 196, .32);
}

/* ---------- 画面留白区 ---------- */
.stage {
  position: relative;
  z-index: 3;
  flex: 1 1 auto;
  min-height: 86px;
  pointer-events: none;
}

.stage-mark {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  opacity: .82;
}

.mark-line {
  display: block;
  width: 1px;
  height: 28px;
  background: linear-gradient(180deg, rgba(231, 189, 108, 0), rgba(231, 189, 108, .85));
}

.mark-text {
  writing-mode: vertical-rl;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 10px;
  letter-spacing: .33em;
  color: rgba(255, 230, 190, .78);
  text-shadow: 0 1px 5px rgba(0, 0, 0, .9);
}

.act-dots {
  position: absolute;
  left: 17px;
  bottom: 11px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.act-dots .dot {
  width: 5px;
  height: 5px;
  transform: rotate(45deg);
  border: 1px solid rgba(231, 189, 108, .42);
  background: rgba(20, 8, 10, .3);
  transition: all .25s ease;
}

.act-dots .dot.done {
  background: rgba(231, 189, 108, .55);
  border-color: rgba(255, 230, 180, .7);
}

.act-dots .dot.active {
  width: 7px;
  height: 7px;
  background: var(--orange);
  border-color: #ffe0ae;
  box-shadow: 0 0 9px rgba(255, 138, 61, .85);
}

/* ---------- 剧情区 ---------- */
.story {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
  margin-top: auto;
  padding: 0 16px;
}

.speaker-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
  margin-bottom: -10px;
}

.speaker-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 70%;
  padding: 5px 14px 6px 6px;
  border: 1px solid rgba(231, 189, 108, .62);
  border-radius: 10px 10px 10px 2px;
  background: linear-gradient(180deg, #65262b 0%, #45171b 55%, #2c0d10 100%);
  box-shadow:
    0 5px 14px rgba(0, 0, 0, .46),
    inset 0 1px 0 rgba(255, 230, 180, .22),
    inset 0 0 0 1px rgba(255, 224, 170, .05);
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .13em;
  color: #ffe3ae;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

.speaker-flower {
  flex: 0 0 21px;
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #5a2409;
  background: radial-gradient(circle at 32% 24%, #fff0c9, #eec375 42%, #bd7d2f 72%, #7f4a12 100%);
  box-shadow: 0 0 0 1px rgba(255, 240, 205, .72), 0 0 9px rgba(255, 166, 74, .25);
}

.speaker-flower .mp-icon {
  width: 13px;
  height: 13px;
}

.scene-count {
  padding-bottom: 4px;
  font-size: 9px;
  letter-spacing: .12em;
  color: rgba(255, 231, 196, .44);
  white-space: nowrap;
}

.dialogue-card {
  position: relative;
  min-height: 88px;
  padding: 18px 18px 15px;
  border: 1px solid rgba(231, 189, 108, .5);
  border-radius: 4px 13px 13px 13px;
  background:
    radial-gradient(140% 100% at 0% 0%, rgba(104, 37, 42, .7) 0%, rgba(55, 17, 21, .92) 48%, rgba(30, 10, 13, .97) 100%);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, .44),
    inset 0 0 0 1px rgba(255, 225, 170, .06),
    inset 0 0 40px rgba(0, 0, 0, .26);
}

.dialogue-card::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(231, 189, 108, .16);
  border-radius: 3px 9px 9px 9px;
  pointer-events: none;
}

.dialogue-card p {
  position: relative;
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 16px;
  line-height: 1.72;
  letter-spacing: .02em;
  color: #ffe8c9;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .55);
}

.orn {
  position: absolute;
  width: 11px;
  height: 11px;
  border-color: rgba(231, 189, 108, .8);
  border-style: solid;
  pointer-events: none;
}

.orn-tl { top: 3px; left: 3px; border-width: 1px 0 0 1px; }
.orn-tr { top: 3px; right: 3px; border-width: 1px 1px 0 0; }
.orn-bl { bottom: 3px; left: 3px; border-width: 0 0 1px 1px; }
.orn-br { bottom: 3px; right: 3px; border-width: 0 1px 1px 0; }

/* ---------- 选项区 ---------- */
.action-area {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 194px;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 14px;
  animation: choicesIn .3s ease both;
}

@keyframes choicesIn {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 10px 12px 10px 11px;
  border: 1px solid rgba(174, 120, 51, .78);
  border-radius: 12px;
  background:
    linear-gradient(180deg, #fff9ec 0%, #fae9ca 36%, #f1d8ad 70%, #e8c795 100%);
  color: var(--ink);
  text-align: left;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: .015em;
  box-shadow:
    0 4px 0 rgba(119, 73, 24, .46),
    0 9px 20px rgba(0, 0, 0, .3),
    inset 0 1px 0 rgba(255, 255, 255, .92);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}

.choice::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(163, 105, 38, .32);
  border-radius: 9px;
  pointer-events: none;
}

.choice::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 42px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(157, 101, 36, .22), transparent);
  pointer-events: none;
}

.choice:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 rgba(119, 73, 24, .46),
    0 4px 11px rgba(0, 0, 0, .32),
    inset 0 1px 0 rgba(255, 255, 255, .9);
  filter: brightness(.985);
}

.choice.is-picked {
  transform: translateY(3px);
  box-shadow:
    0 0 0 2px rgba(255, 170, 90, .8),
    0 0 24px rgba(255, 138, 61, .45),
    inset 0 1px 0 #fffdf6;
  filter: brightness(1.04);
}

.choices.is-locked .choice {
  pointer-events: none;
}

.choice-icon {
  flex: 0 0 27px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #7c3b16;
  background: radial-gradient(circle at 32% 24%, #fff7d8 0%, #f3d492 38%, #e2b466 64%, #b77a2e 100%);
  box-shadow:
    0 0 0 1px rgba(255, 246, 220, .9),
    0 0 10px rgba(255, 187, 96, .28),
    inset 0 -1px 2px rgba(124, 75, 20, .25);
}

.choice-icon .mp-icon {
  width: 15px;
  height: 15px;
}

.choice-text {
  flex: 1 1 auto;
  min-width: 0;
}

.choice-arrow {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  color: rgba(119, 67, 20, .5);
}

/* ---------- 结果与继续 ---------- */
.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  margin-top: 14px;
  animation: riseIn .28s ease both;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.delta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 25px;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}

.delta .mp-icon {
  width: 14px;
  height: 14px;
}

.delta.up {
  color: #ffe2ad;
  border: 1px solid rgba(255, 175, 95, .45);
  background: rgba(255, 138, 61, .18);
  box-shadow: 0 0 14px rgba(255, 138, 61, .12);
}

.delta.down {
  color: #ffc3b5;
  border: 1px solid rgba(255, 129, 108, .36);
  background: rgba(176, 54, 42, .22);
}

.delta.flat {
  color: rgba(255, 231, 196, .62);
  border: 1px solid rgba(255, 231, 196, .16);
  background: rgba(255, 255, 255, .05);
}

.next-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 154px;
  height: 44px;
  padding: 0 24px;
  border: 1px solid rgba(255, 228, 178, .68);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffbb79 0%, #ff8a3d 52%, #dc6820 100%);
  color: #3a1706;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .16em;
  text-indent: .16em;
  box-shadow:
    0 5px 0 #9c4714,
    0 11px 24px rgba(255, 138, 61, .3),
    inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}

.next-btn .mp-icon {
  width: 18px;
  height: 18px;
  color: #3a1706;
}

.next-btn:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 #9c4714,
    0 6px 14px rgba(255, 138, 61, .24),
    inset 0 1px 0 rgba(255, 255, 255, .45);
  filter: brightness(.98);
}

/* ---------- 底部菜单 ---------- */
.tabbar {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  margin: 14px -16px 0;
  padding: 8px 10px calc(var(--safe-bottom) + 6px);
  border-top: 1px solid rgba(231, 189, 108, .33);
  background: linear-gradient(180deg, rgba(30, 12, 14, .95) 0%, #0e0506 100%);
  box-shadow: 0 -9px 26px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 230, 180, .06);
}

.tab {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 0 2px;
  color: rgba(255, 231, 196, .46);
  font-size: 10px;
  letter-spacing: .14em;
  transition: color .2s ease, transform .12s ease;
}

.tab + .tab::after {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  height: 56%;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(231, 189, 108, .2), transparent);
}

.tab .mp-icon {
  width: 22px;
  height: 22px;
}

.tab:active {
  transform: scale(.94);
}

.tab.is-active {
  color: #ffb466;
}

.tab.is-active .mp-icon {
  filter: drop-shadow(0 0 8px rgba(255, 138, 61, .55));
}

.tab.is-active::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 28px;
  height: 2px;
  border-radius: 2px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, #ff9a4d, transparent);
  box-shadow: 0 0 9px #ff8a3d;
}

.tab-dot {
  position: absolute;
  top: 0;
  right: calc(50% - 25px);
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 8px;
  background: #ff8a3d;
  color: #2a0f04;
  font-size: 9px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  box-shadow: 0 0 8px rgba(255, 138, 61, .4);
}

/* ---------- 提示 ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 96px);
  z-index: 50;
  max-width: 86%;
  padding: 8px 16px;
  border: 1px solid rgba(231, 189, 108, .42);
  border-radius: 999px;
  background: rgba(22, 9, 11, .94);
  color: #ffe6b8;
  font-size: 12px;
  letter-spacing: .04em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity .24s ease, transform .24s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 结局 ---------- */
.ending-layer {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 18px) 18px calc(var(--safe-bottom) + 18px);
}

.ending-layer[hidden] {
  display: none;
}

.ending-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 3, 4, .7);
  -webkit-backdrop-filter: blur(10px) saturate(.85);
  backdrop-filter: blur(10px) saturate(.85);
  animation: fadeIn .3s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ending-card {
  position: relative;
  width: 100%;
  max-width: 358px;
  max-height: 100%;
  overflow-y: auto;
  padding: 104px 22px 22px;
  border: 1px solid rgba(231, 189, 108, .68);
  border-radius: 20px;
  background:
    radial-gradient(120% 80% at 50% 0%, #742f30 0%, #4b191d 38%, #2a0d10 78%, #1a080a 100%);
  box-shadow:
    0 26px 70px rgba(0, 0, 0, .66),
    inset 0 0 0 1px rgba(255, 226, 170, .12),
    inset 0 0 70px rgba(0, 0, 0, .28);
  text-align: center;
  animation: cardIn .46s cubic-bezier(.18, .9, .26, 1.08) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ending-card::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(231, 189, 108, .2);
  border-radius: 14px;
  pointer-events: none;
}

.ending-card.is-bad {
  background:
    radial-gradient(120% 80% at 50% 0%, #4b3a3f 0%, #2d2126 42%, #190f13 80%, #10080a 100%);
}

.ending-portrait {
  position: absolute;
  top: 14px;
  left: 50%;
  width: 80px;
  height: 80px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #2a0d10 url("assets/portrait.jpg") center 26% / cover no-repeat;
  box-shadow:
    0 0 0 2px rgba(231, 189, 108, .82),
    0 0 0 5px rgba(26, 8, 10, .88),
    0 0 0 6px rgba(231, 189, 108, .32),
    0 12px 26px rgba(0, 0, 0, .5);
}

.ending-seal {
  position: absolute;
  top: 16px;
  right: 14px;
  width: 40px;
  height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(214, 77, 58, .62);
  border-radius: 3px;
  color: rgba(231, 99, 76, .82);
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 10px;
  line-height: 1.05;
  letter-spacing: .06em;
  transform: rotate(-7deg);
  opacity: .85;
}

.ending-kicker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-bottom: 7px;
  font-size: 9px;
  letter-spacing: .32em;
  color: rgba(255, 226, 176, .62);
}

.ending-kicker span {
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(231, 189, 108, .68));
}

.ending-kicker span:last-child {
  background: linear-gradient(90deg, rgba(231, 189, 108, .68), transparent);
}

.ending-card h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: .16em;
  text-indent: .16em;
  color: #ffe4ad;
  text-shadow: 0 2px 12px rgba(255, 154, 70, .28), 0 2px 3px rgba(0, 0, 0, .6);
}

.ending-rank {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 13px;
  border: 1px solid rgba(231, 189, 108, .38);
  border-radius: 999px;
  background: rgba(255, 218, 150, .08);
  font-size: 11px;
  letter-spacing: .14em;
  color: #ffd28e;
}

.ending-card p {
  margin: 14px 2px 0;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 14px;
  line-height: 1.85;
  letter-spacing: .02em;
  color: rgba(255, 236, 208, .82);
  text-align: left;
}

.ending-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.ending-stats span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border: 1px solid rgba(231, 189, 108, .22);
  border-radius: 999px;
  background: rgba(0, 0, 0, .16);
  font-size: 11px;
  color: rgba(255, 231, 196, .76);
}

.ending-stats .mp-icon {
  width: 14px;
  height: 14px;
  color: #ffb45f;
}

.ending-actions {
  display: flex;
  gap: 9px;
  margin-top: 18px;
}

.btn-primary,
.btn-ghost {
  display: inline-flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .1em;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}

.btn-primary {
  border: 1px solid rgba(255, 228, 178, .66);
  background: linear-gradient(180deg, #ffbb79 0%, #ff8a3d 55%, #dc6820 100%);
  color: #3a1706;
  box-shadow: 0 4px 0 #9c4714, 0 9px 20px rgba(255, 138, 61, .24), inset 0 1px 0 rgba(255, 255, 255, .48);
}

.btn-ghost {
  border: 1px solid rgba(231, 189, 108, .48);
  background: rgba(255, 218, 150, .06);
  color: #ffe1ae;
}

.btn-primary:active,
.btn-ghost:active {
  transform: translateY(2px);
  filter: brightness(.97);
}

.btn-primary:active {
  box-shadow: 0 1px 0 #9c4714, 0 4px 10px rgba(255, 138, 61, .2);
}

/* ---------- 底部面板 ---------- */
.sheet-layer {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
}

.sheet-layer[hidden] {
  display: none;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 2, 3, .64);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fadeIn .22s ease both;
}

.sheet {
  position: relative;
  width: 100%;
  max-height: 78%;
  overflow-y: auto;
  padding: 16px 18px calc(var(--safe-bottom) + 14px);
  border-top: 1px solid rgba(231, 189, 108, .48);
  border-radius: 24px 24px 0 0;
  background:
    radial-gradient(120% 90% at 50% 0%, #3c1418 0%, #240c0f 48%, #150708 100%);
  box-shadow: 0 -22px 60px rgba(0, 0, 0, .62), inset 0 1px 0 rgba(255, 230, 180, .1);
  animation: sheetUp .3s cubic-bezier(.18, .86, .28, 1) both;
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  display: block;
  width: 38px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 2px;
  background: rgba(255, 231, 196, .25);
}

.sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.sheet-head h3 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .12em;
  color: #ffe4ad;
}

.sheet-head span {
  font-size: 11px;
  letter-spacing: .1em;
  color: #ffb466;
}

.sheet-sub {
  margin: 7px 0 14px;
  font-size: 11px;
  line-height: 1.6;
  color: rgba(255, 231, 196, .5);
}

.sheet-desc {
  margin: 12px 2px 17px;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 14px;
  line-height: 1.8;
  color: rgba(255, 236, 208, .8);
}

.sheet-actions {
  display: flex;
  gap: 9px;
}

.ending-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.ending-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid rgba(231, 189, 108, .2);
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(255, 225, 170, .065), rgba(255, 225, 170, .025));
}

.ending-item.locked {
  opacity: .58;
  border-color: rgba(231, 189, 108, .12);
}

.ending-medal {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(231, 189, 108, .26);
  border-radius: 50%;
  background: rgba(0, 0, 0, .18);
  color: rgba(255, 231, 196, .44);
}

.ending-medal.on {
  color: #4a1c08;
  background: radial-gradient(circle at 32% 24%, #fff1cc 0%, #f2c679 34%, #d39444 66%, #96601f 100%);
  box-shadow: 0 0 0 1px rgba(255, 240, 205, .6), 0 0 14px rgba(255, 165, 74, .22);
}

.ending-medal .mp-icon {
  width: 19px;
  height: 19px;
}

.ending-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.ending-item-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.ending-item-head strong {
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 15px;
  letter-spacing: .08em;
  color: #ffe3ae;
}

.ending-item-head em {
  font-style: normal;
  font-size: 9px;
  letter-spacing: .08em;
  color: rgba(255, 180, 110, .7);
}

.ending-copy p {
  margin: 3px 0 0;
  font-size: 11px;
  line-height: 1.55;
  color: rgba(255, 231, 196, .52);
}

.sheet-close {
  display: block;
  width: 100%;
  height: 40px;
  margin-top: 14px;
  border: 1px solid rgba(231, 189, 108, .34);
  border-radius: 999px;
  color: rgba(255, 231, 196, .76);
  font-size: 13px;
  letter-spacing: .16em;
  background: rgba(255, 225, 170, .045);
  transition: transform .12s ease, background .12s ease;
}

.sheet-close:active {
  transform: scale(.985);
  background: rgba(255, 225, 170, .09);
}

/* ---------- 短屏适配 ---------- */
@media (max-width: 374px) {
  .hud { padding-left: 12px; padding-right: 12px; }
  .chapter-copy strong { max-width: 82px; font-size: 13px; }
  .stat { padding: 0 6px; }
  .stat-copy em { display: none; }
  .stat-copy b { margin-top: 0; }
  .story { padding-left: 12px; padding-right: 12px; }
  .tabbar { margin-left: -12px; margin-right: -12px; }
  .choice { font-size: 14px; gap: 8px; }
  .choice::after { left: 39px; }
  .choice-icon { flex-basis: 25px; width: 25px; height: 25px; }
  .ending-card { padding-left: 18px; padding-right: 18px; }
}

@media (max-height: 700px) {
  .hud { padding-top: calc(var(--safe-top) + 6px); padding-bottom: 7px; }
  .stage { min-height: 64px; }
  .dialogue-card { min-height: 78px; padding: 14px 15px 11px; }
  .dialogue-card p { font-size: 15px; line-height: 1.6; }
  .action-area { min-height: 174px; }
  .choices { gap: 7px; margin-top: 10px; }
  .choice { min-height: 50px; padding: 8px 11px 8px 10px; font-size: 14px; }
  .tabbar { margin-top: 10px; padding-top: 6px; }
  .tab { padding-top: 2px; }
  .tab .mp-icon { width: 20px; height: 20px; }
  .ending-card { padding-top: 84px; }
  .ending-portrait { width: 70px; height: 70px; top: 12px; }
  .ending-card h2 { font-size: 26px; }
}

@media (max-height: 600px) {
  .stage { min-height: 34px; }
  .speaker-row { margin-bottom: -8px; }
  .scene-count { display: none; }
  .choice { min-height: 46px; font-size: 13.5px; }
  .dialogue-card { min-height: 70px; padding: 12px 14px 10px; }
  .dialogue-card p { font-size: 14px; }
  .action-area { min-height: 162px; }
  .hud { padding-bottom: 5px; }
  .chapter-copy em { display: none; }
  .chapter-copy strong { margin-top: 0; }
}

@media (min-width: 521px) {
  .game {
    border-left: 1px solid rgba(231, 189, 108, .14);
    border-right: 1px solid rgba(231, 189, 108, .14);
  }
}

@media (prefers-reduced-motion: reduce) {
  .art { animation: none; }
  .petal { display: none; }
  * {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
