:root {
  --bg: #100e0c;
  --bg-2: #1a1510;
  --card: #221c16;
  --gold: #c9a36a;
  --gold-dim: #8d7348;
  --blood: #9a4040;
  --ok: #7d9a6a;
  --text: #f0e6d6;
  --muted: #8a7d6e;
  --line: #3a3228;
  --shadow: rgba(0, 0, 0, 0.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #070605;
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  overscroll-behavior: none;
}

#app {
  max-width: 430px;
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  background:
    radial-gradient(120% 80% at 50% -10%, #2a2118 0%, transparent 55%),
    var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.65);
}

.grain,
.vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 8;
}

.grain {
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.vignette {
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.55) 100%);
}

.hud {
  position: relative;
  z-index: 3;
  padding: calc(10px + var(--safe-top)) 16px 8px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 14, 12, 0.96), rgba(16, 14, 12, 0.78));
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hud-day {
  font-family: "Songti SC", "Noto Serif SC", "STSong", "SimSun", serif;
  letter-spacing: 0.12em;
  font-size: 14px;
  color: var(--gold);
}

.hud-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
}

.res-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.res-pill {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  min-width: 0;
}

.res-pill b {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.res-pill span {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.res-pill.warn b { color: #e0b15a; }
.res-pill.bad b { color: #e07a6a; }
.res-pill.flash { animation: flash 0.55s ease; }

@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(201, 163, 106, 0.55); }
  100% { box-shadow: 0 0 0 10px transparent; }
}

.cast-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.cast-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0 0;
  background: none;
  border: 0;
  color: inherit;
  min-width: 0;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  border: 2px solid var(--line);
  position: relative;
}

.avatar.linxia { background: #5a3030; }
.avatar.zhouye { background: #2c3c48; }
.avatar.chenmo { background: #3a4030; }
.avatar.xiaoyu { background: #4a3a28; }
.avatar.dead {
  filter: grayscale(1);
  opacity: 0.45;
}
.avatar.away { border-style: dashed; opacity: 0.7; }

.cast-chip em {
  font-style: normal;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.trust {
  width: 100%;
  height: 3px;
  background: #2a241c;
  border-radius: 99px;
  overflow: hidden;
}

.trust > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #8f3d3d, var(--gold));
  width: 50%;
}

.stage {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow: auto;
  padding: 18px 18px 12px;
  -webkit-overflow-scrolling: touch;
}

.stage::-webkit-scrollbar { width: 0; }

.title-wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 8px;
}

.skyline {
  height: 168px;
  margin: 12px 8px 28px;
  position: relative;
}

.skyline .block {
  position: absolute;
  bottom: 18px;
  background: #16110e;
  box-shadow: inset 0 0 0 1px #2a221a;
}

.skyline .w {
  position: absolute;
  width: 5px;
  height: 7px;
  background: #3a3228;
}

.skyline .w.lit {
  background: #c9a36a;
  box-shadow: 0 0 10px rgba(201, 163, 106, 0.7);
  animation: pulse 2.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.skyline .ground {
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: 0;
  height: 20px;
  background: #0c0a08;
  border-top: 1px solid #2a221a;
}

.logo {
  font-family: "Songti SC", "Noto Serif SC", "STSong", "SimSun", serif;
  font-size: 34px;
  letter-spacing: 0.28em;
  margin: 0 0 10px;
  text-indent: 0.28em;
}

.lead {
  color: var(--muted);
  line-height: 1.85;
  font-size: 14px;
  margin: 0 0 22px;
}

.prose {
  font-family: "Songti SC", "Noto Serif SC", "STSong", "SimSun", Georgia, serif;
  font-size: 16.5px;
  line-height: 1.95;
  letter-spacing: 0.03em;
  white-space: pre-wrap;
}

.prose p {
  margin: 0 0 1em;
}

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

.scene-kicker {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--gold-dim);
  margin: 0 0 12px;
  text-transform: none;
}

.loot-chip {
  display: inline-block;
  margin: 10px 6px 0 0;
  padding: 4px 10px;
  border: 1px solid var(--gold-dim);
  border-radius: 99px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.choices {
  position: relative;
  z-index: 4;
  padding: 8px 14px calc(14px + var(--safe-bot));
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(180deg, transparent, rgba(16, 14, 12, 0.92) 18%, var(--bg));
}

.btn,
.choice,
.btn-ghost,
.btn-danger {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  padding: 12px 14px;
  text-align: left;
}

.btn { text-align: center; background: #2a2218; border-color: var(--gold-dim); color: var(--gold); }
.btn-ghost { text-align: center; background: transparent; }
.btn-danger { text-align: center; color: #e08a7a; border-color: #5a3030; background: #2a1816; }

.choice { display: block; }
.choice small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.choice:active,
.btn:active,
.btn-ghost:active,
.cast-chip:active,
.hud-icon:active {
  transform: scale(0.985);
}

.choice[disabled],
.btn[disabled] {
  opacity: 0.4;
}

.toast {
  position: absolute;
  left: 50%;
  top: calc(88px + var(--safe-top));
  transform: translateX(-50%);
  z-index: 9;
  background: #2a2218;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  padding: 8px 14px;
  border-radius: 99px;
  font-size: 12px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet {
  position: absolute;
  inset: 0;
  z-index: 10;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 82%;
  overflow: auto;
  background: #1a1510;
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(18px + var(--safe-bot));
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 99px;
  background: #3a3228;
  margin: 4px auto 12px;
}

.sheet-panel h2 {
  font-family: "Songti SC", "Noto Serif SC", "STSong", serif;
  font-weight: 500;
  letter-spacing: 0.16em;
  font-size: 18px;
  margin: 0 0 12px;
}

.person {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.person .meta { font-size: 12px; color: var(--muted); line-height: 1.7; }
.person h3 { margin: 0 0 2px; font-size: 16px; font-weight: 600; }
.person .bar {
  margin-top: 8px;
  height: 4px;
  background: #2a241c;
  border-radius: 99px;
  overflow: hidden;
}
.person .bar > i { display: block; height: 100%; background: var(--gold); }

.item-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 16px;
}

.menu-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  margin: 0 0 14px;
}

.ending-mark {
  font-family: "Songti SC", "Noto Serif SC", "STSong", serif;
  color: var(--gold);
  letter-spacing: 0.2em;
  font-size: 13px;
  margin: 0 0 8px;
}

.ending-name {
  font-family: "Songti SC", "Noto Serif SC", "STSong", serif;
  font-size: 28px;
  letter-spacing: 0.18em;
  margin: 0 0 16px;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
