/* ============================================================
   《湿件协议》v2 — 高对比、移动适配、更强氛围
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;700;900&family=JetBrains+Mono:wght@300;400;500&family=Cormorant+Garamond:wght@300;400;600&display=swap');

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

:root {
  --bg: #050608;
  --ink: #fff5ee;
  --ink-dim: rgba(255, 245, 238, 0.72);
  --ink-faint: rgba(255, 245, 238, 0.4);
  --neon-pink: #ff5fb0;
  --neon-cyan: #5dffd9;
  --neon-amber: #ffc46e;
  --neon-violet: #b18bff;
  --neon-blood: #ff3a64;
  --rule: rgba(255, 255, 255, 0.12);
}

html, body, #root {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Serif SC', serif;
  -webkit-font-smoothing: antialiased;
  cursor: default;
}
html, body { overscroll-behavior: none; touch-action: manipulation; }

button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }

.app {
  position: fixed; inset: 0; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(80, 30, 60, 0.22), transparent 60%),
    radial-gradient(ellipse at 30% 90%, rgba(20, 60, 80, 0.26), transparent 55%),
    #050608;
  transition: background 1.6s ease;
}
.app.mood-thinking { background: radial-gradient(ellipse at 50% 30%, rgba(140, 90, 30, 0.24), transparent 60%), radial-gradient(ellipse at 30% 90%, rgba(80, 50, 20, 0.2), transparent 55%), #060503; }
.app.mood-pain { background: radial-gradient(ellipse at 50% 40%, rgba(150, 25, 50, 0.32), transparent 55%), radial-gradient(ellipse at 70% 90%, rgba(80, 10, 30, 0.25), transparent 55%), #070304; }
.app.mood-love { background: radial-gradient(ellipse at 50% 40%, rgba(150, 60, 110, 0.26), transparent 60%), radial-gradient(ellipse at 30% 80%, rgba(70, 20, 90, 0.25), transparent 55%), #08050c; }
.app.mood-merge { background: radial-gradient(ellipse at 50% 50%, rgba(120, 70, 200, 0.32), transparent 55%), radial-gradient(ellipse at 30% 80%, rgba(70, 40, 140, 0.28), transparent 60%), #07050e; }
.app.mood-dying { background: radial-gradient(ellipse at 50% 50%, rgba(50, 50, 60, 0.4), transparent 60%), #030305; }
.app.mood-gone { background: #020203; }
.app.mood-ending { background: radial-gradient(ellipse at 50% 50%, rgba(180, 80, 140, 0.3), transparent 60%), radial-gradient(ellipse at 30% 80%, rgba(80, 30, 100, 0.25), transparent 60%), #08060a; }

.neural-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; opacity: 0.95;
  mix-blend-mode: screen;
}

.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(0,0,0,0.85) 100%);
}
.grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  opacity: 0.06;
  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='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
.scanlines {
  position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0px, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: overlay;
  opacity: 0.5;
}

/* 标题屏 */
.title-screen {
  position: relative; z-index: 10;
  width: 100%; height: 100%;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 5vh 6vw; text-align: center;
  animation: fadeUp 1.2s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.title-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; letter-spacing: 0.4em; color: var(--neon-pink);
  margin-bottom: 30px; opacity: 0.85;
}
.title-main {
  font-family: 'Noto Serif SC', serif; font-weight: 900;
  font-size: clamp(56px, 11vw, 168px);
  letter-spacing: 0.05em; line-height: 1;
  background: linear-gradient(180deg, #ffe6f0 0%, #ff85c0 40%, #b04060 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 30px rgba(255, 100, 170, 0.3));
}
.title-sub {
  font-family: 'JetBrains Mono', monospace; font-weight: 300;
  font-size: clamp(13px, 1.8vw, 22px); letter-spacing: 0.4em;
  color: var(--ink-dim); margin: 12px 0 50px;
}
.title-deck {
  font-size: clamp(15px, 1.4vw, 18px); line-height: 2;
  color: var(--ink-dim); max-width: 640px; margin-bottom: 36px;
  text-wrap: pretty;
}
.title-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.2em; color: var(--ink-faint);
  margin-bottom: 50px;
}

.start-btn {
  position: relative; padding: 18px 48px;
  font-family: 'Noto Serif SC', serif;
  font-size: 17px; letter-spacing: 0.3em;
  color: var(--ink);
  border: 1px solid rgba(255, 95, 176, 0.55);
  background: rgba(255, 95, 176, 0.08);
  backdrop-filter: blur(10px);
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
}
.start-btn:hover, .start-btn:active {
  border-color: rgba(255, 95, 176, 0.95);
  background: rgba(255, 95, 176, 0.16);
  letter-spacing: 0.4em;
  box-shadow: 0 0 50px rgba(255, 95, 176, 0.4), inset 0 0 20px rgba(255, 95, 176, 0.12);
}
.start-pulse {
  position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(255, 95, 176, 0.4), transparent 70%);
  opacity: 0; animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0; transform: scale(0.8); } 50% { opacity: 0.5; transform: scale(1.1); } }

