/* =====================================================================
   荒野低语 —— 游戏样式
   布局：背景 + 立绘铺满；左上标题图标，右上小猫设置；
        底部文本框（左窄=说话人 / 右宽=台词）；选项浮在文本框上方。
   ===================================================================== */

:root {
  --ink: #0a0b10;
  --ink-2: #0f1118;
  --panel: rgba(15, 17, 24, 0.88);
  --panel-line: rgba(216, 162, 74, 0.22);
  --paper: #e9e4d9;
  --paper-dim: #a9a49a;
  --accent: #d8a24a;
  --accent-soft: rgba(216, 162, 74, 0.16);
  --danger: #c9614f;
  --ok: #7fae8b;
  --radius: 14px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --font-sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", system-ui,
    -apple-system, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  position: fixed;
  inset: 0;
}

button {
  font-family: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 15px;
}

input {
  font-family: inherit;
  color: inherit;
}

.hidden { display: none !important; }

/* 可点/可长按的元素：禁止长按选中文字、去掉 300ms 点击延迟 */
.slot,
.invite-row,
.menu-item,
.choice-btn,
.status-card,
.seg-item,
.cat-btn,
.logo-btn,
.btn {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* ------------------------------ 屏幕容器 ------------------------------ */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  opacity: 0;
}

.screen.active {
  display: flex;
  opacity: 1;
  animation: screen-in 0.34s ease both;
}

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

/* ------------------------------ 启动页 ------------------------------ */

.boot {
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, #16202b 0%, #06070a 70%);
}

.boot-inner { text-align: center; }

.boot-mark {
  color: var(--accent);
  opacity: 0.85;
  animation: pulse 2.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.97); }
  50% { opacity: 0.9; transform: scale(1.03); }
}

.boot-text {
  margin-top: 14px;
  color: var(--paper-dim);
  letter-spacing: 0.28em;
  font-size: 12px;
}

/* ------------------------------ 登录页 ------------------------------ */

.login {
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--sat)) 20px calc(24px + var(--sab));
  background:
    radial-gradient(ellipse at 50% 0%, rgba(216, 162, 74, 0.10), transparent 60%),
    radial-gradient(circle at 50% 120%, #14181f 0%, #06070a 65%);
  overflow-y: auto;
}

.login-card {
  width: min(400px, 100%);
  padding: 30px 24px 24px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.login-head { text-align: center; margin-bottom: 22px; }

.login-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  color: var(--paper);
}

.login-sub {
  margin: 8px 0 0;
  font-size: 12px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--accent);
  opacity: 0.8;
}

.field { display: block; margin-bottom: 15px; }

.field > span {
  display: block;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--paper-dim);
  margin-bottom: 7px;
}

.field input {
  width: 100%;
  padding: 12px 13px;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.18s, background 0.18s;
}

.field input:focus {
  border-color: rgba(216, 162, 74, 0.6);
  background: rgba(216, 162, 74, 0.07);
}

.field input::placeholder { color: rgba(233, 228, 217, 0.28); }

.login-actions { display: grid; gap: 10px; margin-top: 20px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 15px;
  letter-spacing: 0.1em;
  transition: transform 0.14s, background 0.18s, border-color 0.18s, opacity 0.18s;
  border: 1px solid transparent;
}

.btn:active { transform: scale(0.975); }

.btn.primary {
  background: linear-gradient(180deg, rgba(216, 162, 74, 0.95), rgba(184, 132, 52, 0.95));
  color: #1a1408;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(216, 162, 74, 0.20);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--paper);
}

.btn.ghost:hover { background: rgba(255, 255, 255, 0.08); }

.btn:disabled { opacity: 0.45; pointer-events: none; }

.msg {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--danger);
  text-align: center;
}

.msg.ok { color: var(--ok); }

.login-foot {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11.5px;
  line-height: 1.75;
  color: rgba(233, 228, 217, 0.36);
  text-align: center;
}

/* ------------------------------ 起始界面 ------------------------------ */

.title-screen {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 42%, #1b2028 0%, #08090d 68%);
  cursor: pointer;
  padding: 24px;
}

.title-inner { text-align: center; animation: rise 0.9s ease both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.game-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(34px, 9.5vw, 66px);
  font-weight: 400;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  color: var(--paper);
  text-shadow: 0 0 46px rgba(216, 162, 74, 0.24);
}

.title-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px 0 22px;
}

