:root {
  color-scheme: light;
  --ink: #2c3a4a;
  --muted: #5c6578;
  --line: #d5dce8;
  --human: #2e8b57;
  --monster: #d4534a;
  --paper: #e2e5f8;
  --header: #303e49;
  --gold: #6a4a22;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  /* 皮面平色（yxtc_img_bg.png 正文）。#8d95a3 是头图侧边的灰边，
     铺在 html 上会把面板洗成一块灰。头图只贴在 .cap。 */
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 "PingFang SC", "Noto Sans SC", sans-serif;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: min(420px, 100%);
  height: 100%;
  max-height: 100%;
  margin: 0 auto;
  /* Flat center color of yxtc_img_bg.png. The bitmap stays on .cap only,
     cropped to the dark header, so it is not stretched down the page. */
  background-color: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.cap {
  /* Dark band in the source is the top 67px of 361. Clip to that so the
     light body of the PNG is not scaled into a soft fade. */
  background-color: var(--header);
  background-image: url("assets/yxtc_img_bg.png");
  background-repeat: no-repeat;
  background-position: top center;
  background-size: 100% calc(100% * 361 / 67);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 0 12px;
}

.brand {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: #f3e0b8;
}

.who {
  margin-top: 1px;
  font-size: 15px;
  font-weight: 650;
  color: #fff;
}

.close {
  width: 36px;
  height: 36px;
  border: 0;
  padding: 0;
  flex: none;
  background: transparent url("assets/yxtc_btn_gb.png") center / 28px 28px no-repeat;
}

.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  align-items: flex-end;
  padding: 0 4px;
}

.tab {
  flex: 1 0 auto;
  min-width: 46px;
  min-height: 34px;
  padding: 4px 2px 6px;
  border: 0;
  background: transparent;
  color: #f3e0b8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-label {
  font-size: 14px;
  font-weight: 750;
  color: #f3e0b8;
  line-height: 1;
}

.tab.on {
  background: url("assets/yxtc_btn_yq.png") center / 100% 34px no-repeat;
}

/* 选中签是浅奶油底。字用近黑，避免白字贴在浅底上看不清。未选中仍是深底浅字。 */
.tab.on,
.tab.on .tab-label {
  color: #1a1008;
  font-weight: 800;
}

.phase, .foot, .page { padding-left: 12px; padding-right: 12px; }

.phase {
  color: var(--muted);
  font-size: 13px;
  padding-top: 8px;
}

.stage, .card, .extra, .block, .sheet-panel {
  position: relative;
  border-style: solid;
  border-width: 14px;
  border-image: url("assets/yxtc_img_xxd14.png") 18 fill / 14px stretch;
  background: transparent;
  color: var(--ink);
  padding: 4px 6px 8px;
}

/* border-image 的填充层会挡住点击，按钮抬到上面 */
.stage > *, .card > *, .extra > *, .block > *, .sheet-panel > * {
  position: relative;
  z-index: 1;
}

.extra, .block { margin-top: 8px; }

.stage h2, .card h2, .block h2, .extra h3, .sheet-top h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 750;
  text-align: center;
  color: var(--ink);
}

.stage h2::after, .block h2::after {
  content: "";
  display: block;
  height: 1px;
  width: 72%;
  margin: 6px auto 0;
  background: url("assets/yxtc_img_fgx.png") center / 100% 1px no-repeat;
}

.muted, .meta { color: var(--muted); }

.row, .doors, .vote, .chips, .subtabs, .sheet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
}

.ghost, .btn, .primary {
  border: 0;
  min-height: 42px;
  min-width: 96px;
  padding: 8px 16px;
  color: var(--ink);
  background: url("assets/yxtc_btn_fang02.png") center / 100% 100% no-repeat;
}

/* 三个入口必须同一排。窄面板里 min-width 96 会把第三个挤到下一行。 */
.entry-row {
  flex-wrap: nowrap;
}
.entry-row .ghost {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 4px;
  font-size: 13px;
}

.primary[data-act="checkin"] {
  background-image: url("assets/yxtc_btn_fang05.png");
  color: #6a3b12;
  font-weight: 700;
}

.door {
  flex: 1;
  max-width: 64px;
  min-height: 52px;
  border: 0;
  font-size: 20px;
  font-weight: 750;
  color: var(--ink);
  background: url("assets/yxtc_btn_fang01.png") center / 50px 54px no-repeat;
}

/* 两列等宽。单个按钮只占一格，不用 flex 把末格拉成整行。 */
.pick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.pick {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  text-align: left;
  border: 2px solid #c5cdd8;
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
  outline-width: 0;
  -webkit-tap-highlight-color: transparent;
}

