/* styles.css —— MIXXTOPIA 样式
 * 触屏虚拟按键（Issue #5）· 屏幕/HUD/对话框/菜单（Issue #6）· 对话框头像位（Issue #28）
 */

html,
body {
  margin: 0;
  height: 100%;
  background: #0b0b1e;
  overflow: hidden;
}

#app {
  position: relative; /* HUD/屏幕层以窗口为锚定位 */
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 游戏画面舞台：HUD 带 + 画布的竖排容器；对话框/虚化层以画布为锚（而非窗口），
   随画布整数缩放一起居中、一起移动（画布 display:block 消除行内基线空隙）。
   引擎 resize 时为 HUD 带预留了高度（main.js 传入 hudReserve），保证 HUD 不进画面 */
#stage {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* 像素风格缩放：整数倍放大 + nearest 采样，无模糊（引擎也通过 JS 兜底设置） */
#game {
  display: block;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  background: #0b0b1e;
}

.hidden {
  display: none !important;
}

/* ── 触屏虚拟按键（Issue #5）：pointer:coarse 设备显示十字键 + 操作键。
   Issue #18：A 确认，B 轻击，C 重击（右侧 2×2 网格，避免窄屏横向溢出） ── */

#touch-controls {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  padding: 0 8px calc(12px + env(safe-area-inset-bottom, 0px));
  pointer-events: none; /* 容器穿透，仅按键自身响应 */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* 粗指针（触屏/混合）设备默认显示；.touch-on 为 JS 检测兜底（旧浏览器无 pointer 媒体查询）；
   .touch-off 供主状态机在菜单/对话界面强制隐藏 */
@media (pointer: coarse), (any-pointer: coarse) {
  #touch-controls:not(.touch-off) {
    display: flex;
  }
}

#touch-controls.touch-on:not(.touch-off) {
  display: flex;
}

#touch-controls.touch-off {
  display: none !important;
}

/* ── 操作偏好（Issue #44）：auto 跟随设备检测；on/off 显式覆盖。
   与菜单态 .touch-off 正交——进入菜单的临时隐藏仍优先，不覆盖玩家偏好 ── */
#touch-controls.touch-pref-off {
  display: none !important;
}

#touch-controls.touch-pref-on:not(.touch-off) {
  display: flex !important;
}

#dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  grid-template-areas:
    ". up ."
    "left . right"
    ". down .";
  gap: 4px;
  pointer-events: auto;
}

#dpad [data-key="up"] { grid-area: up; }
#dpad [data-key="left"] { grid-area: left; }
#dpad [data-key="down"] { grid-area: down; }
#dpad [data-key="right"] { grid-area: right; }

.tbtn {
  width: 52px;
  height: 52px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Press Start 2P", monospace;
  font-size: 16px;
  line-height: 1;
  color: #f0e6d2;
  background: rgba(11, 11, 30, 0.6);
  border: 2px solid #ffc857;
  border-radius: 8px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
  touch-action: none;
  cursor: pointer;
  -webkit-touch-callout: none;
}

.tbtn.pressed {
  background: rgba(255, 200, 87, 0.45);
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}

#tbtn-a {
  grid-area: 2 / 1 / 3 / 3;
  justify-self: end;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border-color: #ff8fa3;
  background: rgba(255, 143, 163, 0.55);
  color: #ffffff;
  font-size: 20px;
  pointer-events: auto;
}

/* 右侧操作区：#18 战斗键 B（轻击）/ C（重击）在上，A（确认）在下 */
#touch-actions {
  display: grid;
  grid-template-columns: 46px 46px;
  grid-template-rows: 46px 56px;
  gap: 6px;
  justify-items: center;
  align-items: center;
  pointer-events: none;
}

#touch-actions #tbtn-b,
#touch-actions #tbtn-c {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 14px;
  pointer-events: auto;
}

#tbtn-b {
  grid-area: 1 / 1;
  border-color: #5ee6b8;
  background: rgba(94, 230, 184, 0.32);
}

#tbtn-c {
  grid-area: 1 / 2;
  border-color: #ffc857;
  background: rgba(255, 200, 87, 0.32);
}