.title-rule span {
  display: block;
  width: 76px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.title-hint {
  margin: 0;
  font-size: 12.5px;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: rgba(233, 228, 217, 0.45);
  animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.85; }
}

/* ------------------------------ 游戏主界面 ------------------------------ */

.game-screen {
  background: #000;
  overflow: hidden;
}

.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.bg-layer {
  position: absolute;
  inset: -2%;
  background-size: cover;
  background-position: center;
  transition: opacity 0.7s ease, background-image 0.01s;
  animation: kenburns 42s ease-in-out infinite alternate;
}

@keyframes kenburns {
  from { transform: scale(1) translate3d(0, 0, 0); }
  to { transform: scale(1.06) translate3d(-1%, -1%, 0); }
}

.bg-layer.swapping { opacity: 0; }

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 42%, rgba(0, 0, 0, 0.52) 100%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.34) 0%, transparent 22%, transparent 62%, rgba(0, 0, 0, 0.55) 100%);
}

.monster-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.55s ease;
}

.monster-layer.show { opacity: 1; }

.monster-layer img {
  max-height: 74%;
  max-width: 78%;
  object-fit: contain;
  filter: drop-shadow(0 0 42px rgba(0, 0, 0, 0.85)) contrast(1.04);
  animation: monster-in 1.4s ease both;
}

@keyframes monster-in {
  from { opacity: 0; transform: scale(1.08); filter: blur(8px) drop-shadow(0 0 42px #000); }
  to { opacity: 1; transform: scale(1); }
}

/* 立绘舞台：左右两栏，永远不重叠；整体抬到文字上方 */
.portrait-stage {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16%;
  height: 78%;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
  z-index: 5;
}

.portrait-slot {
  position: relative;
  flex: 1 1 50%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.36s ease, transform 0.5s ease, filter 0.36s ease;
}

/* 场上只有一个人时：居中铺满，不再占半边 */
.portrait-stage.solo .portrait-slot:not(.occupied) { display: none; }
.portrait-stage.solo .portrait-slot.occupied { flex: 1 1 100%; }
.portrait-stage.solo #portrait-left img.sprite,
.portrait-stage.solo #portrait-right img.sprite { margin: 0; }

/* 说话的人：往中间挪一点、更亮更大 */
.portrait-slot.active { transform: translateY(0) scale(1); z-index: 2; }
.portrait-slot.dim {
  opacity: 0.5;
  filter: brightness(0.72) saturate(0.8);
  transform: scale(0.94);
}

.portrait-slot img.sprite {
  max-height: 100%;
  max-width: 96%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 12px 42px rgba(0, 0, 0, 0.72));
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.42s ease, transform 0.5s ease;
  pointer-events: none;
}

.portrait-slot img.sprite.on { opacity: 1; transform: translateY(0); }

/* 左栏的人往右探一点，右栏的人往左探一点，视觉上更靠近画面中心 */
#portrait-left img.sprite { margin-right: -8%; }
#portrait-right img.sprite { margin-left: -8%; }

/* 顶栏 */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(10px + var(--sat)) calc(12px + var(--sar)) 0 calc(12px + var(--sal));
  pointer-events: none;
  z-index: 30;
}

.logo-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px 4px 4px;
  border-radius: 999px;
  background: rgba(8, 9, 13, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
  opacity: 0.82;
  transition: opacity 0.2s;
}

.logo-btn:hover { opacity: 1; }

.logo-glyph {
  width: 24px;
  height: 24px;
  color: var(--accent);
  flex: none;
}

.logo-text {
  font-family: var(--font-serif);
  font-size: 12.5px;
  letter-spacing: 0.14em;
  color: rgba(233, 228, 217, 0.9);
  white-space: nowrap;
}

.cat-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(8, 9, 13, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
  transition: transform 0.18s, background 0.2s, border-color 0.2s;
  opacity: 0.85;
}

.cat-btn:hover {
  background: rgba(216, 162, 74, 0.16);
  border-color: rgba(216, 162, 74, 0.45);
  opacity: 1;
  transform: scale(1.04);
}

.cat-btn:active { transform: scale(0.94); }

.cat-btn svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: rgba(233, 228, 217, 0.92);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cat-btn svg .eye { fill: var(--accent); stroke: none; }

/* 文本框：参照图风格——不要方框，文字直接压在画面上，
   背后只留一层柔和的压暗，保证任何背景上都读得清 */
