/* 江湖棋谱 · 夜墨山水 visual system
   Night-ink ground, brass mounting lines, cinnabar lacquer for the one action that matters. */
:root {
  color-scheme: dark;
  --night: oklch(0.165 0.016 168);
  --night-0: oklch(0.13 0.014 168);
  --night-2: oklch(0.205 0.019 168);
  --night-3: oklch(0.25 0.021 168);
  --night-4: oklch(0.30 0.023 168);
  --ivory: oklch(0.95 0.018 88);
  --mist: oklch(0.82 0.022 115);
  --mist-2: oklch(0.70 0.02 125);
  --brass: oklch(0.83 0.095 80);
  --brass-2: oklch(0.68 0.08 78);
  --brass-line: oklch(0.83 0.095 80 / 0.26);
  --brass-faint: oklch(0.83 0.095 80 / 0.11);
  --cinnabar: oklch(0.51 0.175 30);
  --cinnabar-hi: oklch(0.57 0.185 31);
  --cinnabar-lo: oklch(0.41 0.145 28);
  --jade: oklch(0.83 0.12 165);
  --amber: oklch(0.86 0.12 80);
  --wood: oklch(0.86 0.06 75);
  --display: 'Noto Serif CJK SC', 'Source Han Serif SC', 'Source Han Serif CN', 'Songti SC', 'STSong', 'SimSun', serif;
  --sans: system-ui, -apple-system, 'PingFang SC', 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --z-banner: 20;
  --z-sticky: 30;
  --z-pact: 40;
  font-family: var(--sans);
  color: var(--ivory);
  background: var(--night);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, p, figure, ol, fieldset { margin: 0; }
body { min-height: 100vh; min-height: 100svh; line-height: 1.65; background: radial-gradient(120% 60% at 50% 0%, var(--night-2), var(--night) 60%) fixed; }
h1, h2, legend, summary, .brand-name { font-family: var(--display); text-wrap: balance; }
h1, h2 { line-height: 1.3; font-weight: 700; }
.shell { width: min(calc(100% - 48px), 1160px); margin-inline: auto; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }

/* ───────── Top bar ───────── */
.topbar { position: relative; z-index: var(--z-sticky); background: var(--night-0); padding-top: env(safe-area-inset-top); border-bottom: 3px double var(--brass-line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font-size: 1.2rem; font-weight: 700; letter-spacing: .18em; }
.brand-mark { display: grid; place-content: center; width: 32px; height: 32px; font: 700 .72rem/1.05 var(--display); writing-mode: vertical-rl; letter-spacing: .05em; color: var(--ivory); background: var(--cinnabar); border-radius: 3px; box-shadow: inset 0 0 0 2px var(--cinnabar), inset 0 0 0 3px oklch(0.95 0.018 88 / .55); transform: rotate(-3deg); }
.camera-state { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border: 1px solid var(--brass-line); border-radius: 999px; color: var(--mist); font-size: .84rem; white-space: nowrap; }
.camera-state::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--mist-2); }
.camera-state.live { color: var(--ivory); border-color: oklch(0.83 0.12 165 / .45); }
.camera-state.live::before { background: var(--jade); animation: breathe 2.4s ease-in-out infinite; }