/* ── 屏幕层与菜单（Issue #6）── */

/* 全屏覆盖层：标题/帮助/暂停/结算/结局共用；叠在画布之上 */
.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  text-align: center;
  color: #f0e6d2;
  font-family: "Press Start 2P", monospace;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(122, 45, 140, 0.35), transparent 60%),
    linear-gradient(180deg, #0b0b1e 0%, #1a1033 55%, #0b0b1e 100%);
}

.screen-title {
  margin: 0;
  font-size: 20px;
  color: #ffc857;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-btn {
  margin: 0;
  padding: 12px 26px;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.6;
  color: #f0e6d2;
  background: #14143a;
  border: 2px solid #ffc857;
  border-radius: 6px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.menu-btn:hover,
.menu-btn:focus-visible {
  background: #23235c;
  outline: none;
}

.menu-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.menu-btn.small {
  padding: 8px 18px;
  font-size: 10px;
}

/* ── 选择存档（Issue #8）：3 个固定存档位 ── */

.save-note {
  margin: 0;
  max-width: 320px;
  font-size: 9px;
  line-height: 1.7;
  color: #b8a8e0;
}

.save-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(320px, 86vw);
}

.slot-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.slot-btn {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  text-align: left;
}

.slot-del {
  flex: 0 0 auto;
  padding: 12px 14px;
  color: #ff9bb5;
  border-color: #7a3d5c;
}

.slot-del-confirm {
  background: #4a1430;
  border-color: #ff7ba9;
}

.slot-name {
  flex: 0 0 auto;
  font-size: 11px;
  color: #ffc857;
}

.slot-meta {
  min-width: 0; /* 允许 flex 子项收缩，超长进度文案走省略号 */
  font-size: 9px;
  line-height: 1.5;
  color: #d8cff0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-btn.slot-empty .slot-meta {
  color: #7f74a8;
}

.slot-btn.slot-confirm {
  border-color: #ff7ba9;
  background: #2a1440;
}

.slot-btn.slot-confirm .slot-meta {
  color: #ffb6c9;
}

.pause-note {
  min-height: 1.2em;
  margin: 0;
  font-size: 9px;
  line-height: 1.6;
  color: #ff9bb5;
}

/* 标题界面 */
.title-glow {
  animation: title-pulse 2.4s ease-in-out infinite alternate;
}

@keyframes title-pulse {
  from { opacity: 0.85; }
  to { opacity: 1; }
}

.title-main {
  margin: 0 0 10px;
  font-size: 34px;
  color: #ffffff;
  letter-spacing: 4px;
  text-shadow: 0 0 14px #ffc857, 2px 2px 0 #7a2d8c;
}

.title-sub {
  margin: 0 0 16px;
  font-size: 12px;
  color: #ff8fa3;
  letter-spacing: 6px;
}

.title-flavor {
  margin: 0;
  max-width: 440px;
  font-size: 8px;
  line-height: 2;
  color: #c9b8e8;
}

.footer-note {
  margin: 6px 0 0;
  font-size: 8px;
  color: #6f5f95;
}

/* 帮助界面 */
.help-body {
  max-width: 440px;
  font-size: 9px;
  line-height: 2.4;
  text-align: left;
  color: #f0e6d2;
}

.help-body b {
  color: #ffc857;
}

/* ── 登录 / 账户（Issue #43）：标题入口 + 登录表单 + 已登录面板 ── */

