/* ============================================================
   树洞 · Tree Hole — 纯黑白像素风（Undertale 风格）
   ------------------------------------------------------------
   配色：纯黑 + 纯白 + 一抹极淡的灰阶
   字体：Press Start 2P（标题/UI） + VT323（正文输入/对话）
   ============================================================ */

:root {
  --c-black: #000000;
  --c-white: #ffffff;
  --c-red: #ff0000;        /* HP 心形 */
  --c-gray-1: #1a1a1a;     /* UI 分隔 */
  --c-gray-2: #4a4a4a;     /* 暗灰 */
  --c-gray-3: #8a8a8a;     /* 提示 */
  --c-gray-4: #c8c8c8;     /* 暗白 */

  --f-pixel: 'Press Start 2P', 'VT323', monospace;
  --f-mono: 'VT323', 'Press Start 2P', monospace;

  /* 像素单位：4px 一格，所有 box-shadow 都按 4px 倍数对齐 */
  --p: 4px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: none;
  text-rendering: geometricPrecision;
  image-rendering: pixelated;
}

body {
  font-family: var(--f-pixel);
  background: var(--c-black);
  color: var(--c-white);
  min-height: 100vh;
  overflow-x: hidden;
  /* CRT 扫描线效果（极轻） */
  background-image:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 2px,
      rgba(255, 255, 255, 0.015) 2px,
      rgba(255, 255, 255, 0.015) 3px
    );
}

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

textarea {
  font-family: inherit;
  background: transparent;
  border: none;
  outline: none;
  color: inherit;
  resize: none;
}

::selection {
  background: var(--c-white);
  color: var(--c-black);
}

/* ============================================================
   屏幕容器
   ============================================================ */
.screen {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  position: relative;
}

.screen.hidden { display: none; }

/* ============================================================
   角色选择页（splash）
   ============================================================ */
.splash__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  max-width: 480px;
  width: 100%;
}

/* 像素树洞图标 */
.treehole {
  margin-bottom: 16px;
}

.treehole__sprite {
  width: var(--p);
  height: var(--p);
  background: var(--c-white);
  /* 用 box-shadow 绘制 32x32 像素的树洞 */
  box-shadow:
    /* 第1行：树冠顶 */
    0 0 0 0 transparent,
    /* 树干（中间列） */
    0 calc(var(--p) * 1) 0 var(--p) var(--c-white),
    0 calc(var(--p) * 2) 0 var(--p) var(--c-white),
    /* 树冠左右 */
    calc(var(--p) * -2) calc(var(--p) * 3) 0 var(--p) var(--c-white),
    calc(var(--p) * -1) calc(var(--p) * 3) 0 var(--p) var(--c-white),
    0 calc(var(--p) * 3) 0 var(--p) var(--c-white),
    calc(var(--p) * 1) calc(var(--p) * 3) 0 var(--p) var(--c-white),
    calc(var(--p) * 2) calc(var(--p) * 3) 0 var(--p) var(--c-white),
    /* 树冠加宽 */
    calc(var(--p) * -3) calc(var(--p) * 4) 0 var(--p) var(--c-white),
    calc(var(--p) * -2) calc(var(--p) * 4) 0 var(--p) var(--c-white),
    calc(var(--p) * -1) calc(var(--p) * 4) 0 var(--p) var(--c-white),
    0 calc(var(--p) * 4) 0 var(--p) var(--c-white),
    calc(var(--p) * 1) calc(var(--p) * 4) 0 var(--p) var(--c-white),
    calc(var(--p) * 2) calc(var(--p) * 4) 0 var(--p) var(--c-white),
    calc(var(--p) * 3) calc(var(--p) * 4) 0 var(--p) var(--c-white),
    /* 树干两侧（更粗） */
    calc(var(--p) * -1) calc(var(--p) * 5) 0 var(--p) var(--c-white),
    0 calc(var(--p) * 5) 0 var(--p) var(--c-white),
    calc(var(--p) * 1) calc(var(--p) * 5) 0 var(--p) var(--c-white),
    /* 树洞入口（黑） */
    0 calc(var(--p) * 5) 0 var(--p) var(--c-black),
    /* 树干底部 */
    0 calc(var(--p) * 6) 0 var(--p) var(--c-white),
    /* 树根 */
    calc(var(--p) * -1) calc(var(--p) * 7) 0 var(--p) var(--c-white),
    0 calc(var(--p) * 7) 0 var(--p) var(--c-white),
    calc(var(--p) * 1) calc(var(--p) * 7) 0 var(--p) var(--c-white);
}