/* ───────── Buttons ───────── */
button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 1px solid var(--brass-line); border-radius: 4px; background: var(--night-3); color: var(--ivory); font: 600 .95rem/1.2 var(--sans); letter-spacing: .06em; cursor: pointer; box-shadow: inset 0 1px 0 oklch(1 0 0 / .05); transition: background-color .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease), transform .12s var(--ease); touch-action: manipulation; }
button:enabled:active { transform: translateY(1px) scale(.985); background: var(--night-2); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { border-color: var(--cinnabar-lo); background: var(--cinnabar); font-family: var(--display); font-weight: 700; letter-spacing: .2em; padding-inline: 22px; }
button.primary::before { content: ''; position: absolute; inset: 3px; border: 1px solid oklch(0.88 0.08 80 / .5); border-radius: 2px; pointer-events: none; }
button.primary:enabled:active { background: var(--cinnabar-lo); }
button.ghost { background: transparent; border-color: transparent; color: var(--mist); box-shadow: none; }
@media (hover: hover) {
  button:enabled:hover { background: var(--night-4); border-color: var(--brass-2); }
  button.primary:enabled:hover { background: var(--cinnabar-hi); border-color: var(--cinnabar); }
  button.ghost:enabled:hover { background: var(--brass-faint); border-color: var(--brass-line); color: var(--ivory); }
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }

/* ───────── Notices ───────── */
.notice { margin-top: 14px; padding: 10px 14px; border: 1px solid oklch(0.86 0.12 80 / .4); border-radius: 4px; background: oklch(0.86 0.12 80 / .08); color: oklch(0.92 0.07 85); font-size: .92rem; line-height: 1.55; animation: notice-in .32s var(--ease); }
.notice:empty { display: none; }

/* ───────── Welcome / title screen ───────── */
.hero { position: relative; isolation: isolate; overflow: hidden; border-bottom: 1px solid var(--brass-line); }
.landscape { position: absolute; inset: 0; z-index: -1; background: url('./spring-landscape.webp') 70% center / cover no-repeat; filter: sepia(.3) saturate(.85) brightness(.74) contrast(1.06); }
.landscape::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, var(--night) 6%, oklch(0.165 0.016 168 / .8) 40%, oklch(0.165 0.016 168 / .12) 70%, oklch(0.165 0.016 168 / .4)), linear-gradient(0deg, var(--night), transparent 30%), linear-gradient(180deg, oklch(0.13 0.014 168 / .6), transparent 22%); }
.hero-inner { display: flex; align-items: center; justify-content: space-between; gap: 32px; min-height: clamp(500px, 74svh, 720px); padding-block: 56px 72px; }
.invitation { max-width: 34rem; }
.invitation > * { animation: rise .8s var(--ease) both; }
.invitation > :nth-child(2) { animation-delay: .18s; }
.invitation > :nth-child(3) { animation-delay: .28s; }
.invitation > :nth-child(4) { animation-delay: .36s; }
.invitation h1 { position: relative; display: inline-flex; align-items: flex-start; gap: 14px; font-size: clamp(2.9rem, 7.2vw, 5.4rem); font-weight: 900; letter-spacing: .08em; line-height: 1.12; }
.title-text { animation: ink-in 1.1s var(--ease) both; }
.title-seal { flex: none; display: grid; place-content: center; margin-top: .55em; width: 1.6em; height: 2.7em; font-size: clamp(.95rem, 1.6vw, 1.2rem); line-height: 1; writing-mode: vertical-rl; letter-spacing: .12em; color: var(--ivory); background: var(--cinnabar); border-radius: 4px; box-shadow: inset 0 0 0 3px var(--cinnabar), inset 0 0 0 4px oklch(0.95 0.018 88 / .6); transform: rotate(-6deg); animation: stamp .5s .75s var(--ease) both; }
.lead { margin-top: 20px; max-width: 30em; color: var(--mist); font-size: 1.06rem; line-height: 1.8; }
.entry-action { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 34px; }
.hero-button { min-height: 58px; min-width: 15rem; justify-content: space-between; gap: 40px; padding-inline: 28px 22px; font-size: 1.22rem; letter-spacing: .32em; }
.move-mark { width: 26px; height: 2px; background: currentColor; position: relative; transition: transform .25s var(--ease); }
.move-mark::after { content: ''; position: absolute; right: -1px; top: -4px; width: 9px; height: 9px; border: solid currentColor; border-width: 2px 2px 0 0; transform: rotate(45deg); }
@media (hover: hover) { .hero-button:enabled:hover .move-mark { transform: translateX(5px); } }
.hero-button[aria-busy='true'] .move-mark { width: 20px; height: 20px; background: none; border: 2px solid oklch(0.95 0.018 88 / .35); border-top-color: var(--ivory); border-radius: 50%; animation: spin .9s linear infinite; }
.hero-button[aria-busy='true'] .move-mark::after { display: none; }
.switch { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; margin-top: 18px; color: var(--mist); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch-track { position: relative; flex: none; width: 46px; height: 26px; border-radius: 999px; background: var(--night-4); border: 1px solid var(--brass-line); transition: background-color .2s var(--ease); }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--mist-2); transition: transform .25s var(--ease), background-color .2s var(--ease); }
.switch input:checked + .switch-track { background: var(--cinnabar); border-color: var(--cinnabar-lo); }
.switch input:checked + .switch-track::after { transform: translateX(20px); background: var(--ivory); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brass); outline-offset: 3px; }
.couplet { display: flex; gap: 22px; flex: none; margin-right: 2%; font: 600 clamp(1.1rem, 1.8vw, 1.45rem) var(--display); color: var(--brass); writing-mode: vertical-rl; letter-spacing: .5em; opacity: .9; animation: fade 1.6s .5s var(--ease) both; }
.couplet span:last-child { margin-top: 3.2em; }

