/* DEVS — Discrete Evolution of Value States */
:root {
  --ink: #07080a;
  --ink-2: #0d0f12;
  --graphite: #1a1d22;
  --line: rgba(220, 226, 234, .08);
  --line-2: rgba(220, 226, 234, .16);
  --silver: #d9dee5;
  --silver-dim: #8b929c;
  --mute: #5d636c;
  --crimson: #e2273a;
  --crimson-soft: rgba(226, 39, 58, .55);
  --lamp: #ff2d3f;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: "Inter", "Helvetica Neue", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --B: clamp(280px, min(68vh, 54vw), 560px);   /* 棋盘边长 */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
}
body {
  background: var(--ink);
  color: var(--silver);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, a { font: inherit; color: inherit; touch-action: manipulation; }
button:focus, a:focus { outline: none; }
button:focus-visible, a:focus-visible {
  outline: 1px solid var(--line-2); outline-offset: 2px;
}
/* 规程等弹层的滚动区用 .sheet-body，不被整页 touch-action: none 吃掉 */
.sheet-body {
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
::selection { background: var(--crimson); color: #fff; }

/* ---------- 背景：近黑 + 极淡网格 + 颗粒 + 暗角 ---------- */
.bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 38%, transparent 0 46%, rgba(0,0,0,.72) 100%),
    radial-gradient(60% 50% at 50% 40%, rgba(170, 180, 196, .045), transparent 70%),
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 64px 64px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 64px 64px,
    var(--ink);
  opacity: .9;
}
.bg::after {
  content: ""; position: absolute; inset: 0; opacity: .07; mix-blend-mode: screen;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------- 版面 ---------- */
.app {
  position: relative; z-index: 1;
  max-width: 1040px; margin: 0 auto;
  padding: clamp(18px, 4vh, 44px) clamp(16px, 4vw, 40px) 22px;
  display: flex; flex-direction: column; gap: clamp(16px, 3vh, 30px);
  min-height: 100vh;
  transform-origin: 50% 40%;
  transition: opacity .9s var(--ease-out), transform 1.2s var(--ease-out);
}
body.theater-on .app { opacity: .18; transform: scale(.985); }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.brand { position: relative; }
.title {
  margin: 0; font-weight: 200; line-height: .9;
  font-size: clamp(40px, 6.4vw, 68px);
  letter-spacing: .52em; margin-right: -.52em;
  color: #eef1f5;
}
.title span { display: inline-block; opacity: 0; transform: translateY(10px); animation: rise .9s var(--ease-out) forwards; }
.title span:nth-child(2) { animation-delay: .08s; }
.title span:nth-child(3) { animation-delay: .16s; }
.title span:nth-child(4) { animation-delay: .24s; }
.hair {
  display: block; height: 1px; margin: 12px 0 9px; width: 100%;
  background: linear-gradient(90deg, var(--crimson) 0 18px, var(--line-2) 18px 100%);
  transform-origin: 0 50%; transform: scaleX(0);
  animation: draw 1.1s .35s var(--ease-out) forwards;
}
.fullname {
  margin: 0; font-family: var(--mono); font-size: 11px; letter-spacing: .26em; text-transform: uppercase;
  color: var(--silver-dim); opacity: 0; animation: fade 1s .6s ease forwards;
}
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes draw { to { transform: scaleX(1); } }
@keyframes fade { to { opacity: 1; } }

.head-r { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.back {
  appearance: none; background: none; border: 0; cursor: pointer; font: inherit;
  font-family: var(--mono); font-size: 11px; letter-spacing: .22em; color: var(--silver-dim); text-decoration: none;
  padding: 4px 2px; transition: color .25s ease;
}
.back:hover, .back:focus-visible { color: #fff; outline: none; }

/* 运行灯（胸前小红灯的意象） */
.run { white-space: nowrap;
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .22em; color: var(--silver-dim);
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,255,255,.015);
}
.lamp {
  position: relative; width: 8px; height: 8px; border-radius: 50%;
  background: var(--lamp);
  box-shadow: 0 0 0 2px rgba(255, 45, 63, .14), 0 0 10px rgba(255, 45, 63, .7);
  animation: breathe 3.6s ease-in-out infinite;
  transition: background-color 1.4s ease, box-shadow 1.4s ease;
}
.lamp .flare {
  position: absolute; inset: -9px; border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, rgba(255, 60, 75, .75), rgba(255, 45, 63, 0) 68%);
}
@keyframes breathe { 0%, 100% { opacity: .55; transform: scale(.88); } 50% { opacity: 1; transform: scale(1); } }
.run.halt .lamp { animation: none; opacity: .5; background: #3a3d42; box-shadow: 0 0 0 2px rgba(255,255,255,.04); }
.run.halt { color: var(--mute); }
.run.conv .lamp { animation-duration: 2.4s; }

/* ---------- 主区 ---------- */
.play {
  display: grid; grid-template-columns: var(--B) minmax(220px, 1fr);
  gap: clamp(22px, 4vw, 52px); align-items: start;
}
.board-col { position: relative; display: flex; flex-direction: column; gap: 12px; }
/* 合并提示出现时把棋盘与 STEP 的间距撑开，提示可以落在中间且不挡住方块 */
.board-col.has-merge-coach { gap: 42px; }

.board {
  position: relative; width: var(--B); height: var(--B);
  --gap: 12px; --cell: 100px;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,0) 40%),
    #0c0e11;
  box-shadow:
    inset 0 0 0 1px rgba(220,226,234,.07),
    inset 0 1px 0 rgba(255,255,255,.05),
    0 30px 80px -30px rgba(0,0,0,.9),
    0 0 0 1px rgba(0,0,0,.6);
  touch-action: none; user-select: none; -webkit-user-select: none;
  outline: none; cursor: grab;
  contain: layout;
  opacity: 0; animation: fade .8s .2s ease forwards;
}
.board:active { cursor: grabbing; }
.board:focus-visible { box-shadow: inset 0 0 0 1px rgba(220,226,234,.25), 0 30px 80px -30px rgba(0,0,0,.9); }
/* 四角刻度 */
.board::before, .board::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none; z-index: 4;
  border-color: rgba(220,226,234,.28); border-style: solid;
}
.board::before { left: -7px; top: -7px; border-width: 1px 0 0 1px; }
.board::after { right: -7px; bottom: -7px; border-width: 0 1px 1px 0; }