.splash__title {
  font-family: var(--f-pixel);
  font-size: 40px;
  letter-spacing: 0.2em;
  color: var(--c-white);
  margin-bottom: 0;
  text-shadow: 4px 4px 0 var(--c-gray-2);
  animation: title-flicker 4s steps(2) infinite;
}

@keyframes title-flicker {
  0%, 95% { opacity: 1; }
  96% { opacity: 0.7; }
  97% { opacity: 1; }
  98% { opacity: 0.5; }
  100% { opacity: 1; }
}

.splash__sub {
  font-family: var(--f-mono);
  font-size: 24px;
  color: var(--c-gray-3);
  letter-spacing: 0.1em;
  margin-top: -8px;
  font-style: italic;
}

.splash__hint {
  font-family: var(--f-pixel);
  font-size: 8px;
  color: var(--c-gray-3);
  letter-spacing: 0.1em;
  margin-top: 16px;
  text-transform: uppercase;
}

/* ============================================================
   角色选项（黑白色调）
   ============================================================ */
.choices {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  max-width: 360px;
  border: 4px solid var(--c-white);
  background: var(--c-black);
  box-shadow: 8px 8px 0 var(--c-gray-2);
}

.choice {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  font-family: var(--f-pixel);
  font-size: 13px;
  color: var(--c-white);
  text-align: left;
  border-bottom: 2px solid var(--c-white);
  background: var(--c-black);
  transition: background 80ms steps(2), color 80ms steps(2);
  letter-spacing: 0.05em;
  position: relative;
}

.choice:last-child {
  border-bottom: none;
}

.choice:hover,
.choice:focus {
  background: var(--c-white);
  color: var(--c-black);
  outline: none;
}

.choice.is-active {
  background: var(--c-white);
  color: var(--c-black);
}

.choice.is-active::before {
  content: '♥';
  position: absolute;
  left: -32px;
  font-size: 24px;
  color: var(--c-red);
  animation: heart-beat 1s steps(2) infinite;
}

@keyframes heart-beat {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

.choice__cursor {
  display: inline-block;
  width: 18px;
  height: 18px;
  position: relative;
  flex-shrink: 0;
}

.choice__cursor::before {
  content: '▶';
  font-family: var(--f-pixel);
  font-size: 12px;
  color: var(--c-white);
  position: absolute;
  top: 0;
  left: 0;
  line-height: 18px;
}

.choice.is-active .choice__cursor::before,
.choice:hover .choice__cursor::before {
  color: var(--c-black);
}

.choice.is-active .choice__cursor {
  animation: blink 0.6s steps(2) infinite;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ============================================================
   倾诉页（黑白色调）
   ============================================================ */
.screen--tree {
  justify-content: flex-start;
  padding: 0;
}

.tree__header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 4px solid var(--c-white);
  font-family: var(--f-pixel);
  font-size: 10px;
  letter-spacing: 0.1em;
  background: var(--c-black);
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.tree__header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tree__back,
.tree__records {
  font-family: var(--f-pixel);
  font-size: 10px;
  color: var(--c-white);
  border: 2px solid var(--c-white);
  padding: 8px 12px;
  letter-spacing: 0.05em;
  transition: background 80ms steps(2), color 80ms steps(2);
  background: var(--c-black);
}

.tree__back:hover,
.tree__records:hover {
  background: var(--c-white);
  color: var(--c-black);
  border-color: var(--c-white);
}

.tree__role {
  font-family: var(--f-pixel);
  font-size: 11px;
  color: var(--c-white);
  letter-spacing: 0.1em;
}

/* HP 血条 */
.tree__hp {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0 0;
}

.hp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--f-pixel);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--c-white);
}