.title-warn {
  position: absolute; bottom: 4vh;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.2em; color: var(--ink-faint);
  padding: 0 6vw;
}

/* HUD */
.play-stage {
  position: relative; z-index: 10;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  animation: fadeUp 0.8s ease;
}
.hud {
  display: grid; grid-template-columns: 1fr 2fr 1fr;
  align-items: start;
  padding: 22px 36px 18px;
  border-bottom: 1px solid var(--rule);
  gap: 20px;
  background: linear-gradient(180deg, rgba(0,0,0,0.4), transparent);
}
.hud-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.3em; color: var(--neon-pink);
}
.hud-chapter {
  font-family: 'Noto Serif SC', serif;
  font-size: 14px; letter-spacing: 0.15em;
  color: var(--ink); margin-top: 6px;
}
.hud-mid { display: flex; justify-content: center; }
.speaker-card {
  text-align: center; padding: 6px 24px;
  border-left: 1px solid var(--rule); border-right: 1px solid var(--rule);
  animation: fadeIn 0.6s ease;
}
.speaker-name {
  font-family: 'Noto Serif SC', serif; font-weight: 500;
  font-size: 13px; letter-spacing: 0.2em; color: var(--ink);
}
.speaker-role {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; letter-spacing: 0.25em; color: var(--ink-faint);
  margin-top: 4px;
}
.hud-right {
  display: flex; gap: 14px; align-items: center; justify-content: flex-end;
}
.pulse-meter { display: flex; align-items: center; gap: 10px; }
.pulse-label, .pulse-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; letter-spacing: 0.2em; color: var(--ink-faint);
}
.pulse-bar { width: 80px; height: 2px; background: rgba(255, 255, 255, 0.1); }
.pulse-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
  box-shadow: 0 0 10px var(--neon-pink);
  transition: width 0.8s ease;
}
.icon-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--rule);
  font-size: 14px; color: var(--ink-dim);
  transition: all 0.3s ease;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover, .icon-btn:active { color: var(--neon-pink); border-color: var(--neon-pink); }

/* 故事 */
.story-frame {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 4vh 8vw 6vh; max-width: 880px; margin: 0 auto; width: 100%;
  overflow-y: auto;
}
.typewriter { cursor: pointer; margin-bottom: 40px; }
.tw-line {
  font-family: 'Noto Serif SC', serif; font-weight: 400;
  font-size: clamp(17px, 1.5vw, 21px); line-height: 1.95;
  letter-spacing: 0.04em; color: var(--ink);
  margin-bottom: 12px; text-wrap: pretty;
  text-shadow: 0 0 18px rgba(255, 240, 230, 0.15);
}
.caret {
  display: inline-block; color: var(--neon-pink);
  animation: blink 0.7s steps(1) infinite; margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

.hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.3em; color: var(--ink-faint);
  text-align: center; margin-top: 20px;
}

/* 选择 — 高对比 */
.choices {
  display: flex; flex-direction: column; gap: 12px;
  opacity: 0; transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.choices.visible { opacity: 1; transform: translateY(0); }

.choice {
  display: grid; grid-template-columns: 100px 1fr 30px;
  align-items: center; gap: 18px;
  padding: 18px 24px; text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(8, 6, 12, 0.62);
  backdrop-filter: blur(10px);
  font-family: 'Noto Serif SC', serif;
  font-size: 16px; font-weight: 500;
  color: var(--ink);
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative; overflow: hidden;
  animation: choiceIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
@keyframes choiceIn { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: translateX(0); } }
.choice::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: linear-gradient(90deg, rgba(255, 95, 176, 0.18), transparent);
  transition: width 0.4s ease;
}
.choice:hover, .choice:active {
  border-color: rgba(255, 95, 176, 0.85);
  padding-left: 32px;
  box-shadow: -2px 0 0 var(--neon-pink), 0 0 24px rgba(255, 95, 176, 0.18);
  background: rgba(20, 10, 22, 0.78);
}
.choice:hover::before, .choice:active::before { width: 100%; }

.choice-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.18em; font-weight: 500;
  color: var(--neon-cyan); text-transform: uppercase;
  text-shadow: 0 0 10px rgba(93, 255, 217, 0.4);
}
.choice:hover .choice-tag, .choice:active .choice-tag {
  color: var(--neon-pink);
  text-shadow: 0 0 12px rgba(255, 95, 176, 0.6);
}
.choice-arrow {
  font-family: 'JetBrains Mono', monospace;
  color: var(--ink-dim); transition: all 0.3s ease;
}
.choice:hover .choice-arrow, .choice:active .choice-arrow { color: var(--neon-pink); transform: translateX(6px); }

