/* ================= 全局 ================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #1c1c1e;
  --red: #b32424;
  --wx-bg: #ededed;
  --wx-green: #95ec69;
  --wx-btn: #07c160;
}

html, body { height: 100%; }

body {
  background:
    radial-gradient(900px 500px at 15% 0%, rgba(150,190,220,.35), transparent 60%),
    radial-gradient(900px 600px at 90% 100%, rgba(170,210,180,.4), transparent 60%),
    linear-gradient(160deg, #eef2f5 0%, #dde5ea 100%);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ================= 统一显示框架：手机壳 ================= */
.phone {
  position: relative;
  width: min(420px, 100vw);
  height: min(860px, 100vh);
  background: var(--wx-bg);
  border-radius: 18px;
  box-shadow: 0 30px 70px rgba(60,80,100,.35), 0 0 0 10px #101014, 0 0 0 11px #333;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.page {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.page.active { display: flex; animation: pagein .25s ease; }
@keyframes pagein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ================= 微信通用组件 ================= */
.wx-top {
  height: 52px;
  flex: none;
  background: #ededed;
  border-bottom: 1px solid #d6d6d6;
  display: flex;
  align-items: center;
  padding: 0 10px;
  position: relative; /* 供标题绝对居中定位 */
}

.wx-title {
  /* 绝对定位实现真正居中：不受左右按钮不对称影响（如返回键 vs 结算+分享） */
  position: absolute;
  left: 0;
  right: 0;
  margin: auto;
  pointer-events: none; /* 不拦截两侧按钮点击 */
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.wx-spacer { width: 34px; flex: none; }
.wx-back { font-size: 26px; color: #333; width: 34px; text-align: center; flex: none; }

.wx-back-btn {
  border: none;
  background: none;
  font-size: 26px;
  color: #d8e2c8;
  width: 34px;
  flex: none;
  cursor: pointer;
}
.wx-back-btn.dark { color: #333; }

/* 聊天页右上角的"结算/分享"入口（对局结束后出现）。
   标题绝对定位后不在 flex 流中，需用 margin-left:auto 推到右侧 */
#btnResult { margin-left: auto; }
.wx-more {
  border: none;
  background: #07c160;
  color: #fff;
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 2px;
}

.wx-body {
  flex: 1;
  overflow-y: auto;
  background: var(--wx-bg);
  padding: 16px;
}
.wx-body.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.card {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.9;
  color: #333;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card p { margin-bottom: 10px; }
.card p:last-child { margin-bottom: 0; }
.card b { color: #333; }
.card .quote {
  padding: 8px 12px;
  background: #f7f7f7;
  border-left: 3px solid #dcdcdc;
  border-radius: 0 4px 4px 0;
  font-size: 13px;
  color: #555;
}

.card-tag {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #333;
  margin-bottom: 10px;
}

.wx-btn {
  width: 100%;
  max-width: 300px;
  padding: 12px 0;
  background: var(--wx-btn);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  letter-spacing: 4px;
  cursor: pointer;
  transition: background .15s;
}
.wx-btn:hover:not(:disabled) { background: #06ad56; }
.wx-btn:disabled { opacity: .45; cursor: not-allowed; }
.wx-btn.ghost { background: #fff; color: #07c160; border: 1px solid #07c160; }
.wx-btn.ghost:hover:not(:disabled) { background: #f2fbf6; }

.home-menu {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.server-status {
  font-size: 12px;
  color: #999;
  text-align: center;
  min-height: 16px;
  margin-bottom: 8px;
}
.server-status.ok { color: #2e7d32; }
.server-status.bad { color: var(--red); }

.footnote {
  font-size: 10.5px;
  color: #999;
  letter-spacing: 1px;
  text-align: center;
}

.typing { font-size: 10px; color: #888; font-weight: 400; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* ================= 主页：个人资料风 ================= */
.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 30px 4px;
}

.profile-avatar {
  width: 76px !important;
  height: 76px !important;
  font-size: 34px !important;
  border-radius: 10px !important;
  margin-bottom: 14px;
}

.profile-name { font-size: 20px; font-weight: 600; color: #111; }

.profile-sub {
  margin-top: 6px;
  font-size: 13px;
  color: #888;
  letter-spacing: 2px;
}

/* ================= 任务简报页 ================= */
#btnAccept { display: block; width: 300px; max-width: 100%; margin: 0 auto; }

/* ================= 微信对话页 ================= */
#page-chat { background: var(--wx-bg); }

/* ---- HUD ---- */
#hud {
  flex: none;
  background: #f7f7f7;
  border-bottom: 1px solid #e0e0e0;
  padding: 6px 12px;
  font-size: 11px;
  color: #666;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  z-index: 5;
}

.hud-row { display: flex; align-items: center; gap: 6px; }
.hud-row.sub { justify-content: space-between; margin-top: 4px; color: #999; }
.hud-right { display: flex; gap: 12px; }

/* 信任天平：左怀疑右信任，指针随倾向值左右移动 */
.balance { display: flex; align-items: center; gap: 8px; }

.bal-label { flex: none; font-size: 11px; font-weight: 600; }
.bal-label.left { color: #e53935; }
.bal-label.right { color: #2e7d32; }

.bal-track {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  position: relative;
  background: linear-gradient(90deg, #e53935 0%, #f2b94d 40%, #b5cf6a 65%, #2e7d32 100%);
}

#balPointer {
  position: absolute;
  top: 50%; left: 40%;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #666;
  transform: translate(-50%, -50%);
  transition: left .5s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

#balPointer.pulse { animation: balpulse .6s; }
@keyframes balpulse { 50% { transform: translate(-50%,-50%) scale(1.35); } }

/* ---- 消息区 ---- */
#chat {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 20px;
  scroll-behavior: smooth;
}

.time-divider {
  text-align: center;
  color: #aaa;
  font-size: 11px;
  margin: 12px 0;
}

.sys-msg {
  text-align: center;
  color: #b2b2b2;
  font-size: 12px;
  margin: 12px 0;
}
/* 微信没有红色系统字：负面提醒同为灰色，仅措辞区分 */
.sys-msg.danger { color: #999; }

.msg-row { display: flex; margin-bottom: 14px; align-items: flex-start; gap: 8px; }
.msg-row.me { flex-direction: row-reverse; }

.avatar {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.avatar.sun { background: url("images/cc.jpg") center/cover no-repeat; }
.avatar.me { background: url("images/tt.jpg") center/cover no-repeat; }

/* 宽度约束放在 wrap 层（相对消息行），避免百分比循环依赖把气泡挤窄 */
.msg-row .wrap { max-width: 74%; }

.bubble {
  max-width: 100%;
  width: fit-content;
  padding: 10px 13px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.55;
  position: relative;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.msg-row:not(.me) .bubble { background: #fff; margin-left: 4px; }
.msg-row.me .bubble { background: var(--wx-green); margin-right: 4px; }

/* 气泡尾巴 */
.msg-row:not(.me) .bubble::before {
  content: "";
  position: absolute;
  left: -6px; top: 14px;
  border: 6px solid transparent;
  border-right-color: #fff;
  border-left: none;
}
.msg-row.me .bubble::after {
  content: "";
  position: absolute;
  right: -6px; top: 14px;
  border: 6px solid transparent;
  border-left-color: var(--wx-green);
  border-right: none;
}

/* 读心按钮：气泡下方的小胶囊，仿微信操作项 */
.read-btn {
  display: inline-block;
  margin-top: 6px;
  border: 1px solid #e2e2e2;
  background: #fff;
  color: #999;
  font-size: 11px;
  padding: 3px 11px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.read-btn:hover:not(:disabled) { color: #576b95; border-color: #d3dcea; background: #f7f9fc; }
.read-btn:disabled { color: #ccc; cursor: default; }

/* 心声：仿微信引用消息的灰底小卡片 */
.inner-thought {
  margin-top: 6px;
  background: #f6f6f6;
  border-radius: 5px;
  padding: 8px 11px;
  font-size: 12.5px;
  color: #7d7d7d;
  line-height: 1.7;
  max-width: 100%;
}
.inner-thought .it-tag {
  display: inline-block;
  margin-right: 6px;
  color: #576b95;
  font-size: 11px;
  font-weight: 600;
}

/* 朋友圈事件卡片 */
.moment-card {
  margin: 16px auto;
  width: 92%;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #e2e2e2;
  padding: 12px 14px;
  font-size: 13px;
}
.moment-card .mc-head { color: #576b95; font-weight: 600; font-size: 12px; margin-bottom: 6px; }
.moment-card .mc-body { line-height: 1.6; color: #333; }

/* ---- 输入区 ---- */
#tipsBar {
  flex: none;
  background: #f7f7f7;
  border-top: 1px solid #e0e0e0;
  padding: 8px 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tip-chip {
  border: 1px solid #c9c9c9;
  background: #fff;
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 12.5px;
  cursor: pointer;
  color: #444;
}
.tip-chip:hover { border-color: var(--wx-btn); color: var(--wx-btn); }

.wx-bottom {
  flex: none;
  background: #f7f7f7;
  border-top: 1px solid #e0e0e0;
  padding: 8px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#input {
  flex: 1;
  resize: none;
  border: none;
  background: #fff;
  border-radius: 5px;
  padding: 9px 10px;
  font-size: 14.5px;
  outline: none;
  max-height: 88px;
  font-family: inherit;
}

.side-btn, .send-btn {
  border: none;
  border-radius: 5px;
  padding: 9px 12px;
  font-size: 14px;
  cursor: pointer;
}
.side-btn { background: #e8e8e8; color: #555; }
.send-btn { background: var(--wx-btn); color: #fff; font-weight: 600; }
.send-btn:hover:not(:disabled) { background: #06ad56; }
.side-btn:hover:not(:disabled) { background: #dedede; }
.send-btn:disabled, .side-btn:disabled { opacity: .45; cursor: default; }

/* 组织密报卡片：微信卡片风（白底灰边 + 链接蓝标题） */
.intel-card {
  margin: 16px auto;
  width: 92%;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.intel-card .ic-head {
  color: #576b95;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.intel-card .ic-body { line-height: 1.7; color: #333; }

/* ---- 结算页 ---- */
.verdict-card { text-align: center; width: 100%; }

#verdictTitle { font-size: 26px; letter-spacing: 4px; color: #1a1a1a; margin-bottom: 4px; }
.verdict-card.fail #verdictTitle { color: var(--red); }
.verdict-card.win #verdictTitle { color: #2e7d32; }

.verdict-grade {
  margin: 8px auto 4px;
  font-size: 48px;
  font-weight: 800;
  font-family: Georgia, serif;
  color: #07c160;
}
.verdict-card.fail .verdict-grade { color: #8a8a8a; }

#verdictText { font-size: 13.5px; line-height: 1.9; color: #555; white-space: pre-wrap; text-align: left; }

.verdict-stats {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed #ddd;
  font-size: 12px;
  color: #999;
  line-height: 2;
}

/* ================= 移动端：去黑边，满屏显示 ================= */
@media (max-width: 520px), (max-height: 720px) {
  body { align-items: stretch; justify-content: stretch; }
  .phone {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}