.hp-row__label {
  width: 64px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.hp-row__bar {
  display: flex;
  gap: 2px;
  flex: 1;
  align-items: center;
  flex-wrap: wrap;
}

.hp-cell {
  width: 10px;
  height: 10px;
  background: var(--c-red);
  display: inline-block;
  position: relative;
}

.hp-cell.is-empty {
  background: transparent;
  border: 1px solid var(--c-red);
}

.hp-row__count {
  color: var(--c-red);
  font-size: 9px;
  font-weight: bold;
  margin-left: 4px;
}

.hp-row.is-low .hp-cell:not(.is-empty) {
  animation: hp-blink 0.4s steps(2) infinite;
}

@keyframes hp-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

.tree__main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* 树洞图标 + 引导语 */
.tree__greeting {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.tree__greeting .treehole__sprite {
  flex-shrink: 0;
  margin-top: 4px;
}

.tree__line {
  font-family: var(--f-mono);
  font-size: 22px;
  line-height: 1.5;
  color: var(--c-white);
  letter-spacing: 0.02em;
  min-height: 1.5em;
}

/* 欢迎语的分段容器（多段拼接为单行） */
.tree__line-seg {
  display: inline;
}

.tree__line-seg--break {
  font-style: italic;
  color: var(--c-gray-3);
  padding-left: 4px;
  border-left: 2px solid var(--c-gray-2);
  margin-left: 4px;
  font-size: 18px;
}

.tree__line-seg--break::before {
  content: '» ';
  color: var(--c-gray-2);
  font-style: normal;
  margin-right: 2px;
}

.tree__line .tw-cursor {
  display: inline-block;
  width: 0.6em;
  height: 1em;
  background: var(--c-white);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 0.5s steps(2) infinite;
}

/* 对话气泡（黑白色调） */
.bubble {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bubble--user {
  align-items: flex-end;
}

.bubble--tree {
  align-items: flex-start;
}

.bubble--user .bubble__text {
  background: var(--c-white);
  color: var(--c-black);
  padding: 14px 18px;
  font-family: var(--f-mono);
  font-size: 20px;
  line-height: 1.5;
  max-width: 80%;
  border: 4px solid var(--c-white);
  box-shadow: 6px 6px 0 var(--c-gray-2);
}

.bubble--tree .bubble__text {
  background: var(--c-black);
  color: var(--c-white);
  padding: 14px 18px;
  font-family: var(--f-mono);
  font-size: 20px;
  line-height: 1.5;
  max-width: 88%;
  border: 4px solid var(--c-white);
  box-shadow: 6px 6px 0 var(--c-gray-2);
}

.bubble__line {
  display: block;
  white-space: pre-wrap;
}

.bubble__line + .bubble__line {
  margin-top: 6px;
}

/* 2 种行类型：calm（直接回答） / break（崩坏） */
.bubble__line--calm {
  color: inherit;
  font-family: var(--f-mono);
  font-size: 20px;
  line-height: 1.6;
  letter-spacing: 0.01em;
}

.bubble__line--break {
  color: var(--c-gray-3);
  font-family: var(--f-mono);
  font-size: 18px;
  line-height: 1.5;
  margin-top: 6px;
  font-weight: bold;
  font-style: italic;
}

.bubble__line--break::before {
  content: '» ';
  color: var(--c-white);
  font-weight: bold;
  font-style: normal;
}

/* 恢复型回应 */
.bubble--is-recovery .bubble__text {
  border-color: var(--c-gray-3);
  box-shadow: 6px 6px 0 var(--c-gray-1);
}

.bubble--is-recovery .bubble__role {
  color: var(--c-gray-3);
  font-style: italic;
}

/* 状态小标签（缓） */
.bubble__state-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border: 1px solid var(--c-white);
  font-size: 9px;
  color: var(--c-white);
  letter-spacing: 0.1em;
  vertical-align: middle;
  font-family: var(--f-pixel);
}

/* 用户气泡下的"分析"小字 */
.bubble__analysis {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  font-family: var(--f-pixel);
  font-size: 8px;
  color: var(--c-gray-3);
  margin-top: 4px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.bubble__analysis span {
  border: 1px solid var(--c-gray-3);
  padding: 2px 5px;
  font-style: normal;
  color: var(--c-white);
}

.bubble__role {
  font-family: var(--f-pixel);
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--c-white);
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
}

.bubble__role-tag {
  display: inline-block;
  border: 1px solid var(--c-white);
  padding: 2px 6px;
  font-size: 8px;
  color: var(--c-white);
  letter-spacing: 0.1em;
  vertical-align: middle;
  font-family: var(--f-pixel);
}

.bubble--user .bubble__role {
  align-self: flex-end;
  text-align: right;
  color: var(--c-gray-3);
}

.bubble--user .bubble__role-tag {
  border-color: var(--c-gray-3);
  color: var(--c-gray-3);
}

.bubble--tree .bubble__role {
  align-self: flex-start;
}

/* 输入框（黑白色调） */
.tree__input-wrap {
  border: 4px solid var(--c-white);
  background: var(--c-black);
  margin-top: auto;
  box-shadow: 6px 6px 0 var(--c-gray-2);
}

.tree__input-box {
  display: flex;
  align-items: flex-start;
  padding: 16px;
  gap: 8px;
  min-height: 80px;
}

.tree__caret {
  font-family: var(--f-pixel);
  font-size: 18px;
  color: var(--c-white);
  flex-shrink: 0;
  line-height: 1.5;
  animation: blink 0.8s steps(2) infinite;
}

.tree__input {
  flex: 1;
  font-family: var(--f-mono);
  font-size: 22px;
  line-height: 1.5;
  color: var(--c-white);
  background: transparent;
  caret-color: var(--c-white);
  width: 100%;
  letter-spacing: 0.02em;
}

.tree__input::placeholder {
  color: var(--c-gray-3);
  font-style: italic;
}

.tree__input.is-post-break::placeholder {
  color: var(--c-gray-2);
  font-style: italic;
}

.tree__input-wrap.is-post-break {
  border-color: var(--c-gray-2);
  box-shadow: 6px 6px 0 var(--c-gray-1);
}

.tree__input-wrap.is-post-break .tree__caret {
  color: var(--c-gray-3);
  animation: none;
}

.tree__input-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 2px solid var(--c-white);
}

.tree__counter {
  font-family: var(--f-pixel);
  font-size: 9px;
  color: var(--c-gray-3);
  letter-spacing: 0.1em;
}

.tree__submit {
  font-family: var(--f-pixel);
  font-size: 11px;
  color: var(--c-black);
  background: var(--c-white);
  padding: 10px 18px;
  border: 2px solid var(--c-white);
  letter-spacing: 0.1em;
  transition: all 80ms steps(2);
  box-shadow: 4px 4px 0 var(--c-gray-2);
}

.tree__submit:hover {
  background: var(--c-gray-3);
  border-color: var(--c-gray-3);
}

.tree__submit:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  box-shadow: none;
}

