:root {
  --bg: #141527;
  --bg2: #211d38;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.12);
  --text: #eef0f8;
  --dim: #969cb8;
  --pink: #ffb3c7;
  --blue: #8ad4ff;
  --mint: #9ce8c4;
  --warn: #ffd479;
  --danger: #ff8f8f;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "HarmonyOS Sans SC", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { overflow: hidden; }

.sky {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(120% 80% at 50% 0%, #2c2650 0%, #1a1830 45%, var(--bg) 100%);
  z-index: -2;
  overflow: hidden;
}

.star {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.5;
  animation: twinkle 5s ease-in-out infinite;
}
.s1 { top: 12%; left: 14%; animation-delay: 0s; }
.s2 { top: 22%; left: 78%; animation-delay: 1.1s; }
.s3 { top: 8%;  left: 46%; animation-delay: 2.3s; }
.s4 { top: 36%; left: 8%;  animation-delay: 0.6s; opacity: 0.3; }
.s5 { top: 30%; left: 88%; animation-delay: 1.7s; opacity: 0.35; }
.s6 { top: 48%; left: 62%; animation-delay: 2.9s; opacity: 0.25; }

@keyframes twinkle {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.75; }
}

.moon {
  position: absolute;
  top: 7%; right: 12%;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8e6, #ffe9b8 55%, #e8c98a 100%);
  box-shadow: 0 0 28px rgba(255, 230, 170, 0.35);
  opacity: 0.9;
}

#app {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 12px 16px calc(12px + var(--safe-b));
  max-width: 520px;
  margin: 0 auto;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 10px;
  flex: 0 0 auto;
}

.who { display: flex; align-items: center; }

.name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.lv {
  margin-left: 8px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 179, 199, 0.16);
  color: var(--pink);
  border: 1px solid rgba(255, 179, 199, 0.25);
}
.lv.ghost {
  background: rgba(138, 212, 255, 0.12);
  color: var(--blue);
  border-color: rgba(138, 212, 255, 0.22);
}

.topbar-btns { display: flex; }
.topbar-btns .icon-btn + .icon-btn { margin-left: 8px; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:active { background: var(--card2); transform: scale(0.96); }

/* ---------- 舞台 ---------- */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 6px;
}

.bubble {
  position: relative;
  max-width: 86%;
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 16px 16px 16px 6px;
  background: rgba(255, 255, 255, 0.92);
  color: #2b2740;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: pop 0.22s ease-out;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 14px; bottom: -6px;
  width: 12px; height: 12px;
  background: inherit;
  transform: rotate(45deg);
  border-radius: 2px;
}
.bubble[hidden] { display: none; }

@keyframes pop {
  from { opacity: 0; transform: translateY(6px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.pet-wrap {
  position: relative;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  display: block;
  animation: bob 3.6s ease-in-out infinite;
  will-change: transform;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}

.pet {
  display: block;
  width: 62vw;
  max-width: 280px;
  min-width: 160px;
  height: auto;
  image-rendering: auto;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.42)) contrast(1.04) saturate(1.06);
  user-select: none;
  pointer-events: none;
}

.pet-shadow {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 46%;
  height: 10px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.4), transparent 70%);
  z-index: -1;
}

.pet-wrap.react { animation: react 0.42s ease-out; }
@keyframes react {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-14px) scale(1.04); }
  70% { transform: translateY(2px) scale(0.98); }
  100% { transform: translateY(0) scale(1); }
}

.exp-wrap {
  position: relative;
  width: 66%;
  height: 8px;
  margin-top: 16px;
  z-index: 1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.exp-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink), var(--blue));
  transition: width 0.4s ease;
}
.exp-text {
  position: absolute;
  top: 11px; left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.4px;
}

/* ---------- 状态条 ---------- */
.stats {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  margin-top: 26px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
}

.stat { flex: 1 1 0; }
.stat + .stat { margin-left: 12px; }

.stat-k {
  display: block;
  font-size: 11px;
  color: var(--dim);
  margin-bottom: 6px;
  letter-spacing: 0.6px;
}

.bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.bar-i {
  display: block;
  height: 100%;
  width: 60%;
  border-radius: 999px;
  transition: width 0.5s ease;
}
.mood { background: linear-gradient(90deg, #ff9fbb, #ffd1dd); }
.hunger { background: linear-gradient(90deg, #ffd479, #ffe9b0); }
.energy { background: linear-gradient(90deg, #8ad4ff, #bceaff); }

/* ---------- 操作 ---------- */
.actions {
  flex: 0 0 auto;
  display: flex;
  margin-top: 12px;
}

.act {
  flex: 1 1 0;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.act + .act { margin-left: 10px; }
.act:active { transform: scale(0.98); background: var(--card2); }

.act.primary {
  flex: 1.6 1 0;
  border: 0;
  background: linear-gradient(135deg, #ff9db8, #c79dff 60%, #8ad4ff);
  color: #221b33;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(199, 157, 255, 0.28);
}

.foot {
  flex: 0 0 auto;
  padding: 10px 2px 0;
  text-align: center;
}
.key-state { font-size: 11px; }
.key-state.ok { color: var(--mint); }
.key-state.warn { color: var(--warn); }
.dim { color: var(--dim); }

/* ---------- 聊天面板 ---------- */
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  height: 72%;
  max-width: 520px;
  margin: 0 auto;
  background: linear-gradient(180deg, #1e1b34, #171528);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.24s ease-out;
}
.sheet[hidden] { display: none; }

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0.6; }
  to   { transform: translateY(0); opacity: 1; }
}

.sheet-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 10px 14px calc(10px + var(--safe-b));
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  padding: 4px 2px 10px;
  flex: 0 0 auto;
}

.chat-list {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}

.msg {
  max-width: 82%;
  margin: 8px 0;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.me {
  margin-left: auto;
  background: linear-gradient(135deg, #ff9db8, #c79dff);
  color: #221b33;
  border-bottom-right-radius: 4px;
}
.msg.pet {
  background: var(--card2);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.msg.sys {
  max-width: 100%;
  margin: 10px auto;
  text-align: center;
  font-size: 12px;
  color: var(--dim);
  background: none;
  padding: 0;
}

.chat-tip {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--warn);
  padding: 6px 2px;
  line-height: 1.5;
}
.chat-tip[hidden] { display: none; }

.chat-form {
  flex: 0 0 auto;
  display: flex;
  padding-top: 8px;
}

#chatInput {
  flex: 1 1 auto;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 0 14px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
#chatInput::placeholder { color: var(--dim); }

.send {
  width: 44px; height: 44px;
  margin-left: 8px;
  border-radius: 14px;
  border: 0;
  background: linear-gradient(135deg, #ff9db8, #c79dff);
  color: #221b33;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.send:disabled { opacity: 0.45; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 60;
  background: rgba(10, 9, 18, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal[hidden] { display: none; }

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #1c1a30;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

.modal-body {
  padding: 6px 16px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.field { display: block; margin: 14px 0; }

.field-k {
  display: block;
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 7px;
  letter-spacing: 0.4px;
}

.field input, .field select {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.field select { padding: 0 8px; }

.field-hint {
  display: block;
  margin-top: 7px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--dim);
}

code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 5px;
}

.row { display: flex; flex-wrap: wrap; margin: 4px 0 2px; }
.row .btn { margin: 6px 8px 0 0; }

.btn {
  height: 40px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.primary {
  border: 0;
  background: linear-gradient(135deg, #ff9db8, #c79dff);
  color: #221b33;
  font-weight: 600;
}
.btn.ghost { background: rgba(255, 255, 255, 0.04); }
.btn.danger { color: var(--danger); border-color: rgba(255, 143, 143, 0.3); }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; }

.key-msg {
  font-size: 12px;
  line-height: 1.5;
  margin: 8px 0 0;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--dim);
}
.key-msg.ok { color: var(--mint); }
.key-msg.err { color: var(--danger); }

.about {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.7;
  color: var(--dim);
}
.about p { margin: 0 0 6px; }
.about a { color: var(--blue); }

/* ---------- 引导向导 ---------- */
.wizard {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 70;
  background: rgba(9, 8, 16, 0.8);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.wizard[hidden] { display: none; }

.wizard-card {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, #232038, #191728);
  border-radius: 24px 24px 0 0;
  border-top: 1px solid var(--line);
  padding: 20px 20px calc(20px + var(--safe-b));
  animation: slideUp 0.3s ease-out;
}

.dots { display: flex; justify-content: center; margin-bottom: 16px; }
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 3px;
  transition: all 0.25s;
}
.dot.on { width: 18px; border-radius: 3px; background: var(--pink); }

.wizard-body { min-height: 220px; }

.wiz-emoji { font-size: 34px; margin-bottom: 12px; }

.wiz-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 10px;
  line-height: 1.35;
}

.wiz-text {
  font-size: 14px;
  line-height: 1.75;
  color: #c9cde0;
  margin: 0 0 14px;
}
.wiz-text b { color: var(--pink); font-weight: 600; }
.wiz-text code { color: var(--blue); }

.wiz-list {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}
.wiz-list li {
  display: flex;
  align-items: flex-start;
  font-size: 13.5px;
  line-height: 1.6;
  color: #c9cde0;
  margin-bottom: 10px;
}
.wiz-list li span.n {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  margin-right: 9px;
  margin-top: 1px;
  border-radius: 50%;
  background: rgba(255, 179, 199, 0.16);
  color: var(--pink);
  font-size: 11px;
  line-height: 20px;
  text-align: center;
}

.wiz-input {
  width: 100%;
  height: 46px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 0 14px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  margin-bottom: 10px;
}

.wiz-note {
  font-size: 11.5px;
  color: var(--dim);
  line-height: 1.6;
  margin: 10px 0 0;
}

.wizard-actions { display: flex; flex-direction: column; margin-top: 6px; }
.wizard-actions .btn { width: 100%; height: 46px; margin-bottom: 8px; }

.skip {
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}

/* ---------- 悬浮提示 ---------- */
.float-hint {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + var(--safe-b));
  z-index: 80;
  max-width: 496px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(28, 26, 48, 0.97);
  border: 1px solid rgba(255, 179, 199, 0.3);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  animation: rise 0.28s ease-out;
}
.float-hint[hidden] { display: none; }

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

.fh-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}

.fh-list {
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}
.fh-list li {
  display: flex;
  align-items: flex-start;
  font-size: 12.5px;
  line-height: 1.55;
  color: #c9cde0;
  margin-bottom: 7px;
}
.fh-list li span {
  flex: 0 0 auto;
  width: 17px; height: 17px;
  margin-right: 8px;
  margin-top: 1px;
  border-radius: 50%;
  background: rgba(138, 212, 255, 0.16);
  color: var(--blue);
  font-size: 10px;
  line-height: 17px;
  text-align: center;
}

.fh-actions { display: flex; }
.fh-actions .btn { flex: 1 1 0; }
.fh-actions .btn + .btn { margin-left: 8px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 90;
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(20, 18, 34, 0.95);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  animation: rise 0.2s ease-out;
}
.toast[hidden] { display: none; }

/* ---------- 小屏适配 ---------- */
@media (max-height: 640px) {
  .pet { width: 48vw; max-width: 210px; }
  .exp-wrap { margin-top: 12px; }
  .stats { margin-top: 14px; }
  .bubble { font-size: 13px; }
}

@media (min-width: 560px) {
  .pet { max-width: 320px; }
}

@media (prefers-reduced-motion: reduce) {
  .pet-wrap { animation: none; }
  .star { animation: none; }
}

/* ---------- 页脚说明 / 许可 ---------- */
.foot-note {
  margin: 8px 0 0;
  font-size: 10px;
  line-height: 1.7;
  color: rgba(150, 156, 184, 0.7);
}

.lic { margin-top: 10px; }
.lic summary {
  font-size: 11px;
  color: var(--dim);
  cursor: pointer;
  outline: none;
  padding: 4px 0;
}
.lic p {
  margin: 6px 0;
  font-size: 10px;
  line-height: 1.6;
  color: rgba(150, 156, 184, 0.75);
}

/* ---------- 场景装修：光晕 / 地面 / 浮尘 ---------- */
.stage::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 48%;
  width: 82%;
  height: 62%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 179, 199, 0.18) 0%,
    rgba(199, 157, 255, 0.12) 38%,
    rgba(138, 212, 255, 0.06) 58%,
    transparent 72%);
  filter: blur(8px);
  z-index: 0;
  pointer-events: none;
}

.stage::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 12%;
  width: 66%;
  height: 20px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(8, 6, 16, 0.55), transparent 72%);
  z-index: 0;
  pointer-events: none;
}

.pet-wrap { z-index: 1; }
.bubble { z-index: 2; }

.dust {
  position: absolute;
  left: 0; top: 0; right: 0; bottom: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.dust i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 236, 200, 0.55);
  box-shadow: 0 0 6px rgba(255, 236, 200, 0.5);
  animation: floatUp 11s linear infinite;
}
.dust i:nth-child(1) { left: 12%; bottom: 18%; animation-delay: 0s; }
.dust i:nth-child(2) { left: 28%; bottom: 8%;  animation-delay: 3.2s; opacity: 0.7; }
.dust i:nth-child(3) { left: 46%; bottom: 22%; animation-delay: 6.1s; width: 2px; height: 2px; }
.dust i:nth-child(4) { left: 68%; bottom: 12%; animation-delay: 1.7s; opacity: 0.6; }
.dust i:nth-child(5) { left: 82%; bottom: 26%; animation-delay: 4.4s; width: 2px; height: 2px; }
.dust i:nth-child(6) { left: 92%; bottom: 6%;  animation-delay: 8.3s; opacity: 0.5; }

@keyframes floatUp {
  0%   { transform: translateY(0) scale(1); opacity: 0; }
  15%  { opacity: 0.9; }
  75%  { opacity: 0.55; }
  100% { transform: translateY(-160px) scale(0.7); opacity: 0; }
}

/* ---------- 互动特效（心心 / 星星 / Zzz） ---------- */
.fx {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  font-size: 15px;
  line-height: 1;
  font-weight: 700;
  animation: fxUp 1.15s ease-out forwards;
  text-shadow: 0 0 10px currentColor;
}

@keyframes fxUp {
  0%   { opacity: 0; transform: translateY(0) scale(0.5); }
  18%  { opacity: 1; transform: translateY(-8px) scale(1.05); }
  100% { opacity: 0; transform: translateY(-66px) scale(0.9); }
}

/* ---------- 高清视频层 ---------- */
.pet[hidden] { display: none; }
video.pet {
  object-fit: contain;
  background: transparent;
  -webkit-mask-image: -webkit-radial-gradient(white, black); /* 老 WebView 的透明兼容 */
}

.check-row {
  display: flex;
  align-items: center;
  margin: 16px 0 4px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.check-row input {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  accent-color: #ff9db8;
}
.check-row em {
  font-style: normal;
  font-size: 11px;
  color: var(--dim);
  margin-left: 4px;
}

/* ---------- 排版修正 ---------- */
.who { flex-wrap: nowrap; min-width: 0; }
.name {
  max-width: 44vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lv { white-space: nowrap; flex: 0 0 auto; }
.stat-k { white-space: nowrap; }
.bubble { overflow-wrap: anywhere; }
.key-msg, .field-hint, .about p { overflow-wrap: anywhere; }
.wiz-list li, .fh-list li { align-items: flex-start; }
.wiz-list li span.n, .fh-list li span { flex: 0 0 auto; }

/* ---------- 微信提示条 ---------- */
.wx-tip {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255, 212, 121, 0.12);
  border-bottom: 1px solid rgba(255, 212, 121, 0.28);
  color: var(--warn);
  font-size: 12px;
  line-height: 1.45;
}
.wx-tip[hidden] { display: none; }
.wx-tip span { flex: 1 1 auto; margin-right: 8px; }

/* ---------- 数据口令 ---------- */
.code-area {
  width: 100%;
  min-height: 74px;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 11.5px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  word-break: break-all;
}

/* ---------- 体检 ---------- */
.diag-list { margin: 6px 0 12px; }
.diag-item {
  display: flex;
  align-items: flex-start;
  padding: 9px 11px;
  margin-bottom: 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  line-height: 1.5;
}
.diag-item .dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin: 6px 9px 0 0;
  border-radius: 50%;
  background: var(--dim);
}
.diag-item.ok .dot { background: var(--mint); box-shadow: 0 0 8px rgba(156, 232, 196, 0.6); }
.diag-item.bad .dot { background: var(--danger); box-shadow: 0 0 8px rgba(255, 143, 143, 0.6); }
.diag-item .d-k { font-weight: 600; }
.diag-item .d-v { display: block; margin-top: 2px; font-size: 11px; color: var(--dim); }
body.wx-open #app { padding-top: 46px; }

/* ---------- 排版保护：彻底压住两端对齐 / 字间距被拉伸 ---------- */
.wiz-list li,
.fh-list li {
  display: block;
  position: relative;
  padding-left: 29px;
  text-align: left;
  text-align-last: left;
  word-spacing: normal;
  letter-spacing: normal;
}
.fh-list li { padding-left: 26px; }
.wiz-list li span.n,
.fh-list li span {
  position: absolute;
  left: 0;
  top: 1px;
  margin-right: 0;
}

.wiz-text,
.wiz-note,
.field-hint,
.key-msg,
.about p,
.bubble,
.msg,
.diag-item {
  text-align: left;
  text-align-last: left;
  text-justify: auto;
  word-spacing: normal;
}

.topbar,
.who {
  text-align: left;
  text-align-last: left;
}

/* ---------- 裁掉素材的透明留白：让角色真正占满舞台 ----------
 * 原始画布 220x124 / 640x360，角色只占约 34% 宽、75% 高。
 * 这里用"放大素材 + 框体裁剪"的方式把留白切掉：
 *   框体 1 单位宽 → 媒体宽 2.94（= 1/0.34），角色正好铺满框体宽；
 *   框体高 122%（角色 bbox 78x95 的比例），不会露出上下空白。
 */
.pet-wrap {
  width: 66vw;
  max-width: 300px;
  height: 0;
  padding: 0;
  padding-top: 122%;
  overflow: hidden;
  z-index: 1;
  animation: bob 3.6s ease-in-out infinite;
}

.pet-wrap .pet,
.pet-wrap #petVideo,
.pet-wrap #petImg {
  position: absolute;
  left: 50%;
  top: 47%;
  width: 294%;
  max-width: none;
  min-width: 0;
  height: auto;
  transform: translate(-50%, -50%);
}