/* 标题账户按钮：昵称/邮箱可能较长，单行省略号截断（#44 标题优先显示昵称） */
.account-btn {
  max-width: min(320px, 86vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-btn.signed-in {
  border-color: #8ef0ff;
  color: #8ef0ff;
}

.account-note {
  min-height: 1.2em;
  margin: 0;
  max-width: 440px;
  font-size: 8px;
  line-height: 1.7;
  color: #ffb86b;
}

.login-note {
  margin: 0;
  max-width: 360px;
  font-size: 8px;
  line-height: 1.9;
  color: #b8a8e0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(320px, 86vw);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 9px;
  color: #ffc857;
  text-align: left;
}

.login-field input {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 10px;
  color: #f0e6d2;
  background: #0b0b1e;
  border: 2px solid #3a2a66;
  border-radius: 6px;
  outline: none;
}

.login-field input:focus {
  border-color: #ffc857;
}

.login-actions {
  display: flex;
  gap: 10px;
}

.login-actions .menu-btn {
  flex: 1 1 0;
  padding-left: 8px;
  padding-right: 8px;
}

.login-account {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.login-account-line {
  margin: 0;
  max-width: 360px;
  font-size: 10px;
  line-height: 1.8;
  color: #8ef0ff;
  overflow-wrap: anywhere;
}

.login-msg {
  min-height: 1.4em;
  margin: 0;
  max-width: 360px;
  font-size: 8px;
  line-height: 1.8;
  color: #b8a8e0;
}

.login-msg.login-msg-error {
  color: #ff9bb5;
}

.login-msg.login-msg-ok {
  color: #8ef0ff;
}

.login-privacy {
  margin: 0;
  max-width: 360px;
  font-size: 7px;
  line-height: 1.9;
  color: #6f5f95;
}

.login-privacy a {
  color: #8ef0ff;
}

.recovery-link {
  color: #8ef0ff;
  font-size: 12px;
  line-height: 1.8;
  text-underline-offset: 4px;
}

/* Standalone recovery remains scrollable with a phone keyboard or enlarged text. */
body.recovery-page {
  height: auto;
  min-height: 100%;
  overflow: auto;
  color: #f0e6d2;
  font-family: system-ui, sans-serif;
}

.recovery-card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  width: min(440px, calc(100% - 32px));
  margin: max(24px, 8vh) auto;
  padding: 28px 24px;
  border: 2px solid #6f5f95;
  border-radius: 12px;
  background: #14142c;
  overflow-wrap: anywhere;
}

.recovery-brand { margin: 0; font-size: 12px; color: #b8a8e0; }
.recovery-card .login-form { width: 100%; }
.recovery-card .login-note,
.recovery-card .login-msg,
.recovery-card .login-privacy { font-size: 13px; max-width: 100%; }
.recovery-card .login-field span { font-size: 13px; }
.recovery-card .login-field input { box-sizing: border-box; width: 100%; font-size: 16px; }
.recovery-card .login-account-line { font-size: 14px; }
.recovery-card .menu-btn { font-size: 14px; min-height: 44px; }
.recovery-card .menu-btn:disabled { opacity: 0.55; cursor: wait; }

/* ── 账户设置（Issue #44）：昵称 + 固定头像集（前端白名单）+ 音效/操作偏好 ── */

.settings-account {
  margin: 0;
  max-width: 360px;
  font-size: 8px;
  line-height: 1.8;
  color: #8ef0ff;
  overflow-wrap: anywhere;
}

.settings-avatar-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(360px, 88vw);
}

.avatar-preview {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 68px;
  height: 68px;
  background: #7fb8e6;
  border: 2px solid #ffc857;
  border-radius: 6px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
}

.avatar-preview-name {
  font-size: 7px;
  line-height: 1;
  color: #0b0b1e;
  max-width: 62px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 像素小脸：暗底 + 两只浅色眼睛，头像占位色由 JS 按 avatarPresets 设置 */
.avatar-face {
  position: relative;
  display: block;
  width: 28px;
  height: 28px;
  background: rgba(11, 11, 30, 0.55);
  border-radius: 4px;
}

.avatar-face::before,
.avatar-face::after {
  content: "";
  position: absolute;
  top: 9px;
  width: 4px;
  height: 4px;
  background: #f0e6d2;
}

.avatar-face::before { left: 6px; }
.avatar-face::after { right: 6px; }

.avatar-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.avatar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 6px 4px;
  min-width: 0;
  font-family: inherit;
  font-size: 7px;
  color: #f0e6d2;
  background: #14143a;
  border: 2px solid #3a2a66;
  border-radius: 6px;
  cursor: pointer;
}

.avatar-btn .avatar-face {
  width: 24px;
  height: 24px;
}

.avatar-btn .avatar-face::before,
.avatar-btn .avatar-face::after {
  top: 8px;
  width: 3px;
  height: 3px;
}

.avatar-btn .avatar-face::before { left: 5px; }
.avatar-btn .avatar-face::after { right: 5px; }

.avatar-btn .avatar-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* 头像占位色是浅色（缪斯配色），按名字用深色以保证对比度 */
  color: #0b0b1e;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}

.avatar-btn:hover {
  border-color: #6f5f95;
}

/* 键盘焦点：与「选中态」的金色边框区分，用青色 outline 保证可见（可访问性） */
.avatar-btn:focus-visible {
  border-color: #8ef0ff;
  outline: 2px solid #8ef0ff;
  outline-offset: 2px;
}

.avatar-btn.is-selected {
  background: #23235c;
  border-color: #ffc857;
  box-shadow: 0 0 0 2px rgba(255, 200, 87, 0.35);
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(360px, 88vw);
  font-size: 9px;
  color: #ffc857;
  text-align: left;
}

.settings-field input {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 10px;
  color: #f0e6d2;
  background: #0b0b1e;
  border: 2px solid #3a2a66;
  border-radius: 6px;
  outline: none;
}

.settings-field input:focus {
  border-color: #ffc857;
}

.settings-hint {
  margin: 0;
  max-width: 360px;
  font-size: 8px;
  line-height: 1.8;
  color: #b8a8e0;
}

.settings-hint.settings-hint-error {
  color: #ff9bb5;
}

.settings-prefs {
  display: flex;
  gap: 10px;
  width: min(360px, 88vw);
}

.settings-prefs .menu-btn {
  flex: 1 1 0;
  padding-left: 8px;
  padding-right: 8px;
}

.settings-prefs .menu-btn.pref-on {
  border-color: #8ef0ff;
  color: #8ef0ff;
}

.settings-msg {
  min-height: 1.4em;
  margin: 0;
  max-width: 360px;
  font-size: 8px;
  line-height: 1.8;
  color: #b8a8e0;
}

.settings-msg.settings-msg-error {
  color: #ff9bb5;
}

.settings-msg.settings-msg-ok {
  color: #8ef0ff;
}

.password-panel {
  width: min(100%, 360px);
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid #554470;
  text-align: left;
}

.password-panel h3 { margin: 0 0 8px; font-size: 11px; }
.password-panel .login-form { width: 100%; }
.password-panel .settings-field { width: 100%; min-width: 0; }

.settings-danger {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(360px, 88vw);
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px dashed #3a2a66;
}

.settings-delete {
  font-size: 8px;
  line-height: 1.6;
  color: #ff9bb5;
  text-decoration: none;
  border-bottom: 1px dotted #7a3d5c;
  padding-bottom: 1px;
}

.settings-delete:hover,
.settings-delete:focus-visible {
  color: #ffc0cf;
  outline: none;
}

.settings-delete-note {
  margin: 0;
  max-width: 360px;
  font-size: 7px;
  line-height: 1.8;
  color: #6f5f95;
}

.menu-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* 矮屏 / 手机横屏：登录/账户设置内容可能超出可视高度，允许界面自身滚动，避免按钮被裁掉 */
.stats-panel {
  width: min(360px, 100%);
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid #6f5f95;
  background: rgba(26, 16, 51, 0.65);
  text-align: left;
  font-size: 10px;
  line-height: 1.8;
  flex-shrink: 0;
}
.stats-panel h3, .stats-panel h4 { margin: 4px 0; color: #FFC857; }
.stats-panel p { margin: 6px 0; }
.stats-lines { white-space: pre-line; overflow-wrap: anywhere; }
#settings-screen {
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: 16px;
  padding-bottom: 24px;
}

@media (max-height: 560px) {
  #login-screen,
  #settings-screen {
    justify-content: flex-start;
    overflow-y: auto;
    gap: 10px;
    padding-top: 12px;
    padding-bottom: 24px;
  }
}

/* 账户设置元素较多：中等高度也允许滚动，避免「保存/返回」被裁掉 */
@media (max-height: 720px) {
  #settings-screen {
    justify-content: flex-start;
    overflow-y: auto;
    padding-top: 12px;
    padding-bottom: 24px;
  }
}

