:root {
  --bg: #faf9f7;
  --ink: #1a1a1a;
  --sub: #8a8a8a;
  --hair: #e5e2dd;
  --accent: #b3342a;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; } /* hidden 属性必须压过 .zz-modal/.actions 等的 display */
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", sans-serif;
  min-height: 100dvh;
}
main { width: 100%; max-width: 520px; margin: 0 auto; padding: 40px 20px 48px; }
h1 { font-size: 26px; text-align: center; }
.tagline { text-align: center; color: var(--sub); font-size: 14px; margin-top: 6px; }
.back { display: inline-block; margin-bottom: 14px; color: var(--sub); text-decoration: none; font-size: 13px; }
.back:hover { color: var(--accent); }

nav { margin-top: 36px; border-top: 1px solid var(--hair); }
nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 4px; font-size: 16px;
  border-bottom: 1px solid var(--hair);
  color: var(--ink); text-decoration: none;
}
nav a:hover { color: var(--accent); }
nav a .arrow { color: var(--sub); }

.field { margin-top: 18px; }
label { display: block; font-size: 13px; color: var(--sub); margin-bottom: 6px; }
input[type=text] {
  width: 100%; padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--hair); border-radius: 8px;
  background: #fff; color: var(--ink);
}
input[type=text]:focus { outline: none; border-color: var(--accent); }