.rite { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 28px 56px; align-items: center; padding-block: 56px max(48px, env(safe-area-inset-bottom)); }
.rite h2 { font-size: 1.7rem; letter-spacing: .14em; }
.rite-steps { display: grid; gap: 22px; margin-top: 24px; padding: 0; list-style: none; }
.rite-steps li { display: grid; grid-template-columns: 52px 1fr; gap: 18px; align-items: start; }
.rite-no { display: grid; place-content: center; width: 52px; height: 52px; font: 700 1.35rem var(--display); color: var(--brass); border: 1px solid var(--brass-line); border-radius: 50%; box-shadow: inset 0 0 0 4px var(--night), inset 0 0 0 5px var(--brass-faint); }
.rite-steps strong { font: 700 1.15rem var(--display); letter-spacing: .12em; }
.rite-steps p { margin-top: 2px; color: var(--mist); max-width: 34em; }
.guide { padding: 22px 22px 16px; background: var(--night-2); border: 1px solid var(--brass-line); border-radius: 6px; box-shadow: inset 0 0 0 5px var(--night-2), inset 0 0 0 6px var(--brass-faint); }
.board-guide { display: block; width: 100%; height: auto; }
.diagram-wood { fill: oklch(0.83 0.095 80 / .06); stroke: var(--brass-line); }
.diagram-lines { stroke: var(--brass-2); stroke-width: 1.3; }
.diagram-sides, .diagram-river { fill: var(--mist); font: 13px var(--display); }
.diagram-pins { fill: var(--cinnabar); stroke: var(--ivory); stroke-width: 1.5; }
.diagram-digits { fill: var(--ivory); font: 700 14px var(--sans); }
.guide figcaption { margin-top: 10px; text-align: center; color: var(--mist-2); font-size: .86rem; }
.privacy { grid-column: 1 / -1; padding-top: 20px; border-top: 1px solid var(--brass-faint); color: var(--mist-2); font-size: .82rem; line-height: 1.6; max-width: 52em; }

/* ───────── Workspace HUD ───────── */
.workspace { padding-block: 14px max(32px, env(safe-area-inset-bottom)); animation: fade .45s var(--ease); }
.hud-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.hud-head h1 { display: flex; align-items: center; gap: 12px; font-size: 1.3rem; letter-spacing: .16em; }
.hud-head h1::before { content: ''; width: 9px; height: 9px; background: var(--cinnabar); transform: rotate(45deg); }
.hud-head .ghost { min-height: 40px; padding-inline: 12px; font-weight: 500; }
.table { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: 16px; align-items: start; }
.col { display: grid; gap: 16px; min-width: 0; }
.panel { position: relative; min-width: 0; padding: 20px; background: var(--night-2); border: 1px solid var(--brass-line); border-radius: 6px; }
.panel::before { content: ''; position: absolute; inset: 4px; border: 1px solid var(--brass-faint); border-radius: 3px; pointer-events: none; }
.panel-tag, .quest-head { color: var(--brass); font-size: .84rem; letter-spacing: .14em; }
.hint { margin-top: 8px; color: var(--mist); font-size: .94rem; }