.textbox {
  position: absolute;
  left: calc(22px + var(--sal));
  right: calc(22px + var(--sar));
  bottom: calc(18px + var(--sab));
  min-height: 96px;
  max-height: 46vh;
  display: grid;
  grid-template-columns: minmax(72px, 13%) 1fr;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  z-index: 20;
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
  isolation: isolate;
}

/* 底部柔和压暗（不阻挡点击） */
.textbox::before {
  content: '';
  position: absolute;
  left: -7%;
  right: -7%;
  top: -84px;
  bottom: -20px;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 62% 120% at 46% 104%, rgba(0, 0, 0, 0.60), rgba(0, 0, 0, 0) 74%),
    linear-gradient(to top, rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0.30) 46%, rgba(0, 0, 0, 0));
}

.textbox.bare { opacity: 0; transform: translateY(8px); pointer-events: none; }

.speaker {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 4px 12px 8px 2px;
  text-align: left;
  font-family: var(--font-serif);
  font-size: 15.5px;
  letter-spacing: 0.14em;
  line-height: 1.5;
  color: var(--accent);
  border-right: none;
  background: none;
  word-break: break-all;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.95);
}

.dialogue-wrap {
  position: relative;
  padding: 2px 40px 10px 6px;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  max-height: 46vh;
  /* 台词长了会滚动，但不要显示滚动条（之前右下角那根白条就是它） */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.dialogue-wrap::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* 其它可滚动区域也统一成细窄的暗色滚动条 */
.slots,
.history,
.status-grid,
.acc-list,
.sprite-grid,
.panel {
  scrollbar-width: thin;
  scrollbar-color: rgba(216, 162, 74, 0.35) transparent;
}

.slots::-webkit-scrollbar,
.history::-webkit-scrollbar,
.status-grid::-webkit-scrollbar,
.acc-list::-webkit-scrollbar,
.sprite-grid::-webkit-scrollbar,
.panel::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.slots::-webkit-scrollbar-thumb,
.history::-webkit-scrollbar-thumb,
.status-grid::-webkit-scrollbar-thumb,
.acc-list::-webkit-scrollbar-thumb,
.sprite-grid::-webkit-scrollbar-thumb,
.panel::-webkit-scrollbar-thumb {
  background: rgba(216, 162, 74, 0.35);
  border-radius: 3px;
}

.slots::-webkit-scrollbar-track,
.history::-webkit-scrollbar-track,
.status-grid::-webkit-scrollbar-track,
.acc-list::-webkit-scrollbar-track,
.sprite-grid::-webkit-scrollbar-track,
.panel::-webkit-scrollbar-track {
  background: transparent;
}

.dialogue {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 500;
  line-height: 2.02;
  letter-spacing: 0.035em;
  color: #f2eee4;
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.95),
    0 6px 22px rgba(0, 0, 0, 0.75);
  flex: 1;
}

.dialogue .em { color: var(--accent); }
.dialogue .shade { color: var(--paper-dim); font-style: italic; }

.cue {
  position: absolute;
  right: 12px;
  bottom: 2px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--accent);
  opacity: 0;
  transition: opacity 0.25s;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.9));
}

.cue.on { opacity: 0.85; animation: cue-bounce 1.15s ease-in-out infinite; }

@keyframes cue-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* 选项 */
.choice-layer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(140px + var(--sab));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  z-index: 40;
}

.choice-btn {
  width: min(560px, 100%);
  padding: 13px 20px;
  font-family: var(--font-serif);
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--paper);
  text-align: center;
  background: rgba(11, 13, 18, 0.90);
  border: 1px solid rgba(216, 162, 74, 0.34);
  border-radius: 11px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  transition: transform 0.16s, background 0.2s, border-color 0.2s;
  animation: choice-in 0.32s ease both;
}

.choice-btn:hover {
  background: rgba(216, 162, 74, 0.18);
  border-color: rgba(216, 162, 74, 0.7);
  transform: translateY(-1px);
}

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

.choice-btn .idx {
  color: var(--accent);
  margin-right: 8px;
  font-size: 13px;
}

@keyframes choice-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* 填空层 */
.input-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 5, 8, 0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 60;
  padding: 20px;
}

.input-card {
  width: min(380px, 100%);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}

.input-prompt {
  margin: 0 0 16px;
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.75;
  color: var(--paper-dim);
}