button {
  cursor: pointer; font-size: 15px; padding: 10px 16px;
  border: 1px solid var(--hair); border-radius: 8px;
  background: #fff; color: var(--ink);
}
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.primary:hover { background: #000; }
button:disabled { opacity: .4; cursor: default; }

.row { display: flex; gap: 8px; margin-top: 12px; }
.row > * { flex: 1; }
.error { color: var(--accent); font-size: 13px; margin-top: 10px; min-height: 1em; text-align: center; }

.seg { display: flex; border: 1px solid var(--hair); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: none; border-radius: 0; background: #fff; padding: 10px 0; }
.seg button.on { background: var(--ink); color: #fff; }

.code-big {
  font-size: 44px; font-weight: 600; letter-spacing: 8px;
  text-align: center; margin: 20px 0 4px;
  font-variant-numeric: tabular-nums;
}
.hint { text-align: center; color: var(--sub); font-size: 14px; margin-top: 16px; }
.status { text-align: center; font-size: 15px; margin: 14px 0 4px; min-height: 1.4em; }
.vs { display: flex; justify-content: space-between; font-size: 14px; color: var(--sub); margin-top: 14px; }
.actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }

canvas { display: block; margin: 14px auto 0; border-radius: 6px; touch-action: manipulation; }

.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.cell {
  aspect-ratio: 1; font-size: 32px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--hair); border-radius: 12px; background: #fff;
  position: relative;
}
.cell.eaten { opacity: .35; }
.cell.mypoison { border: 2px dashed var(--accent); }
.cell.reveal { background: #f6e3e1; }
.cell .mark { position: absolute; top: 1px; right: 4px; font-size: 12px; }

/* 狼人杀 */
.card { background: #fff; border: 1px solid var(--hair); border-radius: 12px; padding: 14px 16px; }
.stepper { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--hair); }
.stepper .ctl { display: flex; align-items: center; gap: 10px; }
.stepper .ctl button { width: 32px; height: 32px; padding: 0; font-size: 18px; line-height: 1; }
.stepper .cnt { min-width: 24px; text-align: center; font-weight: 600; }
.names { font-size: 15px; line-height: 2; }
.banner { text-align: center; font-size: 17px; font-weight: 600; margin-top: 16px; }
.rolecard {
  margin-top: 14px; border: 1px solid var(--hair); border-radius: 12px;
  background: #fff; padding: 18px; text-align: center;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.rolecard .emoji { font-size: 44px; }
.rolecard .rname { font-size: 20px; font-weight: 700; margin-top: 6px; }
.rolecard .rdesc { color: var(--sub); font-size: 13px; margin-top: 4px; }
.rolecard.hidden-card .emoji,
.rolecard.hidden-card .rname,
.rolecard.hidden-card #rc-desc { display: none; }
.log { font-size: 14px; margin-top: 12px; background: #fff; border: 1px solid var(--hair); border-radius: 8px; padding: 10px 14px; line-height: 1.7; }
.big-result { text-align: center; font-size: 18px; }
.tbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tbtns button { flex: 1 1 40%; }
.wide-btn { width: 100%; margin-top: 10px; }
.pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.seatbtn {
  padding: 8px 4px; font-size: 14px; text-align: center;
  border: 1px solid var(--hair); border-radius: 8px; background: #fff;
}
.seatbtn.dead { opacity: .4; }
.seatbtn.me { border-color: var(--accent); }
.seatbtn .no { display: block; font-size: 11px; color: var(--sub); }

/* 接龙创作 */
.story-list { margin-top: 28px; border-top: 1px solid var(--hair); }
.story-item {
  display: block; padding: 12px 4px;
  border-bottom: 1px solid var(--hair);
  color: var(--ink); text-decoration: none;
}
.story-item:hover .st-title { color: var(--accent); }
.story-item .st-title { display: block; font-size: 15px; }
.story-item .st-meta { display: block; font-size: 12px; color: var(--sub); margin-top: 2px; }
.book-title { text-align: center; font-size: 21px; font-weight: 700; margin-top: 10px; }
.book {
  margin-top: 16px; background: #fff;
  border: 1px solid var(--hair); border-radius: 12px;
  padding: 20px 18px;
}
.book .para { font-size: 15px; line-height: 1.9; text-indent: 2em; margin-bottom: 2px; }
.book .who { display: block; font-size: 12px; color: var(--sub); margin-bottom: 14px; }
textarea {
  width: 100%; padding: 10px 12px; font-size: 16px; line-height: 1.7;
  border: 1px solid var(--hair); border-radius: 8px;
  background: #fff; color: var(--ink); resize: vertical;
  font-family: inherit;
}
textarea:focus { outline: none; border-color: var(--accent); }

/* K线猜猜乐 */
.k-stats { text-align: center; font-size: 13px; color: var(--sub); margin-top: 12px; min-height: 1.2em; }
.k-chart-wrap { margin-top: 14px; background: #fff; border: 1px solid var(--hair); border-radius: 12px; padding: 10px 6px 4px; }
.k-chart-wrap canvas { margin: 0 auto; }
.k-caption { text-align: center; font-size: 12px; color: var(--sub); padding: 4px 0 8px; }
.k-btns { display: flex; gap: 10px; margin-top: 14px; }
.k-btns button { flex: 1; padding: 14px 0; font-size: 17px; font-weight: 600; border-radius: 12px; }
.k-up { border-color: #d5453c; color: #d5453c; background: #fff; }
.k-up:hover { background: #d5453c; color: #fff; }
.k-down { border-color: #2e9e5b; color: #2e9e5b; background: #fff; }
.k-down:hover { background: #2e9e5b; color: #fff; }
.k-result { margin-top: 14px; background: #fff; border: 1px solid var(--hair); border-radius: 12px; padding: 14px 16px; text-align: center; }
.k-verdict { font-size: 17px; font-weight: 700; }
.k-win { color: #d5453c; }
.k-lose { color: #2e9e5b; }
.k-flat { color: var(--sub); }
.k-who { font-size: 13px; color: var(--sub); margin-top: 8px; line-height: 1.6; }
.k-again { font-size: 12px; color: var(--sub); margin-top: 6px; }
.k-board-title { text-align: center; font-size: 17px; margin-top: 32px; }
.k-board { margin-top: 10px; background: #fff; border: 1px solid var(--hair); border-radius: 12px; padding: 6px 14px; }
.k-board table { width: 100%; border-collapse: collapse; font-size: 14px; }
.k-board th, .k-board td { padding: 8px 4px; text-align: center; border-bottom: 1px solid var(--hair); }
.k-board tr:last-child td { border-bottom: none; }
.k-board th { font-size: 12px; color: var(--sub); font-weight: 400; }
.k-board td:nth-child(2), .k-board th:nth-child(2) { text-align: left; }
.k-case { margin-top: 12px; text-align: left; background: #faf9f7; border: 1px solid var(--hair); border-radius: 8px; padding: 10px 12px; }
.k-case-title { font-size: 13px; font-weight: 600; color: var(--accent); }
.k-case-text { font-size: 13px; color: #555; line-height: 1.8; margin-top: 6px; }
.k-disclaimer { text-align: center; font-size: 11px; color: #c9c5be; margin-top: 28px; }

/* 坐庄 */
.zz-rules { margin-top: 16px; font-size: 14px; line-height: 1.9; }
.zz-rules p { margin-bottom: 8px; }
.zz-rules p:last-child { margin-bottom: 0; }
.zz-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 16px; font-size: 15px; font-variant-numeric: tabular-nums;
}
.zz-meters { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.zz-meter { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--sub); }
.zz-meter span { width: 60px; text-align: right; }
.zz-meter b { width: 26px; font-variant-numeric: tabular-nums; }
.zz-bar { flex: 1; height: 8px; background: #f0ede8; border-radius: 4px; overflow: hidden; }
.zz-bar i { display: block; height: 100%; border-radius: 4px; transition: width .3s; }
.zz-hold { text-align: center; font-size: 13px; color: var(--sub); margin-top: 10px; }
.zz-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.zz-acts button { padding: 12px 8px; font-size: 16px; font-weight: 600; border-radius: 12px; }
.zz-acts button span { display: block; font-size: 11px; font-weight: 400; color: var(--sub); margin-top: 3px; }
.zz-log { max-height: 180px; overflow-y: auto; line-height: 1.8; }
.zz-log div { margin-bottom: 4px; }
.zz-toast { color: var(--accent); font-weight: 600; }
.zz-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10;
}
.zz-modal-box {
  background: var(--bg); border-radius: 14px; padding: 18px;
  width: 100%; max-width: 440px; max-height: 90dvh; overflow-y: auto;
}
.zz-modal-box h3 { text-align: center; margin-bottom: 10px; }
.zz-modal-box label { display: block; font-size: 13px; color: var(--sub); margin: 12px 0 6px; }
.zz-modal-box .tbtns button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.zz-rumor {
  margin-top: 14px; background: #fff; border: 1px dashed var(--accent);
  border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.9;
}
.zz-verdict { margin-top: 10px; }

/* 拿个十年 */
.hold-big {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 8px; font-variant-numeric: tabular-nums;
}
.hold-big #hold-value { font-size: 30px; font-weight: 700; }
.hold-big #hold-ret { font-size: 18px; font-weight: 600; }
#hold-chart { margin-top: 0; }
.k-chart-wrap { position: relative; }
#hold-pops { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.hold-pop {
  position: absolute; bottom: 10px; max-width: 62%;
  background: rgba(26,26,26,.88); color: #fff; font-size: 12px; line-height: 1.5;
  border-radius: 10px; padding: 6px 10px;
  animation: hold-pop-in .25s ease-out;
  transition: opacity .4s;
}
.hold-pop.dim { background: rgba(26,26,26,.62); }
.hold-pop.out { opacity: 0; }
@keyframes hold-pop-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.hold-progress { height: 4px; background: #f0ede8; border-radius: 2px; margin-top: 10px; overflow: hidden; }
.hold-progress i { display: block; height: 100%; background: var(--ink); width: 0; }
.hold-ctl { display: flex; gap: 10px; margin-top: 12px; }
.hold-ctl .seg { flex: 1; }
#hold-sell {
  flex: 2; position: relative; overflow: hidden;
  border-color: var(--accent); color: var(--accent);
  font-weight: 700; font-size: 16px; border-radius: 10px;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
#hold-sell i {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: var(--accent); opacity: .85;
}
#hold-sell span { position: relative; }
#hold-sell:active { color: #fff; }
.hold-reveal { font-size: 16px; line-height: 1.7; margin-bottom: 10px; }
.hold-truth { color: var(--accent); font-size: 19px; }
.hold-code { color: var(--sub); font-size: 12px; }

/* AI 狼人杀·围观局 */
.aw-live-card { margin-bottom: 12px; font-size: 15px; }
.aw-live-card a { color: var(--accent); text-decoration: none; }
.aw-seats { display: flex; justify-content: space-between; margin-top: 14px; }
.aw-seat { flex: 1; text-align: center; }
.aw-seat.dead { opacity: .38; }
.aw-avatar {
  width: 44px; height: 44px; border-radius: 50%; margin: 0 auto;
  color: #fff; font-size: 19px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.aw-alias { font-size: 13px; margin-top: 4px; }
.aw-role { display: block; font-size: 11px; color: var(--sub); margin-top: 2px; }
.aw-godrow { display: block; text-align: center; font-size: 13px; color: var(--sub); margin-top: 14px; user-select: none; }
.aw-godrow input { vertical-align: -2px; }
.aw-feed {
  margin-top: 12px; background: #fff; border: 1px solid var(--hair); border-radius: 12px;
  padding: 12px 14px; min-height: 260px; max-height: 56dvh; overflow-y: auto;
}
.aw-ev { margin-bottom: 10px; font-size: 14px; line-height: 1.7; }
.aw-sys { text-align: center; color: var(--sub); font-size: 13px; }
.aw-death { text-align: center; color: var(--accent); font-weight: 600; }
.aw-speech { display: flex; gap: 8px; align-items: flex-start; }
.aw-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 8px; }
.aw-bubble { background: #f4f2ee; border-radius: 4px 14px 14px 14px; padding: 8px 12px; }
.aw-bubble b { display: block; font-size: 12px; color: var(--sub); margin-bottom: 2px; }
.aw-vote { color: #555; font-size: 13px; padding-left: 18px; }
.aw-os { color: #9b59b6; font-size: 12px; margin-top: 2px; }
.aw-godmsg {
  background: #f7f2fb; border: 1px dashed #c9a8e0; border-radius: 10px;
  padding: 7px 11px; font-size: 13px; color: #6c3483;
}
.aw-review { margin-top: 12px; text-align: left; }
.aw-mvp { text-align: center; font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.aw-review-line { font-size: 13px; line-height: 1.8; color: #555; }