.grid {
  position: absolute; inset: var(--gap);
  display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: var(--gap);
}
.grid i {
  border-radius: 6px;
  background: rgba(255,255,255,.018);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03), inset 0 2px 6px rgba(0,0,0,.5);
  position: relative;
}
.grid i::after { /* 格心微点 */
  content: ""; position: absolute; left: 50%; top: 50%; width: 2px; height: 2px; margin: -1px;
  background: rgba(220,226,234,.10); border-radius: 50%;
}

.tiles, .fx { position: absolute; inset: 0; pointer-events: none; }
.fx { z-index: 3; }

/* ---------- 瓦片：刻字算力块 ---------- */
.tile {
  position: absolute; left: 0; top: 0;
  width: var(--cell); height: var(--cell);
  will-change: transform;
  z-index: 1;
}
.tile.merged { z-index: 2; }
.face {
  position: absolute; inset: 0; border-radius: 6px;
  display: grid; place-items: center;
  --bg1: #17191d; --bg2: #121418; --fg: #8d949e; --edge: rgba(255,255,255,.06); --bit: rgba(220,226,234,.55);
  background: linear-gradient(180deg, var(--bg1), var(--bg2));
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--edge), inset 0 1px 0 rgba(255,255,255,.06), 0 6px 14px -8px rgba(0,0,0,.9);
  will-change: transform, opacity;
  transition: opacity .9s ease;
}
.face::before { /* 内刻框 */
  content: ""; position: absolute; inset: calc(var(--cell) * .06); border-radius: 3px;
  border: 1px solid rgba(255,255,255,.035); pointer-events: none;
}
.face .val {
  grid-area: 1 / 1; position: relative; z-index: 1;
  font-family: var(--mono); font-weight: 500; letter-spacing: -.02em;
  font-size: calc(var(--cell) * .36);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(0,0,0,.65), 0 -1px 0 rgba(255,255,255,.05);
  will-change: transform, opacity;
}
.face.d3 .val { font-size: calc(var(--cell) * .30); }
.face.d4 .val { font-size: calc(var(--cell) * .245); }
.face.d5 .val, .face.d6 .val, .face.d7 .val { font-size: calc(var(--cell) * .195); }
.face .ex {
  position: absolute; left: calc(var(--cell) * .1); top: calc(var(--cell) * .085);
  font-family: var(--mono); font-size: max(8px, calc(var(--cell) * .095)); letter-spacing: .06em;
  opacity: .5;
}
.face .bits {
  position: absolute; left: calc(var(--cell) * .1); right: calc(var(--cell) * .1); bottom: calc(var(--cell) * .1);
  display: flex; gap: 2px; height: 2px;
}
.face .bits i { flex: 1; background: rgba(255,255,255,.06); border-radius: 1px; }
.face .bits i.on { background: var(--bit); }
.face .bits i.hd { background: var(--crimson); box-shadow: 0 0 4px var(--crimson-soft); }
.face .bloom {
  position: absolute; inset: -30%; border-radius: 50%; opacity: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(circle, rgba(255, 70, 86, .55), rgba(226, 39, 58, .18) 38%, rgba(226,39,58,0) 66%);
  mix-blend-mode: screen;
}