/* iOS 对 font-size < 16px 的输入框会自动放大页面；触屏设备上提高输入字号避免跳缩放 */
@media (pointer: coarse) {
  .login-field input,
  .settings-field input {
    font-size: 16px;
  }
}

/* 结算与结局 */
.clear-text {
  font-size: 11px;
  line-height: 1.9;
  color: #f0e6d2;
}

.ending-body {
  max-width: 420px;
  font-size: 10px;
  line-height: 2;
  color: #f0e6d2;
}

.ending-body p {
  margin: 8px 0;
}

/* ── HUD（Issue #6）：游戏画面上方、左缘对齐的关卡名 + 星数，不压画面。
   引擎为状态和目标两行预留空间（hudReserve=44px），HUD 隐藏时仍占位避免画布跳动。
   Issue #18：追加 HP 与被动能量条（窄屏下关卡名截断，保证一行放下） */
#hud {
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  height: 37px;        /* 固定两行高度，目标更新或隐藏时画布不跳动 */
  width: 100%;
  margin: 0 0 6px;
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  line-height: 1;
  color: #f0e6d2;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
  pointer-events: none;
  white-space: nowrap;
  max-width: 100%;
}

#hud-status {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  height: 17px;
}

#hud-objective {
  display: block;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  line-height: 18px;
  color: #b8e0d2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 隐藏态只不可见、仍占位：保证标题/游玩切换时画布不上下跳动 */