/* 底部 */
.tree__footer {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-top: 2px solid var(--c-white);
  font-family: var(--f-pixel);
  font-size: 8px;
  color: var(--c-gray-3);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

#break-counter {
  font-style: italic;
  text-align: right;
}

/* ============================================================
   家庭记忆画面（CRT 录像带美学）
   致敬 Football Game —— 模糊像素 + 扫描线 + 录像带 UI
   ============================================================ */
.frame {
  position: fixed;
  inset: 0;
  background: var(--c-black);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  animation: frame-fade-in 320ms steps(8) forwards;
}

@keyframes frame-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.frame__tv {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  max-width: 960px;
  width: 100%;
}

/* 屏幕：模糊的电视画面 */
.frame__screen {
  position: relative;
  flex: 1;
  aspect-ratio: 4 / 3;
  background: var(--c-black);
  border: 2px solid var(--c-white);
  padding: 32px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 0 4px var(--c-black),
    0 0 0 6px var(--c-white),
    12px 12px 0 rgba(255, 255, 255, 0.08);
}

/* 扫描线：横向重复 */
.frame__scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.03) 0px,
    rgba(255, 255, 255, 0.03) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  animation: scanlines-shift 4s linear infinite;
}

@keyframes scanlines-shift {
  from { background-position: 0 0; }
  to   { background-position: 0 60px; }
}