/* 层级：从石墨到银白，高位带绯红微光 */
.e1  { --bg1:#16181c; --bg2:#111317; --fg:#7f8690; }
.e2  { --bg1:#1a1d22; --bg2:#14161a; --fg:#9aa1ab; }
.e3  { --bg1:#1f2228; --bg2:#171a1e; --fg:#b3bac3; --edge: rgba(255,255,255,.08); }
.e4  { --bg1:#252930; --bg2:#1b1e23; --fg:#c8ced6; --edge: rgba(255,255,255,.10); }
.e5  { --bg1:#2c3038; --bg2:#1f2228; --fg:#dde2e8; --edge: rgba(255,255,255,.12); }
.e6  { --bg1:#343943; --bg2:#23272d; --fg:#eef1f4; --edge: rgba(255,255,255,.15); }
.e7, .e8, .e9 {
  --bg1:#3b404a; --bg2:#25282e; --fg:#f6f8fa; --edge: rgba(255,255,255,.18); --bit: rgba(240,244,248,.85);
}
.e7 { box-shadow: inset 0 0 0 1px var(--edge), inset 0 1px 0 rgba(255,255,255,.1), 0 0 calc(var(--cell)*.18) -2px rgba(226,39,58,.18), 0 6px 14px -8px #000; }
.e8 { box-shadow: inset 0 0 0 1px var(--edge), inset 0 1px 0 rgba(255,255,255,.12), inset 0 -10px 20px -14px rgba(226,39,58,.55), 0 0 calc(var(--cell)*.24) -2px rgba(226,39,58,.26), 0 6px 14px -8px #000; }
.e9 { box-shadow: inset 0 0 0 1px rgba(255,255,255,.22), inset 0 1px 0 rgba(255,255,255,.14), inset 0 -14px 24px -14px rgba(226,39,58,.7), 0 0 calc(var(--cell)*.3) -2px rgba(226,39,58,.34), 0 6px 14px -8px #000; }
.e10 {
  --bg1:#4a505b; --bg2:#2b2e35; --fg:#ffffff; --bit:#fff;
  box-shadow: inset 0 0 0 1px rgba(255, 90, 104, .55), inset 0 1px 0 rgba(255,255,255,.18), inset 0 -16px 28px -14px rgba(226,39,58,.8), 0 0 calc(var(--cell)*.36) 0 rgba(226,39,58,.38), 0 6px 14px -8px #000;
}
.e11 { /* 2048：银白反相，绯红核心 */
  --bg1:#f1f3f6; --bg2:#c3c9d1; --fg:#0b0c0f; --bit:#14161a; --edge: rgba(255,255,255,.7);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.75), inset 0 -18px 30px -16px rgba(226,39,58,.55), 0 0 0 1px rgba(226,39,58,.45), 0 0 calc(var(--cell)*.5) 2px rgba(226,39,58,.42), 0 0 calc(var(--cell)*.9) 0 rgba(220,226,234,.12);
}
.e11 .val { text-shadow: 0 1px 0 rgba(255,255,255,.6); font-weight: 600; }
.e11::before { border-color: rgba(0,0,0,.12); }
.e12 { /* 超越 2048：黑底绯红刻字 */
  --bg1:#101114; --bg2:#060708; --fg:#ff3a4b; --bit: #ff3a4b; --edge: rgba(255,58,75,.55);
  box-shadow: inset 0 0 0 1px var(--edge), 0 0 calc(var(--cell)*.4) 0 rgba(226,39,58,.4);
}
.e12 .val { text-shadow: 0 0 calc(var(--cell)*.08) rgba(255,58,75,.6); }

/* 停机：瓦片按对角线依次暗下 */
.board.halted .face { opacity: .26; transition-delay: var(--d, 0s); }

/* ---------- 特效层 ---------- */
.ring {
  position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell); border-radius: 10px;
  border: 1px solid rgba(255, 70, 86, .8);
  box-shadow: 0 0 12px rgba(226,39,58,.35);
  opacity: 0; will-change: transform, opacity;
}
.ring.silver { border-color: rgba(230, 236, 244, .7); box-shadow: 0 0 10px rgba(230,236,244,.2); }
.edgeglow {
  position: absolute; inset: 0; border-radius: 10px; opacity: 0; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255,70,86,.55), inset 0 0 40px rgba(226,39,58,.18);
}
.scan {
  position: absolute; left: 0; top: 0; width: 100%; height: 1px; z-index: 3; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(230,236,244,.65) 30%, rgba(255,70,86,.8) 50%, rgba(230,236,244,.65) 70%, transparent);
  box-shadow: 0 0 12px rgba(230,236,244,.25);
  opacity: 0; will-change: transform, opacity;
}

/* ---------- 停机覆盖 ---------- */
.end {
  position: absolute; inset: 0; z-index: 5; border-radius: 10px;
  display: grid; place-items: center; text-align: center;
  background: radial-gradient(80% 70% at 50% 50%, rgba(7,8,10,.55), rgba(7,8,10,.86));
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 1s ease .5s, visibility 0s linear 1.5s;
}
.end.show { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 1s ease .55s, visibility 0s; }
.end-in { transform: translateY(10px); transition: transform 1.2s var(--ease-out) .55s; }
.end.show .end-in { transform: none; }
.end .k { margin: 0 0 12px; font-family: var(--mono); font-size: 11px; letter-spacing: .3em; color: var(--silver-dim); }
.end-score { margin: 0; font-family: var(--mono); font-weight: 200; font-size: clamp(36px, calc(var(--B) * .13), 64px); color: #f2f4f7; letter-spacing: .04em; }
.end-sub { margin: 8px 0 22px; font-size: 13px; color: var(--silver-dim); letter-spacing: .08em; }
.end-acts { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- 读数 ---------- */
.readout {
  margin: 0; font-family: var(--mono); font-size: 11px; letter-spacing: .2em; color: var(--mute);
  display: flex; justify-content: space-between; white-space: nowrap; overflow: hidden;
}

/* ---------- 侧栏 ---------- */
.side { display: flex; flex-direction: column; gap: 22px; padding-top: 2px; opacity: 0; animation: fade .9s .45s ease forwards; }
.scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score {
  position: relative; padding: 12px 14px 10px; border-radius: 8px;
  background: rgba(255,255,255,.02); box-shadow: inset 0 0 0 1px var(--line);
}
.score .lbl { display: block; font-size: 11px; letter-spacing: .3em; color: var(--silver-dim); margin-bottom: 4px; }
.score output { display: block; font-family: var(--mono); font-size: 26px; font-weight: 300; color: #f1f3f6; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.delta {
  position: absolute; right: 12px; top: 10px; font-family: var(--mono); font-size: 12px; color: var(--lamp);
  opacity: 0; pointer-events: none; will-change: transform, opacity;
}

.acts { display: flex; flex-wrap: wrap; gap: 8px; }
.acts button, .end-acts button, .win-acts button {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 6px; border: 0;
  background: rgba(255,255,255,.035);
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--silver); font-size: 13px; letter-spacing: .14em;
  transition: background-color .25s ease, box-shadow .25s ease, color .25s ease, opacity .25s ease, transform .15s ease;
}
.acts button:hover, .end-acts button:hover, .win-acts button:hover { background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 1px rgba(220,226,234,.3); }
.acts button:active, .end-acts button:active, .win-acts button:active { transform: translateY(1px); }
.acts button:focus-visible, .end-acts button:focus-visible, .win-acts button:focus-visible { outline: 1px solid var(--crimson); outline-offset: 2px; }
button:disabled { opacity: .32; cursor: default; pointer-events: none; }
button.primary { box-shadow: inset 0 0 0 1px rgba(255,70,86,.55); color: #fff; }
button.primary:hover { background: rgba(226,39,58,.14); box-shadow: inset 0 0 0 1px rgba(255,70,86,.85); }
button.ghost { background: transparent; }
button.arm { box-shadow: inset 0 0 0 1px rgba(255,70,86,.8); color: #fff; background: rgba(226,39,58,.12); }
kbd {
  font-family: var(--mono); font-size: 10px; color: var(--mute); padding: 1px 5px; border-radius: 3px;
  box-shadow: inset 0 0 0 1px var(--line-2); letter-spacing: 0;
}

.meta { margin: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.meta > div { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.meta dt { font-size: 12px; letter-spacing: .2em; color: var(--silver-dim); }
.meta dd { margin: 0; font-family: var(--mono); font-size: 13px; color: var(--silver); }

.howto-h { margin: 0 0 8px; font-size: 11px; letter-spacing: .4em; color: var(--silver-dim); }
.howto ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.howto li { position: relative; padding-left: 14px; font-size: 12.5px; line-height: 1.65; color: #a9b0b9; }
.howto li::before { content: ""; position: absolute; left: 0; top: .78em; width: 6px; height: 1px; background: var(--mute); }
.howto b { color: var(--silver); font-weight: 500; }

.foot { margin-top: auto; padding-top: 8px; font-size: 11px; color: #4b5058; letter-spacing: .05em; line-height: 1.6; }

/* ---------- 收敛剧场（通关） ---------- */
.theater {
  position: fixed; inset: 0; z-index: 20;
  visibility: hidden; pointer-events: none;
  transition: visibility 0s linear .8s;
}
.theater.on { visibility: visible; pointer-events: auto; transition: none; }
.theater .veil {
  position: absolute; inset: 0; opacity: 0;
  background:
    radial-gradient(42% 60% at 34% 58%, rgba(226,39,58,.10), transparent 70%),
    radial-gradient(120% 100% at 50% 50%, rgba(6,7,9,.86), rgba(3,3,4,.97));
  transition: opacity .7s ease;
}
.theater.on .veil { opacity: 1; transition: opacity 1.3s ease; }

.stage {
  position: absolute; inset: 0; display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: end; max-width: 1100px; margin: 0 auto;
  padding: var(--safe-t) clamp(16px, 5vw, 64px) calc(12px + var(--safe-b));
}
.moss {
  position: relative; margin: 0; justify-self: end; align-self: end;
  height: min(88vh, 860px); aspect-ratio: 680 / 1060;
  opacity: 0; transform: translateY(26px);
  transition: opacity .5s ease, transform .5s ease;
}
.theater.on .moss { opacity: 1; transform: none; transition: opacity 2.2s ease .7s, transform 2.6s var(--ease-out) .7s; }
.moss img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block;
  -webkit-mask-image: linear-gradient(180deg, #000 0 80%, transparent 99%);
          mask-image: linear-gradient(180deg, #000 0 80%, transparent 99%);
  user-select: none; -webkit-user-drag: none;
}
.moss .halo {
  position: absolute; left: 50%; top: 18%; width: 120%; aspect-ratio: 1; transform: translateX(-50%);
  background: radial-gradient(circle, rgba(220,226,234,.09), rgba(220,226,234,0) 60%);
  border-radius: 50%;
}
/* 胸前小红灯：素材中心约在 50.24% / 42.26% */
.moss .chest {
  position: absolute; left: 50.24%; top: 42.26%; width: 9%; aspect-ratio: 1; transform: translate(-50%, -50%);
  pointer-events: none;
}
.moss .chest::before { /* 外晕 */
  content: ""; position: absolute; inset: -60%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,50,66,.5), rgba(255,45,63,.12) 40%, rgba(255,45,63,0) 70%);
  mix-blend-mode: screen; opacity: 0;
}
.moss .chest .core {
  position: absolute; inset: 31%; border-radius: 50%;
  background: radial-gradient(circle, #ffd9dc 0 12%, #ff4656 34%, rgba(255,45,63,0) 72%);
  mix-blend-mode: screen; opacity: 0;
}
.theater.on .moss .chest::before { animation: ignite 1.6s ease 2.4s forwards, chestBreath 4.2s ease-in-out 4s infinite; }
.theater.on .moss .chest .core { animation: ignite 1.2s ease 2.2s forwards, coreBreath 4.2s ease-in-out 4s infinite; }
@keyframes ignite { 0% { opacity: 0; transform: scale(.6); } 60% { opacity: 1; transform: scale(1.12); } 100% { opacity: .85; transform: scale(1); } }
@keyframes chestBreath { 0%, 100% { opacity: .85; transform: scale(1); } 50% { opacity: .35; transform: scale(.86); } }
@keyframes coreBreath { 0%, 100% { opacity: .85; } 50% { opacity: .45; } }

.copy { align-self: center; padding: 0 0 0 clamp(12px, 3vw, 48px); max-width: 420px; }
.copy .ln { opacity: 0; transform: translateY(8px); transition: opacity .4s ease, transform .4s ease; }
.theater.on .copy .ln { opacity: 1; transform: none; transition: opacity 1.2s ease, transform 1.6s var(--ease-out); }
.theater.on .copy .ln { transition-delay: var(--dl, 1.3s); }
.copy .k { margin: 0 0 14px; font-family: var(--mono); font-size: 11px; letter-spacing: .32em; color: var(--silver-dim); display: flex; align-items: center; gap: 10px; }
.copy .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lamp); box-shadow: 0 0 10px rgba(255,45,63,.8); animation: breathe 4.2s ease-in-out infinite; }
.copy .n { margin: 0; font-family: var(--mono); font-weight: 200; font-size: clamp(56px, 9vw, 112px); letter-spacing: .08em; color: #f4f6f9; line-height: 1; }
.copy .rule {
  display: block; height: 1px; margin: 18px 0 18px; width: 100%;
  background: linear-gradient(90deg, var(--crimson), rgba(226,39,58,.0) 70%);
  transform-origin: 0 50%; transform: scaleX(0); transition: transform .4s ease;
}
.theater.on .copy .rule { transform: scaleX(1); transition: transform 1.8s var(--ease-out) 2s; }
.copy .line { margin: 0 0 6px; font-size: 15px; letter-spacing: .12em; color: #e6e9ee; }
.copy .line.dim { color: var(--silver-dim); font-size: 13px; }
.copy .line.small { font-size: 12px; }
.copy .line b { font-family: var(--mono); font-weight: 400; color: var(--silver); }
.win-acts { display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; }

/* ---------- 响应 ---------- */
@media (max-width: 860px) {
  :root { --B: min(92vw, 520px, 66vh); }
  .play { grid-template-columns: 1fr; justify-items: center; }
  .board-col { width: var(--B); }
  .side { width: var(--B); }
  .howto { display: none; }
  .meta { display: none; }
  .title { font-size: clamp(34px, 11vw, 56px); }
}
@media (max-width: 860px) and (min-height: 760px) {
  .howto { display: block; }
}
@media (max-width: 760px) {
  .stage {
    grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; align-items: end;
    padding: var(--safe-t) clamp(16px, 5vw, 32px) 0;
  }
  .moss {
    justify-self: center; grid-row: 1; align-self: end;
    height: min(50vh, 480px, calc(100svh - 300px - var(--safe-t) - var(--safe-b)));
    max-height: 100%;
  }
  .copy {
    grid-row: 2; justify-self: center; text-align: center; position: relative;
    margin-top: 0; z-index: 1; max-width: min(420px, 100%);
    padding: 10px 8px calc(28px + var(--safe-b));
  }
  .copy .k { justify-content: center; }
  .win-acts { justify-content: center; }
  .copy .rule { background: linear-gradient(90deg, rgba(226,39,58,0), var(--crimson), rgba(226,39,58,0)); transform-origin: 50% 50%; }
}
@media (max-width: 480px) {
  .head { flex-direction: column; align-items: flex-start; }
  .head-r { align-self: stretch; flex-direction: row-reverse; justify-content: space-between; align-items: center; }
  .acts button { padding: 9px 12px; }
  kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .lamp, .copy .dot { animation: none; }
  .theater.on .moss .chest::before, .theater.on .moss .chest .core { animation: ignite .01s forwards; }
  .title span, .hair, .fullname, .board, .side {
    animation: none !important; opacity: 1; transform: none;
  }
  .coach .swipe-dot { animation: none; }
}

/* ---------- 手机竖屏（Android 版也用）：分数与按钮放到棋盘上方，一屏完整可玩 ---------- */
@media (max-width: 600px) {
  :root { --B: min(calc(100vw - 28px - var(--safe-l) - var(--safe-r)), calc(100vh - 292px - var(--safe-t) - var(--safe-b)), 520px); }
  @supports (height: 100svh) { :root { --B: min(calc(100vw - 28px - var(--safe-l) - var(--safe-r)), calc(100svh - 292px - var(--safe-t) - var(--safe-b)), 520px); } }
  .app {
    padding: calc(14px + var(--safe-t)) calc(14px + var(--safe-r)) calc(16px + var(--safe-b)) calc(14px + var(--safe-l));
    gap: 12px; min-height: auto;
  }
  .head { flex-direction: row; align-items: flex-end; gap: 10px; }
  .title { font-size: 28px; letter-spacing: .42em; margin-right: -.42em; }
  .hair { margin: 7px 0 5px; }
  .fullname { font-size: 8.5px; letter-spacing: .16em; }
  .head-r { flex-direction: column; align-items: flex-end; gap: 6px; align-self: auto; }
  .run { padding: 5px 9px; font-size: 10px; letter-spacing: .14em; gap: 7px; }
  .play { display: flex; flex-direction: column; align-items: center; gap: 12px; }
  .side { order: -1; width: var(--B); gap: 10px; }
  .scores { gap: 8px; }
  .score { padding: 7px 10px 6px; }
  .score .lbl { font-size: 10px; margin-bottom: 1px; }
  .score output { font-size: 20px; }
  .acts { flex-wrap: nowrap; gap: 6px; }
  .acts button { flex: 1 1 0; justify-content: center; padding: 9px 6px; font-size: 12.5px; letter-spacing: .08em; }
  .meta, .howto { display: none; }
  .readout { font-size: 10px; letter-spacing: .12em; }
  .board::before, .board::after { width: 10px; height: 10px; }
  .board::before { left: -5px; top: -5px; } .board::after { right: -5px; bottom: -5px; }
  .foot { font-size: 10px; }
  .copy .n { font-size: 52px; }
  .moss { height: min(42vh, 400px, calc(100svh - 300px - var(--safe-t) - var(--safe-b))); }
}
/* 很矮的手机屏：底部说明收起 */
@media (max-width: 600px) and (max-height: 700px) { .foot { display: none; } }

/* ---------- 触屏短边横屏：请竖屏游玩（不影响桌面浏览器） ---------- */
.rotate-hint {
  display: none;
  position: fixed; inset: 0; z-index: 40;
  flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: calc(24px + var(--safe-t)) 28px calc(24px + var(--safe-b));
  background:
    radial-gradient(80% 70% at 50% 45%, rgba(20,22,26,.2), rgba(7,8,10,.97)),
    var(--ink);
  pointer-events: auto; text-align: center;
}
body.need-portrait .rotate-hint { display: flex; }
body.need-portrait .rotate-hint { visibility: visible; }
.rotate-hint .phone {
  display: block; width: 36px; height: 58px; border-radius: 7px;
  border: 1px solid rgba(220,226,234,.35);
  box-shadow: inset 0 0 0 1px rgba(220,226,234,.06);
  position: relative;
}
.rotate-hint .phone::before {
  content: ""; position: absolute; left: 50%; top: 5px; width: 8px; height: 2px; margin-left: -4px;
  background: var(--crimson); border-radius: 1px;
}
.rotate-hint .t {
  margin: 0;
  font-family: var(--sans); font-weight: 300; font-size: 18px;
  letter-spacing: .42em; margin-right: -.42em; color: #eef1f5;
}
.rotate-hint p {
  margin: 0;
  font-family: var(--mono); font-size: 11px; letter-spacing: .22em;
  color: var(--silver-dim);
}

/* ---------- 第三批：菜单 / 规程与成就弹层 / 引导 / 横幅（不动剧场与横屏提示排版） ---------- */
.menu-wrap, .sheet-wrap {
  position: fixed; inset: 0; z-index: 30;
  display: none; align-items: flex-end; justify-content: center;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  background: rgba(7,8,10,.62);
}
.menu-wrap.on, .sheet-wrap.on { display: flex; }
.menu-wrap { align-items: center; z-index: 31; }
.sheet-wrap { z-index: 32; }
.menu-card, .sheet {
  width: min(420px, 100%);
  background: #0c0e11;
  box-shadow: inset 0 0 0 1px var(--line-2), 0 30px 80px -30px rgba(0,0,0,.9);
  border-radius: 10px;
  color: var(--silver);
}
.menu-card {
  padding: 22px 18px 16px; text-align: center;
}
.menu-card .k {
  margin: 0 0 16px; font-family: var(--mono); font-size: 11px;
  letter-spacing: .32em; color: var(--silver-dim);
}
.menu-card nav { display: grid; gap: 8px; }
.menu-card nav button, .menu-card nav a {
  appearance: none; cursor: pointer; display: block; width: 100%;
  padding: 11px 16px; border-radius: 6px; border: 0;
  background: rgba(255,255,255,.035);
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--silver); font-size: 13px; letter-spacing: .16em;
  text-decoration: none; text-align: center;
}
.menu-card nav button:hover, .menu-card nav a:hover,
.menu-card nav button:focus-visible, .menu-card nav a:focus-visible {
  background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 1px rgba(220,226,234,.3); outline: none;
}
.menu-card nav button.primary { box-shadow: inset 0 0 0 1px rgba(255,70,86,.55); color: #fff; }
.menu-card nav .quiet { color: var(--silver-dim); background: transparent; }

.sheet {
  max-height: min(84vh, calc(100dvh - 24px - var(--safe-t) - var(--safe-b)));
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sheet-h {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 10px; flex: 0 0 auto;
  box-shadow: 0 1px 0 var(--line);
}
.sheet-titles {
  flex: 1; min-width: 0; text-align: left;
}
.sheet-h .k {
  margin: 0 0 4px; font-family: var(--mono); font-size: 11px;
  letter-spacing: .32em; color: var(--silver-dim);
  text-align: left;
}
.sheet-h h2 {
  margin: 0; font-weight: 300; font-size: 16px; letter-spacing: .2em;
  text-align: left;
}
.sheet-h .x {
  appearance: none; background: rgba(255,255,255,.035); border: 0;
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--silver-dim);
  cursor: pointer; font-family: var(--mono); font-size: 12px; letter-spacing: .16em;
  min-width: 44px; min-height: 44px; padding: 0 10px; border-radius: 6px;
  flex: 0 0 auto;
}
.sheet-h .x:focus { outline: none; }
.sheet-h .x:focus-visible {
  outline: 1px solid var(--line-2); outline-offset: 2px;
}
.sheet-h .x:hover { box-shadow: inset 0 0 0 1px rgba(220,226,234,.3); color: var(--silver); }
.sheet-body-wrap {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
}
.sheet-fade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 52px;
  pointer-events: none;
  background: linear-gradient(to top, #0c0e11 18%, rgba(12,14,17,0) 100%);
}
.sheet-body {
  overflow: auto; overscroll-behavior: contain; touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 22px;
  font-size: 13px; line-height: 1.7; color: #a9b0b9;
}
.sheet-body h3 {
  margin: 16px 0 8px; font-size: 11px; letter-spacing: .28em;
  color: var(--silver-dim); font-weight: 400;
}
.sheet-body .stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 8px;
}
.sheet-body .stat {
  padding: 10px 12px; border-radius: 8px;
  background: rgba(255,255,255,.02); box-shadow: inset 0 0 0 1px var(--line);
}
.sheet-body .stat .lbl { display: block; font-size: 10px; letter-spacing: .22em; color: var(--silver-dim); }
.sheet-body .stat b { font-family: var(--mono); font-weight: 400; font-size: 18px; color: #f1f3f6; }
.ach-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ach-list li {
  padding: 10px 12px; border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line);
  display: grid; gap: 2px;
}
.ach-list li.on { box-shadow: inset 0 0 0 1px rgba(255,70,86,.4); background: rgba(226,39,58,.06); }
.ach-list .an { font-size: 13px; letter-spacing: .14em; color: var(--silver); }
.ach-list .ad { font-size: 12px; color: var(--mute); }
.ach-list li.off .an { color: #9aa1aa; }
.ach-list li.off .ad { color: #7e858e; }
.ach-list .st { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; color: var(--lamp); }
.ach-list li.off .st { color: #4a4f56; }
.set-row {
  appearance: none; display: flex; width: 100%; box-sizing: border-box;
  align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; margin: 0; padding: 8px 0; border: 0;
  background: none; color: inherit; font: inherit; cursor: pointer; text-align: left;
  box-shadow: 0 1px 0 var(--line);
}
.set-row .nm { color: var(--silver); letter-spacing: .14em; }
.set-row:focus { outline: none; }
.set-row:focus-visible { outline: 1px solid var(--line-2); outline-offset: 2px; }
.switch {
  position: relative; flex: 0 0 auto;
  width: 56px; height: 28px; border-radius: 999px;
  background: #3a3d42;
  box-shadow: inset 0 0 0 1px rgba(220,226,234,.14);
}
.set-row.on .switch { background: #6e121c; box-shadow: inset 0 0 0 1px rgba(226,39,58,.45); }
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #c5cad1; transition: transform .2s ease, background-color .2s ease;
}
.set-row.on .switch .knob { transform: translateX(28px); background: #f1f3f6; }
.switch .lab {
  position: absolute; top: 0; bottom: 0; display: flex; align-items: center;
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
  pointer-events: none;
}
.set-row:not(.on) .switch .lab { right: 8px; color: #b0b6be; }
.set-row.on .switch .lab { left: 8px; color: #f3d6d8; }
.sheet-body .howto-ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.sheet-body .howto-ul li { position: relative; padding-left: 14px; }
.sheet-body .howto-ul li::before {
  content: ""; position: absolute; left: 0; top: .78em; width: 6px; height: 1px; background: var(--mute);
}
.sheet-body .howto-ul b { color: var(--silver); font-weight: 500; }
.sheet-body .howto-keys { margin-top: 4px; }
.sheet-body .howto-keys h3 { margin-top: 16px; }
@media (pointer: coarse) {
  .sheet-body .howto-keys { display: none; }
}
html.touch-coarse .sheet-body .howto-keys { display: none; }

.toast {
  position: fixed; left: 16px; right: 16px; top: 0;
  transform: translateY(-8px);
  z-index: 15; pointer-events: none;
  padding: 10px 14px; border-radius: 8px;
  background: #12151a; box-shadow: inset 0 0 0 1px rgba(255,70,86,.45), 0 16px 40px -20px #000;
  color: var(--silver); opacity: 0;
  transition: opacity .28s ease, transform .28s var(--ease-out);
}
.toast.on { opacity: 1; transform: translateY(0); }
.toast .tt, .toast .td {
  display: block; white-space: nowrap; overflow: hidden;
}
.toast .tt { font-size: 11px; letter-spacing: .18em; color: var(--lamp); font-family: var(--mono); }
.toast .td { margin-top: 2px; font-size: 13px; letter-spacing: .06em; }

.coach {
  position: absolute; left: 0; width: 100%; top: 0; height: var(--B);
  z-index: 6;
  display: none; place-items: start center; text-align: center;
  padding: 16px 14px 0;
  background: radial-gradient(70% 70% at 50% 50%, rgba(7,8,10,.28), rgba(7,8,10,.5));
  pointer-events: none; border-radius: 10px;
  box-sizing: border-box;
}
.coach.on { display: grid; }
.coach-card {
  margin-top: 6px; margin-bottom: 18px;
  padding: 14px 16px 16px;
  max-width: min(280px, calc(100% - 12px));
  background: rgba(8,10,13,.86);
  box-shadow: inset 0 0 0 1px var(--line-2), 0 12px 28px -16px #000;
  border-radius: 10px;
}
.coach p {
  margin: 12px 0 0; font-size: 13px; letter-spacing: .12em; color: #e6e9ee; line-height: 1.6;
}
.coach .swipe-demo {
  position: relative; width: 80px; height: 80px; margin: 0 auto;
  color: rgba(220,226,234,.72);
}
.coach .swipe-demo svg { display: block; overflow: visible; }
.coach .swipe-dot {
  position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px;
  border-radius: 50%; background: #f1f3f6;
  box-shadow: 0 0 6px rgba(226,39,58,.35);
  animation: swipeHint 2.4s var(--ease-out) infinite;
}
/* 行程 8px：圆点边缘最远 12px，箭头内端在 18px（80px 图里 22→中心 40），全程不压箭头 */
@keyframes swipeHint {
  0%, 100% { transform: translate(0, 0); opacity: .35; }
  12% { transform: translate(0, -8px); opacity: 1; }
  24% { transform: translate(0, 0); opacity: .35; }
  36% { transform: translate(8px, 0); opacity: 1; }
  48% { transform: translate(0, 0); opacity: .35; }
  60% { transform: translate(0, 8px); opacity: 1; }
  72% { transform: translate(0, 0); opacity: .35; }
  84% { transform: translate(-8px, 0); opacity: 1; }
}
.coach.merge {
  top: var(--B); height: auto; padding: 6px 0 0;
  background: none; border-radius: 0; place-items: start center;
}
.coach.merge .swipe-demo { display: none; }
.coach.merge .coach-card {
  margin: 0; padding: 6px 14px;
  max-width: 100%; width: 100%;
  box-sizing: border-box;
}
.coach.merge p { margin: 0; font-size: 13px; line-height: 1.45; }
.coach.merge.above {
  top: 0; padding: 0 0 6px;
  transform: translateY(-100%);
}

@media (max-width: 600px) {
  #btnHelp { flex: 0 0 auto; min-width: 42px; padding-left: 0; padding-right: 0; }
}
