/* =========================================================
   《卧底，请睁眼》· 浅色主题
   配色：深蓝 #1B2A4A / 珊瑚橙 #FF6B4A / 薄荷绿 #2FBF9B / 奶油白 #FBF7F2
   规则：圆角 ≤ 8px、最小点击区 44px、适配 360 / 390 / 768
   ========================================================= */
:root {
  --navy: #1b2a4a;
  --navy-2: #2c3f68;
  --coral: #ff6b4a;
  --coral-d: #e8502f;
  --mint: #2fbf9b;
  --cream: #fbf7f2;
  --card: #ffffff;
  --ink: #16233d;
  --ink2: #62708f;
  --ink3: #98a2b8;
  --line: #e8e3da;
  --line2: #f1ede6;
  --bad: #e5484d;
  --gold: #f0a92e;
  --r: 8px;
  --shadow: 0 2px 10px rgba(22, 35, 61, .07);
  --shadow2: 0 6px 22px rgba(22, 35, 61, .14);
  --tap: 44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--cream);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hide { display: none !important; }

/* ---------------- 通用控件 ---------------- */
.btn {
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: var(--r);
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .08s, background .15s, border-color .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn.primary:active { background: var(--coral-d); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.mint { background: var(--mint); border-color: var(--mint); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink2); font-weight: 500; }
.btn.block { width: 100%; }
.btn[disabled], .btn:disabled { opacity: .45; pointer-events: none; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.rec { background: var(--bad); border-color: var(--bad); color: #fff; }

.input {
  width: 100%; min-height: var(--tap);
  padding: 10px 12px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: #fff;
  outline: none;
}
.input:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(44, 63, 104, .1); }
textarea.input { resize: none; line-height: 1.45; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.sep { height: 1px; background: var(--line2); margin: 12px 0; }
.muted { color: var(--ink2); }
.tiny { font-size: 12.5px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 6px;
  font-size: 12px; font-weight: 600;
  background: var(--line2); color: var(--ink2);
}
.tag.uc { background: #ffe6df; color: var(--coral-d); }
.tag.civ { background: #e2f6f0; color: #1a8c71; }
.tag.host { background: #eef1f8; color: var(--navy); }
.tag.out { background: #f4f2ef; color: var(--ink3); }

/* ---------------- 顶部栏 ---------------- */
#top {
  position: sticky; top: 0; z-index: 30;
  background: rgba(251, 247, 242, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
  display: flex; align-items: center; gap: 8px;
  min-height: 56px;
}
#top .brand { font-weight: 800; letter-spacing: .5px; color: var(--navy); white-space: nowrap; }
.chipbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 30px; padding: 0 9px;
  border-radius: 6px; background: #fff; border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--ink2);
  white-space: nowrap;
}
.chip b { color: var(--ink); }
.chip.gold { background: #fff6e6; border-color: #f6dcae; color: #8a5a10; }
.chip.timer.low { background: #ffe9e4; border-color: #ffc7ba; color: var(--coral-d); }

/* ---------------- 页面骨架 ---------------- */
#main { max-width: 768px; margin: 0 auto; padding: 14px 12px 92px; }
.scr { display: none; }
.scr.on { display: block; }
h1.title { font-size: 22px; margin: 4px 0 2px; color: var(--navy); letter-spacing: .5px; }
h2.sec { font-size: 14px; margin: 16px 0 8px; color: var(--ink2); font-weight: 700; }
.lbl { font-size: 13px; font-weight: 700; color: var(--ink2); margin: 12px 0 6px; display: block; }

/* ---------------- 首页 ---------------- */
.hero {
  padding: 18px 16px;
  border-radius: var(--r);
  background: linear-gradient(0deg, #fff, #fff);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -20px; top: -20px;
  width: 96px; height: 96px; border-radius: 50%;
  background: #ffece7;
}
.hero h1 { margin: 0 0 4px; font-size: 24px; color: var(--navy); }
.hero p { margin: 0; color: var(--ink2); font-size: 13.5px; }
.hero .eye { font-size: 40px; line-height: 1; }
.panelpad { padding: 14px; }
.joinrow { display: flex; gap: 8px; margin-top: 8px; }
.joinrow .input { text-transform: uppercase; letter-spacing: 3px; font-weight: 700; text-align: center; }

/* ---------------- 玩家列表 ---------------- */
.plist { display: flex; flex-direction: column; gap: 8px; }
.pitem {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  min-height: 56px;
}
.pitem.me { border-color: var(--navy-2); box-shadow: 0 0 0 2px rgba(44, 63, 104, .08); }
.pitem.turn { border-color: var(--coral); background: #fff8f5; box-shadow: 0 0 0 2px rgba(255, 107, 74, .12); }
.pitem.out { opacity: .5; }
.pitem.voted { border-style: dashed; }
.av {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 20px; background: var(--line2);
}
.av.lg { width: 54px; height: 54px; font-size: 28px; }
.pname { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.pmeta { font-size: 12px; color: var(--ink3); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink3); display: inline-block; }
.dot.on { background: var(--mint); }
.dot.off { background: #d7d3cb; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: repeat(3, 1fr); } }

/* ---------------- 主题 / 卧底数选择 ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chipsel {
  min-height: var(--tap); padding: 0 14px;
  border-radius: var(--r); border: 1px solid var(--line);
  background: #fff; font-weight: 600; color: var(--ink2);
  display: inline-flex; align-items: center;
}
.chipsel.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chipsel[disabled] { opacity: .6; }

/* ---------------- 游戏页 ---------------- */
#gbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow);
}
#gbar .round { font-weight: 800; color: var(--navy); }
#gbar .clock { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 800; color: var(--navy); }
#gbar .clock.low { color: var(--bad); }
.bar { height: 4px; background: var(--line2); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--mint); transition: width .4s linear; }
.bar > i.low { background: var(--coral); }

#wordcard {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; margin-bottom: 10px;
  border-radius: var(--r);
  background: #fff; border: 1px dashed #d9d2c6;
}
#wordcard .wcd { font-weight: 800; font-size: 18px; color: var(--navy); letter-spacing: 2px; }
#wordcard .wcbtn { margin-left: auto; }

#feed { display: flex; flex-direction: column; gap: 8px; }
.fitem {
  padding: 9px 11px; border-radius: var(--r);
  background: #fff; border: 1px solid var(--line);
  font-size: 14.5px;
}
.fitem .fwh { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink3); margin-bottom: 3px; }
.fitem.sys { background: #f7f5f1; border-style: dashed; color: var(--ink2); font-size: 13px; }
.fitem.sep { text-align: center; background: transparent; border: 0; font-weight: 800; color: var(--navy); font-size: 13.5px; padding: 4px 0; }
.fitem.bad { border-color: #ffd2ca; background: #fff6f4; }
.fitem.warn { border-color: #f6e0b4; background: #fffaf0; }
.fitem.me { border-color: var(--navy-2); }

#bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
#bottom .inner { max-width: 768px; margin: 0 auto; }
#sayrow { display: flex; gap: 8px; align-items: flex-end; }
#sayrow textarea { min-height: 46px; max-height: 96px; }
.roundbtn {
  width: var(--tap); height: var(--tap); flex: none;
  border-radius: 50%; background: var(--line2); color: var(--navy);
  display: grid; place-items: center; font-size: 19px;
  border: 1px solid var(--line);
}
.roundbtn[disabled] { opacity: .45; }
.roundbtn.on { background: var(--bad); color: #fff; border-color: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,72,77,.5); } 50% { box-shadow: 0 0 0 8px rgba(229,72,77,0); } }

#votes { display: flex; flex-wrap: wrap; gap: 8px; }
.vbtn {
  min-height: var(--tap); padding: 0 12px;
  border-radius: var(--r); border: 1px solid var(--line); background: #fff;
  font-weight: 700;
}
.vbtn.on { background: var(--coral); border-color: var(--coral); color: #fff; }
.vbtn.sel { border-color: var(--coral); background: #fff3ef; color: var(--coral-d); }

/* 说话提示 */
#talk {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 84px; z-index: 45;
  background: rgba(27, 42, 74, .94); color: #fff;
  padding: 7px 14px; border-radius: var(--r);
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.wave { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.wave i { width: 3px; background: currentColor; border-radius: 2px; animation: wv .8s infinite ease-in-out; }
.wave i:nth-child(2) { animation-delay: .15s; }
.wave i:nth-child(3) { animation-delay: .3s; }
.wave i:nth-child(4) { animation-delay: .45s; }
@keyframes wv { 0%,100% { height: 3px; } 50% { height: 12px; } }

/* ---------------- 词语遮罩弹层 ---------------- */
#mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(22, 35, 61, .72);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 20px;
}
#mask .sheetbox {
  width: 100%; max-width: 340px;
  background: #fff; border-radius: var(--r);
  padding: 20px 18px; text-align: center;
  box-shadow: var(--shadow2);
}
#mask .wtitle { font-size: 13px; color: var(--ink2); font-weight: 700; }
#mask .word {
  font-size: 38px; font-weight: 900; letter-spacing: 6px;
  color: var(--navy); margin: 14px 0 6px;
}
#mask .role { font-size: 13px; font-weight: 700; }
#mask .role.civ { color: #1a8c71; }
#mask .role.uc { color: var(--coral-d); }
#mask .cd { font-size: 12.5px; color: var(--ink3); margin-top: 10px; }
#mask .mbtn { margin-top: 16px; }

/* ---------------- 结算页 ---------------- */
.banner {
  padding: 18px 16px; border-radius: var(--r); color: #fff;
  background: var(--navy); text-align: center; margin-bottom: 12px;
}
.banner.civ { background: var(--mint); }
.banner.uc { background: var(--coral); }
.banner .bt { font-size: 20px; font-weight: 900; letter-spacing: 1px; }
.banner .bs { font-size: 13px; opacity: .92; margin-top: 4px; }
.wordbox { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.wordbox .wb { padding: 12px; border-radius: var(--r); background: #fff; border: 1px solid var(--line); text-align: center; }
.wordbox .wb .wl { font-size: 12px; color: var(--ink2); font-weight: 700; }
.wordbox .wb .ww { font-size: 21px; font-weight: 900; color: var(--navy); letter-spacing: 3px; margin-top: 4px; }
.wordbox .wb.uc { border-color: #ffd2ca; background: #fff8f6; }
.wordbox .wb.uc .ww { color: var(--coral-d); }

/* ---------------- 提示条 ---------------- */
#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; gap: 6px; align-items: center;
  pointer-events: none; width: calc(100% - 32px); max-width: 420px;
}
#toast > div {
  background: rgba(27, 42, 74, .95); color: #fff;
  padding: 9px 14px; border-radius: var(--r); font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow2); animation: tin .18s ease-out;
}
#toast > div.warn { background: #b8442a; }
#toast > div.ok { background: #1a8c71; }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }

/* ---------------- 小屏适配 ---------------- */
@media (max-width: 400px) {
  #main { padding: 10px 10px 88px; }
  .hero h1 { font-size: 21px; }
  .av { width: 34px; height: 34px; font-size: 18px; }
  #top .brand { font-size: 14px; }
  .chip { font-size: 12px; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (min-width: 769px) {
  #main { padding: 18px 16px 100px; }
  .grid2 { grid-template-columns: repeat(3, 1fr); }
}