/* Stage */
.stage { position: relative; display: grid; place-items: center; padding: 10px; background: var(--night-0); border: 1px solid var(--brass-line); border-radius: 6px; }
.stage::after { content: ''; position: absolute; inset: 5px; pointer-events: none; --c: var(--brass); background:
  linear-gradient(var(--c), var(--c)) top left / 24px 2px, linear-gradient(var(--c), var(--c)) top left / 2px 24px,
  linear-gradient(var(--c), var(--c)) top right / 24px 2px, linear-gradient(var(--c), var(--c)) top right / 2px 24px,
  linear-gradient(var(--c), var(--c)) bottom left / 24px 2px, linear-gradient(var(--c), var(--c)) bottom left / 2px 24px,
  linear-gradient(var(--c), var(--c)) bottom right / 24px 2px, linear-gradient(var(--c), var(--c)) bottom right / 2px 24px;
  background-repeat: no-repeat; }
.frame { --video-ratio: 1.33333; --room: 58vh; --room: 58svh; position: relative; width: min(100%, calc(var(--video-ratio) * var(--room))); aspect-ratio: var(--video-ratio); background: oklch(0.1 0.01 168); }
.frame video, .frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.frame video { object-fit: contain; }
.frame canvas { cursor: crosshair; touch-action: manipulation; }
.frame canvas:focus-visible { outline-offset: -3px; }

/* Turn banner: a brief ink band across the stage when the turn changes. */
.banner { position: absolute; inset: 0; z-index: var(--z-banner); display: grid; place-items: center; pointer-events: none; opacity: 0; }
.banner span { display: block; width: 100%; padding: .32em 0; text-align: center; white-space: nowrap; font: 900 clamp(1.9rem, 6.5vw, 3.4rem)/1.2 var(--display); letter-spacing: .4em; text-indent: .4em; color: var(--ivory); background: linear-gradient(90deg, transparent, oklch(0.13 0.014 168 / .88) 18%, oklch(0.13 0.014 168 / .88) 82%, transparent); border-block: 1px solid; border-image: linear-gradient(90deg, transparent, var(--brass) 25%, var(--brass) 75%, transparent) 1; text-shadow: 0 2px 12px oklch(0 0 0 / .5); }
.banner.red span { color: oklch(0.80 0.13 32); }
.banner.show { animation: banner-out 1.7s var(--ease) both; }
.banner.show span { animation: banner-in .55s var(--ease) both; }

/* Stage alert strip for immediate vision feedback */
.stage-alert { position: absolute; inset-inline: 10px; bottom: 10px; z-index: var(--z-banner); display: flex; align-items: flex-start; gap: 8px; width: fit-content; max-width: calc(100% - 20px); margin-inline: auto; padding: 8px 12px; border: 1px solid oklch(0.83 0.095 80 / .5); border-radius: 4px; background: oklch(0.13 0.014 168 / .92); box-shadow: inset 0 0 0 2px oklch(0.13 0.014 168 / .92), inset 0 0 0 3px oklch(0.83 0.095 80 / .16); color: oklch(0.94 0.05 85); font-size: .82rem; line-height: 1.5; text-align: left; text-wrap: pretty; pointer-events: none; animation: notice-in .25s var(--ease); }
.stage-alert::before { content: ''; flex: none; width: 6px; height: 6px; margin-top: .5em; background: var(--amber); transform: rotate(45deg); }

