/* ============ 天华学园 Online · 设计令牌（沿用角色卡原版视觉体系）============
   取自原版前端 :root 令牌：
   --primary-color:#d32f2f 朱红 / --bg-paper:#fdfbf3 米白纸 / --accent-color:#8b4513 褐
   --player-msg-bg:#e3f2fd 玩家气泡 / 标题字体 'Ma Shan Zheng' 毛笔楷书
   变量名保持原样，只替换取值，避免改动页面结构。 */
:root {
  /* 纸张层级 */
  --bg-0: #fdfbf3;   /* 主纸色 */
  --bg-1: #fff9e6;   /* 暖纸（次层） */
  --bg-2: #ffffff;   /* 卡片白 */
  --bg-3: #f5f0e3;   /* 凹陷/次级底 */
  /* 墨色 */
  --ink: #333333;
  --ink-2: #666666;
  --ink-3: #999999;
  /* 强调色：朱红 / 褐 */
  --gold: #8b4513;
  --gold-2: #a0522d;
  --sakura: #d32f2f;
  --blue: #1976d2;
  --mint: #2e7d32;
  --danger: #c62828;
  /* 描边与层次 */
  --line: rgba(0, 0, 0, 0.1);
  --line-2: rgba(0, 0, 0, 0.16);
  --glass: rgba(0, 0, 0, 0.035);
  --glass-2: rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-strong: 0 8px 30px rgba(0, 0, 0, 0.16);
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  /* 原版专用令牌 */
  --paper: #fdfbf3;
  --paper-warm: #fff9e6;
  --red: #d32f2f;
  --red-light: #ff6659;
  --red-dark: #9a0007;
  --brown: #8b4513;
  --player-bubble: #e3f2fd;
  --player-bubble-ink: #0d47a1;
  --title-font: "Ma Shan Zheng", "STKaiti", "KaiTi", "楷体", "Songti SC", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #e9e4d6;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* 手机外壳：移动端铺满，桌面端居中成手机 */
#phone {
  position: relative;
  width: 100%;
  height: 100vh;        /* 旧内核回退 */
  height: var(--app-h, 100dvh); /* JS 实测可视高度，最稳 */
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(253, 251, 243, 0.7) 40%, var(--paper) 100%),
    var(--paper);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* 纸纹：极淡的横向纤维感，替代原版深色星尘 */
#phone::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(139, 69, 19, 0.022) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(139, 69, 19, 0.016) 0 1px, transparent 1px 4px);
  opacity: .8;
  pointer-events: none;
  z-index: 0;
}
#phone > * { position: relative; z-index: 1; }

@media (min-width: 520px) {
  body { display: flex; align-items: center; justify-content: center; background: #ded8c9; }
  #phone {
    width: 430px;
    /* 高度自适应：矮窗口/带工具栏/系统缩放都不裁切。旧内核回退 100vh，
       再用 JS 实测的 --app-h（visualViewport 高）兜底，保底至少留 12px 边距。 */
    height: min(920px, calc(100vh - 16px));
    height: min(920px, calc(var(--app-h, 100dvh) - 16px));
    min-height: 420px;
    border-radius: 34px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.45);
  }
}

#app { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
#overlay-root { position: fixed; inset: 0; pointer-events: none; z-index: 9999; }
#overlay-root > * { pointer-events: auto; }