#hud.hidden {
  display: flex !important;
  visibility: hidden;
}

#hud-level {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 136px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  color: #ffc857;
}

#hud-shards {
  flex: none;
  color: #ffffff;
}

#hud.peaceful #hud-level {
  max-width: none;
}

/* HP：♥ 当前/上限；低血量变红 */
#hud-hp {
  flex: none;
  font-size: 9px;
  color: #ff8fa3;
}

#hud-hp.low {
  color: #ff4d6d;
  animation: hp-low-blink 0.7s steps(2, end) infinite;
}

@keyframes hp-low-blink {
  50% { opacity: 0.45; }
}

/* 被动能量条：攒满后金色脉冲 + 标签提示 F/G 能量炮 */
#hud-energy {
  flex: none;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 8px;
  color: #b8a8e0;
}

#hud-energy-bar {
  display: block;
  width: 40px;
  height: 8px;
  padding: 1px;
  box-sizing: border-box;
  border: 1px solid #8b7bb8;
  background: #1a1033;
}

#hud-energy-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: #5ee6b8;
  transition: width 0.12s linear;
}

#hud-energy-label {
  min-width: 22px;
}

#hud-energy.ready #hud-energy-bar {
  border-color: #ffc857;
}

#hud-energy.ready #hud-energy-fill {
  background: #ffc857;
  animation: energy-ready-pulse 0.55s steps(2, end) infinite;
}

#hud-energy.ready #hud-energy-label {
  color: #ffc857;
}

@keyframes energy-ready-pulse {
  50% { opacity: 0.5; }
}

/* ── 对话框（Issue #6 外壳；打字机/快进/翻页由 Issue #7 扩充）──
 * 星露谷式：锚定游戏画面底部、左右各留 10px 间距，横向通栏；
 * 说话人头像位（Issue #28）位于对话框右上方、探出框顶；
 * 对话期间背景虚化（#dialog-backdrop），只突出对话框与头像 */
#dialog {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 15;
  padding: 12px 16px;
  box-sizing: border-box;
  font-family: "Press Start 2P", monospace;
  color: #f0e6d2;
  background: rgba(11, 11, 30, 0.92);
  border: 2px solid #ffc857;
  border-radius: 6px;
  cursor: pointer;      /* 点击翻页（Issue #7） */
  user-select: none;    /* 连点不选中文本 */
  -webkit-user-select: none;
}

/* 对话背景虚化层：对话态显示，盖住画布与 HUD（z 12 < 对话框 z 15），
   压暗 + 毛玻璃，让视线集中在对话框与头像上 */