.input-card input {
  width: 100%;
  padding: 12px 14px;
  font-size: 17px;
  text-align: center;
  letter-spacing: 0.14em;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(216, 162, 74, 0.4);
  border-radius: 10px;
  outline: none;
  margin-bottom: 16px;
}

.input-card input:focus { border-color: var(--accent); background: rgba(216, 162, 74, 0.08); }

/* toast */
.toast {
  position: absolute;
  left: 50%;
  top: calc(58px + var(--sat));
  transform: translate(-50%, -8px);
  padding: 9px 18px;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--paper);
  background: rgba(10, 12, 17, 0.95);
  border: 1px solid rgba(216, 162, 74, 0.34);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s, transform 0.28s;
  z-index: 90;
  white-space: nowrap;
}

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

/* ------------------------------ 面板类界面 ------------------------------ */

.panel-screen {
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--sat)) 14px calc(16px + var(--sab));
  background:
    radial-gradient(ellipse at 50% -10%, rgba(216, 162, 74, 0.09), transparent 55%),
    #07080c;
  overflow-y: auto;
}

.panel {
  width: min(400px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 22px 20px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: panel-in 0.28s ease both;
}

.panel-wide { width: min(760px, 100%); }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(10px) scale(0.995); }
  to { opacity: 1; transform: none; }
}

.panel-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 18px;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--paper);
  flex: none;
}

.panel-note {
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-style: normal;
  letter-spacing: 0.08em;
  color: rgba(233, 228, 217, 0.38);
}

.panel-hint {
  margin: 14px 0 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: rgba(233, 228, 217, 0.5);
}

.panel-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: center;
  flex: none;
}

.panel-actions .btn { min-width: 108px; }

/* 设置六键 */
.menu-list { display: grid; gap: 9px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  font-size: 16px;
  letter-spacing: 0.16em;
  text-align: left;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 11px;
  transition: background 0.18s, border-color 0.18s, transform 0.14s;
}

.menu-item:hover {
  background: var(--accent-soft);
  border-color: rgba(216, 162, 74, 0.42);
}

.menu-item:active { transform: scale(0.99); }

.mi-icon {
  width: 22px;
  text-align: center;
  color: var(--accent);
  font-size: 15px;
  opacity: 0.85;
}

/* 次要操作（退出登录）：做得不显眼，别抢主按钮的注意力 */
.link-btn {
  display: block;
  margin: 18px auto 2px;
  padding: 8px 16px;
  font-size: 12.5px;
  letter-spacing: 0.16em;
  color: rgba(233, 228, 217, 0.38);
  border-radius: 8px;
  transition: color 0.18s, background 0.18s;
}

.link-btn:hover {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.05);
}

.title-logout {
  position: absolute;
  left: 50%;
  bottom: calc(30px + var(--sab));
  transform: translateX(-50%);
  padding: 8px 18px;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: rgba(233, 228, 217, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 999px;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}

.title-logout:hover {
  color: var(--paper);
  border-color: rgba(216, 162, 74, 0.5);
  background: rgba(216, 162, 74, 0.08);
}

/* 存档位 */
.slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 9px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px;
  flex: 1 1 auto;
  min-height: 0;
}

.slot {
  position: relative;
  min-height: 84px;
  padding: 10px 11px;
  text-align: left;
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 10px;
  transition: background 0.16s, border-color 0.16s, transform 0.14s;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.slot:hover { border-color: rgba(216, 162, 74, 0.45); background: rgba(216, 162, 74, 0.09); }
.slot:active { transform: scale(0.985); }
.slot.empty { opacity: 0.62; }
.slot.auto { border-style: dashed; }
.slot.disabled { opacity: 0.3; pointer-events: none; }
.slot.longpressed { border-color: var(--accent); }

.slot-no {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
  opacity: 0.85;
}

.slot-name {
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--paper);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}

.slot-meta {
  margin-top: auto;
  font-size: 10.5px;
  color: rgba(233, 228, 217, 0.38);
  letter-spacing: 0.04em;
}

/* 回顾 */
.history {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px;
  min-height: 0;
  min-height: 160px;
  max-height: 56vh;
  font-family: var(--font-serif);
  font-size: 14.5px;
  line-height: 2;
  color: rgba(233, 228, 217, 0.78);
  white-space: pre-wrap;
  word-break: break-word;
}