/* Turn rail & AI move order card */
.turn-rail { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; padding: 0; list-style: none; }
.turn-rail li { padding: 6px 4px; text-align: center; font: 600 .8rem/1.2 var(--display); letter-spacing: .06em; color: var(--mist-2); background: var(--night-3); border: 1px solid var(--brass-faint); border-radius: 4px; transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease); }
.turn-rail li.active { color: var(--ivory); border-color: var(--brass); background: oklch(0.83 0.095 80 / .14); }
.turn-rail li[data-role='execute'].active { background: var(--cinnabar); border-color: var(--cinnabar-lo); color: var(--ivory); }
.turn-rail li[data-role='thinking'].active::after { content: '…'; }

.move-order { margin-top: 14px; padding: 14px; background: var(--night-3); border: 1px solid var(--brass-2); border-radius: 6px; animation: notice-in .3s var(--ease); }
.move-order.rewind { border-color: oklch(0.83 0.12 165 / .55); }
.order-head { display: flex; align-items: center; gap: 10px; }
.order-title { min-width: 0; flex: 1; }
.order-title strong { display: block; font: 700 1.2rem/1.3 var(--display); letter-spacing: .1em; color: var(--ivory); }
.order-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.order-tags:empty { display: none; }
.order-tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font: 700 .74rem/1.4 var(--sans); letter-spacing: .06em; color: var(--ivory); background: var(--cinnabar); }
.order-tag.rewind-tag { background: oklch(0.42 0.08 165); }
.order-repeat { min-height: 34px; padding: 0 10px; font-size: .82rem; border-color: var(--brass-line); }
.order-steps { display: grid; gap: 8px; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--brass-faint); list-style: none; }
.order-steps li { display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: baseline; font-size: .9rem; line-height: 1.5; color: var(--mist); }
.order-steps .step-no { display: grid; place-content: center; width: 22px; height: 22px; border-radius: 50%; font: 700 .76rem var(--display); color: var(--brass); border: 1px solid var(--brass-line); }
.order-steps li strong { color: var(--ivory); font-weight: 600; }
.order-steps .step-warn { color: oklch(0.92 0.1 80); font-weight: 600; }
.order-steps .step-ok { color: var(--jade); }

/* Dialogue box */
.talk { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; }
.talk-avatar { display: grid; place-content: center; width: 58px; height: 58px; border-radius: 50%; font: 900 1.6rem var(--display); color: var(--ivory); background: radial-gradient(circle at 35% 30%, oklch(0.42 0.06 165), oklch(0.26 0.04 168)); box-shadow: 0 0 0 2px var(--night-2), 0 0 0 3px var(--brass-2); transition: box-shadow .3s var(--ease); }
.talk.speaking .talk-avatar { box-shadow: 0 0 0 2px var(--night-2), 0 0 0 3px var(--brass), 0 0 0 7px oklch(0.83 0.095 80 / .18); }
.talk-body { min-width: 0; }
.talk-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.talk-head h2 { font-size: 1.05rem; letter-spacing: .2em; color: var(--brass); }
#voice-status { display: inline-flex; align-items: center; gap: 6px; color: var(--mist-2); font-size: .82rem; }
#voice-status:not(:empty)::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--mist-2); }
.talk.mic-on #voice-status::before { background: var(--jade); animation: breathe 2s ease-in-out infinite; }
#spoken { margin-top: 6px; min-height: 1.7em; font: 500 1.14rem/1.7 var(--display); color: var(--ivory); overflow-wrap: anywhere; }
#spoken:empty::before { content: '小僧候着，少侠请开局。'; color: var(--mist-2); }
#spoken.fresh { animation: brush .6s var(--ease) both; }
#heard:not(:empty) { margin-top: 8px; color: var(--mist); font-size: .88rem; }
.talk-tip { margin-top: 8px; color: var(--mist-2); font-size: .84rem; }
.talk .actions { margin-top: 12px; }
#voice-switch[aria-pressed='true'] { border-color: oklch(0.83 0.12 165 / .5); color: var(--jade); }