/* 噪点：模拟信号差 */
.frame__noise {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px),
    radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px);
  background-size: 40px 40px, 60px 60px, 80px 80px;
  pointer-events: none;
  animation: noise-jitter 200ms steps(2) infinite;
  mix-blend-mode: screen;
}

@keyframes noise-jitter {
  0%   { opacity: 0.6; }
  50%  { opacity: 0.9; }
  100% { opacity: 0.6; }
}

/* 字幕（白字） */
.frame__caption {
  position: relative;
  z-index: 2;
  font-family: var(--f-mono);
  font-size: 24px;
  color: var(--c-white);
  text-align: center;
  line-height: 1.6;
  letter-spacing: 0.05em;
  max-width: 90%;
  text-shadow:
    0 0 4px rgba(255, 255, 255, 0.5),
    0 0 12px rgba(255, 255, 255, 0.2);
  animation: caption-flicker 80ms steps(2) infinite;
}

/* 字幕重影（灰阶错位） */
.frame__caption-shadow {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--f-mono);
  font-size: 24px;
  color: transparent;
  letter-spacing: 0.05em;
  text-shadow:
    -2px 0 rgba(255, 255, 255, 0.55),
    2px 0 rgba(180, 180, 180, 0.4);
  pointer-events: none;
  animation: caption-flicker 80ms steps(2) infinite;
}

@keyframes caption-flicker {
  0%   { opacity: 1; }
  50%  { opacity: 0.92; }
  100% { opacity: 1; }
}

/* 录像带 UI */
.frame__vhs {
  width: 140px;
  flex-shrink: 0;
  background: var(--c-black);
  border: 2px solid var(--c-white);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow:
    0 0 0 4px var(--c-black),
    0 0 0 6px var(--c-white);
}

.frame__vhs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--f-pixel);
  font-size: 9px;
  color: var(--c-white);
  letter-spacing: 0.05em;
}

.frame__vhs-row--center {
  justify-content: center;
  gap: 16px;
}

.frame__vhs-dot {
  width: 8px;
  height: 8px;
  background: var(--c-white);
  border-radius: 50%;
  animation: vhs-blink 0.6s steps(2) infinite;
}

@keyframes vhs-blink {
  0%   { opacity: 1; }
  50%  { opacity: 0.2; }
  100% { opacity: 1; }
}

.frame__vhs-time {
  color: var(--c-white);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.frame__vhs-label {
  color: var(--c-white);
  font-size: 8px;
  letter-spacing: 0.15em;
  border: 1px solid var(--c-white);
  padding: 2px 4px;
}

.frame__vhs-btn {
  color: var(--c-white);
  font-family: var(--f-pixel);
  font-size: 12px;
  letter-spacing: 0.05em;
  user-select: none;
}

.frame__vhs-btn--play {
  font-size: 14px;
}

/* 磁带槽 */
.frame__vhs-tape {
  width: 100%;
  height: 36px;
  background: var(--c-black);
  border: 1px solid var(--c-white);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.frame__vhs-tape::before,
.frame__vhs-tape::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  background: var(--c-white);
}

.frame__vhs-tape::before { left: 0; }
.frame__vhs-tape::after  { right: 0; }

.frame__vhs-tape-inner {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 100%;
  padding: 0 12px;
  animation: tape-scroll 3s linear infinite;
}

.frame__vhs-tape-inner span {
  display: block;
  width: 4px;
  height: 16px;
  background: var(--c-white);
}

.frame__vhs-tape-inner span:nth-child(2) { height: 10px; }
.frame__vhs-tape-inner span:nth-child(3) { height: 18px; }
.frame__vhs-tape-inner span:nth-child(4) { height: 8px; }
.frame__vhs-tape-inner span:nth-child(5) { height: 16px; }
.frame__vhs-tape-inner span:nth-child(6) { height: 12px; }

@keyframes tape-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-16px); }
}