/* ============ 基础元件 ============ */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; font-family: inherit; font-weight: 600;
  border-radius: 999px; padding: 14px 24px; font-size: 15px;
  transition: transform .16s cubic-bezier(.2,.9,.3,1.2), filter .2s, opacity .2s;
  user-select: none;
}
.btn:active { transform: scale(.965); }
.btn[disabled] { opacity: .45; pointer-events: none; }
/* 主按钮：原版「确认入学」朱红实底白字 */
.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, var(--red-light) 0%, var(--red) 55%, #b71c1c 100%);
  box-shadow: 0 8px 20px -8px rgba(211, 47, 47, .55), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-ghost {
  color: var(--brown); background: rgba(255, 255, 255, .82); border: 1px solid rgba(139, 69, 19, .28);
}
.btn-ghost:active { background: #fff; }
.btn-danger { color: #fff; background: linear-gradient(135deg, #e4606f, #b93b4a); }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 16px; font-size: 13px; }

.input, .textarea, select {
  width: 100%; font-family: inherit; font-size: 15px; color: var(--ink);
  background: #fff; border: 1px solid rgba(139, 69, 19, .22); border-radius: 10px;
  padding: 12px 14px; outline: none; transition: border-color .2s, box-shadow .2s;
  appearance: none;
}
.input:focus, .textarea:focus, select:focus {
  border-color: rgba(211, 47, 47, .5);
  box-shadow: 0 0 0 3px rgba(211, 47, 47, .1);
}
.input::placeholder, .textarea::placeholder { color: #b3aca0; }
.textarea { resize: none; min-height: 92px; line-height: 1.6; }
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
select option { background: #fff; color: var(--ink); }

.field { margin-bottom: 16px; }
.label { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); margin-bottom: 7px; letter-spacing: .04em; }
.label .hint { color: var(--ink-3); font-size: 11.5px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 999px; font-size: 12px;
  background: var(--glass); border: 1px solid var(--line); color: var(--ink-2);
  white-space: nowrap;
}
.chip.gold { color: var(--brown); border-color: rgba(139, 69, 19, .28); background: rgba(139, 69, 19, .07); }
.chip.sakura { color: var(--red); border-color: rgba(211, 47, 47, .28); background: rgba(211, 47, 47, .07); }
.chip.mint { color: var(--mint); border-color: rgba(46, 125, 50, .25); background: rgba(46, 125, 50, .07); }
.chip.blue { color: var(--blue); border-color: rgba(25, 118, 210, .25); background: rgba(25, 118, 210, .07); }

.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; font-weight: 700; font-size: 17px;
  color: #fff; letter-spacing: .02em;
  background: linear-gradient(145deg, #ff6659, #d32f2f);
  box-shadow: 0 6px 16px -8px rgba(211, 47, 47, .7), inset 0 1px 0 rgba(255, 255, 255, .4);
}
.avatar.lg { width: 62px; height: 62px; border-radius: 50%; font-size: 24px; }
.avatar.rose { background: linear-gradient(145deg, #ffc9d6, #ee8ba5); }
.avatar.sky { background: linear-gradient(145deg, #9ec6f5, #1976d2); }
/* NPC 真实头像（/avatars/角色名.png）：盖在首字头像同一格上，
   object-fit:cover 填满圆形、裁掉多余部分，保证清晰不变形；
   加载失败由 onerror 移除，露出底下的首字。 */
.avatar .ava-pic { grid-area: 1 / 1; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; pointer-events: none; }

.divider { height: 1px; background: var(--line); margin: 18px 0; }

.skeleton {
  background: linear-gradient(90deg, rgba(0,0,0,.05), rgba(0,0,0,.1), rgba(0,0,0,.05));
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: 8px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* 滚动 */
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* 动效 */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.rise { animation: rise .42s cubic-bezier(.22,.9,.32,1) both; }
.rise-2 { animation: rise .42s .07s cubic-bezier(.22,.9,.32,1) both; }
.rise-3 { animation: rise .42s .14s cubic-bezier(.22,.9,.32,1) both; }

/* 启动页 */
.boot { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.boot-crest { position: relative; width: 86px; height: 86px; display: grid; place-items: center; margin-bottom: 8px; }
.crest-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(139, 69, 19, .35);
  box-shadow: 0 0 32px rgba(139, 69, 19, .12), inset 0 0 22px rgba(139, 69, 19, .08);
  animation: pulse 2.4s infinite;
}
.crest-word { font-size: 34px; font-weight: 300; color: var(--brown); letter-spacing: .1em; font-family: var(--title-font); }
.boot-title { margin: 0; font-size: 19px; letter-spacing: .32em; color: var(--ink); font-weight: 300; }
.boot-sub { margin: 0; font-size: 10.5px; letter-spacing: .26em; color: var(--ink-3); }
.boot-bar { width: 96px; height: 2px; background: rgba(0, 0, 0, .12); border-radius: 2px; overflow: hidden; margin-top: 22px; }
.boot-bar i { display: block; width: 40%; height: 100%; background: linear-gradient(90deg, transparent, var(--red), transparent); animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }

/* ============ 原版质感：毛笔标题 / 纸卷 / 印章 ============ */
.title-brush {
  font-family: var(--title-font);
  color: var(--red);
  letter-spacing: .12em;
  font-weight: 400;
}
/* 纸卷：入学通知书的版心底 */
.paper-sheet {
  position: relative;
  background: var(--paper);
  border: 1px solid rgba(139, 69, 19, .16);
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .08), inset 0 0 0 1px rgba(255, 255, 255, .7);
  padding: 22px 18px;
}
.paper-sheet::before {
  content: "";
  position: absolute; inset: 6px;
  border: 1px solid rgba(139, 69, 19, .1);
  border-radius: 3px;
  pointer-events: none;
}
/* 分节标题：左侧朱红短竖条 + 下方细线（原版「一、基本信息」） */
.sec-head {
  display: flex; align-items: center; gap: 9px;
  margin: 22px 0 12px;
}
.sec-head::before {
  content: ""; width: 3px; height: 16px; border-radius: 1px;
  background: var(--red); flex: none;
}
.sec-head b {
  font-family: var(--title-font); font-size: 19px; color: var(--ink);
  font-weight: 400; letter-spacing: .06em;
}
.sec-head i { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(211,47,47,.35), rgba(211,47,47,.06)); }
/* 点数胶囊（原版「可用点数：100」） */
.point-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 16px; border-radius: 999px;
  border: 1.5px solid var(--red); color: var(--red);
  background: rgba(211, 47, 47, .04);
  font-size: 14px; letter-spacing: .04em;
}
.point-pill b { font-size: 17px; font-variant-numeric: tabular-nums; }
/* 表单行：标签居左、输入下划线（原版入学通知书排版） */
.paper-row { display: flex; align-items: flex-start; gap: 14px; padding: 13px 0; }
.paper-row > label {
  flex: 0 0 62px; text-align: justify; text-align-last: justify;
  font-size: 14px; color: var(--ink-2); padding-top: 2px;
}
.paper-row > .val { flex: 1; min-width: 0; }

/* ============ 统一可见滚动条（过长页面可拖动、可滚轮、可触摸滑动）============
   纸感主题：细滚动条，棕金半透明，不抢内容；电脑端鼠标滚轮、手机端手指滑动都生效。 */
* {
  scrollbar-width: thin;                 /* Firefox：细滚动条 */
  scrollbar-color: rgba(139, 69, 19, .45) transparent;
}
*::-webkit-scrollbar { width: 7px; height: 7px; }      /* WebKit：垂直/水平统一尺寸 */
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(139, 69, 19, .4);
  border-radius: 999px;
  border: 1.5px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: rgba(139, 69, 19, .65); }
*::-webkit-scrollbar-corner { background: transparent; }
/* 可滚动容器：保证触摸惯性 + 鼠标滚轮 */
.page-body, .scene, .sheet, .scroll, .modal .body {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;          /* 滚到底不带动外层 */
}