/* Quest panel */
.quest-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#mode-label { display: inline-flex; align-items: center; gap: 8px; }
#mode-label::before { content: ''; width: 6px; height: 6px; background: currentColor; transform: rotate(45deg); }
#count { color: var(--mist-2); font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.quest h2 { margin-top: 10px; font-size: 1.5rem; letter-spacing: .06em; }
.quest h2.fresh { animation: brush .45s var(--ease) both; }
.corner-steps { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 20px; padding: 0; list-style: none; counter-reset: corner; }
.corner-steps li { position: relative; display: grid; justify-items: center; gap: 6px; color: var(--mist-2); font-size: .78rem; counter-increment: corner; }
.corner-steps li::before { content: counter(corner); position: relative; z-index: 1; display: grid; place-content: center; width: 32px; height: 32px; border-radius: 50%; font: 700 .95rem var(--display); color: var(--mist); background: var(--night-2); border: 1px solid var(--brass-line); transition: background-color .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease), transform .25s var(--ease); }
.corner-steps li + li::after { content: ''; position: absolute; top: 16px; right: 50%; width: 100%; height: 1px; background: var(--brass-line); }
.corner-steps li.done + li::after { background: var(--cinnabar); }
.corner-steps li.done { color: var(--mist); }
.corner-steps li.done::before { background: var(--cinnabar); border-color: var(--cinnabar-lo); color: var(--ivory); }
.corner-steps li.current { color: var(--ivory); }
.corner-steps li.current::before { border-color: var(--brass); color: var(--brass); transform: scale(1.08); animation: beacon 1.8s ease-out infinite; }

/* Game panel */
.game-head { display: grid; gap: 2px; }
.game-head h2 { font-size: 1.25rem; letter-spacing: .04em; }
#turn-info { color: var(--mist-2); font-size: .86rem; }
fieldset { min-width: 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 8px; font-size: .95rem; font-weight: 600; color: var(--mist); letter-spacing: .08em; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.sides legend { grid-column: 1 / -1; }
.side-tile, .token { position: relative; cursor: pointer; }
.side-tile input, .token input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.side-tile { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px; border: 1px solid var(--brass-line); border-radius: 4px; background: var(--night-3); transition: border-color .2s var(--ease), background-color .2s var(--ease); }
.piece { flex: none; display: grid; place-content: center; width: 36px; height: 36px; border-radius: 50%; font: 900 1.05rem var(--display); background: var(--wood); box-shadow: inset 0 0 0 2px var(--wood), inset 0 0 0 3.5px currentColor, 0 2px 0 oklch(0.55 0.06 70); }
.piece.red { color: oklch(0.48 0.18 29); }
.piece.black { color: oklch(0.22 0.01 168); }
.side-text { display: grid; line-height: 1.3; }
.side-text b { font: 700 1rem var(--display); letter-spacing: .1em; }
.side-text small { color: var(--mist-2); font-size: .8rem; }
.side-tile:has(input:checked) { border-color: var(--brass); background: oklch(0.83 0.095 80 / .1); }
.side-tile:has(input:focus-visible), .token:has(input:focus-visible) { outline: 2px solid var(--brass); outline-offset: 2px; }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 18px; }
.levels legend { grid-column: 1 / -1; }
.token span { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 0 10px; border: 1px solid var(--brass-line); border-radius: 18px 18px 4px 4px; background: var(--night-3); color: var(--mist); transition: transform .25s var(--ease), background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease); }
.token span::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--night); box-shadow: 0 0 0 1px var(--brass-line); }
.token b { flex: none; font: 700 .98rem/1 var(--display); writing-mode: vertical-rl; letter-spacing: .2em; white-space: nowrap; }
.token i { margin-top: 2px; font: 600 .74rem var(--display); font-style: normal; color: var(--mist-2); }
.token:has(input:checked) span { background: var(--cinnabar); border-color: var(--cinnabar-lo); color: var(--ivory); box-shadow: inset 0 0 0 3px var(--cinnabar), inset 0 0 0 4px oklch(0.88 0.08 80 / .5); transform: translateY(-4px); }
.token:has(input:checked) i { color: oklch(0.92 0.05 80); }
@media (hover: hover) { .token:hover span { border-color: var(--brass-2); color: var(--ivory); } .side-tile:hover { border-color: var(--brass-2); } }
fieldset:disabled .side-tile, fieldset:disabled .token { cursor: not-allowed; opacity: .55; }
#level-help { min-height: 3.1em; }
.game-actions:not(:has(> :not([hidden]))) { display: none; }
.game-actions #start-game { flex: 1 1 100%; min-height: 52px; font-size: 1.1rem; }