.history .h-name { color: var(--accent); }

/* 状态页 */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 11px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px;
}

.status-card {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(180deg, #191d26, #0c0e13);
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.status-card:hover {
  transform: translateY(-3px);
  border-color: rgba(216, 162, 74, 0.55);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}

.status-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  opacity: 0.96;
  transition: transform 0.3s;
  padding-top: 6%;
}

.status-card:hover img { transform: scale(1.04); }

.status-card .sc-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 8px 8px;
  font-family: var(--font-serif);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--paper);
  background: linear-gradient(transparent, rgba(4, 5, 8, 0.92));
}

.status-card.dead::after {
  content: "已故";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 16px;
  letter-spacing: 0.2em;
  color: rgba(201, 97, 79, 0.9);
  background: rgba(28, 8, 8, 0.55);
  backdrop-filter: grayscale(1);
}

/* 角色详情 */
.detail-body {
  display: grid;
  grid-template-columns: minmax(120px, 34%) 1fr;
  gap: 18px;
  flex: 1;
  min-height: 0;
}

.detail-photo {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(216, 162, 74, 0.24);
  background: linear-gradient(180deg, #191d26, #0c0e13);
  align-self: start;
  aspect-ratio: 3 / 4;
}

.detail-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  padding-top: 8%;
}

.detail-photo-name {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: 10px 6px 22px;
  font-family: var(--font-serif);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--paper);
  background: linear-gradient(rgba(4, 5, 8, 0.9), transparent);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}

.detail-stats { display: flex; flex-direction: column; gap: 18px; padding-top: 6px; }

.stat-row { display: flex; align-items: center; gap: 12px; }

.stat-label {
  flex: none;
  width: 62px;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--paper-dim);
}

.stat-bar {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.stat-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

#bar-faith { background: linear-gradient(90deg, #8e6f2f, var(--accent)); }
#bar-shelter { background: linear-gradient(90deg, #2f5a66, #6fb6c4); }

.stat-num {
  flex: none;
  width: 34px;
  text-align: right;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--paper);
}

.alive-row { margin-top: 4px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.07); }

.stat-alive { font-size: 15px; letter-spacing: 0.18em; color: var(--ok); }
.stat-alive.dead { color: var(--danger); }

/* 分段按钮 */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
}

.seg-item {
  padding: 10px 6px;
  font-size: 14.5px;
  letter-spacing: 0.14em;
  color: var(--paper-dim);
  border-radius: 8px;
  transition: background 0.18s, color 0.18s;
}

.seg-item.on {
  background: rgba(216, 162, 74, 0.9);
  color: #1a1408;
  font-weight: 600;
}

.seg.small { grid-auto-columns: auto; }

.seg.small .seg-item { padding: 7px 14px; font-size: 13px; letter-spacing: 0.08em; }

.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  font-size: 13.5px;
  letter-spacing: 0.1em;
  color: var(--paper-dim);
}

/* ------------------------------ 作者后台 ------------------------------ */

.admin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.invite-out {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 9px;
  overflow-y: auto;
  min-height: 40px;
  padding: 2px;
}

.invite-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(216, 162, 74, 0.26);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s;
}

.invite-row:hover { background: rgba(216, 162, 74, 0.12); border-color: rgba(216, 162, 74, 0.55); }
.invite-row:active { background: rgba(216, 162, 74, 0.2); }
.invite-row.used { opacity: 0.42; }

/* 刚生成的那一批，给个高亮方便一眼认出 */
.invite-row.fresh {
  border-color: rgba(216, 162, 74, 0.72);
  background: rgba(216, 162, 74, 0.10);
  box-shadow: inset 0 0 0 1px rgba(216, 162, 74, 0.18);
}

.invite-code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 14.5px;
  letter-spacing: 0.09em;
  color: var(--accent);
  word-break: break-all;
}

.invite-tag { font-size: 10.5px; letter-spacing: 0.06em; color: rgba(233, 228, 217, 0.42); }

.invite-empty {
  grid-column: 1 / -1;
  padding: 20px 0;
  text-align: center;
  font-size: 12.5px;
  letter-spacing: 0.12em;
  color: rgba(233, 228, 217, 0.32);
}

.total-bar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 4px 2px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 12px;
  flex: none;
}

.total-label { font-size: 13px; letter-spacing: 0.14em; color: var(--paper-dim); }

