@font-face {
  font-family: 'Ma';
  /* WOFF2 为主（5.58MB → 3.23MB），TTF 仅作老 WebView 兜底 */
  src: url('assets/fonts/ma.woff2') format('woff2'),
       url('assets/fonts/ma.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --screen-height: 100vh;
  /* 宽度：手机铺满，电脑最大600px */
  --game-width: min(100vw, calc(var(--screen-height) * 0.5625), 600px);
  /* 高度：铺满屏幕 */
  --game-height: var(--screen-height);
  --animation-state: running;  /* 动画状态控制，页面隐藏时设为paused */
  /* 按钮设计令牌（与弹窗系统共享） */
  --bg: #424242;     /* 主背景色（弹窗卡片） */
  --bg2: #3a3a3a;    /* 二级背景（按钮/卡片/输入区） */
  --bg3: #2a2a2a;    /* 三级背景（深色折叠体/代码块） */
  --bd: #000;        /* 主边框色 */
  --bd2: #666;       /* 二级边框色（分隔线） */
  --c1: #fff;        /* 一级文字（标题/高亮） */
  --c2: #ddd;        /* 二级文字（正文/按钮） */
  --c3: #ccc;        /* 三级文字（描述/对话） */
  --c4: #aaa;        /* 四级文字（辅助信息） */
  --c5: #888;        /* 五级文字（标签/禁用） */
  --accent: #64b5f6; /* 强调色（激活/链接/开关）蓝色 */
  --r: 6px;          /* 主圆角（弹窗/卡片/按钮） */
  --r2: 4px;         /* 小圆角（天书项/表情格） */
  --tap-bd: #ddd;    /* 点击态边框（变白） */
  --popup-shadow: 0 0 15px rgba(0,0,0,0.8), inset 0 0 8px rgba(0,0,0,0.3); /* 弹窗阴影 */
}

*, *:before, *:after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

html { overflow: hidden; position: fixed; width: 100%; height: 100%; background: #000; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

body {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: var(--screen-height, 100vh);
  color: #fff;
  font-size: calc(12px * var(--fs, 1));
  line-height: 1.1;
  background: radial-gradient(ellipse at center, #3a3a3a 0%, #252525 40%, #151515 70%, #000 100%);
  overflow: hidden;
  position: fixed;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input, textarea {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

#preloader {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: var(--game-width, 100vw);
  height: var(--screen-height, 100vh);
  background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 1;
  transition: opacity 0.5s ease;
}
#preloader.hidden { opacity: 0; pointer-events: none; }

.health-tip {
  position: absolute;
  bottom: 20px;
  left: 0; right: 0;
  margin: 0;
  text-align: center;
  font-size: 9px;
  color: rgba(180, 180, 180, 0.8);
  line-height: 1.6;
}

.preloader-container {
  width: var(--game-width, 100vw);
  height: var(--game-height, 100vh);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.preloader-content {
  width: calc(var(--game-width, 100vw) * 0.6);
  padding: calc(var(--game-width, 100vw) * 0.08) calc(var(--game-width, 100vw) * 0.06);
  background: rgba(30, 30, 30, 0.95);
  border: 2px solid rgba(180, 180, 180, 0.3);
  border-radius: calc(var(--game-width, 100vw) * 0.02);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.8),
              inset 0 0 10px rgba(255, 255, 255, 0.05);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ink-decoration {
  position: absolute;
  width: calc(var(--game-width, 100vw) * 0.15);
  height: calc(var(--game-width, 100vw) * 0.15);
  border-radius: 50%;
  opacity: 0.1;
  pointer-events: none;
}
.ink-top {
  top: calc(var(--game-width, 100vw) * -0.05);
  left: calc(var(--game-width, 100vw) * -0.05);
  background: radial-gradient(circle, rgba(200, 200, 200, 0.3) 0%, transparent 70%);
  animation: inkPulse 3s ease-in-out infinite;
}
.ink-bottom {
  bottom: calc(var(--game-width, 100vw) * -0.05);
  right: calc(var(--game-width, 100vw) * -0.05);
  background: radial-gradient(circle, rgba(150, 150, 150, 0.2) 0%, transparent 70%);
  animation: inkPulse 3s ease-in-out 1.5s infinite;
}

@keyframes inkPulse {
  0%, 100% { transform: scale(1); opacity: 0.1; }
  50% { transform: scale(1.2); opacity: 0.2; }
}

.preloader-title {
  font-size: calc(var(--game-width, 100vw) / 12);
  font-weight: bold;
  color: #e8e8e8;
  text-align: center;
  letter-spacing: calc(var(--game-width, 100vw) * 0.015);
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.3),
               0 1px 2px rgba(0, 0, 0, 0.8);
  margin-bottom: calc(var(--game-width, 100vw) * 0.01);
  animation: titleGlow 2s ease-in-out infinite;
}

@keyframes titleGlow {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; }
}

.preloader-subtitle {
  font-size: calc(var(--game-width, 100vw) / 28);
  color: #b0b0b0;
  text-align: center;
  letter-spacing: calc(var(--game-width, 100vw) * 0.008);
  margin-bottom: calc(var(--game-width, 100vw) * 0.02);
}

.progress-container {
  width: 100%;
  height: calc(var(--game-width, 100vw) * 0.04);
  background: rgba(50, 50, 50, 0.8);
  border: 1px solid rgba(150, 150, 150, 0.3);
  border-radius: calc(var(--game-width, 100vw) * 0.02);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}
.progress-bar {
  height: 100%;
  width: 0%;
  max-width: 100%;
  background: linear-gradient(90deg, rgba(200, 200, 200, 0.8) 0%, #b4b4b4 50%, rgba(200, 200, 200, 0.8) 100%);
  border-radius: calc(var(--game-width, 100vw) * 0.015);
  transition: width 0.3s;
  position: absolute;
  top: 0;
  left: 0;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.4);
}
.progress-bar::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent 0, rgba(255, 255, 255, 0.4) 50%, transparent 100%);
  animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
  0% { left: -100%; }
  100% { left: 200%; }
}

.progress-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: calc(var(--game-width, 100vw) / 35);
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.loading-hint {
  font-size: calc(var(--game-width, 100vw) / 32);
  color: #999;
  text-align: center;
  margin-top: calc(var(--game-width, 100vw) * 0.01);
  animation: hintPulse 1.5s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.app {
  width: var(--game-width);
  height: var(--screen-height, 100vh);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
}

.auth-flow {
  width: 100%;
  min-height: var(--screen-height, 100vh);
  height: var(--screen-height, 100vh);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  user-select: none;
}

.game-container {
  width: 100%;
  height: var(--game-height);
  position: relative;
  overflow: hidden;
  background-image: url('/assets/images/登陆背景.webp');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.clear-cache-container {
  position: absolute;
  top: calc(var(--game-width) * 0.02);
  right: calc(var(--game-width) * 0.02);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.clear-cache-container > * { margin-top: calc(var(--game-width) * 0.01); } /* gap 替代方案 */
.clear-cache-container > *:first-child { margin-top: 0; }

/* 版本号显示 */
.version-display {
  font-size: calc(var(--game-width) / 32);
  color: #fff;
  text-align: right;
  user-select: none;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
}

.clear-cache-btn {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: calc(var(--game-width) * 0.01) calc(var(--game-width) * 0.02);
  font-size: calc(var(--game-width) / 35);
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none;
}

.transparent-box {
  width: calc(var(--game-width) * 0.8);
  position: absolute;
  top: 60%; left: 50%;/* top50 */
  transform: translate(-50%, -25%);  /* 向上调整 */
}
.login-form {
  display: flex;
  flex-direction: column;
}
.login-form > * { margin-top: calc(var(--game-width) * 0.04); } /* gap 替代方案 */
.login-form > *:first-child { margin-top: 0; }
.form-group {
  display: flex;
  align-items: center;
  position: relative;
}
.form-group label {
  font-size: calc(var(--game-width) / 20);
  color: #fff;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
  margin-right: calc(var(--game-width) * 0.02);
}
.input-wrapper {
  display: inline-flex;
  align-items: center;
  flex: 1;
  position: relative;
  border-bottom: 1px solid #fff;
}
.input-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  padding: 8px calc(var(--game-width) * 0.03);
  font-size: calc(var(--game-width) / 25);
  color: #fff;
  user-select: text;
  -webkit-user-select: text;
  -webkit-appearance: none;
  appearance: none;
}
.input-wrapper input::placeholder { color: rgba(255, 255, 255, 0.4); }

.dropdown-btn, .eye-btn {
  position: absolute;
  right: calc(var(--game-width) * 0.02);
  top: 50%;
  transform: translateY(-50%);
  width: calc(var(--game-width) * 0.06);
  height: calc(var(--game-width) * 0.06);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: calc(var(--game-width) / 30);
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.eye-btn svg, .dropdown-btn svg { width: 60%; height: 60%; }
.eye-btn { position: relative; }
.eye-btn.pwd-visible::after {
  content: '';
  position: absolute;
  width: 70%;
  height: 2px;
  background: currentColor;
  top: 50%;
  left: 15%;
  transform: rotate(-45deg);
}
.dropdown-btn:active, .eye-btn:active { transform: translateY(-50%) scale(0.9); }

.history-dropdown {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-height: calc(var(--game-width) * 0.4);
  overflow-y: auto;
  margin-top: 4px;
}
.history-item {
  padding: calc(var(--game-width) * 0.025);
  cursor: pointer;
  font-size: calc(var(--game-width) / 28);
  color: #333;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}
.history-item:last-child { border-bottom: none; }
.history-item:active { background: rgba(0, 0, 0, 0.1); }
.history-empty {
  padding: calc(var(--game-width) * 0.03);
  text-align: center;
  color: #999;
  font-size: calc(var(--game-width) / 30);
}

.button-group {
  display: flex;
  justify-content: center;
  margin-top: calc(var(--game-width) * 0.02);
}
.button-group > * { margin: 0 calc(var(--game-width) * 0.02); } /* gap 替代方案 */
.button-group > *:first-child { margin-left: 0; }
.button-group > *:last-child { margin-right: 0; }
.button-group button {
  flex: 1;
  height: calc(var(--game-width) / 10);
  border: none;
  font-size: calc(var(--game-width) / 20);
  cursor: pointer;
  background-image: url('/assets/images/按钮.webp');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-color: transparent;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  outline: none;
}
.button-group button:active {
  filter: brightness(1.15);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
}
.button-group button:disabled { opacity: 0.6; }

/* 隐私协议链接 */
.privacy-link {
  position: absolute;
  bottom: calc(var(--game-width) * 0.02);
  left: calc(var(--game-width) * 0.03);
  font-size: calc(var(--game-width) / 30);
  color: #ffffff;
}

/* 适龄提示 */
.age-rating {
  position: absolute;
  bottom: calc(var(--game-width) * 0.02);
  right: calc(var(--game-width) * 0.03);
  width: calc(var(--game-width) * 0.1);
  height: auto;
  pointer-events: none;
}

/* 隐私协议弹窗 */
#privacy-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  padding: calc(var(--game-width) * 0.05);
  box-sizing: border-box;
}
.privacy-popup {
  width: 100%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
}
.privacy-header {
  background: #555;
  padding: calc(var(--game-width) * 0.04);
  text-align: center;
  color: #fff;
  font-size: calc(var(--game-width) / 20);
  flex-shrink: 0;
}
.privacy-body {
  flex: 1;
  background: #fff;
  color: #333;
  padding: calc(var(--game-width) * 0.04);
  overflow-y: auto;
  font-size: calc(var(--game-width) / 28);
  line-height: 1.6;
  overscroll-behavior: contain;
}
.privacy-body h3 {
  color: #000;
  font-size: calc(var(--game-width) / 22);
  margin: 0 0 calc(var(--game-width) * 0.03) 0;
}
.privacy-body h4 {
  color: #000;
  font-size: calc(var(--game-width) / 26);
  font-weight: bold;
  margin: calc(var(--game-width) * 0.03) 0 calc(var(--game-width) * 0.015) 0;
}
.privacy-body p {
  margin-bottom: calc(var(--game-width) * 0.02);
  text-indent: 2em;
}
.privacy-footer {
  background: #f5f5f5; display: flex;
  padding: calc(var(--game-width) * 0.03);
  flex-shrink: 0;
}
.privacy-footer > * { margin: 0 calc(var(--game-width) * 0.02); }
.privacy-footer > *:first-child { margin-left: 0; }
.privacy-footer > *:last-child { margin-right: 0; }
.privacy-btn-reject, .privacy-btn-accept {
  flex: 1;
  padding: calc(var(--game-width) * 0.03);
  border: none;
  border-radius: 6px;
  font-size: calc(var(--game-width) / 24);
}
.privacy-btn-reject { background: #ddd; color: #333; }
.privacy-btn-accept { background: #4CAF50; color: #fff; }

/* 消息提示 */
.status-message {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: calc(var(--game-width) * 0.03) calc(var(--game-width) * 0.06);
  background: rgba(0, 0, 0, 0.85);
  border-radius: 8px;
  color: #fff;
  font-size: calc(var(--game-width) / 28);
  z-index: 9999;
  display: none;
  white-space: nowrap;  /* 不换行 */
  max-width: 90vw;      /* 最大宽度 */
}
.status-message.show {
  display: block;
  animation: fadeOut 2s ease-out forwards;
}
@keyframes fadeOut {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* 选区/创建角色 - 公共样式 */
.character-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  pointer-events: none;
}
.character-panel {
  position: absolute;
  width: calc(var(--game-width) * 0.8);
  height: calc(var(--game-height) * 0.5);/*0.6*/
  top: calc(var(--game-height) * 0.4);/*0.3*/
  left: 50%;
  transform: translateX(-50%);
  background-image: url('/assets/images/服务器列表.webp');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  z-index: 1001;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  padding: calc(var(--game-width) * 0.05) calc(var(--game-width) * 0.02);
}
.character-panel h1 {
  font-size: calc(var(--game-width) / 12);
  color: #fff;
  text-align: center;
  /*margin-bottom: calc(var(--game-width) * 0.06);*/
  flex-shrink: 0;
}

.character-buttons {
  width: 100%;
  display: flex;
  margin-top: calc(var(--game-width) * 0.02);
  flex-shrink: 0;
}
.character-buttons > * { margin: 0 calc(var(--game-width) * 0.015); } /* gap 替代方案 */
.character-buttons > *:first-child { margin-left: 0; }
.character-buttons > *:last-child { margin-right: 0; }
.character-buttons button {
  flex: 1;
  background-image: url('/assets/images/按钮.webp');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-color: transparent;
  border: none;
  padding: calc(var(--game-width) * 0.015);
  cursor: pointer;
  font-size: calc(var(--game-width) / 28);
  color: #000;
  min-height: calc(var(--game-width) / 12);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.character-buttons button:active {
  filter: brightness(1.15);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
}

.character-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.character-content > * { margin: calc(var(--game-width) * 0.03) 0; } /* gap 替代方案 */
.character-content > *:first-child { margin-top: 0; }
.character-content > *:last-child { margin-bottom: 0; }
.character-name-group {
  display: flex;
  align-items: center;
  justify-content: center;
}
.character-name-group label {
  font-size: calc(var(--game-width) / 18);
  color: #333;
  margin-right: calc(var(--game-width) * 0.01);
}
.character-name-group .input-wrapper {
  width: calc(var(--game-width) * 0.45);
  /* 面板是宣纸底，白色下划线等于看不见，改用墨色 */
  border-bottom-color: rgba(70, 58, 44, 0.45);
}
/* 宣纸底必须用黑字：默认 .input-wrapper input 是白字，名字会糊成一片
   用暖墨 #3b342c 而不是纯黑，纯黑压在大面积米色上会发刺眼 */
.character-name-group .input-wrapper input {
  font-size: calc(var(--game-width) / 22);
  color: #3b342c;
  caret-color: #3b342c;
  text-shadow: none;
}
.character-name-group .input-wrapper input::placeholder {
  color: rgba(70, 58, 44, 0.4);
}
.random-name-btn {
  width: calc(var(--game-width) * 0.1);
  height: calc(var(--game-width) * 0.1);
  background: url('/assets/images/骰子.webp') center/80% no-repeat transparent;
  border: none;
  cursor: pointer;
  transition: transform 0.2s;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  padding: 0;
}
.random-name-btn:active { transform: scale(0.9); }
.character-gender-group {
  display: flex;
  align-items: center;
}
.gender-label {
  font-size: calc(var(--game-width) / 18);
  color: #333;
  margin: 0 calc(var(--game-width) * 0.02);
}
.gender-btn {
  width: calc(var(--game-width) * 0.15);
  height: calc(var(--game-width) * 0.15);
  background-size: 100% 100%;
  background-color: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s;
}
.gender-btn:active { transform: scale(0.9); }
/* 两套图：不带 2 的是浓墨，带 2 的是淡墨。淡墨=未选，浓墨=选中
   （选中态文字是白色，必须压深底；原先是反的，默认深底灰字、选中淡底白字都看不清） */
.male-btn { background-image: url('/assets/images/注册性别左2.webp'); }
.male-btn.selected { background-image: url('/assets/images/注册性别左.webp'); }
.female-btn { background-image: url('/assets/images/注册性别右2.webp'); }
.female-btn.selected { background-image: url('/assets/images/注册性别右.webp'); }
.gender-btn .gender-text {
  font-size: calc(var(--game-width) / 18);
  /* 未选中是淡墨底，灰字对比度只有 1.7:1，改暖墨与名字同一套色 */
  color: #3b342c;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
.male-btn .gender-text { left: 40%; }
.female-btn .gender-text { left: 60%; }
/* 选中是黑墨底：纯白太亮，压到 #dcdcdc（仍是白色，只是不刺眼的灰白） */
.gender-btn.selected .gender-text { color: #dcdcdc; font-weight: bold; }
.char-error {
  color: #ff4444;
  font-size: calc(var(--game-width) / 30);
  text-align: center;
  min-height: calc(var(--game-width) * 0.05);
}
button {
  line-height: 1;
  font-size: calc(12px * var(--fs, 1));
  background: rgba(255,255,255,0.05); /* 微透明底色 */
  border: 1px solid var(--bd); /* 统一边框 */
  border-radius: var(--r);    /* 统一圆角 */
  color: var(--c2);           /* 统一文字色 */
  cursor: pointer;
  transition: transform 0.1s ease; /* 缩放过渡 */
  outline: none;
  touch-action: manipulation;  /* 禁用双击缩放，减少300ms延迟 */
}

.button-group button {
  flex: 1;
}
button:active {
  transform: scale(0.9);       /* 缩放反馈 */
  border-color: var(--tap-bd); /* 边框变白 */
}
button:disabled {
  background: #555;
  cursor: not-allowed;
  opacity: 0.7;
}

.container {
  width: 100%;
  height: var(--game-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #fff;
  background-color: #333;
  position: relative;
}

#chat {
  height: 100px;
  overflow-x: hidden;
  overflow-y: auto;
  border-bottom: 1px solid #000;
  /* 性能优化 */
  overscroll-behavior: contain;  /* 防止滚动链穿透 */
  touch-action: auto;  /* 关键：允许所有方向触摸滚动 */
}
/* .chat-container 和 #chat 是同一元素，不需要额外样式 */
.message {
  display: block;
  font-size: calc(12px * var(--fs, 1));
  word-break: break-all;
}
.message:first-child { margin-top: 0; }
.message:last-child { margin-bottom: 0; }

#obj button, #acts button, .act-btn {
  width: 99%;
  height: calc(var(--game-width) * 0.078);
  min-height: 35px;
  flex-shrink: 0;    /* 不缩小 */
  margin: 1px 0;
  box-sizing: border-box;
}
/* 分类排序 */
#obj .obj-func { order: 1; }
#obj .obj-npc { order: 2; }
#obj .obj-player { order: 3; }
#obj .obj-item { order: 4; }
/* 玩家炫彩边框 */
#obj .border-rainbow { animation: rainbow 2s linear infinite; }
#obj .border-gold { border-color: #ffd700; box-shadow: 0 0 4px #ffd700; }
#obj .border-fire { animation: fire-glow 1s ease-in-out infinite; }
@keyframes rainbow { 0%,100%{border-color:#f00} 17%{border-color:#ff0} 33%{border-color:#0f0} 50%{border-color:#0ff} 67%{border-color:#00f} 83%{border-color:#f0f} }
@keyframes fire-glow { 0%,100%{border-color:#ff4500;box-shadow:0 0 4px #ff4500} 50%{border-color:#ff6600;box-shadow:0 0 8px #ff6600} }

.map-container {
  flex: 1; width: 100%; height: 100%; overflow: auto;
  text-align: center; box-sizing: border-box;
  contain: layout style;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}
.map-wrapper { display: inline-block; }
.map-grid {
  display: inline-grid;
  contain: layout;
}
.map-room {
  background: #555; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: calc(11px * var(--fs, 1));
  white-space: nowrap; overflow: hidden;
  touch-action: manipulation;
  contain: layout style;
}
.map-room:active { transform: scale(0.9); }
.map-room-current { border: 1px solid #6a6; }
.map-room-cross { border: 1px dashed #888; color: #999; background: #3a3a3a; }
.map-path { color: #666; display: flex; align-items: center; justify-content: center; }
.map-path-h { width: 100%; height: 2px; background: #666; }
.map-path-v { width: 2px; height: 100%; background: #666; }

/* HP和Buff共用容器样式 */
div#hps, #buffs {
  width: 100%;
  display: flex;
  height: calc(var(--game-width) * 0.055);
  max-height: 25px;
  background: #333;
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
}
#buffs { overflow-x: auto; scrollbar-width: none; }
#buffs::-webkit-scrollbar { display: none; }

/* HP和Buff共用槽位样式 */
.hp-row, .buff-item {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  border-right: 1px solid #000;
}
.hp-row:last-child, .buff-item:last-child { border-right: none; }
.hp-row { flex: 1; }
.buff-item { flex: 0 0 20%; min-width: 20%; justify-content: center; }

/* HP和Buff共用填充条 */
.hp-row .fill, .buff-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 0;
  transition: width .3s;
}
.buff-fill { background: rgba(50, 205, 50, 0.6); }

/* HP和Buff共用文字 */
.hp-row .val, .buff-name {
  position: relative;
  padding: 0;
  font-size: calc(10px * var(--fs, 1));
  color: #fff;
  text-shadow: 0 0 2px #000;
  white-space: nowrap;
}

/* HP特有 */
.hp-row.name-row { background: #2d3a4a; }
.hp-row.name-row .val { font-weight: bold; }
.hp-row.name-row.busy { background: #333; }
.hp-row.name-row.busy .val { color: #ffd700; }
@keyframes lowHpFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.hp-row.low-hp { animation: lowHpFlash 0.6s ease-in-out infinite; }

/* Buff特有 */
.buff-item.buff-warn { animation: buffWarn 0.5s ease-in-out infinite; }
@keyframes buffWarn {
  0%, 100% { background: rgba(255, 0, 0, 0.3); }
  50% { background: rgba(255, 0, 0, 0.6); }
}
.buff-item.buff-empty .buff-name { color: #666; }
.buff-item.buff-empty .buff-fill { display: none; }

/* 右侧灯笼悬浮按钮 */
#lantern-panel {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lantern-btn {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -8px;
}
.lantern-btn:first-child { margin-top: 0; }
.lantern-btn img {
  width: calc(var(--game-width) * 0.065);
  height: calc(var(--game-width) * 0.13);
  object-fit: contain;
  display: block;
}
.lantern-btn span {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: calc(var(--game-width) * 0.03);
  font-weight: bold;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  pointer-events: none;
}
.lantern-btn:active { transform: scale(0.92); }
#lantern-panel .lantern-tassel {
  width: calc(var(--game-width) * 0.065);
  height: calc(var(--game-width) * 0.065);
  object-fit: contain;
  cursor: pointer;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: auto;
}
#lantern-panel img { -webkit-user-drag: none; }
#lantern-panel.collapsed .lantern-btn { display: none; }
#lantern-panel.collapsed .lantern-tassel { display: block; }

#tbar {
  height: calc(var(--game-width) * 0.10);
  max-height: 48px;
  padding: 2px;
  border-bottom: 1px solid #000;
  display: flex;
  align-items: center;
}
#here {
  height: 100%;
  font-size: calc(16px * var(--fs, 1));
  font-family: 'Ma', sans-serif;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9), 0 0 6px rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  border: none;
  white-space: nowrap;
}


#story {
  position: absolute;  /* 覆盖模式，不占据flex空间，避免内容变化导致out跳动 */
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;  /* 覆盖在out上方 */
  background: rgba(50, 50, 50, 0.95);
  padding: 3px 5px;
  border-bottom: 1px solid #666;
  color: #e0e0e0;
  font-size: calc(12px * var(--fs, 1));
  font-style: italic;
  max-height: 200px;
  overflow: hidden;
}
/* 空时完全隐藏 */
#story:empty { 
  display: none;
}
#story.hidden { display: none; }

#tmenu {
  flex-grow: 1;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
#tmenu::-webkit-scrollbar { height: 0; }
#tmenu button {
  width: calc(var(--game-width) * 0.13);
  height: 90%;
  margin: 0 1px;
  flex-shrink: 0;
  text-align: center;
  white-space: normal;
  overflow: hidden;
  word-wrap: break-word;
}

#main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}
#mleft {
  display: flex;
  width: 18%;
  height: 100%;
  flex-direction: column;
}
#obj {
  flex: 1;
  width: 100%;
  min-height: 0;  /* 关键！允许flex子元素缩小并启用滚动 */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
}
#acts {
  flex-shrink: 0;
  width: 100%;
}
#mright {
  display: flex;
  width: 82%;
  height: 100%;
  flex-direction: column;
  border-left: 1px solid #000;
  position: relative;
}
#out {
  position: relative;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* 正常布局 + 自动滚动，避免 column-reverse 的重排问题 */
  display: block;
}

/* toast已迁移到popup.css，保留keyframe供其他使用 */
span.out {
  white-space: pre-wrap;
  word-break: break-all;
  display: block;
  font-size: calc(12px * var(--fs, 1));
}

span.out a {
  text-decoration: none;
  color: #87ceeb;
  text-decoration-line: underline;
  text-decoration-skip-ink: auto;
}

/* ========== 底部区域 - 12个按钮统一大小 ========== */
/* 结构：6列2行 grid，12个按钮 + 地图覆盖层 */
#bottom-area {
  width: 100%;
  height: calc(var(--game-width) * 0.28);
  max-height: 200px;
  flex-shrink: 0;  /* 防止flex布局中被压缩 */
  border-top: 1px solid #000;
  display: grid;
  -ms-grid-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
  grid-template-columns: repeat(6, minmax(0, 1fr));  /* minmax(0,1fr) 防止内容撑开 */
  -ms-grid-rows: 1fr 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));  /* 行高也防止撑开 */
  padding: 2px;
  gap: 3px;
  position: relative;
  contain: layout style;  /* 渲染隔离 */
  touch-action: manipulation;  /* 禁用双击缩放 */
}

/* 12个按钮统一样式 */
#bottom-area .cmd-btn {
  position: relative;  /* 支持运行状态小绿点的绝对定位 */
  width: 100%;
  height: 100%;
  min-width: 0;
  max-width: 100%;  /* 防止内容撑开 */
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  word-break: keep-all;  /* 保持词组完整 */
  opacity: 0;
  pointer-events: none;
  contain: layout;  /* 隔离单个按钮的布局计算 */
  transition: opacity 0.1s ease;
}
/* b11/b12 始终显示 */
#bottom-area .cmd-btn.side-btn { opacity: 1; pointer-events: auto; }
/* 自定义模式或命令模式显示所有按钮 */
#bottom-area.show-btns .cmd-btn { opacity: 1; pointer-events: auto; }
/* 服务端未传数据的按钮不显示 */
#bottom-area.show-btns .cmd-btn.empty { opacity: 0; pointer-events: none; }

/* 地图覆盖层（覆盖前5列2行） */
/* 地图覆盖层：绝对定位覆盖前5列，切换自定义按钮时淡出隐藏 */
#bottom-area .exits-wrap {
  position: absolute;
  width: 83.7%;  /* 占6列中的前5列宽度 */
  height: 100%;
  z-index: 1;
  contain: layout style;  /* 隔离渲染，避免影响外部布局 */
  transition: opacity 0.1s ease;
}
/* 切换到自定义按钮/命令模式时隐藏地图 */
#bottom-area.show-btns .exits-wrap { opacity: 0; pointer-events: none; }

/* 地图3x3表格：出口按钮 + 中心房间名 */
.exits-table {
  border-collapse: separate;
  width: 100%;
  height: 100%;
}
/* 每个格子占1/3宽高，内容居中 */
.exits-table td {
  width: 33.33%;
  height: 33.33%;
  text-align: center;
  vertical-align: middle;
}
/* 空格子去掉背景 */
.exits-table td:empty { background: transparent !important; }
/* 中心格子：显示当前房间名，点击触发look */
.exits-table td.scene-name {
  white-space: nowrap;
  overflow: hidden;
  border-radius: var(--r);    /* 统一圆角 */
  text-overflow: ellipsis;
  border: 1px solid #000;
  cursor: pointer;
}
.exits-table td.scene-name:active { transform: scale(0.9); }

/* 出口按钮：撑满格子，其余继承全局button样式 */
.exits-table button {
  width: 100%;
  height: 100%;
}
/* 出口按钮按下反馈 */
.exits-table button:active { background: rgba(255,255,255,0.15); }

#mycmds {
  height: calc(var(--game-width) / 9);
  min-height: 36px;
  max-height: 46px;
  display: flex;
  border-top: 1px solid #3a3a3a;
}
#mycmds button {
  flex: 1;
  font-size: calc(18px * var(--fs, 1));
  font-family: 'Ma', sans-serif;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9), 0 0 6px rgba(0,0,0,0.7);
  touch-action: manipulation;
}

