/* styles.css — Publish or Perish · 学术求生（Rose Pink 同源令牌） */

:root {
  --bg: #FFF7F9;
  --surface: #FFFFFF;
  --surface-muted: #FAF3F6;
  --border: #E3D8DC;
  --ink: #241D20;
  --sub: #473A40;
  --muted: #6E5F66;
  --danger: #C24040;
  --ok: #2E7D5B;
  --violet: #7A3FC4;
  --gold: #B07A1A;
  --brand: #D61F69;
  --brand-hover: #B5195A;
  --brand-soft: #FBEFF4;
  --brand-soft-strong: #F5DEE8;
  --brand-text: #B5195A;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-md: 0 6px 16px rgba(214, 31, 105, .10);
  --shadow-card: 0 14px 34px rgba(214, 31, 105, .16);

  --font-display: Georgia, 'Times New Roman', 'Songti SC', 'STSong', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(520px 360px at 12% -6%, rgba(214, 31, 105, .10), transparent 60%),
    radial-gradient(640px 420px at 96% 108%, rgba(122, 63, 196, .06), transparent 62%),
    var(--bg);
}

button { font-family: inherit; font-size: inherit; color: inherit; border: none; background: none; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

#app {
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
}

.rise { animation: rise .45s cubic-bezier(.2,.7,.3,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.d1 { animation-delay: .06s; } .d2 { animation-delay: .12s; } .d3 { animation-delay: .18s; } .d4 { animation-delay: .24s; }

/* ---------- 通用 ---------- */

.h1 { font-family: var(--font-display); font-size: 30px; font-weight: 700; letter-spacing: .2px; }
.h2 { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.sub { color: var(--sub); }
.muted { color: var(--muted); font-size: 13px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--brand); color: #fff;
  font-weight: 600; font-size: 16px;
  transition: transform .12s, background .18s, box-shadow .18s;
  box-shadow: var(--shadow-md);
}
.btn:hover { background: var(--brand-hover); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--surface); color: var(--brand-text); border: 1.5px solid var(--brand-soft-strong); box-shadow: none; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.sm { min-height: 38px; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
a.btn { text-decoration: none; }

input[type="text"] {
  width: 100%; min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 16px; font-family: inherit; color: var(--ink);
}
input[type="text"]:focus { outline: none; border-color: var(--brand); }

.seg { display: inline-flex; background: var(--brand-soft); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { padding: 7px 16px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--brand-text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

/* ---------- 首页 ---------- */

.hero { text-align: center; padding: 34px 0 18px; }
.hero .h1 { font-size: 34px; }
.hero .tag { margin-top: 6px; color: var(--muted); }

.stack { display: grid; gap: 12px; margin-top: 18px; }

.rules { margin-top: 20px; padding: 16px; }
.rules li { margin: 6px 0 0 18px; color: var(--sub); font-size: 14px; }

/* ---------- 大厅 ---------- */

.codebox { text-align: center; padding: 26px 18px; }
.codebox .code { font-family: var(--font-display); font-size: 52px; font-weight: 700; letter-spacing: 10px; color: var(--brand-text); margin: 6px 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; background: var(--brand-soft); color: var(--brand-text); border-radius: 999px; font-weight: 600; font-size: 14px; }
.chip.off { opacity: .45; }

/* ---------- 对局 ---------- */

.board { display: grid; gap: 8px; }
.prow {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 10px 12px;
}
.prow.me { border-color: var(--brand-soft-strong); background: var(--brand-soft); }
.prow.active { border-color: var(--brand); box-shadow: var(--shadow-md); }
.board.dense { gap: 5px; }
.board.dense .prow { padding: 7px 10px; }
.pname { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; font-weight: 700; }
.b-skip { background: #F4E3E3; color: var(--danger); }
.b-block { background: #F4E3E3; color: var(--danger); }
.b-grant { background: #EDE4F8; color: var(--violet); }
.b-nature { background: #F5ECDC; color: var(--gold); }
.b-off { background: var(--surface-muted); color: var(--muted); }
.stat { text-align: right; font-variant-numeric: tabular-nums; }
.stat .c { font-weight: 800; color: var(--brand-text); font-size: 17px; }
.stat .p { display: block; font-size: 11px; color: var(--muted); }

.turnbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: linear-gradient(135deg, var(--brand), #C026D3);
  color: #fff; border-radius: var(--radius-md);
  padding: 11px 14px; font-weight: 700;
  box-shadow: var(--shadow-md);
}
.turnbar.mine { background: linear-gradient(135deg, var(--ok), #3B9E76); }

.bench { margin-top: 12px; }
.slotrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.slot {
  padding: 6px 10px; border-radius: 10px; font-size: 13px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand-text);
  border: 1.5px dashed var(--brand-soft-strong);
}
.slot.extra { background: #F5ECDC; color: var(--gold); border-style: solid; }
.slot.filled { background: var(--brand); color: #fff; border: 1.5px solid var(--brand); box-shadow: var(--shadow-md); }

.hand { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.hcard {
  position: relative;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); padding: 10px 8px 8px;
  min-height: 78px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  transition: transform .12s, border-color .15s, box-shadow .15s;
  text-align: center;
}
.hcard:active { transform: scale(.96); }
.hcard .cat { width: 22px; height: 22px; border-radius: 50%; display: block; }
.hcard .nm { font-size: 13px; font-weight: 700; line-height: 1.2; }
.hcard .ct { font-size: 10px; color: var(--muted); }
.cat.research { background: radial-gradient(circle at 32% 30%, #F584B4, var(--brand)); }
.cat.action { background: radial-gradient(circle at 32% 30%, #A66BE0, var(--violet)); }
.cat.sabotage { background: radial-gradient(circle at 32% 30%, #E06666, var(--danger)); }
.cat.wild { background: radial-gradient(circle at 32% 30%, #E0B055, var(--gold)); }

.hint { margin-top: 8px; color: var(--muted); font-size: 12.5px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.log { margin-top: 12px; }
.loglist { display: grid; gap: 5px; margin-top: 8px; }
.logline { font-size: 13px; color: var(--sub); padding: 7px 10px; background: var(--surface-muted); border-radius: 8px; }
.logline b { color: var(--ink); }
.logline .fx { color: var(--brand-text); font-weight: 700; }

/* ---------- 挑战 / 弹层 ---------- */

.challenge {
  margin-top: 12px;
  background: #FFF1F1; border: 1.5px solid #F0CACA; border-radius: var(--radius-lg);
  padding: 16px;
}
.timerbar { height: 6px; border-radius: 999px; background: #F0CACA; overflow: hidden; margin-top: 10px; }
.timerbar i { display: block; height: 100%; background: var(--danger); transition: width .3s linear; }
.votes { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.vdot { width: 12px; height: 12px; border-radius: 50%; background: var(--border); }
.vdot.no { background: var(--danger); }
.vdot.yes { background: var(--ok); }

.sheet {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(36, 29, 32, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet .inner {
  width: 100%; max-width: 560px;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 82dvh; overflow-y: auto;
}
.sheet h3 { font-family: var(--font-display); font-size: 19px; margin-bottom: 12px; }
.optgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.opt {
  padding: 12px; border-radius: var(--radius-md);
  background: var(--surface); border: 1.5px solid var(--border);
  font-weight: 600; text-align: center; font-size: 14px;
}
.opt:active { transform: scale(.97); }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); }

.togglerow { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 14px; color: var(--sub); }
.togglerow input { width: 18px; height: 18px; accent-color: var(--brand); }

/* ---------- 帮助：规则与图鉴 ---------- */

.h4 { font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.rlist { margin: 8px 0 0 18px; display: grid; gap: 7px; }
.rlist li { color: var(--sub); font-size: 13.5px; line-height: 1.55; }
.cathead { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; color: var(--sub); margin: 14px 0 7px; }
.cathead .cat { width: 15px; height: 15px; border-radius: 50%; flex: none; }
.crows { display: grid; gap: 6px; }
.crow {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 9px 12px;
}
.crow .cat { width: 14px; height: 14px; border-radius: 50%; flex: none; margin-top: 3px; }
.crowmain { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.crowmain .nm { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.cnt { font-style: normal; font-size: 11px; color: var(--muted); font-weight: 700; background: var(--surface-muted); border-radius: 999px; padding: 1px 7px; }
.crowmain .ds { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.crowmain .tm { font-size: 11.5px; color: var(--sub); margin-top: 2px; line-height: 1.45; }
.timing {
  font-size: 12.5px; color: var(--sub); background: var(--surface-muted);
  border-radius: 10px; padding: 8px 10px; margin-bottom: 12px; line-height: 1.5;
}
.hcard.off { opacity: .5; }

/* ---------- 结算 ---------- */

.result { text-align: center; padding: 30px 18px; }
.winner-name { font-family: var(--font-display); font-size: 34px; font-weight: 800; color: var(--brand-text); margin: 10px 0 2px; }
.title-chip { display: inline-block; margin: 8px 4px 0; padding: 8px 16px; border-radius: 999px; background: #F5ECDC; color: var(--gold); font-weight: 700; }
.title-chip.sad { background: #F4E3E3; color: var(--danger); }

.footnote { text-align: center; margin-top: 22px; }
