/* 差一筹 — system fonts only; the rods and the board are drawn by CSS, no images. */
:root {
  --bg: #0b0e13;
  --ink: #e6edf3;
  --dim: #8b949e;
  --rule: #1c232d;
  --accent: #ff6b6b;
  --bamboo: #e9d6ab;
  --gold: #f2c86b;
  --line: rgba(233, 206, 160, .12);
  --miss: #c2453d;
  --hit: #3f9e5d;
  --sans: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --mono: ui-monospace, "DejaVu Sans Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  min-height: 100%;
  background: radial-gradient(70rem 30rem at 50% 0, rgba(233, 206, 160, .06), transparent 70%) no-repeat, var(--bg);
}
body {
  margin: 0 auto;
  max-width: 34rem;
  padding: 0 1rem calc(2rem + env(safe-area-inset-bottom));
  color: var(--ink);
  font: 17px/1.7 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--ink); text-decoration: none; border-bottom: 1px solid #3a4553; }
a:hover { color: var(--accent); border-bottom-color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--dim); }
.small { font-size: .82rem; }
button {
  font: inherit; color: #1a0f0f; background: var(--accent); border: 0; border-radius: .6rem;
  padding: .55rem 1.2rem; cursor: pointer; font-weight: 600;
}
button:focus-visible, a:focus-visible, .rod:focus-visible, .cell:focus-visible, summary:focus-visible { outline: 2px solid var(--bamboo); outline-offset: 2px; }
.ghostbtn { background: transparent; color: var(--ink); border: 1px solid #2f3a46; font-weight: 500; padding: .4rem .95rem; font-size: .9rem; }
.ghostbtn:hover { border-color: var(--bamboo); }

/* top bar */
.bar { display: flex; align-items: baseline; gap: .35rem; padding: 1rem 0 .6rem; border-bottom: 1px solid var(--rule); font-size: .95rem; }
.bar .home { font: 700 1.05rem var(--mono); border: 0; }
.bar .here { border: 0; font-weight: 600; }
.bar .sep { color: var(--dim); }
.bar nav { margin-left: auto; display: flex; gap: .9rem; font-size: .88rem; }
.bar nav a { border: 0; color: var(--dim); }
.bar nav a:hover { color: var(--accent); }

.meta { display: flex; justify-content: space-between; align-items: center; color: var(--dim); font-size: .85rem; margin: .7rem 0 .2rem; font-family: var(--mono); }
.lv { font: 600 .74rem var(--sans); padding: .05rem .5rem; border-radius: 1rem; border: 1px solid; }
.lv0 { color: #8fd3a5; border-color: rgba(143, 211, 165, .35); }
.lv1 { color: #e9c46a; border-color: rgba(233, 196, 106, .35); }
.lv2 { color: #ff8a80; border-color: rgba(255, 138, 128, .4); }
.task { margin: .1rem 0 .7rem; font-size: .95rem; color: #c9d1d9; }

.modebar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .8rem; margin: .4rem 0 .5rem; font-size: .88rem; }
.seg { display: inline-flex; border: 1px solid #2f3a46; border-radius: .6rem; overflow: hidden; }
.seg button { background: transparent; color: var(--dim); border-radius: 0; padding: .3rem .85rem; font-weight: 500; font-size: .9rem; }
.seg button.on { background: #1d2530; color: var(--ink); }
.modebar .back { margin-left: auto; font-size: .82rem; color: var(--dim); border: 0; }

/* the counting board */
.board { display: flex; justify-content: center; margin: 0 auto; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.stage {
  position: relative; border-radius: 16px; overflow: visible;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 220, 170, .08), transparent 62%),
    repeating-linear-gradient(91deg, rgba(255, 235, 200, .022) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(89deg, rgba(0, 0, 0, .10) 0 1px, transparent 1px 23px),
    linear-gradient(180deg, #261b13, #18110c 70%, #140e0a);
  box-shadow: inset 0 0 0 1px rgba(233, 206, 160, .12), inset 0 2px 0 rgba(255, 255, 255, .035), inset 0 -18px 40px rgba(0, 0, 0, .35), 0 18px 44px rgba(0, 0, 0, .5);
}
.cell {
  position: absolute; border-radius: 9px;
  border: 1px solid var(--line);
  background: radial-gradient(90% 80% at 50% 40%, rgba(255, 230, 190, .035), transparent 70%);
  transition: border-color .25s, background-color .25s;
}
.cell.opcell { border-color: transparent; background: none; }
.cell.mark { border-color: rgba(242, 200, 107, .6); background-color: rgba(242, 200, 107, .07); }
.head { position: absolute; transform: translate(-50%, -50%); font-size: .72rem; letter-spacing: .12em; color: rgba(233, 206, 160, .5); }
.rv { position: absolute; display: none; font: 600 .74rem/1.5 var(--mono); color: rgba(240, 220, 180, .9);
  background: rgba(20, 14, 10, .82); padding: 0 .35rem; border-radius: .3rem; pointer-events: none; z-index: 2; }
.stage.reading .rv { display: block; }

.rod {
  position: absolute; left: 0; top: 0; z-index: 1; cursor: pointer; border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(122, 84, 40, .38) 0, transparent 7%, transparent 93%, rgba(122, 84, 40, .38) 100%),
    linear-gradient(90deg, transparent 31%, rgba(130, 92, 46, .22) 32%, rgba(255, 245, 225, .25) 33.5%, transparent 34.5%),
    linear-gradient(180deg, #fbf2dc 0%, #ecdab2 34%, #d5b886 78%, #b99a68 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), inset 0 -1px 0 rgba(90, 60, 25, .4), 0 1px 1px rgba(0, 0, 0, .7), 0 3px 7px rgba(0, 0, 0, .38);
  transition: transform .4s cubic-bezier(.22, .9, .3, 1), box-shadow .25s, filter .25s, opacity .25s;
  will-change: transform;
}
.rod::before { content: ""; position: absolute; inset: -10px -3px; }
.rod.up { z-index: 4; filter: brightness(1.07); box-shadow: 0 0 0 2px rgba(255, 198, 120, .8), 0 0 18px rgba(255, 190, 110, .35), 0 14px 24px rgba(0, 0, 0, .6); }
.board.holding .rod:not(.up) { opacity: .78; }
.rod.hinted { animation: hinted 1.2s ease-in-out infinite alternate; }
.rod.nope { animation: nope .42s ease; }
@keyframes hinted { from { box-shadow: 0 0 0 2px rgba(255, 198, 120, .55), 0 0 6px rgba(255, 190, 110, .3); filter: brightness(1); } to { box-shadow: 0 0 0 4px rgba(255, 206, 130, 1), 0 0 22px rgba(255, 190, 110, .8); filter: brightness(1.15); } }
@keyframes nope { 0%, 100% { translate: 0 0; } 20% { translate: -4px 0; } 45% { translate: 4px 0; } 70% { translate: -2px 0; } }
.cell.can { border: 1.5px dashed rgba(255, 206, 135, .9); background-color: rgba(255, 190, 110, .09); cursor: pointer; animation: canpulse 1.1s ease-in-out infinite alternate; }
@keyframes canpulse { from { box-shadow: 0 0 0 0 rgba(255, 190, 110, 0); } to { box-shadow: 0 0 14px rgba(255, 190, 110, .28), inset 0 0 12px rgba(255, 190, 110, .12); } }
.choice {
  position: absolute; z-index: 8; display: flex; gap: .4rem; padding: .4rem; transform: translate(-50%, calc(-100% - 6px));
  background: #1d1611; border: 1px solid rgba(233, 206, 160, .4); border-radius: .8rem; box-shadow: 0 12px 30px rgba(0, 0, 0, .65);
}
.choice.below { transform: translate(-50%, 6px); }
.choice .opt { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .3rem .45rem .2rem; background: #261c14; border: 1px solid #3d2f23; border-radius: .55rem; color: var(--ink); font-weight: 500; }
.choice .opt:hover, .choice .opt:focus-visible { border-color: var(--gold); }
.choice .opt svg { width: 2.7rem; height: auto; display: block; }
.choice .opt rect { fill: var(--bamboo); }
.choice .opt span { font: 600 .8rem var(--mono); color: var(--bamboo); }
.board.shake .stage { animation: shake .45s ease; }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.board.won .rod {
  cursor: default;
  background:
    linear-gradient(90deg, rgba(150, 100, 30, .35) 0, transparent 7%, transparent 93%, rgba(150, 100, 30, .35) 100%),
    linear-gradient(180deg, #fff2c8 0%, #f6d27f 45%, #d9a842 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 0 12px rgba(255, 200, 90, .35), 0 3px 7px rgba(0, 0, 0, .4);
}
.board.won .stage { box-shadow: inset 0 0 0 1px rgba(242, 200, 107, .35), inset 0 -18px 40px rgba(0, 0, 0, .35), 0 0 40px rgba(242, 200, 107, .12), 0 18px 44px rgba(0, 0, 0, .5); }
.seal {
  position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; display: grid; place-items: center;
  font: 700 26px/1 var(--serif); color: #fff1e4; background: #b3322a; border-radius: 7px;
  box-shadow: inset 0 0 0 2.5px rgba(255, 228, 210, .55), inset 0 0 0 5px #b3322a, inset 0 0 0 6px rgba(255, 228, 210, .3), 0 4px 12px rgba(0, 0, 0, .45);
  opacity: 0; transform: scale(1.8) rotate(-12deg); transition: opacity .3s ease .25s, transform .45s cubic-bezier(.2, 1.5, .4, 1) .25s; pointer-events: none; z-index: 5;
}
.board.won .seal { opacity: .94; transform: scale(1) rotate(-8deg); }

.msg { min-height: 1.6em; text-align: center; margin: .6rem 0 .1rem; font-size: .9rem; color: var(--dim); }
.msg.warn { color: #ff9c8f; }
.msg.ok { color: var(--gold); font-weight: 600; }
.tools { display: flex; align-items: center; gap: .9rem; margin: .5rem 0 0; }
.triesbox { display: flex; align-items: center; gap: .5rem; margin-right: auto; min-height: 1.5rem; }
.tries { display: flex; gap: .25rem; }
.tries .t { width: .8rem; height: .8rem; border-radius: .2rem; }
.tries .miss { background: var(--miss); }
.tries .hit { background: var(--hit); }
label.read { display: inline-flex; align-items: center; gap: .3rem; color: var(--dim); cursor: pointer; }
label.read input { accent-color: var(--gold); }
#hint.nudge { border-color: var(--gold); color: var(--gold); }

/* the key */
.key { margin: 1.1rem 0 0; border: 1px solid var(--rule); border-radius: .8rem; padding: .2rem .9rem .5rem; background: #0f141b; }
.key summary { cursor: pointer; color: var(--dim); font-size: .88rem; padding: .45rem 0; }
.krow { margin: .2rem 0 .5rem; }
.kcap { margin: .2rem 0; font-size: .78rem; color: var(--dim); }
.kd { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(9, 1fr); gap: .25rem; }
.kd li { display: flex; flex-direction: column; align-items: center; background: #19130e; border: 1px solid #2a2119; border-radius: .4rem; padding: .25rem 0 .1rem; }
.kd svg { width: 100%; max-width: 2.3rem; height: auto; aspect-ratio: 84 / 112; }
.kd rect { fill: var(--bamboo); }
.kd span { font: .7rem var(--mono); color: var(--dim); }
.kfoot { font-size: .8rem; color: var(--dim); margin: .4rem 0 0; }

/* finished */
.result { text-align: center; font-size: 1.15rem; font-weight: 600; margin: 1.1rem 0 .4rem; }
.eqs { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: .3rem .7rem; margin: .3rem 0; font: 600 1rem var(--mono); }
.eq.no { color: #ff9c8f; text-decoration: line-through; text-decoration-thickness: 1px; opacity: .85; }
.eq.yes { color: #8fd3a5; }
.arrow { color: var(--dim); }
.movetext { text-align: center; color: var(--dim); font-size: .86rem; margin: .2rem 0 1rem; }
.note { border: 1px solid #2c2318; background: linear-gradient(180deg, #17120d, #120e0b); border-radius: .9rem; padding: .9rem 1.1rem .7rem; margin: 0 0 1.1rem; }
.note .nk { margin: 0; font-size: .74rem; letter-spacing: .14em; color: rgba(233, 206, 160, .6); }
.note h2 { margin: .1rem 0 .4rem; font: 700 1.2rem var(--serif); color: #f3e3c3; }
.note p { margin: .3rem 0; line-height: 1.85; font-size: .96rem; }
.note blockquote { margin: .7rem 0 .4rem; padding: .1rem 0 .1rem .8rem; border-left: 2px solid rgba(233, 206, 160, .4); font: 1rem/1.8 var(--serif); color: #e8dcc2; }
.note .cite { font-size: .78rem; color: var(--dim); }
.note .cite a { color: var(--dim); }
.sharebox { background: #10151c; border: 1px solid var(--rule); border-radius: .8rem; padding: .8rem 1rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem .8rem; }
.sharebox pre { flex: 1 1 13.5rem; margin: 0; font: .95rem/1.5 var(--sans); white-space: pre-wrap; }
.daynav { display: flex; justify-content: center; flex-wrap: wrap; gap: .6rem 1.4rem; margin: 1.2rem 0; font-size: .92rem; }
.daynav .go { color: var(--gold); border-bottom-color: rgba(242, 200, 107, .4); }
.statsbox .nums { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; margin: .6rem 0; }
.statsbox .num b { display: block; font-size: 1.4rem; }
.statsbox .num span { font-size: .75rem; color: var(--dim); }
.dist { list-style: none; padding: 0; margin: .4rem 0; }
.dist li { display: flex; align-items: center; gap: .5rem; margin: .2rem 0; font-size: .8rem; }
.dist .k { width: 1.4rem; color: var(--dim); text-align: right; }
.dist .bar { background: #2a323d; border-radius: .25rem; padding: 0 .4rem; text-align: right; min-width: 1.4rem; display: block; border: 0; font-size: .8rem; }

/* archive */
#archive h1 { font-size: 1.2rem; margin: 1.2rem 0 .6rem; }
.archivelist { list-style: none; padding: 0; margin: 0; }
.archivelist a { display: flex; align-items: center; gap: .9rem; padding: .55rem .2rem; border-bottom: 1px solid var(--rule); }
.archivelist .an { font-family: var(--mono); width: 2.8rem; }
.archivelist .ad { flex: 1; color: var(--dim); }
.archivelist .ar { color: var(--dim); font-size: .85rem; min-width: 4.5rem; text-align: right; }

.fail { text-align: center; margin: 2.4rem 0; color: var(--dim); }

dialog {
  max-width: min(28rem, 92vw); max-height: 86vh; overflow-y: auto; background: #121820; color: var(--ink); border: 1px solid #2c3540; border-radius: 1rem;
  padding: 1.2rem 1.4rem; font-size: .96rem;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 .6rem; font-size: 1.1rem; }
dialog h3 { margin: 1rem 0 .3rem; font-size: .98rem; color: var(--bamboo); }
dialog p { margin: .5rem 0; }
dialog blockquote { margin: .5rem 0; padding-left: .8rem; border-left: 2px solid rgba(233, 206, 160, .4); font-family: var(--serif); color: #e8dcc2; }
dialog blockquote span { display: block; font: .76rem var(--sans); color: var(--dim); }
dialog button { margin-top: .6rem; }
.hkey { display: flex; justify-content: space-between; gap: .4rem; margin: .8rem 0 .4rem; }
.hk { display: flex; flex-direction: column; align-items: center; gap: .15rem; flex: 1; }
.hk svg { width: 100%; max-width: 4.6rem; height: auto; background: linear-gradient(180deg, #241a13, #17110c); border-radius: .45rem; }
.hk rect { fill: var(--bamboo); }
.hk rect.kc { fill: none; stroke: rgba(233, 206, 160, .14); stroke-width: 1.5; }
.hk b { font: 600 .85rem var(--mono); color: var(--bamboo); }

.foot { margin-top: 2.4rem; padding-top: 1rem; border-top: 1px solid var(--rule); text-align: center; font-size: .82rem; color: var(--dim); }
.foot a { color: var(--dim); }

/* credits page */
.page { max-width: 44rem; }
.credits h1 { font-size: 1.4rem; margin: 1.4rem 0 .4rem; }
.credits h2 { font-size: 1.05rem; margin: 1.8rem 0 .4rem; color: var(--accent); }
.credits p, .credits li { color: #c9d1d9; font-size: .95rem; }
.credits .refs li { margin: .45rem 0; }
.credits .refs .lic { color: var(--dim); font-size: .82rem; }

@media (prefers-reduced-motion: reduce) {
  .rod, .seal, .cell { transition: none; }
  .cell.can, .rod.hinted { animation: none; }
  .board.shake .stage { animation: none; }
}
@media (max-width: 22rem) {
  body { font-size: 16px; }
  .bar nav { gap: .6rem; }
}