/* 结局 */
.ending-screen {
  position: relative; z-index: 10;
  width: 100%; height: 100%;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; align-items: center;
  padding: 6vh 6vw; animation: fadeUp 1.4s ease;
}
.ending-frame { max-width: 760px; width: 100%; }
.ending-header {
  text-align: center; margin-bottom: 50px;
  border-bottom: 1px solid var(--rule); padding-bottom: 30px;
}
.ending-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.4em;
  color: var(--ending-color, var(--neon-pink)); margin-bottom: 14px;
}
.ending-title {
  font-family: 'Noto Serif SC', serif; font-weight: 700;
  font-size: clamp(34px, 5vw, 64px); letter-spacing: 0.05em;
  background: linear-gradient(180deg, #ffffff 0%, var(--ending-color, var(--neon-pink)) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-wrap: balance;
  filter: drop-shadow(0 0 30px var(--ending-color, rgba(255, 95, 176, 0.4)));
}
.ending-body { margin-bottom: 50px; }
.ending-body .tw-line {
  font-size: clamp(15px, 1.35vw, 19px); line-height: 2.05;
}

.ending-epilogue {
  font-family: 'Cormorant Garamond', serif; font-style: italic;
  font-size: 17px; line-height: 1.85;
  color: var(--ending-color, var(--neon-pink));
  text-align: center; padding: 28px 24px;
  border-top: 1px solid var(--ending-color, var(--rule));
  border-bottom: 1px solid var(--ending-color, var(--rule));
  margin-bottom: 50px; opacity: 0.92;
  text-wrap: balance;
}

.ending-collection { margin-bottom: 40px; }
.collection-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.3em;
  color: var(--ink-dim); text-align: center; margin-bottom: 20px;
}
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}
.collection-cell {
  padding: 14px 10px;
  border: 1px solid var(--rule);
  background: rgba(255,255,255,0.025); text-align: center;
  transition: all 0.4s ease;
}
.collection-cell.unlocked { border-color: rgba(255, 255, 255, 0.22); }
.collection-cell.current {
  border-color: var(--cell-color);
  background: rgba(255,255,255,0.05);
  box-shadow: 0 0 20px var(--cell-color);
}
.cell-name {
  font-family: 'Noto Serif SC', serif;
  font-size: 13px; font-weight: 500;
  color: var(--ink); margin-bottom: 4px;
}
.collection-cell.locked .cell-name { color: var(--ink-faint); }
.collection-cell.unlocked .cell-name { color: var(--cell-color); }
.cell-desc {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; letter-spacing: 0.15em; color: var(--ink-faint);
}

.restart-big {
  display: block; margin: 30px auto 0;
  padding: 18px 40px;
  font-family: 'Noto Serif SC', serif;
  font-size: 15px; letter-spacing: 0.25em;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.04);
  transition: all 0.4s ease;
}
.restart-big:hover, .restart-big:active {
  border-color: var(--ending-color);
  color: var(--ending-color);
  letter-spacing: 0.35em;
  box-shadow: 0 0 30px var(--ending-color);
}

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

/* ============================================================
   移动端适配
   ============================================================ */
@media (max-width: 768px) {
  .hud {
    grid-template-columns: 1fr auto;
    padding: 14px 16px;
    gap: 12px;
  }
  .hud-mid { display: none; }
  .hud-label { font-size: 9px; letter-spacing: 0.2em; }
  .hud-chapter { font-size: 12px; letter-spacing: 0.1em; }
  .pulse-meter { gap: 6px; }
  .pulse-bar { width: 50px; }
  .pulse-label { display: none; }
  .icon-btn { width: 32px; height: 32px; }

  .story-frame { padding: 3vh 5vw 4vh; }
  .tw-line { font-size: 16px; line-height: 1.85; margin-bottom: 10px; }

  .choice {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 14px 16px;
    font-size: 15px;
  }
  .choice-tag { font-size: 10px; }
  .choice-arrow { display: none; }
  .choice:hover, .choice:active { padding-left: 20px; }

  .title-main { font-size: 56px; letter-spacing: 0.04em; }
  .title-sub { font-size: 12px; margin: 8px 0 32px; }
  .title-deck { font-size: 14px; line-height: 1.85; margin-bottom: 24px; }
  .title-meta { font-size: 10px; margin-bottom: 32px; }
  .start-btn { padding: 14px 32px; font-size: 14px; letter-spacing: 0.25em; }
  .title-warn { font-size: 9px; }

  .ending-screen { padding: 4vh 5vw 6vh; }
  .ending-title { font-size: 36px; }
  .ending-body .tw-line { font-size: 14px; line-height: 1.85; }
  .ending-epilogue { font-size: 14px; padding: 18px 14px; }
  .collection-grid { grid-template-columns: repeat(3, 1fr); }
  .restart-big { padding: 14px 24px; font-size: 13px; letter-spacing: 0.2em; }
}

@media (max-width: 480px) {
  .title-main { font-size: 44px; }
  .ending-title { font-size: 28px; }
  .collection-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 横屏小高度适配 */
@media (max-height: 500px) and (orientation: landscape) {
  .title-screen { padding: 2vh 4vw; }
  .title-main { font-size: 48px; margin: 6px 0; }
  .title-sub { margin: 4px 0 16px; }
  .title-deck { margin-bottom: 16px; line-height: 1.6; }
  .title-meta { margin-bottom: 16px; }
  .title-warn { display: none; }
}
