/* SUDO — Systematic Unveiling of Determined Order */
:root {
  --ink: #07080a;
  --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);
  --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);
  --pad-x: 14px;
  /* 盘面边长：宽度优先，高度不够时让出给控制区 */
  --B: min(calc(100vw - 2 * var(--pad-x) - var(--safe-l) - var(--safe-r)), calc(100vh - 412px - var(--safe-t) - var(--safe-b)), 500px);
}
@supports (height: 100svh) {
  :root { --B: min(calc(100vw - 2 * var(--pad-x) - var(--safe-l) - var(--safe-r)), calc(100svh - 412px - var(--safe-t) - var(--safe-b)), 500px); }
}

* { 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%;
  -webkit-tap-highlight-color: transparent;
}
body {
  background: var(--ink); color: var(--silver); font-family: var(--sans);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
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; }
::selection { background: var(--crimson); color: #fff; }

/* ---------- 背景 ---------- */
.bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 42%, transparent 0 46%, rgba(0,0,0,.72) 100%),
    radial-gradient(60% 50% at 50% 46%, rgba(170, 180, 196, .05), 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;
  width: 100%; max-width: calc(var(--B) + 2 * var(--pad-x) + var(--safe-l) + var(--safe-r)); margin: 0 auto;
  height: 100%;
  padding: calc(14px + var(--safe-t)) calc(var(--pad-x) + var(--safe-r)) calc(14px + var(--safe-b)) calc(var(--pad-x) + var(--safe-l));
  display: flex; flex-direction: column; gap: 12px;
  transform-origin: 50% 40%;
  transition: opacity .9s var(--ease-out), transform 1.2s var(--ease-out);
}
body.theater-on .app { opacity: .16; }
body.win-seq .app, body.theater-on .app { will-change: transform, opacity; }
body.win-seq .theater .veil-t, .theater.on .veil-t { will-change: opacity; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex: 0 0 auto; }
.brand { position: relative; }
.title {
  margin: 0; font-weight: 200; line-height: .9; font-size: 28px;
  letter-spacing: .42em; margin-right: -.42em; 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: 7px 0 5px; 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: 8.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--silver-dim); opacity: 0; animation: fade 1s .6s ease forwards; white-space: nowrap;
}
@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: 6px; }
.back {
  appearance: none; background: none; border: 0; cursor: pointer;
  font-family: var(--mono); font-size: 11px; letter-spacing: .22em; color: var(--silver-dim);
  min-height: 32px; padding: 4px 2px; margin: -6px 0 -4px; transition: color .25s ease;
  position: relative;
}
.back::after { content: ""; position: absolute; inset: -6px -10px; } /* 触控区补到 44px */
.back:hover, .back:focus-visible { color: #fff; outline: none; }
.run {
  white-space: nowrap; display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .14em; color: var(--silver-dim);
  padding: 5px 9px; 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;
}
.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 {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
}
.hud, .board-wrap, .controls { width: var(--B); }
.hud { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 8px; opacity: 0; animation: fade .9s .4s ease forwards; }
.hud .cell-r {
  position: relative; padding: 7px 10px 6px; border-radius: 8px;
  background: rgba(255,255,255,.02); box-shadow: inset 0 0 0 1px var(--line);
  transition: opacity .3s ease;
}
.hud .lbl { display: block; font-size: 10px; letter-spacing: .3em; color: var(--silver-dim); margin-bottom: 1px; }
.hud output { display: block; font-family: var(--mono); font-size: 18px; font-weight: 300; color: #f1f3f6; font-variant-numeric: tabular-nums; letter-spacing: .02em; white-space: nowrap; }
.hud #hDiff { font-family: var(--sans); font-size: 16px; letter-spacing: .16em; padding-top: 1px; }
.hud .off output { color: var(--mute); }
.hud #hErr.bump { color: var(--lamp); }

.board-wrap { position: relative; display: flex; flex-direction: column; gap: 8px; }

.board {
  position: relative; width: var(--B); height: var(--B);
  border-radius: 10px; padding: 3px;
  background: rgba(220,226,234,.24);  /* 宫线 */
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.9), 0 0 0 1px rgba(0,0,0,.6);
  touch-action: none; outline: none; contain: layout;
  opacity: 0; animation: fade .8s .2s ease forwards;
}
.board:focus-visible { box-shadow: 0 0 0 1px rgba(220,226,234,.3), 0 30px 80px -30px rgba(0,0,0,.9); }
.board::before, .board::after {
  content: ""; position: absolute; width: 10px; height: 10px; pointer-events: none; z-index: 9;
  border-color: rgba(220,226,234,.32); border-style: solid;
}
.board::before { left: -6px; top: -6px; border-width: 1px 0 0 1px; }
.board::after { right: -6px; bottom: -6px; border-width: 0 1px 1px 0; }

.boxes {
  position: absolute; inset: 3px; display: grid; gap: 2px;
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  border-radius: 7px; overflow: hidden;
}
.box {
  display: grid; gap: 1px; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  background: rgba(220,226,234,.075); /* 格线 */
}
.cell {
  position: relative; background: #0d0f12; overflow: hidden;
  display: grid; place-items: center; cursor: pointer;
  --cs: calc((var(--B) - 14px) / 9);
}
.cell.given {
  background: linear-gradient(180deg, #181b20, #121418);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.cell .hl, .cell .tint, .cell .flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
}
.cell .hl { background: rgba(220,226,234,.11); box-shadow: inset 0 -2px 0 rgba(220,226,234,.5); transition: opacity .16s ease; }
.cell.same .hl { opacity: 1; }
.cell .tint { background: rgba(226,39,58,.22); transition: opacity .2s ease; }
.cell.bad .tint { opacity: 1; }
.cell .flash { background: radial-gradient(circle closest-side, rgba(240,244,248,.52) 0%, rgba(226,39,58,.16) 36%, rgba(226,39,58,0) 68%); will-change: opacity, transform; }
.cell .v {
  position: relative; z-index: 1; grid-area: 1 / 1;
  font-family: var(--mono); font-size: calc(var(--cs) * .54); line-height: 1;
  font-variant-numeric: tabular-nums; color: #b9c4d2; font-weight: 300;
  text-shadow: 0 1px 0 rgba(0,0,0,.65);
  will-change: transform, opacity;
}
.cell.given .v { color: #f1f3f6; font-weight: 500; text-shadow: 0 1px 0 rgba(0,0,0,.65), 0 -1px 0 rgba(255,255,255,.05); }
.cell.same .v { color: #ffffff; }
.cell.wrong .v, .cell.conf .v, .cell.given.conf .v { color: #ff4a5a; }
.cell.wrong .v { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.cell .nt {
  position: absolute; inset: 2px; z-index: 1; grid-area: 1 / 1;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  font-family: var(--mono); font-size: max(8.5px, calc(var(--cs) * .23)); line-height: 1; color: #8b929c;
}
.cell .nt i { display: grid; place-items: center; font-style: normal; opacity: 0; transition: opacity .12s ease, color .12s ease; position: relative; }
.cell .nt i.on { opacity: 1; }
.cell .nt i.lit { color: #e6eaf0; font-weight: 600; }
.cell .nt i.hd { opacity: 1; color: #ff8a95; font-weight: 600; }
.cell .nt i.he { opacity: 1; color: #ff4a5a; font-weight: 600; }
.cell .nt i.he::after { content: ""; position: absolute; left: 50%; top: 50%; width: 1.25em; height: 1px; margin-left: -.625em; background: #ff4a5a; box-shadow: 0 0 3px rgba(255,45,63,.6); }
/* 提示依据格 */
.cell .hb { position: absolute; inset: 1px; pointer-events: none; border-radius: 2px; opacity: 0; box-shadow: inset 0 0 0 1px rgba(255,70,86,.7); background: rgba(226,39,58,.07); transition: opacity .25s ease; }
.cell.basis .hb { opacity: 1; }
.cell.house .hb { opacity: 1; box-shadow: inset 0 0 0 1px rgba(220,226,234,.16); background: rgba(220,226,234,.035); }

/* 行 / 列 / 宫高亮带，与选中框：只动 transform 和 opacity */
.band {
  position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; opacity: 0;
  background: rgba(220,226,234,.12);
  transition: transform .14s var(--ease-out), opacity .2s ease;
}
.band-b { background: rgba(220,226,234,.08); }
.board.has-sel .band { opacity: 1; }
.sel {
  position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 0 1px rgba(230,236,244,.92), 0 0 0 1px rgba(220,226,234,.22);
  border-radius: 2px;
  transition: transform .12s var(--ease-out), opacity .2s ease;
}
.board.has-sel .sel { opacity: 1; }
.sel::before, .sel::after { content: ""; position: absolute; width: 5px; height: 5px; border-color: #e6eaf0; border-style: solid; }
.sel::before { left: -3px; top: -3px; border-width: 1px 0 0 1px; }
.sel::after { right: -3px; bottom: -3px; border-width: 0 1px 1px 0; }
.sel.note { box-shadow: inset 0 0 0 1px rgba(220,226,234,.7), 0 0 0 1px rgba(220,226,234,.14); }
.sel.note::before, .sel.note::after { border-color: #c5ccd5; }

.fx { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.sweep {
  position: absolute; left: 0; top: 0; pointer-events: none; opacity: 0; will-change: transform, opacity;
  background: linear-gradient(90deg, rgba(230,236,244,0), rgba(230,236,244,.32) 40%, rgba(255,70,86,.5) 50%, rgba(230,236,244,.32) 60%, rgba(230,236,244,0));
  mix-blend-mode: screen;
}
.sweep.v { background: linear-gradient(180deg, rgba(230,236,244,0), rgba(230,236,244,.32) 40%, rgba(255,70,86,.5) 50%, rgba(230,236,244,.32) 60%, rgba(230,236,244,0)); }
.hairline { position: absolute; left: 0; top: 0; height: 1px; pointer-events: none; opacity: 0; transform-origin: 0 50%; background: linear-gradient(90deg, var(--crimson), rgba(230,236,244,.8), rgba(230,236,244,0)); box-shadow: 0 0 8px rgba(226,39,58,.45); will-change: transform, opacity; }
.hairline.v { width: 1px; height: auto; transform-origin: 50% 0; background: linear-gradient(180deg, var(--crimson), rgba(230,236,244,.8), rgba(230,236,244,0)); }
.boxring { position: absolute; left: 0; top: 0; pointer-events: none; opacity: 0; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255,70,86,.85), 0 0 16px rgba(226,39,58,.35); will-change: transform, opacity; }
.edgeglow { position: absolute; inset: 0; border-radius: 10px; opacity: 0; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(255,70,86,.6), inset 0 0 44px rgba(226,39,58,.2); }
.scan {
  position: absolute; left: 0; top: 0; width: 100%; height: 1px; z-index: 7; 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;
}

/* 暂停遮罩 / 生成中 */
.veil, .gen {
  position: absolute; inset: 0; z-index: 8; border-radius: 10px;
  display: grid; place-content: center; text-align: center; gap: 8px;
  background: radial-gradient(80% 70% at 50% 50%, #0b0d10, #07080a);
  box-shadow: inset 0 0 0 1px var(--line-2);
  opacity: 0; visibility: hidden; transition: opacity .28s ease, visibility 0s linear .28s;
}
.board.veiled .veil, .board.generating .gen { opacity: 1; visibility: visible; transition: opacity .22s ease; }
.veil .k, .gen .k { margin: 0; font-family: var(--mono); font-size: 11px; letter-spacing: .3em; color: var(--silver-dim); }
.veil .t, .gen .t { margin: 0; font-size: 13px; letter-spacing: .14em; color: #a9b0b9; }
.gen .k::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 10px; border-radius: 50%; background: var(--lamp); box-shadow: 0 0 8px rgba(255,45,63,.8); animation: breathe 1.2s ease-in-out infinite; vertical-align: 1px; }

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

/* ---------- 控制区 ---------- */
.controls { position: relative; display: flex; flex-direction: column; gap: 10px; opacity: 0; animation: fade .9s .45s ease forwards; }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tool {
  appearance: none; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 56px; padding: 6px 4px 5px; border-radius: 8px; border: 0;
  background: rgba(255,255,255,.03); box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--silver); font-size: 12px; letter-spacing: .2em;
  transition: background-color .2s ease, box-shadow .2s ease, color .2s ease, opacity .2s ease, transform .12s ease;
}
.tool span { margin-right: -.2em; }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; color: #c5ccd5; }
.tool:active { transform: translateY(1px); }
.tool .flag {
  position: absolute; right: 7px; top: 6px; font-family: var(--mono); font-size: 9.5px; font-weight: 400; letter-spacing: 0;
  min-width: 16px; padding: 1px 4px; border-radius: 3px; color: var(--silver-dim); box-shadow: inset 0 0 0 1px var(--line-2);
}
.tool[aria-checked="true"] { background: rgba(226,39,58,.12); box-shadow: inset 0 0 0 1px rgba(255,70,86,.75); color: #fff; }
.tool[aria-checked="true"] svg { color: #ff6b78; }
.tool[aria-checked="true"] .flag { color: #f3d6d8; background: #6e121c; box-shadow: none; }
#tHint.spent .flag { color: #4a4f56; }
.tool:disabled { opacity: .32; }

.pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 0; }
.key {
  appearance: none; cursor: pointer; position: relative; border: 0; background: none; padding: 0;
  min-height: 70px; min-width: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: #eef1f5;
}
.key::before {
  content: ""; position: absolute; inset: 0 2px; border-radius: 7px;
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.015));
  box-shadow: inset 0 0 0 1px var(--line-2), inset 0 1px 0 rgba(255,255,255,.05);
  transition: background-color .2s ease, box-shadow .2s ease, opacity .3s ease;
}
.key b { position: relative; font-family: var(--mono); font-weight: 300; font-size: 26px; line-height: 1; transition: opacity .3s ease; }
.key small { position: relative; font-family: var(--mono); font-size: 9px; letter-spacing: .08em; color: var(--mute); transition: opacity .3s ease; }
.key .press { position: absolute; inset: 0 2px; border-radius: 7px; opacity: 0; background: rgba(226,39,58,.18); box-shadow: inset 0 0 0 1px rgba(255,70,86,.7); pointer-events: none; }
.key.cur::before { box-shadow: inset 0 0 0 1px rgba(230,236,244,.75), inset 0 1px 0 rgba(255,255,255,.08); }
.key.done b, .key.done small { opacity: .22; }
.key.done::before { opacity: .45; }
.notes-on .key b { font-size: 19px; color: #c5ccd5; }
.notes-on .key b::after { content: ""; position: absolute; right: -6px; top: -2px; width: 3px; height: 3px; border-radius: 50%; background: #ff6b78; }

/* 提示卡 / 收束条：盖在控制区上，盘面保持可见 */
.hintcard {
  position: absolute; left: 0; right: 0; bottom: 0; top: -22px; z-index: 10;
  display: flex; align-items: stretch;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .22s ease, transform .3s var(--ease-out), visibility 0s linear .3s;
}
.hintcard.on { opacity: 1; visibility: visible; transform: none; transition: opacity .22s ease, transform .3s var(--ease-out); }
.hc-in {
  flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 12px 14px; border-radius: 10px;
  background: #0c0e11; box-shadow: inset 0 0 0 1px rgba(255,70,86,.42), 0 20px 50px -20px #000;
}
.hc-h { display: flex; align-items: center; gap: 10px; }
.hc-titles { flex: 1; min-width: 0; }
.hc-in .k { margin: 0 0 3px; font-family: var(--mono); font-size: 10px; letter-spacing: .28em; color: var(--lamp); white-space: nowrap; }
.hc-in h3 { margin: 0; font-weight: 300; font-size: 15px; letter-spacing: .16em; color: #eef1f5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-text { margin: 0; flex: 1; font-size: 12.5px; line-height: 1.6; color: #a9b0b9; letter-spacing: .03em; overflow: auto; touch-action: pan-y; }
.hc-text b { color: #f1f3f6; font-weight: 500; font-family: var(--mono); }
.hc-acts { display: flex; gap: 8px; flex: 0 0 auto; }
.hc-acts button { padding: 10px 14px; }
.hc-acts button[hidden] { display: none; }
.hintcard.done .hc-in { box-shadow: inset 0 0 0 1px var(--line-2), 0 20px 50px -20px #000; }
.hintcard.done .k { color: var(--silver-dim); }
.hintcard.done h3 { font-family: var(--mono); font-weight: 200; font-size: 30px; letter-spacing: .04em; overflow: visible; }

.hc-acts button, .win-acts button, .coach-acts button {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; 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, transform .15s ease;
}
.hc-acts button:active, .win-acts button:active, .coach-acts button:active { transform: translateY(1px); }
button:disabled { 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.quiet { background: transparent; color: var(--silver-dim); }

.foot { flex: 0 0 auto; font-size: 10px; color: #4b5058; letter-spacing: .05em; line-height: 1.5; text-align: center; }

/* ---------- 收束剧场（通关，无角色） ---------- */
.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-t {
  position: absolute; inset: 0; opacity: 0;
  background:
    radial-gradient(50% 36% at 50% 44%, 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-t { opacity: 1; transition: opacity 1.1s ease; }
.stage { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--safe-t) 24px var(--safe-b); }
.copy { text-align: center; width: min(400px, 100%); }
.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.1s ease, transform 1.4s var(--ease-out); transition-delay: var(--dl, .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; justify-content: 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: 64px; letter-spacing: .06em; color: #f4f6f9; line-height: 1; font-variant-numeric: tabular-nums; }
.copy .rule {
  display: block; height: 1px; margin: 20px auto 18px; width: 100%;
  background: linear-gradient(90deg, rgba(226,39,58,0), var(--crimson), rgba(226,39,58,0));
  transform: scaleX(0); transition: transform .4s ease;
}
.theater.on .copy .rule { transform: scaleX(1); transition: transform 1.6s var(--ease-out) .8s; }
.copy .line { margin: 0 0 8px; font-size: 18px; letter-spacing: .14em; color: #f1f3f6; }
.copy .line.dim { color: #a9b0b9; font-size: 13px; }
.copy .line.dimmer { color: #6a717a; font-size: 11px; letter-spacing: .1em; }
.copy .line b { font-family: var(--mono); font-weight: 400; color: inherit; }
.copy .line.dim b { color: #c5ccd5; }
.copy .line.dimmer b { color: #8b929c; }
.copy .line .rec { color: var(--lamp); font-family: var(--mono); font-size: 11px; letter-spacing: .24em; margin-left: 6px; }
.copy .achl {
  margin-top: 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  font-size: 12px; letter-spacing: .08em; color: var(--silver);
}
.copy .achl[hidden] { display: none; }
.copy .ach-lab { font-family: var(--mono); font-size: 10px; letter-spacing: .2em; color: var(--silver-dim); margin-right: 2px; }
.copy .ach-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px; border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(220,226,234,.38);
  color: #d9dee5; font-size: 12px; letter-spacing: .14em; background: rgba(255,255,255,.025);
}
.copy .ach-pill .dot { width: 5px; height: 5px; box-shadow: 0 0 6px rgba(255,45,63,.6); animation: none; }
.win-acts { display: flex; gap: 10px; margin-top: 26px; justify-content: center; }
.win-acts button { min-width: 112px; }
.win-acts button.primary {
  box-shadow: inset 0 0 0 1px rgba(230,236,244,.78);
  color: #f4f6f9; background: rgba(220,226,234,.12);
}
.win-acts button.primary:hover { background: rgba(220,226,234,.18); box-shadow: inset 0 0 0 1px rgba(230,236,244,.95); }
.win-acts #winView { box-shadow: inset 0 0 0 1px var(--line-2); color: var(--silver-dim); background: transparent; }

/* ---------- 竖屏提示 ---------- */
.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);
  text-align: center;
}
body.need-portrait .rotate-hint { display: flex; }
.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-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; color: var(--silver); border-radius: 10px;
  box-shadow: inset 0 0 0 1px var(--line-2), 0 30px 80px -30px rgba(0,0,0,.9);
}
.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%; min-height: 44px;
  padding: 12px 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); }
.sheet-h h2 { margin: 0; font-weight: 300; font-size: 16px; letter-spacing: .2em; }
.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: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;
  user-select: text; -webkit-user-select: text;
}
.sheet-body h3 { margin: 18px 0 8px; font-size: 11px; letter-spacing: .28em; color: var(--silver-dim); font-weight: 400; }
.sheet-body h3:first-child { margin-top: 2px; }
.sheet-body .note { margin: 12px 0 0; font-size: 12px; color: var(--mute); letter-spacing: .06em; line-height: 1.65; }

/* 新局：难度选择 */
.diff-list { display: grid; gap: 8px; }
.diff {
  appearance: none; cursor: pointer; width: 100%; text-align: left; border: 0;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px;
  min-height: 56px; padding: 10px 14px; border-radius: 8px;
  background: rgba(255,255,255,.025); box-shadow: inset 0 0 0 1px var(--line); color: var(--silver);
  transition: background-color .2s ease, box-shadow .2s ease;
}
.diff:hover, .diff:focus-visible { background: rgba(255,255,255,.055); box-shadow: inset 0 0 0 1px rgba(220,226,234,.28); outline: none; }
.diff .dn { font-size: 15px; letter-spacing: .24em; color: #eef1f5; }
.diff .dn em { font-style: normal; font-family: var(--mono); font-size: 10px; letter-spacing: .26em; color: var(--silver-dim); margin-left: 10px; }
.diff .dd { grid-column: 1; font-size: 11.5px; color: #7e858e; letter-spacing: .06em; }
.diff .db { grid-column: 2; grid-row: 1 / span 2; text-align: right; font-family: var(--mono); font-size: 11px; color: var(--silver-dim); letter-spacing: .08em; line-height: 1.5; }
.diff .db b { display: block; font-weight: 400; font-size: 15px; color: #f1f3f6; }
.diff.daily { box-shadow: inset 0 0 0 1px rgba(255,70,86,.45); background: rgba(226,39,58,.06); }
.diff.daily .dn em { color: var(--lamp); }
.diff.cur .dn::after { content: "当前"; margin-left: 10px; font-size: 10px; letter-spacing: .2em; color: var(--lamp); font-family: var(--sans); }
.warn { margin: 10px 0 0; font-size: 12px; color: #b98990; letter-spacing: .05em; }

/* 统计 */
.stat-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.stat-table th { font-weight: 400; font-size: 10px; letter-spacing: .22em; color: var(--silver-dim); text-align: right; padding: 0 0 6px; }
.stat-table th:first-child, .stat-table td:first-child { text-align: left; }
.stat-table td { padding: 9px 0; border-top: 1px solid var(--line); text-align: right; font-family: var(--mono); color: var(--silver); }
.stat-table td:first-child { font-family: var(--sans); letter-spacing: .2em; }
.sheet-body .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 4px; }
.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 { position: relative; 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(220,226,234,.32); background: #16181c; }
.ach-list li.on::before {
  content: ""; position: absolute; left: 0; top: 14px; width: 1px; height: 16px;
  background: var(--crimson); box-shadow: 0 0 6px rgba(226,39,58,.35);
}
.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: #8b929c; }
.ach-list li.off .st { color: #4a4f56; }

/* 设置开关 */
.set-row {
  appearance: none; display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; 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; display: grid; gap: 1px; }
.set-row .nm small { font-size: 11px; letter-spacing: .04em; color: var(--mute); }
.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); transition: background-color .2s ease; }
.set-row.on .switch { background: #9ea6b0; box-shadow: inset 0 0 0 1px rgba(220,226,234,.28), inset 0 1px 0 rgba(255,255,255,.22); }
.set-row.on .switch::before {
  content: ""; position: absolute; left: -11px; top: 50%; width: 4px; height: 4px; margin-top: -2px;
  border-radius: 50%; background: var(--lamp); box-shadow: 0 0 6px rgba(255,45,63,.55);
}
.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, box-shadow .2s ease; }
.set-row.on .switch .knob { transform: translateX(28px); background: #f4f6f9; box-shadow: 0 1px 2px rgba(0,0,0,.28); }
.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: #1c1e22; }
.set-row.na { cursor: default; opacity: .4; pointer-events: none; }
.set-row.na .switch::before { display: none; }

/* 规则 */
.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; }
.tech-list { display: grid; gap: 6px; margin: 0; }
.tech-list > div { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.tech-list dt { font-family: var(--mono); font-size: 10px; letter-spacing: .2em; color: var(--lamp); padding-top: 3px; }
.tech-list dd { margin: 0; font-size: 12.5px; }
.tech-list dd b { color: var(--silver); font-weight: 500; }
html.touch-coarse .sheet-body .howto-keys { display: none; }
@media (pointer: coarse) { .sheet-body .howto-keys { display: none; } }

.toast {
  position: fixed; left: 16px; right: 16px; top: 0; max-width: 420px; margin: 0 auto;
  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; text-overflow: ellipsis; }
.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; inset: 0; z-index: 9; display: none; place-items: center;
  border-radius: 10px; background: radial-gradient(70% 70% at 50% 50%, rgba(7,8,10,.42), rgba(7,8,10,.7));
}
.coach.on { display: grid; }
.coach-card {
  width: min(300px, calc(100% - 32px)); padding: 16px 16px 12px; text-align: center;
  background: rgba(8,10,13,.92); border-radius: 10px;
  box-shadow: inset 0 0 0 1px var(--line-2), 0 12px 28px -16px #000;
}
.coach-demo { width: 96px; height: 72px; margin: 2px auto 8px; color: rgba(220,226,234,.75); }
.coach-demo svg { display: block; width: 100%; height: 100%; overflow: visible; }
.coach-demo .tapdot { transform-box: fill-box; transform-origin: center; animation: tap 1.8s var(--ease-out) infinite; }
@keyframes tap { 0%, 100% { opacity: .35; transform: scale(1); } 30% { opacity: 1; transform: scale(.72); } 60% { opacity: .55; transform: scale(1); } }
.coach-demo .tapring { transform-box: fill-box; transform-origin: center; animation: tapring 1.8s ease-out infinite; }
@keyframes tapring { 0%, 25% { opacity: 0; transform: scale(.6); } 35% { opacity: .8; } 80%, 100% { opacity: 0; transform: scale(1.7); } }
.coach-k { margin: 0 0 6px; font-family: var(--mono); font-size: 10px; letter-spacing: .3em; color: var(--silver-dim); }
.coach p#coachText { margin: 0; font-size: 13px; letter-spacing: .1em; color: #e6e9ee; line-height: 1.65; }
.coach-acts { display: flex; justify-content: space-between; margin-top: 12px; gap: 8px; }
.coach-acts button { padding: 10px 14px; }

@media (prefers-reduced-motion: reduce) {
  .lamp, .copy .dot, .coach-demo .tapdot, .coach-demo .tapring, .gen .k::before { animation: none; }
  .title span, .hair, .fullname, .board, .hud, .controls { animation: none !important; opacity: 1; transform: none; }
  .band, .sel { transition: opacity .1s ease; }
}
/* 矮屏：收起说明与读数 */
@media (max-height: 720px) { .foot { display: none; } .readout { display: none; } .key { min-height: 56px; } }
@media (max-height: 640px) { .tool { min-height: 46px; } .tool svg { display: none; } }

/* review1 follow-up: done-board 「新局」 matches win primary (silver, no red) */
.hintcard.done #hcApply.primary { background: rgba(220,226,234,.1); box-shadow: inset 0 0 0 1px rgba(230,236,244,.8); color: #fff; }
.hintcard.done #hcApply.primary:hover { background: rgba(220,226,234,.18); box-shadow: inset 0 0 0 1px rgba(230,236,244,.95); }