.pet-wrap .pet-shadow {
  left: 50%;
  bottom: 4%;
  width: 52%;
  height: 8px;
  z-index: 0;
}

/* 小屏时别太满 */
@media (max-height: 640px) {
  .pet-wrap { width: 56vw; }
}

/* 裁剪后不再需要外发光阴影（会被框体切断） */
.pet-wrap .pet { filter: contrast(1.04) saturate(1.06); }

/* ================= v0.2 主界面改版 ================= */

/* 舞台变成"画布"：气泡与经验条脱离文档流，宠物可以自由移动 */
.stage {
  position: relative;
  justify-content: flex-start;
  min-height: 180px;
}

.pet-layer {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  transform: translate(-50%, -50%) translate(var(--px, 0px), var(--py, 0px));
  transition: transform 2.4s ease-in-out;
}

.pet-wrap { width: 54vw; max-width: 250px; }
.pet-wrap.flip .pet { transform: translate(-50%, -50%) scaleX(-1); }

.bubble {
  position: absolute;
  top: 6px;
  left: 50%;
  margin: 0;
  max-width: 88%;
  z-index: 3;
  transform: translate(-50%, 0);
}

@keyframes pop {
  from { opacity: 0; transform: translate(-50%, 6px) scale(0.96); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.exp-wrap {
  position: absolute;
  left: 50%;
  bottom: 2px;
  margin: 0;
  transform: translateX(-50%);
  z-index: 2;
}

/* 内嵌聊天区 */
.chatbar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  height: 30vh;
  min-height: 142px;
  max-height: 280px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  overflow: hidden;
}

.chatbar .chat-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 0;
}

