/* 字骨 · 样式
 * 纸、墨、朱砂、木块。圆角一律不超过 3px。
 */

:root {
  --paper: #EFE7D8;
  --desk: #E9E0CD;
  --line: #D6C8AE;
  --slot: #E2D8C2;
  --slot-line: #C3B59A;
  --ink: #1C1A17;
  --ink-2: #6B6357;
  --ink-3: #8A8175;
  --red: #B23A2F;
  --wood: #D8BC8A;
  --wood-line: #A9854F;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", "Songti SC", "STSong", "SimSun", serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

/* 纸张噪点：内联 SVG feTurbulence，压得很淡 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}

#app { position: relative; z-index: 1; min-height: 100%; }

.screen { display: none; }
.screen.is-on { display: block; }

/* 全页轻微一震（答对时） */
@keyframes page-jolt {
  0% { transform: translateY(0); }
  45% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}
#app.is-jolt { animation: page-jolt 80ms linear 1; }
/* 窄屏托盘是 fixed 的，给 #app 上 transform 会让它瞬间跳位，所以只震案台 */
@media (max-width: 720px) {
  #app.is-jolt { animation: none; }
  #app.is-jolt .desk { animation: page-jolt 80ms linear 1; }
}

/* ============ 通用小件 ============ */
.brow {
  margin: 0 0 18px;
  font-size: 13px;
  letter-spacing: .28em;
  color: var(--ink-3);
}
.rule-red {
  display: block;
  width: 56px;
  height: 3px;
  background: var(--red);
  margin: 14px 0 18px;
}
.foot-note {
  margin: 26px 0 0;
  font-size: 12px;
  letter-spacing: .06em;
  color: var(--ink-3);
}
.ink-btn {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: .3em;
  padding: 12px 34px 12px 40px;
  border-radius: 2px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.ink-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(28, 26, 23, .22); }
.ink-btn:active { transform: translateY(1px); box-shadow: none; }
.ink-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

/* ============ 封面 ============ */
#cover { position: relative; min-height: 100vh; padding: 6vh 7vw 70px; }

.cover-wrap {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 40px;
  max-width: 1120px;
  margin: 0 auto;
}

.cover-left { flex: 1 1 auto; max-width: 620px; }

.logo {
  margin: 0;
  font-size: 116px;
  line-height: 1;
  letter-spacing: .06em;
  font-weight: 600;
}
.sub { margin: 0 0 22px; font-size: 20px; color: var(--ink); }
.copy { margin: 0 0 14px; color: var(--ink-2); font-size: 16px; }
.copy p { margin: 2px 0; }
.aside-red { margin: 0 0 30px; font-size: 13px; color: var(--red); }

.cover-right {
  flex: 0 0 auto;
  margin-top: 96px;
  text-align: center;
}
.demo-row { display: flex; align-items: center; gap: 10px; }
.arrow { display: block; }
.wood-static {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  background: var(--wood);
  border: 1px solid var(--wood-line);
  border-bottom-width: 3px;
  border-radius: 2px;
  font-size: 38px;
  color: #2A2318;
  box-shadow: 0 2px 4px rgba(28, 26, 23, .14);
}
.demo-note { margin: 14px 0 0; font-size: 13px; color: var(--ink-2); }

.seal-corner { position: absolute; right: 0; top: -8px; opacity: .92; }

.shop-line {
  position: absolute;
  right: 7vw;
  bottom: 26px;
  margin: 0;
  font-size: 12px;
  color: var(--ink-3);
}

/* ============ 对局页 ============ */
#stage {
  max-width: 900px;
  margin: 0 auto;
  padding: 26px 22px 30px;
  min-height: 100vh;
}

.stage-top { margin-bottom: 22px; }
.top-line {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.lvl { font-size: 15px; letter-spacing: .14em; color: var(--ink); }
.combo {
  font-size: 14px;
  letter-spacing: .1em;
  color: var(--red);
  border: 1px solid rgba(178, 58, 47, .5);
  border-radius: 2px;
  padding: 0 7px;
}
.combo[hidden] { display: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.score-box { font-size: 14px; color: var(--ink-2); }
.score-box em { font-style: normal; letter-spacing: .1em; margin-right: 5px; color: var(--ink-3); }
.score-box b { font-size: 17px; color: var(--ink); }

.icon-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink-2);
  width: 30px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.icon-btn .ico-cross { display: none; }
.icon-btn.is-muted .ico-wave { display: none; }
.icon-btn.is-muted .ico-cross { display: inline; }
.icon-btn.is-muted { color: var(--red); border-color: rgba(178, 58, 47, .45); }

.text-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: .12em;
  color: var(--ink-2);
  padding: 4px 10px;
  cursor: pointer;
}
.text-btn:hover { border-color: var(--ink); color: var(--ink); }

/* 计时条：一根墨条 */
.timer-rail {
  height: 6px;
  background: var(--slot);
  border: 1px solid var(--slot-line);
  border-radius: 2px;
  overflow: hidden;
}
.timer-bar {
  height: 100%;
  width: 100%;
  background: var(--ink);
  transform-origin: left center;
}
@keyframes bar-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .48; }
}
.timer-bar.is-hot { background: var(--red); animation: bar-pulse .6s ease-in-out infinite; }