.frame__hint {
  margin-top: 24px;
  font-family: var(--f-pixel);
  font-size: 9px;
  color: var(--c-gray-3);
  letter-spacing: 0.2em;
  animation: blink 1s steps(2) infinite;
}

/* 画面下隐藏其他元素 */
.frame.active ~ * {
  /* 让 frame 之外的元素在 frame 激活时失焦 */
}

/* AI 生成的画面 */
.frame__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  filter:
    grayscale(1)
    contrast(1.15)
    brightness(0.92);
  animation: frame-img-appear 800ms steps(12) forwards;
  pointer-events: none;
}

@keyframes frame-img-appear {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* 文字 caption 悬浮在图片上 */
.frame__caption,
.frame__caption-shadow {
  position: absolute;
  z-index: 3;
  bottom: 24px;
  left: 0;
  right: 0;
  text-align: center;
  padding: 0 24px;
  max-width: none;
  transform: none;
  top: auto;
}

.frame__img:not(.hidden) ~ .frame__caption,
.frame__img:not(.hidden) ~ .frame__caption-shadow {
  text-shadow:
    0 0 4px rgba(0, 0, 0, 0.95),
    0 0 12px rgba(0, 0, 0, 0.8),
    2px 2px 0 rgba(0, 0, 0, 0.8);
}

/* Loading 动画 */
.frame__loading {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--f-pixel);
  font-size: 10px;
  color: var(--c-white);
  letter-spacing: 0.2em;
  background: var(--c-black);
}

.frame__loading-dot {
  width: 6px;
  height: 6px;
  background: var(--c-white);
  border-radius: 50%;
  animation: loading-blink 0.6s steps(2) infinite;
}

.frame__loading-dot:nth-child(2) { animation-delay: 0.2s; }
.frame__loading-dot:nth-child(3) { animation-delay: 0.4s; }

.frame__loading-text {
  margin-left: 12px;
  color: var(--c-white);
}

@keyframes loading-blink {
  0%   { opacity: 0.2; }
  50%  { opacity: 1; }
  100% { opacity: 0.2; }
}

@media (max-width: 600px) {
  .frame__tv {
    flex-direction: column;
  }
  .frame__vhs {
    width: 100%;
  }
  .frame__caption,
  .frame__caption-shadow {
    font-size: 18px;
  }
}

/* ============================================================
   弹窗
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal.hidden { display: none; }

.modal__card {
  background: var(--c-black);
  border: 2px solid var(--c-white);
  padding: 24px;
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal__title {
  font-family: var(--f-pixel);
  font-size: 14px;
  color: var(--c-white);
  letter-spacing: 0.1em;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--c-white);
}

.modal__sub {
  font-family: var(--f-mono);
  font-size: 16px;
  color: var(--c-gray-3);
}

.records {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--c-gray-2);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 50vh;
}

.records:empty::before {
  content: '还没有记录。';
  display: block;
  text-align: center;
  color: var(--c-gray-3);
  font-family: var(--f-mono);
  font-size: 16px;
  padding: 24px 0;
}

.record {
  border: 1px solid var(--c-gray-2);
  padding: 8px 12px;
  font-family: var(--f-mono);
  font-size: 16px;
  color: var(--c-white);
}

.record__head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--c-gray-3);
  margin-bottom: 4px;
}

.record__role {
  color: var(--c-white);
  font-weight: bold;
}

.record__body {
  line-height: 1.5;
}

.record__q {
  color: var(--c-white);
  margin-bottom: 4px;
}

.record__a {
  color: var(--c-gray-3);
  padding-left: 12px;
  border-left: 1px solid var(--c-gray-2);
}

.record__line {
  line-height: 1.5;
  color: var(--c-white);
  margin-bottom: 2px;
}

.record__line--break {
  font-style: italic;
  color: var(--c-gray-3);
  padding-left: 8px;
  border-left: 1px solid var(--c-gray-2);
  margin-top: 4px;
  margin-bottom: 4px;
  font-size: 14px;
}

.record__line--break::before {
  content: '» ';
  color: var(--c-gray-2);
  font-style: normal;
  margin-right: 2px;
}

.record__tag {
  display: inline-block;
  border: 1px solid var(--c-gray-3);
  padding: 1px 6px;
  font-size: 10px;
  margin-left: 6px;
  font-style: italic;
  color: var(--c-gray-3);
  letter-spacing: 0.1em;
  vertical-align: middle;
}

.record__tag--break {
  border-color: var(--c-gray-3);
}

.record__tag--recovery {
  border-style: dashed;
}

.modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn-pix {
  font-family: var(--f-pixel);
  font-size: 9px;
  color: var(--c-white);
  background: var(--c-black);
  border: 2px solid var(--c-white);
  padding: 10px 14px;
  letter-spacing: 0.1em;
  transition: all 80ms steps(2);
}

.btn-pix:hover {
  background: var(--c-white);
  color: var(--c-black);
}

.btn-pix--primary {
  background: var(--c-white);
  color: var(--c-black);
}

.btn-pix--primary:hover {
  background: var(--c-black);
  color: var(--c-white);
}

/* ============================================================
   通用工具
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   身份赋予页
   ============================================================ */