#dialog-backdrop {
  position: absolute;
  inset: 0;
  z-index: 12;
  background: rgba(11, 11, 30, 0.4);
  backdrop-filter: blur(4px) brightness(0.75);
  -webkit-backdrop-filter: blur(4px) brightness(0.75);
  pointer-events: none; /* 点击穿透，不影响游戏区（对话页由对话框处理） */
}

/* 透明原图直接叠在虚化场景上：底边贴对话框顶边，不加底板与画框。
   完整保留原图比例；限制高度，为矮窗口与长对话留出空间。 */
#dialog-portrait {
  position: absolute;
  right: -2px;
  bottom: calc(100% + 2px); /* 对齐对话框外边沿 */
  width: 33.333%;
  height: auto;
  max-height: 45vh;
  object-fit: contain;
  object-position: right bottom;
  image-rendering: auto;
  pointer-events: none;
}

#dialog-name {
  display: inline-block;
  margin-bottom: 8px;
  padding: 2px 8px;
  font-size: 10px;
  background: #1a1033;
  border: 1px solid #ffc857;
}

#dialog-text {
  min-height: 42px;
  font-size: 11px;
  line-height: 1.9;
}

#dialog-hint {
  margin-top: 8px;
  font-size: 9px;
  color: #c9b8e8;
  text-align: right;
  animation: hint-blink 1s steps(2, start) infinite;
}

/* 对话选项列表（Issue #12：check 节点，↑↓ 选择 · E 确认） */
#dialog-options {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#dialog-options:empty {
  display: none;
}

.dialog-option {
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1.6;
  color: #c9b8e8;
  border: 1px dashed rgba(201, 184, 232, 0.45);
  border-radius: 4px;
}

.dialog-option.selected {
  color: #ffc857;
  border: 1px solid #ffc857;
  background: #1a1033;
}

@keyframes hint-blink {
  50% { opacity: 0.35; }
}

/* 触屏设备：对话框抬高，避开底部虚拟按键（#18 右侧操作区两行更高） */
@media (pointer: coarse), (any-pointer: coarse) {
  #dialog {
    bottom: calc(132px + env(safe-area-inset-bottom, 0px));
  }

  /* 竖屏序章画布居中，按键在画布下方；对话留在画面底部。 */
  @media (orientation: portrait) {
    #dialog-backdrop.scene-art + #dialog {
      bottom: 10px;
    }
  }

  /* 矮横屏缩小立绘，为选项留出纵向空间。 */
  @media (orientation: landscape) and (max-height: 450px) {
    #dialog-portrait {
      width: min(33.333%, 12vh);
    }
  }
}

/* #45: per-slot cloud choices, including touch layouts. */
#save-screen { overflow-y: auto; justify-content: flex-start; padding-top: 24px; }
.cloud-status, .cloud-meta, .cloud-merge { font-size: 12px; line-height: 1.6; }
.cloud-status { max-width: 460px; color: var(--gold, #FFC857); text-align: center; }
.cloud-meta { margin: 4px 0; overflow-wrap: anywhere; }
.cloud-slot { margin: 0 0 12px; padding: 0 8px 8px; border-bottom: 1px solid #ffffff30; }
.cloud-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cloud-actions .menu-btn { flex: 1; min-height: 44px; }
.cloud-merge { max-width: 460px; padding: 10px; border: 1px solid #FFC857; }
@media (pointer: coarse) {
  #save-screen { padding: 12px 12px 32px; }
  .cloud-actions { flex-direction: column; }
}

/* 六位 Muse：三列两行的透明头像图集，保留色块头像作为无素材回退。 */
.avatar-face.has-portrait {
  width: 52px;
  height: 52px;
  background-color: transparent;
  background-size: 300% 200%;
  background-repeat: no-repeat;
  border-radius: 0;
  image-rendering: pixelated;
}
.avatar-btn .avatar-face.has-portrait { width: 48px; height: 48px; }
.avatar-face.has-portrait::before, .avatar-face.has-portrait::after { content: none; }