/* 案台 */
.desk {
  background: var(--desk);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 26px 24px 20px;
  text-align: center;
}
.desk-head { margin-bottom: 20px; }
.pinyin {
  display: block;
  font-size: 30px;
  letter-spacing: .12em;
  color: var(--ink);
}
.clue { display: block; margin-top: 6px; font-size: 15px; color: var(--ink-2); }

.slot-field { position: relative; display: inline-block; padding: 6px 0; }

/* 空槽 */
.slots { display: flex; align-items: center; justify-content: center; gap: 12px; }
.slot {
  position: relative;
  width: 92px; height: 92px;
  background: var(--slot);
  border: 1px dashed var(--slot-line);
  border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  cursor: default;
}
.slot.is-full { border-style: solid; cursor: pointer; background: transparent; }
.slot .ord {
  position: absolute;
  left: 5px; top: 2px;
  font-size: 11px;
  color: var(--ink-3);
}
.slot.is-full .ord { display: none; }

@keyframes slot-bad {
  0%, 100% { background: var(--slot); }
  40% { background: rgba(178, 58, 47, .18); }
}
.slot.is-bad { animation: slot-bad .4s ease-in-out 1; }

/* 结构布局 */
.slots[data-structure="上下"] { flex-direction: column; }
.slots[data-structure="品字"] {
  display: grid;
  grid-template-columns: repeat(2, 92px);
  grid-template-rows: repeat(2, 92px);
  gap: 10px;
}
.slots[data-structure="品字"] .slot:nth-child(1) { grid-column: 1 / span 2; justify-self: center; }
.slots[data-structure="全包围"],
.slots[data-structure="半包围"] {
  position: relative;
  display: block;
  width: 150px; height: 150px;
}
.slots[data-structure="全包围"] .slot:nth-child(1),
.slots[data-structure="半包围"] .slot:nth-child(1) { width: 150px; height: 150px; }
.slots[data-structure="全包围"] .slot:nth-child(2) {
  position: absolute; width: 74px; height: 74px;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
}
.slots[data-structure="半包围"] .slot:nth-child(2) {
  position: absolute; width: 78px; height: 78px;
  left: 58%; top: 42%; transform: translate(-50%, -50%);
}
.slots[data-structure="三件"] .slot { width: 84px; height: 84px; }

/* 描红虚影 */
.ghost {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 132px;
  line-height: 1;
  color: rgba(178, 58, 47, .17);
  opacity: 0;
  transition: opacity .16s ease;
  pointer-events: none;
  z-index: 3;
}
.ghost.is-on { opacity: 1; }

/* 朱砂印章：1.6 倍旋转 -8° 盖下 */
.stamp {
  position: absolute;
  right: -34px; top: -18px;
  width: 76px; height: 76px;
  border: 4px solid var(--red);
  border-radius: 2px;
  color: var(--red);
  display: flex; align-items: center; justify-content: center;
  font-size: 25px;
  letter-spacing: .02em;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  transform: scale(1.6) rotate(-8deg);
}
@keyframes stamp-down {
  0% { transform: scale(1.6) rotate(-8deg); opacity: 0; }
  55% { opacity: 1; }
  100% { transform: scale(1) rotate(-8deg); opacity: 1; }
}
.stamp.is-on { animation: stamp-down .3s cubic-bezier(.18, .86, .3, 1) forwards; }
.stamp.is-off { opacity: 0; transition: opacity .35s ease; transform: scale(1) rotate(-8deg); }

.struct-hint { margin: 20px 0 0; font-size: 13px; letter-spacing: .1em; color: var(--ink-3); }
.verdict { margin: 8px 0 0; min-height: 26px; font-size: 15px; color: var(--ink-2); }
.verdict.is-right { color: var(--red); }
.verdict.is-wrong { color: var(--red); }

/* 印章架 */
.shelf-row {
  display: flex; align-items: center; gap: 12px;
  margin: 22px 0 6px;
  flex-wrap: wrap;
}
.shelf-label { font-size: 12px; letter-spacing: .16em; color: var(--ink-3); }
.seal-shelf { display: flex; gap: 6px; flex: 1 1 auto; min-height: 30px; align-items: center; }
.seal-chip {
  width: 30px; height: 30px;
  border: 2px solid var(--red);
  border-radius: 2px;
  color: var(--red);
  font-size: 10px;
  line-height: 1.05;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  writing-mode: vertical-rl;
  opacity: .9;
}
.peek-left { font-size: 12px; color: var(--ink-3); }
.peek-left b { color: var(--ink-2); font-size: 14px; display: inline-block; }
.peek-left.is-low b { color: var(--red); }
@keyframes peek-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.28); color: var(--red); }
  100% { transform: scale(1); }
}
.peek-left.is-pulse b { animation: peek-pulse .5s ease-out 1; }
.peek-refill {
  font-size: 11px;
  color: var(--red);
  letter-spacing: .04em;
  opacity: .85;
}
.peek-refill[hidden] { display: none; }

