:root {
  --bg: #fff0f6;
  --bg2: #f5f0ff;
  --card: #ffffff;
  --soft: #fff6f9;
  --line: #ffe0ec;
  --text: #55404f;
  --dim: #a98fa6;
  --pink: #ff7ea8;
  --pink-d: #ff5c8a;
  --purple: #b79bff;
  --ok: #4fd39a;
  --danger: #ff5c7a;
  --shadow: 0 8px 24px rgba(255, 126, 168, .14);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(circle at 12% 8%, #ffe3ef 0%, transparent 42%),
    radial-gradient(circle at 88% 88%, #ede4ff 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(#ffd3e3 1px, transparent 1px);
  background-size: 18px 18px;
  mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 70%);
}
.bg-deco { position: fixed; inset: 0; pointer-events: none; font-size: 18px; color: #ffc3d8; }
.bg-deco span { position: absolute; animation: float 6s ease-in-out infinite; }
.bg-deco span:nth-child(1) { left: 8%; top: 18%; }
.bg-deco span:nth-child(2) { right: 10%; top: 12%; animation-delay: 1.2s; color: #d9c8ff; }
.bg-deco span:nth-child(3) { left: 14%; bottom: 26%; animation-delay: 2.4s; color: #d9c8ff; }
.bg-deco span:nth-child(4) { right: 12%; bottom: 32%; animation-delay: .6s; }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-10px) } }

.app { max-width: 520px; margin: 0 auto; padding: 0 16px; position: relative; }

/* ---------- 顶部 ---------- */
.top { display: flex; align-items: center; gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 2px 14px; }
.mascot { width: 58px; height: 58px; flex: 0 0 58px; display: grid; place-items: center;
  background: #fff; border-radius: 20px; box-shadow: var(--shadow); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg) } 50% { transform: translateY(-5px) rotate(2deg) } }
.titles { flex: 1; min-width: 0; }
h1 { font-size: 21px; margin: 0 0 3px; letter-spacing: .04em; font-weight: 800; color: #6b4a5e; }
h1::after { content: " ♡"; color: var(--pink); font-size: 16px; }
.status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #e5d3dc; }
.status.wait .dot { background: #ffc857; animation: blink 1.2s infinite; }
.status.on .dot { background: var(--ok); box-shadow: 0 0 8px rgba(79,211,154,.8); }
.status.on { color: #3aa87a; }
@keyframes blink { 50% { opacity: .35 } }
.cap { font-size: 11.5px; color: #c07f9b; background: #fff; border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: 24px; padding: 18px;
  box-shadow: var(--shadow); margin-bottom: 14px; border: 1px solid #fff; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 800; color: #6b4a5e;
  display: flex; align-items: center; gap: 8px; }
.num { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, #ffd3e3, #e3d4ff);
  color: #8a5b74; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.tag { font-style: normal; font-size: 10.5px; font-weight: 600; color: #8a5b74;
  background: #fff0f6; padding: 2px 8px; border-radius: 999px; margin-left: auto; }
.tag.ok { color: #2f9e73; background: #e7fbf1; }
.tag.off { color: #b5a0ae; background: #f7f2f5; }

.hint { color: var(--dim); font-size: 13px; line-height: 1.7; margin: 0 0 14px; }
.hint.center { text-align: center; margin: 10px 0 0; }
.hint.inline { margin: 0; }
.hint.tiny { font-size: 11.5px; margin: 8px 0 0; line-height: 1.6; }
.hint b { color: #8a5b74; }

/* ---------- 按钮 ---------- */
button { font: inherit; border: 0; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
button:active { transform: scale(.97); }
.primary { width: 100%; padding: 16px; border-radius: 18px; font-size: 16px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--pink) 0%, #ff9ec0 55%, #c8a8ff 100%);
  box-shadow: 0 10px 22px rgba(255, 126, 168, .32); letter-spacing: .03em; }
.primary:disabled { background: #f0e3ea; color: #c0a9b7; box-shadow: none; }
.ghost { background: var(--soft); color: #7d5a6f; padding: 12px 16px; border-radius: 14px;
  border: 1.5px solid var(--line); font-size: 14px; font-weight: 600; }
.ghost:active { background: #ffeaf3; }
.ghost.wide { display: block; width: 100%; text-align: center; margin-top: 10px; text-decoration: none; }
.ghost.icon { padding: 12px 13px; }
.grow { flex: 1; }

/* ---------- 配对 ---------- */
.pair { margin-top: 16px; }
.qr { background: #fff; border-radius: 20px; padding: 10px; width: 100%; max-width: 250px;
  margin: 0 auto; border: 2.5px solid #ffe0ec; box-shadow: 0 6px 18px rgba(255,126,168,.18); }
.qr.svgWrap { line-height: 0; }
#qr svg { display: block; width: 100%; height: auto; border-radius: 12px; }

/* ---------- 设备 ---------- */
.devline { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.devline b { font-size: 15px; color: #6b4a5e; }
.devline span { color: var(--dim); font-size: 12.5px; }
.channels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.ch { background: linear-gradient(160deg, #fff7fa, #f7f2ff); border: 1.5px solid #ffe8f1;
  border-radius: 20px; padding: 12px 8px; text-align: center; }
.chHead { font-size: 12px; color: #b08fa3; font-weight: 600; }
.val { font-size: 42px; font-weight: 800; line-height: 1.15; color: #6b4a5e; font-variant-numeric: tabular-nums; }
.chBtns { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.rnd { width: 56px; height: 48px; border-radius: 16px; font-size: 22px; font-weight: 700; color: #8a5b74;
  background: #fff; border: 1.5px solid #ffdcea; box-shadow: 0 4px 10px rgba(255,126,168,.14); }
.rnd:active { background: #fff0f6; }

/* ---------- 表单 ---------- */
.row { display: flex; gap: 9px; align-items: center; }
.row + .row { margin-top: 10px; }
.row.small { font-size: 13px; color: var(--dim); gap: 10px; }
.row.small label { display: flex; align-items: center; gap: 5px; color: #7d5a6f; }
.label { white-space: nowrap; font-size: 12.5px; color: #b08fa3; }
select, input[type="text"] {
  flex: 1; min-width: 0; font: inherit; font-size: 14px; color: var(--text);
  background: var(--soft); border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px;
  appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, #c9a8bb 50%), linear-gradient(135deg, #c9a8bb 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
  padding-right: 34px; }
input:focus, select:focus { outline: none; border-color: #ffc3da; background: #fff; }
input[type="radio"] { accent-color: var(--pink); width: 16px; height: 16px; }

/* ---------- AI ---------- */
.chat { max-height: 210px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 12px; font-size: 14px; line-height: 1.6; scroll-behavior: smooth; }
.chat:empty::after { content: "还什么都没说呢～"; color: #c9b4c1; font-size: 12.5px; text-align: center; padding: 12px 0; }
.chat .m { padding: 8px 13px; border-radius: 16px; max-width: 86%; word-break: break-word; }
.chat .me { align-self: flex-end; background: linear-gradient(135deg, #ffd6e6, #ffe9f2); color: #6b4a5e; border-bottom-right-radius: 5px; }
.chat .ai { align-self: flex-start; background: #f6f1ff; color: #5f5270; border-bottom-left-radius: 5px; }
.chat .act { align-self: center; font-size: 11.5px; color: #b39bb0; background: #fdf6f9; padding: 4px 12px; border-radius: 999px; }
.sep { height: 1px; background: linear-gradient(90deg, transparent, #ffe0ec, transparent); margin: 14px 0; }
.row.small select.mini { flex: 0 0 auto; width: auto; padding: 7px 30px 7px 12px; font-size: 13px;
  border-radius: 12px; background-position: calc(100% - 14px) 50%, calc(100% - 8px) 50%; }
.keybox { display: flex; gap: 8px; align-items: center; }
.keybox input { flex: 1; min-width: 0; font-size: 13px; padding: 11px 13px;
  background: #fffafc; border: 1.5px dashed #ffd3e3; border-radius: 14px; }
.keybox input::placeholder { color: #d4bcc9; }
#aiMode { margin: 6px 0 12px; color: #c09aae; }

/* ---------- 急停 ---------- */
.estop { position: fixed; left: 16px; right: 16px; bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 10; max-width: 488px; margin: 0 auto;
  padding: 17px 20px; font-size: 16px; font-weight: 800; letter-spacing: .08em; color: #fff;
  background: linear-gradient(135deg, #ff7f97, #ff5470);
  border-radius: 20px; border: 2px solid #ffd3dd;
  box-shadow: 0 10px 26px rgba(255, 84, 112, .35); }
.estop:active { filter: brightness(.94); transform: scale(.985); }

/* ---------- 提示 ---------- */
.toast { position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top)); transform: translateX(-50%);
  background: #fff; color: #6b4a5e; padding: 10px 20px; border-radius: 999px; font-size: 13.5px;
  font-weight: 600; box-shadow: 0 10px 28px rgba(180, 110, 145, .22); z-index: 30;
  border: 1.5px solid #ffe0ec; max-width: 88vw; text-align: center; }
.hidden { display: none !important; }

#autoBtn.running { background: #fff0f3; border-color: #ffc9d4; color: #e0506e; }
.hint.safe { background: #fff8fb; border: 1.5px dashed #ffd3e3; border-radius: 12px;
  padding: 8px 12px; color: #b08fa3; }
.hint.safe b { color: #e0506e; }
/* ---------- 视图 ---------- */
.view { animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: none } }

/* ---------- 大厅 ---------- */
.devmini { padding: 14px 16px; }
.devmini .devline { margin-bottom: 10px; }
.minich { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #b08fa3; }
.minich b { color: #6b4a5e; font-size: 15px; }
.minich .spacer { flex: 1; }
.rnd.sm { width: 42px; height: 36px; font-size: 13px; font-weight: 700; border-radius: 12px; }

.gamecard { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: linear-gradient(160deg, #fff7fa, #f7f2ff); border: 1.5px solid #ffe8f1;
  border-radius: 20px; padding: 16px; margin-bottom: 10px; color: inherit; }
.gamecard:active { transform: scale(.985); }
.gamecard.soon { opacity: .55; }
.gc-icon { font-size: 26px; }
.gc-body { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.gc-body b { font-size: 15px; color: #6b4a5e; }
.gc-body small { font-size: 12px; color: #b08fa3; }
.gc-go { color: #d3b3c4; font-size: 22px; }

input[type="range"] { flex: 1; accent-color: #ff7ea8; }

/* ---------- 游戏头 ---------- */
.gamehead { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.gamehead h2 { margin: 0; flex: 1; font-size: 16px; }
.ghost.back { padding: 8px 14px; font-size: 18px; line-height: 1; }
.ghost.stat { font-size: 12px; padding: 7px 12px; color: #b08fa3; }

/* ---------- 转盘 ---------- */
.wheelbox { position: relative; display: grid; place-items: center; margin: 4px 0 14px; }
.wheelbox canvas { width: 100%; max-width: 340px; height: auto; display: block;
  filter: drop-shadow(0 10px 24px rgba(255,126,168,.25)); }
.pointer { position: absolute; top: -2px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 11px solid transparent; border-right: 11px solid transparent;
  border-top: 20px solid #ff5c8a; filter: drop-shadow(0 2px 3px rgba(0,0,0,.15)); z-index: 2; }
.spinbtn { width: 100%; padding: 18px; border-radius: 20px; font-size: 17px; font-weight: 800;
  color: #fff; background: linear-gradient(135deg, #ff7ea8, #c8a8ff);
  box-shadow: 0 10px 24px rgba(255,126,168,.3); }
.spinbtn:disabled { background: #f0e3ea; color: #c0a9b7; box-shadow: none; }

.result { margin-top: 14px; border-radius: 18px; padding: 16px; text-align: center;
  background: linear-gradient(160deg, #fff7fa, #f7f2ff); border: 1.5px solid #ffe8f1; }
.result .big { font-size: 22px; font-weight: 800; color: #6b4a5e; margin-bottom: 6px; }
.result .sub { font-size: 13px; color: #b08fa3; }

.hist { margin-top: 12px; font-size: 12px; color: #b08fa3; text-align: center; line-height: 1.8; }

/* ================= 地牢：黑暗风 ================= */
body.dungeon-mode {
  background:
    radial-gradient(ellipse at 50% -20%, #3a152c 0%, transparent 55%),
    radial-gradient(ellipse at 50% 120%, #1a0b16 0%, transparent 60%),
    #07050a;
  color: #e6dbe4;
}
body.dungeon-mode::before { opacity: .18; }
body.dungeon-mode .bg-deco { opacity: .25; filter: hue-rotate(-40deg) saturate(.4); }
body.dungeon-mode .top h1 { color: #e8d3e0; text-shadow: 0 0 18px rgba(255, 80, 130, .35); }
body.dungeon-mode .top h1::after { color: #ff5f86; }
body.dungeon-mode .mascot { background: #1a1018; box-shadow: 0 0 24px rgba(255, 60, 110, .18); }
body.dungeon-mode .status { color: #9a8394; }
body.dungeon-mode .cap { color: #b98aa0; background: #170f16; border-color: #33202f; }
body.dungeon-mode .gamehead h2 { color: #e8d3e0; }
body.dungeon-mode .ghost { background: #150e15; border-color: #33202f; color: #d6bccd; }
body.dungeon-mode .ghost:active { background: #1f1420; }

body.dungeon-mode .card {
  background: linear-gradient(165deg, #17101a, #100a13);
  border: 1px solid #2b1a2a;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 120, 160, .06);
}
body.dungeon-mode .hint { color: #8d7388; }
body.dungeon-mode .label, body.dungeon-mode .row.small { color: #8d7388; }
body.dungeon-mode select, body.dungeon-mode input[type="text"], body.dungeon-mode input[type="password"] {
  background: #110b12; border-color: #33202f; color: #e6dbe4;
}
body.dungeon-mode .keybox input { background: #110b12; border-color: #33202f; }
body.dungeon-mode .primary {
  background: linear-gradient(135deg, #a1194a, #6d1030);
  box-shadow: 0 10px 26px rgba(160, 20, 70, .4);
}

/* HUD */
.dghud { padding: 14px 16px 12px; }
.hudline { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; }
.hudline b { font-size: 15px; letter-spacing: .22em; color: #f0d9e4; font-weight: 600; }
.hudline span { font-size: 11px; color: #8d7388; letter-spacing: .1em; }
.dangerbar { height: 3px; background: #241722; border-radius: 99px; overflow: hidden; }
.dangerbar i { display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #ff4d6d, #ff2d55);
  box-shadow: 0 0 12px rgba(255, 60, 100, .8); transition: width .5s ease; }
.hudsub { display: flex; justify-content: space-between; margin-top: 9px; font-size: 11px; color: #7d6579; letter-spacing: .08em; }
.hudsub span:first-child { color: #c9a0b6; }

/* 正文 */
.dgscene { padding: 20px 18px 18px; }
.narration {
  font-family: "Songti SC", "SimSun", Georgia, serif;
  font-size: 16.5px; line-height: 2; color: #efe2ea; margin: 0 0 18px;
  letter-spacing: .03em; text-align: justify; min-height: 84px;
  animation: dgfade .45s ease;
}
@keyframes dgfade { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

.choices { display: flex; flex-direction: column; gap: 9px; }
.choice {
  width: 100%; text-align: left; padding: 13px 16px; border-radius: 14px;
  background: #150e16; border: 1px solid #33202f; color: #dcc7d4;
  font-size: 14px; font-family: inherit; letter-spacing: .02em;
  transition: all .16s ease;
}
.choice::before { content: "› "; color: #a1194a; }
.choice:active { background: #22141f; border-color: #64203c; color: #fff; }
.choice:disabled { opacity: .45; }

.dgfoot { margin-top: 4px; }
body.dungeon-mode .estop { background: linear-gradient(135deg, #c31245, #7d0b2b); border-color: #ff8ba5; }
body.dungeon-mode .mascot svg { filter: grayscale(.55) brightness(.75) hue-rotate(-25deg); }
body.dungeon-mode .gi-deco { opacity: 0; }

/* ================= 忍耐挑战 ================= */
.etimer { font-size: 66px; font-weight: 800; text-align: center; letter-spacing: .04em;
  color: #f3e6ec; font-variant-numeric: tabular-nums; margin: 14px 0 6px;
  text-shadow: 0 0 34px rgba(255, 80, 120, .38); }
.esub { display: flex; justify-content: space-between; font-size: 13px; color: #a98a9e; padding: 0 8px; }
.ebar { height: 4px; background: #2a1a26; border-radius: 99px; overflow: hidden; margin: 10px 8px 20px; }
.ebar i { display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #ffb347, #ff4d6d);
  box-shadow: 0 0 12px rgba(255, 90, 120, .7); transition: width .12s linear; }
.escore { text-align: center; font-size: 13px; color: #a98a9e; margin-bottom: 20px; letter-spacing: .1em; }
.escore b { font-size: 24px; color: #ffd9a0; margin-left: 6px; }
.erow { display: flex; gap: 10px; }
.ebtn { flex: 1; padding: 18px 12px; border-radius: 18px; border: 1px solid #3a2333;
  background: #170f18; color: #e8d3e0; font-size: 15px; font-weight: 700;
  display: flex; flex-direction: column; gap: 4px; align-items: center; }
.ebtn small { font-size: 11px; color: #a98a9e; font-weight: 400; }
.ebtn.boost:active { background: #22141f; }
.ebtn.stop { background: linear-gradient(135deg, #7d0b2b, #45081a); border-color: #ff8ba5; }
.donegrid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 10px 0 4px; text-align: center; }
.donegrid span { display: block; font-size: 11px; color: #a98a9e; margin-bottom: 5px; }
.donegrid b { font-size: 19px; color: #f3e6ec; }
.donegrid b.big { font-size: 26px; color: #ffd9a0; }
.rank { margin-top: 12px; font-size: 12px; color: #a98a9e; }
.rankrow { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid #2a1a26; }
.rankrow span { width: 16px; color: #7d6579; }
.rankrow b { color: #ffd9a0; width: 62px; }
.rankrow small { color: #8d7388; font-size: 11.5px; }
.dangerbar i.over { background: linear-gradient(90deg, #ff2d55, #ff0055);
  box-shadow: 0 0 22px rgba(255, 0, 85, .95); animation: dangerpulse 1s ease-in-out infinite; }
@keyframes dangerpulse { 50% { opacity: .55 } }
#dgDangerNum { color: #7d6579; letter-spacing: .06em; }
#dgDangerNum.hot { color: #ff4d6d; }
body.dungeon-mode h2 { color: #ecd8e4; }
body.dungeon-mode .hint b { color: #e0c3d2; }
body.dungeon-mode .label { color: #b0929f; }