.chatbar .chat-form { flex: 0 0 auto; padding-top: 8px; }
.chatbar .chat-tip { flex: 0 0 auto; }

/* 余额徽章 */
.balance {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  color: var(--mint);
  background: rgba(156, 232, 196, 0.12);
  border: 1px solid rgba(156, 232, 196, 0.22);
}
.balance[hidden] { display: none; }

/* 小屏收紧 */
@media (max-height: 680px) {
  .chatbar { height: 26vh; min-height: 128px; }
  .pet-wrap { width: 44vw; max-width: 190px; }
}

.stage { overflow: hidden; }

/* ---------- 尺寸回调：比最初大一点，别糊 ---------- */
.pet-wrap {
  width: 30vw;
  max-width: 132px;
}
.pet-wrap .pet { width: 294%; }
.chatbar { height: 28vh; }

@media (max-height: 680px) {
  .pet-wrap { width: 26vw; max-width: 110px; }
  .chatbar { height: 26vh; }
}

/* 高清层不要再叠对比度，避免发脏 */
.pet-wrap .pet { filter: none; }

/* 版本不一致提示条 */
.ver-bar {
  position: fixed;
  left: 12px; right: 12px;
  top: 12px;
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 143, 143, 0.16);
  border: 1px solid rgba(255, 143, 143, 0.35);
  color: #ffd7d7;
  font-size: 12px;
  line-height: 1.4;
}
.ver-bar button {
  margin-left: 10px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: #ff8f8f;
  color: #2a1414;
  font-size: 12px;
  font-weight: 600;
}

/* ---------- 鼠标 / 手指拖动 ---------- */
.pet-wrap {
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.pet-wrap:active { cursor: grabbing; }
.pet-wrap.dragging { cursor: grabbing; animation: none; }