.screen--identity {
  justify-content: flex-start;
  padding: 48px 24px;
}

.identity__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 560px;
  width: 100%;
}

.identity__title {
  font-family: var(--f-pixel);
  font-size: 18px;
  letter-spacing: 0.15em;
  color: var(--c-white);
  text-align: center;
  margin-top: 8px;
  text-transform: uppercase;
}

.identity__sub {
  font-family: var(--f-mono);
  font-size: 18px;
  color: var(--c-gray-3);
  text-align: center;
  line-height: 1.6;
  letter-spacing: 0.05em;
}

.identity-presets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  width: 100%;
  border: 4px solid var(--c-white);
  background: var(--c-black);
  box-shadow: 8px 8px 0 var(--c-gray-2);
}

.identity-preset {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  font-family: var(--f-pixel);
  font-size: 10px;
  color: var(--c-white);
  text-align: left;
  background: var(--c-black);
  border-right: 2px solid var(--c-white);
  border-bottom: 2px solid var(--c-white);
  transition: background 80ms steps(2), color 80ms steps(2);
  letter-spacing: 0.05em;
  min-height: 48px;
  position: relative;
}

.identity-preset:nth-child(2n) {
  border-right: none;
}

.identity-preset:nth-last-child(-n+2) {
  border-bottom: none;
}

.identity-preset:hover,
.identity-preset:focus {
  background: var(--c-white);
  color: var(--c-black);
  outline: none;
}

.identity-preset.is-active {
  background: var(--c-white);
  color: var(--c-black);
}

.identity-preset.is-active::before {
  content: '♥';
  position: absolute;
  left: -28px;
  font-size: 20px;
  color: var(--c-red);
  animation: heart-beat 1s steps(2) infinite;
}

.identity-preset__cursor {
  display: inline-block;
  width: 12px;
  height: 12px;
  position: relative;
  flex-shrink: 0;
}

.identity-preset__cursor::before {
  content: '▶';
  font-family: var(--f-pixel);
  font-size: 10px;
  color: var(--c-white);
  line-height: 12px;
}

.identity-preset.is-active .identity-preset__cursor::before,
.identity-preset:hover .identity-preset__cursor::before {
  color: var(--c-black);
}

.identity-preset.is-active .identity-preset__cursor {
  animation: blink 0.6s steps(2) infinite;
}

.identity-preset__label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.identity-or {
  font-family: var(--f-pixel);
  font-size: 9px;
  color: var(--c-gray-3);
  letter-spacing: 0.15em;
  margin-top: 8px;
  text-transform: uppercase;
}

.identity-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 4px solid var(--c-white);
  padding: 14px 16px;
  background: var(--c-black);
  box-shadow: 8px 8px 0 var(--c-gray-2);
}

.identity-input__caret {
  font-family: var(--f-mono);
  font-size: 20px;
  color: var(--c-white);
  flex-shrink: 0;
  animation: blink 0.8s steps(2) infinite;
}

.identity-input {
  flex: 1;
  font-family: var(--f-mono);
  font-size: 20px;
  color: var(--c-white);
  background: transparent;
  border: none;
  outline: none;
  caret-color: var(--c-white);
  width: 100%;
  letter-spacing: 0.02em;
}