.stage-tip { margin: 0 0 18px; font-size: 12px; color: var(--ink-3); }

/* 托盘 */
.tray {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 14px 12px;
  background: var(--desk);
  border: 1px solid var(--line);
  border-radius: 2px;
  min-height: 92px;
}

/* 木块 */
.block {
  appearance: none;
  position: relative;
  width: 66px; height: 66px;
  background: var(--wood);
  border: 1px solid var(--wood-line);
  border-bottom-width: 3px;
  border-radius: 2px;
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1;
  color: #2A2318;
  cursor: pointer;
  box-shadow: 0 2px 3px rgba(28, 26, 23, .13);
  transition: transform .1s ease, box-shadow .1s ease;
  padding: 0;
}
.block:hover { transform: translateY(-2px); box-shadow: 0 6px 10px rgba(28, 26, 23, .22); }
.block:active { transform: translateY(1px); box-shadow: 0 1px 2px rgba(28, 26, 23, .18); }
.block:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.block .num {
  position: absolute;
  right: 4px; bottom: 2px;
  font-size: 10px;
  color: rgba(42, 35, 24, .5);
}
.block.is-used { visibility: hidden; }

/* 已落座的木块 */
.slot .block {
  width: 100%; height: 100%;
  cursor: pointer;
  box-shadow: inset 0 -2px 0 rgba(169, 133, 79, .5);
}
.slot .block .num { display: none; }
@keyframes seat-in {
  0% { transform: scale(.9); }
  100% { transform: scale(1); }
}
.slot .block.is-seat { animation: seat-in .16s ease-out 1; }

@keyframes blk-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-5px); }
  35% { transform: translateX(4px); }
  55% { transform: translateX(-3px); }
  75% { transform: translateX(2px); }
}
.block.is-shake { animation: blk-shake .32s ease-in-out 1; }

/* 公布答案时的样子 */
.slot .block.is-told { background: #E4D3B4; }

/* ============ 结算页 ============ */
#tally { min-height: 100vh; padding: 10vh 7vw; }
.tally-wrap { max-width: 560px; margin: 0 auto; }
.tally-score { display: flex; align-items: baseline; gap: 8px; }
.tally-score b { font-size: 88px; line-height: 1; font-weight: 600; }
.tally-score em { font-style: normal; font-size: 16px; color: var(--ink-3); letter-spacing: .2em; }

.tally-list { list-style: none; margin: 0 0 24px; padding: 0; }
.tally-list li {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px dashed var(--line);
  padding: 9px 0;
}
.tally-list em { font-style: normal; font-size: 14px; color: var(--ink-2); letter-spacing: .1em; }
.tally-list b { font-size: 19px; }
.remark { margin: 0 0 30px; font-size: 21px; color: var(--red); }

/* ============ 窄屏 ============ */
@media (max-width: 860px) {
  .logo { font-size: 82px; }
  .cover-wrap { flex-direction: column; }
  .cover-right { margin-top: 10px; align-self: flex-start; text-align: left; }
  .seal-corner { position: static; margin-bottom: 10px; }
  .shop-line { position: static; margin-top: 34px; }
  #cover { padding: 5vh 7vw 40px; }
}

@media (max-width: 720px) {
  body { font-size: 15px; }
  #stage { padding: 18px 14px 130px; }
  .desk { padding: 20px 12px 16px; }
  .pinyin { font-size: 25px; }
  .slot { width: 74px; height: 74px; }
  .slots[data-structure="品字"] { grid-template-columns: repeat(2, 74px); grid-template-rows: repeat(2, 74px); }
  .slots[data-structure="全包围"], .slots[data-structure="半包围"] { width: 124px; height: 124px; }
  .slots[data-structure="全包围"] .slot:nth-child(1),
  .slots[data-structure="半包围"] .slot:nth-child(1) { width: 124px; height: 124px; }
  .slots[data-structure="全包围"] .slot:nth-child(2) { width: 62px; height: 62px; }
  .slots[data-structure="半包围"] .slot:nth-child(2) { width: 66px; height: 66px; }
  .slots[data-structure="三件"] .slot { width: 66px; height: 66px; }
  .ghost { font-size: 104px; }
  .stamp { right: -10px; top: -10px; width: 62px; height: 62px; font-size: 20px; }

  /* 托盘钉在底部 */
  .tray {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    border-left: 0; border-right: 0; border-bottom: 0;
    border-radius: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    justify-content: center;
    z-index: 5;
    box-shadow: 0 -3px 10px rgba(28, 26, 23, .1);
  }
  .block { width: 56px; height: 56px; font-size: 27px; }
  .tally-score b { font-size: 64px; }
}

@media (max-width: 420px) {
  .logo { font-size: 66px; }
  .slot { width: 64px; height: 64px; }
  .slots[data-structure="三件"] .slot { width: 58px; height: 58px; }
  .block { width: 50px; height: 50px; font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