/* TMP临时消息 - 覆盖在chat区域上方 */
#tmpmsg {
  position: absolute;
  width: 100%;
  background: #000;
  z-index: 50;
  display: none;
  pointer-events: none;
}
#tmpmsg.show { display: block; }



/* 伤害飘字动画 */
.damage-float {
    position: absolute;
    top: 50%;
    left: 50%;
    color: #ff0000;
    font-weight: bold;
    font-size: calc(12px * var(--fs, 1));
    font-family: Arial, Helvetica, sans-serif;
    /* 轻微发光效果，让数字更清晰 */
    text-shadow: 0 0 3px #000, 0 0 3px #000;
    transform: translate(-50%, -50%) scale(0);
    animation: damageUp 0.8s ease-out forwards;
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
}

/* 爆炸弹出效果 */
@keyframes damageUp {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.3);
    }
    30% {
        transform: translate(-50%, -60%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -120%) scale(0.9);
    }
}

/* 游戏主界面固定背景 */
#game-interface {
  background-image: url('/assets/images/背景二.webp');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* 覆盖浏览器自动填充的默认底色/字色，避免表单被填充后与深色主题冲突 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill {
  /* 用 box-shadow 盖住 Chrome 的浅蓝填充底；半透明深色对登录页图片背景和游戏内深色弹窗都协调 */
  -webkit-box-shadow: 0 0 0 1000px rgba(18, 18, 22, 0.55) inset !important;
  box-shadow: 0 0 0 1000px rgba(18, 18, 22, 0.55) inset !important;
  -webkit-text-fill-color: #fff !important;
  color: #fff !important;
  caret-color: #fff;
  transition: background-color 9999s ease-in-out 0s;
}