/* Record */
.record { margin-top: 16px; padding-block: 0; }
.record summary { display: flex; align-items: center; justify-content: space-between; min-height: 52px; font-weight: 700; letter-spacing: .14em; cursor: pointer; list-style: none; }
.record summary small { margin-left: 8px; font: 500 .8rem var(--sans); letter-spacing: .04em; color: var(--mist-2); }
.record summary::-webkit-details-marker { display: none; }
.record summary::after { content: ''; width: 8px; height: 8px; border: solid var(--brass); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); transition: transform .25s var(--ease); }
.record[open] summary::after { transform: rotate(-135deg); }
.move-log { display: grid; gap: 6px; padding: 0 0 16px; list-style: none; font-variant-numeric: tabular-nums; }
.move-log .log-empty { color: var(--mist-2); font-size: .9rem; }
.move-log li.round-row { display: grid; grid-template-columns: 4.2em 1fr 1fr; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 4px; background: var(--night-3); font-size: .9rem; }
.move-log .round-no { color: var(--mist-2); font-size: .8rem; }
.move-log .ply { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--ivory); font-family: var(--display); }
.move-log .ply.latest { color: var(--brass); font-weight: 700; }
.move-log .ply-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.move-log .ply-dot.red { background: var(--cinnabar-hi); }
.move-log .ply-dot.black { background: var(--mist-2); border: 1px solid var(--ivory); }
.move-log .ply-who { font: 500 .74rem var(--sans); color: var(--mist-2); }
.move-log .ply-cap { padding: 0 5px; border-radius: 3px; background: oklch(0.51 0.175 30 / .35); color: oklch(0.95 0.04 50); font: 600 .7rem var(--sans); }

/* Confirmation pact */
.pact { position: fixed; z-index: var(--z-pact); left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); width: min(calc(100% - 24px), 440px); padding: 18px 20px 20px; transform: translateX(-50%); overflow: hidden; background: var(--night-3); border: 1px solid var(--brass-2); border-radius: 6px; box-shadow: 0 8px 8px oklch(0 0 0 / .35); animation: pact-in .4s var(--ease); }
.pact-tag { color: var(--brass); font-size: .82rem; letter-spacing: .2em; }
#pact-text { margin-top: 4px; font: 700 1.15rem/1.5 var(--display); }
.pact .actions { margin-top: 14px; }
.pact .actions button { flex: 1; }
.pact-timer { position: absolute; left: 0; bottom: 0; width: 100%; height: 3px; background: var(--cinnabar); transform-origin: left; animation: countdown 8s linear both; }