.pick.human { border-color: #2e8b57; }
.pick.monster { border-color: #d4534a; }
/* 选中保留淡黄底。好人加粗绿边，鬼怪加粗红边，随机仍是白粗框。 */
.pick.on {
  background: #fff6e4;
  color: #1a1008;
  font-weight: 750;
  box-shadow: none;
  outline: none;
  outline-width: 0;
}

.pick.human.on { border: 6px solid #2e8b57; }
.pick.monster.on { border: 6px solid #d4534a; }
/* 纯白 6px 贴在 --paper / 卡片暖底和淡黄选中底上几乎看不见。
   白框保留，内外各加一圈顶栏同色细边把它从浅底上分开，不用阵营绿/红。 */
.pick.on:not(.human):not(.monster) {
  border: 6px solid #fff;
  box-shadow:
    inset 0 0 0 1px rgba(48, 62, 73, 0.7),
    0 0 0 2px rgba(48, 62, 73, 0.88);
}

.pick:focus,
.pick:focus-visible {
  outline: none;
  outline-width: 0;
  box-shadow: none;
}

.primary:disabled, .btn:disabled, .pick:disabled, .chip:disabled { opacity: 0.45; }

.vote input {
  flex: 1;
  min-height: 44px;
  border: 1px solid #d5dce8;
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.chip {
  min-height: 32px;
  padding: 4px 12px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px #d5dce8;
  color: #3e4a5c;
}

.chip.on {
  background: url("assets/yxtc_btn_yq.png") center / 100% 100% no-repeat;
  box-shadow: none;
  color: var(--gold);
  font-weight: 700;
}

.bar {
  height: 12px;
  margin: 8px 0;
  background: url("assets/yxtc_img_jdt01.png") center / 100% 12px no-repeat;
  border-radius: 0;
}

.bar > span {
  display: block;
  height: 12px;
  width: 0;
  background: url("assets/yxtc_img_jdt02.png") left center / auto 11px no-repeat;
}

/* 经验条素材只有一条细图，拉满后两端发糊。等级条改用纯色圆角。 */
.bar.level {
  height: 10px;
  border-radius: 999px;
  background: #4e5968;
  background-image: none;
  overflow: hidden;
}

.bar.level > span {
  height: 100%;
  border-radius: inherit;
  background: #3b9eff;
  background-image: none;
}

.identity {
  font-size: 40px;
  font-weight: 750;
  text-align: center;
  margin: 8px 0 4px;
  color: var(--ink);
}

.human-text { color: var(--human); }
.monster-text { color: var(--monster); }
.dead { color: var(--monster); font-weight: 700; }

.team { margin: 6px 0 0; }
.team .team-zombie { color: #e53935; }
.team .team-youhun { color: #2f9d4a; }
.win { color: var(--human); }
.lose { color: var(--monster); }

.page h3 { margin: 4px 0 8px; text-align: center; }

.role {
  padding: 8px 2px 10px;
  border-top: 0;
  background: url("assets/yxtc_img_fgx.png") center top / 92% 1px no-repeat;
}

.role b { font-weight: 750; }

.prop, .stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin-top: 8px;
  padding: 8px 12px;
  color: #4a3828;
  background: #fffaf3;
  border: 1px solid #c8b49a;
  border-radius: 8px;
}

.me-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.me-head img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 50%;
  background: #303e49 url("assets/yxtc_img_txk.png") center / 72px 72px no-repeat;
}

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(48, 62, 73, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 5;
}

.sheet[hidden] { display: none; }

.sheet-panel {
  width: min(420px, 100%);
  max-height: 86dvh;
  overflow: auto;
  padding: 8px 8px calc(16px + env(safe-area-inset-bottom));
}

.sheet-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.sheet-list {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
}

.announce-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
}

.announce-item + .announce-item {
  border-top: 1px solid rgba(44, 58, 74, 0.12);
}

.announce-item.on {
  font-weight: 750;
  color: #3a250e;
}

.sheet-body { white-space: pre-wrap; word-break: break-word; }

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: clamp(92px, 22vh, 180px);
  bottom: auto;
  transform: translateX(-50%);
  width: min(388px, calc(100% - 24px));
  /* 与 .sheet 同一套 #303e49。半透明深底，白字在浅纸上仍可读，不是整页遮罩。 */
  background: rgba(48, 62, 73, 0.8);
  color: #fff;
  padding: 12px 14px;
  text-align: center;
  border-radius: 10px;
  pointer-events: none;
  box-shadow: 0 8px 22px rgba(48, 62, 73, 0.22);
}