.total-num {
  font-family: var(--font-serif);
  font-size: 34px;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.total-online {
  margin-left: auto;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ok);
}

.acc-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; }

.acc-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 9px;
}

.acc-code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 13.5px;
  letter-spacing: 0.06em;
  color: var(--paper);
  word-break: break-all;
}

.acc-time { font-size: 12.5px; color: var(--paper-dim); font-variant-numeric: tabular-nums; }

.acc-dot { display: flex; align-items: center; gap: 5px; font-size: 11.5px; letter-spacing: 0.06em; color: rgba(233, 228, 217, 0.34); }
.acc-dot i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); }
.acc-dot.on { color: var(--ok); }
.acc-dot.on i { background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: dot-pulse 2s ease-in-out infinite; }

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.acc-empty { padding: 26px 0; text-align: center; font-size: 12.5px; color: rgba(233, 228, 217, 0.32); }

/* ------------------------------ 立绘切换 ------------------------------ */

.sprite-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 2px;
}

.sprite-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.sprite-char {
  flex: none;
  width: 92px;
  font-size: 12.5px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  color: var(--paper-dim);
}

.sprite-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }

.sprite-thumb {
  position: relative;
  width: 62px;
  height: 86px;
  padding: 0;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #1a1e26, #0d0f14);
  overflow: hidden;
  transition: border-color 0.16s, transform 0.14s, opacity 0.16s;
}

.sprite-thumb:hover { border-color: rgba(216, 162, 74, 0.5); transform: translateY(-2px); }

.sprite-thumb.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(216, 162, 74, 0.22);
}

.sprite-thumb.missing { opacity: 0.22; pointer-events: none; }

.sprite-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
}

.sprite-thumb .tag {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2px 0;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-align: center;
  color: rgba(233, 228, 217, 0.9);
  background: rgba(4, 5, 8, 0.62);
}

/* ------------------------------ 通用弹窗 ------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 5, 8, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal {
  width: min(360px, 100%);
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: panel-in 0.22s ease both;
}

.modal-title {
  margin: 0 0 14px;
  font-size: 14px;
  letter-spacing: 0.12em;
  color: var(--paper-dim);
}

.modal-input {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(216, 162, 74, 0.4);
  border-radius: 10px;
  outline: none;
}

.modal-input:focus { border-color: var(--accent); }

.modal-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }
.modal-actions .btn { min-width: 84px; padding: 10px 16px; font-size: 14px; }

/* ------------------------------ 横屏 / 桌面适配 ------------------------------ */

@media (min-width: 900px) {
  .textbox {
    left: 6%;
    right: 6%;
    min-height: 150px;
    grid-template-columns: minmax(110px, 12%) 1fr;
  }
  .dialogue { font-size: 17.5px; }
  .portrait-stage { bottom: 18%; height: 76%; }
  .choice-layer { bottom: calc(186px + var(--sab)); }
}

@media (max-height: 460px) and (orientation: landscape) {
  .textbox {
    min-height: 92px;
    max-height: 52vh;
  }
  .dialogue { font-size: 14px; line-height: 1.7; }
  .speaker { font-size: 12.5px; }
  .choice-layer { bottom: calc(104px + var(--sab)); gap: 7px; }
  .choice-btn { padding: 9px 16px; font-size: 14px; }
  .portrait-stage { bottom: 22%; height: 74%; }
  .cat-btn { width: 36px; height: 36px; }
  .cat-btn svg { width: 22px; height: 22px; }
  .logo-glyph { width: 20px; height: 20px; }
  .logo-text { font-size: 11px; }
}

/* 窄屏（手机竖屏）：两栏放不下，只显示正在说话的那一位，另一侧隐藏，绝不重叠 */
@media (max-width: 759px) {
  .portrait-stage { bottom: 19%; height: 74%; }
  .portrait-slot { flex: 1 1 100%; }
  .portrait-slot.dim { opacity: 0; }
  .portrait-slot img.sprite { max-width: 88%; }
  #portrait-left img.sprite,
  #portrait-right img.sprite { margin: 0; }
}

@media (max-width: 380px) {
  .textbox { grid-template-columns: minmax(66px, 20%) 1fr; }
  .speaker { font-size: 12.5px; padding: 12px 4px; }
  .dialogue { font-size: 15px; line-height: 1.85; }
  .dialogue-wrap { padding: 14px 28px 14px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .bg-layer { animation: none; }
}