/* ───────── Motion ───────── */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes ink-in { from { opacity: 0; filter: blur(8px); clip-path: inset(0 100% 0 0); } to { opacity: 1; filter: blur(0); clip-path: inset(0 -10% 0 0); } }
@keyframes stamp { from { opacity: 0; transform: rotate(-6deg) scale(1.8); } 60% { opacity: 1; transform: rotate(-6deg) scale(.94); } to { transform: rotate(-6deg) scale(1); } }
@keyframes brush { from { opacity: .2; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0 -2% 0 0); } }
@keyframes notice-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes breathe { 50% { opacity: .35; } }
@keyframes beacon { 0% { box-shadow: 0 0 0 0 oklch(0.83 0.095 80 / .45); } 100% { box-shadow: 0 0 0 10px oklch(0.83 0.095 80 / 0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes banner-out { 0% { opacity: 0; } 12% { opacity: 1; } 72% { opacity: 1; } 100% { opacity: 0; } }
@keyframes banner-in { from { clip-path: inset(0 50%); letter-spacing: .9em; filter: blur(4px); } to { clip-path: inset(0 0); letter-spacing: .4em; filter: blur(0); } }
@keyframes pact-in { from { opacity: 0; transform: translate(-50%, 16px); } }
@keyframes countdown { to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .banner.show { animation: banner-out 1.7s linear both !important; }
  .banner.show span { animation: none !important; }
  .pact-timer { animation: countdown 8s linear both !important; }
}

/* ───────── Responsive ───────── */
@media (max-width: 960px) {
  .table { display: flex; flex-direction: column; align-items: stretch; }
  .col { display: contents; }
  .stage { order: 1; } .quest { order: 2; } .talk { order: 3; } .game-panel { order: 4; }
}
@media (max-width: 740px) {
  .shell { width: calc(100% - 24px); }
  .topbar-inner { min-height: 50px; }
  .brand-name { font-size: 1.05rem; }
  .camera-state { font-size: .78rem; padding: 3px 10px; }
  .landscape { inset: 0 0 auto; height: 300px; background-position: 72% 40%; }
  .landscape::after { background: linear-gradient(0deg, var(--night) 4%, oklch(0.165 0.016 168 / .45) 55%, oklch(0.165 0.016 168 / .25)); }
  .hero-inner { display: block; min-height: 0; padding-block: 150px 40px; }
  .invitation h1 { font-size: clamp(2.5rem, 12vw, 3.2rem); letter-spacing: .05em; gap: 10px; }
  .title-seal { font-size: .82rem; }
  .lead { margin-top: 14px; font-size: 1rem; }
  .entry-action { margin-top: 26px; }
  .hero-button { flex: 1 1 100%; min-width: 0; }
  .couplet { display: none; }
  .rite { grid-template-columns: 1fr; gap: 24px; padding-top: 36px; }
  .rite h2 { font-size: 1.4rem; }
  .rite-steps li { grid-template-columns: 44px 1fr; gap: 14px; }
  .rite-no { width: 44px; height: 44px; font-size: 1.15rem; }
  .guide { max-width: 360px; width: 100%; justify-self: center; }
  .workspace { padding-top: 8px; }
  .hud-head { margin-bottom: 8px; }
  .hud-head h1 { font-size: 1.1rem; }
  .table, .col { gap: 12px; }
  .panel { padding: 16px; }
  .stage { padding: 6px; }
  .frame { --room: 52vh; --room: 52svh; }
  .quest h2 { font-size: 1.3rem; }
  .talk { grid-template-columns: 44px 1fr; gap: 12px; }
  .talk-avatar { width: 44px; height: 44px; font-size: 1.2rem; }
  .levels { gap: 5px; }
  .token b { font-size: .92rem; letter-spacing: .16em; }
}
@media (orientation: landscape) and (max-height: 560px) and (min-width: 600px) {
  .hero-inner { min-height: 0; padding-block: 28px; }
  .landscape { inset: 0; height: auto; }
  .workspace { padding-top: 6px; }
  .hud-head { margin-bottom: 6px; }
  .table { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 34%); }
  .col { display: grid; }
  .frame { --room: calc(100vh - 110px); --room: calc(100svh - 110px); }
  .panel { padding: 14px; }
}
.hero-button[aria-busy='true'] { opacity: 1; cursor: progress; }