.identity-input::placeholder {
  color: var(--c-gray-3);
  font-style: italic;
}

.identity-hint {
  font-family: var(--f-pixel);
  font-size: 8px;
  color: var(--c-gray-3);
  letter-spacing: 0.1em;
  margin-top: 4px;
  text-transform: uppercase;
}

/* 记录弹窗中的身份风格小标签 */
.record__tag--style {
  border-style: dashed;
  color: var(--c-gray-3);
}

/* ============================================================
   GAME OVER 屏（精神状态归零 → 强制刷新）
   ============================================================ */
.screen--gameover {
  background: var(--c-black);
  z-index: 300;
  animation: gameover-fade 600ms steps(8) forwards;
}

@keyframes gameover-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.gameover__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 560px;
  width: 100%;
  text-align: center;
}

.gameover__heart {
  font-size: 80px;
  color: var(--c-red);
  line-height: 1;
  animation: heart-shatter 0.8s steps(4) forwards;
  text-shadow: 6px 6px 0 var(--c-gray-2);
}

@keyframes heart-shatter {
  0%   { transform: scale(1); opacity: 1; filter: none; }
  50%  { transform: scale(1.4) rotate(8deg); filter: blur(2px); }
  100% { transform: scale(0.8) rotate(-4deg); opacity: 0.85; filter: grayscale(1); }
}

.gameover__title {
  font-family: var(--f-pixel);
  font-size: 48px;
  letter-spacing: 0.2em;
  color: var(--c-red);
  text-shadow: 4px 4px 0 var(--c-gray-2);
  animation: gameover-flicker 1.2s steps(2) infinite;
}

@keyframes gameover-flicker {
  0%, 90% { opacity: 1; }
  92%     { opacity: 0.5; }
  94%     { opacity: 1; }
  96%     { opacity: 0.3; }
  98%     { opacity: 1; }
  100%    { opacity: 1; }
}

.gameover__sub {
  font-family: var(--f-mono);
  font-size: 22px;
  color: var(--c-white);
  line-height: 1.6;
  letter-spacing: 0.05em;
  font-style: italic;
}

.gameover__bar {
  width: 80%;
  height: 16px;
  border: 2px solid var(--c-white);
  background: var(--c-black);
  position: relative;
  overflow: hidden;
}

.gameover__bar::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  background:
    repeating-linear-gradient(
      90deg,
      var(--c-red) 0,
      var(--c-red) 12px,
      transparent 12px,
      transparent 16px
    );
  animation: gameover-bar-drain 1.5s steps(8) forwards;
}

@keyframes gameover-bar-drain {
  from { width: 100%; }
  to   { width: 0%; }
}

.gameover__btn {
  margin-top: 16px;
  font-family: var(--f-pixel);
  font-size: 13px;
  color: var(--c-white);
  background: var(--c-black);
  border: 2px solid var(--c-white);
  padding: 14px 24px;
  letter-spacing: 0.15em;
  box-shadow: 4px 4px 0 var(--c-gray-2);
  transition: all 80ms steps(2);
  animation: blink 1.2s steps(2) infinite;
}

.gameover__btn:hover {
  background: var(--c-white);
  color: var(--c-black);
}

.gameover__hint {
  font-family: var(--f-pixel);
  font-size: 8px;
  color: var(--c-gray-3);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 8px;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 480px) {
  .splash__title { font-size: 24px; }
  .splash__sub { font-size: 18px; }
  .choice { font-size: 12px; padding: 16px 18px; }
  .tree__line { font-size: 18px; }
  .bubble--user .bubble__text,
  .bubble--tree .bubble__text { font-size: 16px; }
  .tree__input { font-size: 16px; }
  .identity__title { font-size: 18px; }
  .identity__sub { font-size: 16px; }
  .identity-presets { grid-template-columns: 1fr; }
  .identity-preset { border-right: none !important; }
  .identity-preset:nth-last-child(2) { border-bottom: 2px solid var(--c-white); }
  .identity-preset:last-child { border-bottom: none; }
  .identity-input { font-size: 16px; }
}
