/* The scene carries the story. Only the brush, lives and pause remain in combat. */
.battle { isolation:isolate; background-color:var(--paper); }
.battle .topbar {justify-content:flex-end;padding:25px 3.5vw;pointer-events:none;}
.battle .topbar button {pointer-events:auto;}
.battle .home-nav,.battle .top-actions>.text-btn,.battle .encounter-name,.battle .battle-note,.battle .drawing-mode,.battle .resolve-group,.battle .tutorial-ribbon,.battle .freeze-label strong,.battle .life-number,.battle .result-word {display:none;}
.battle .top-actions {gap:0;}
.battle .icon-btn {border:3px solid var(--ink);border-radius:48% 52% 51% 49%;width:52px;height:52px;background:var(--paper);font-size:25px;box-shadow:0 0 0 1px var(--paper),0 0 0 2px var(--ink);}
.battle-title {top:34px;left:50%;transform:translateX(-50%);max-width:55%;opacity:.5;}
.battle-title .eyebrow {font-size:9px;letter-spacing:.17em;}
.battle-title .seals {justify-content:center;margin-top:9px;}
.battle .lives {left:4%;top:40px;gap:9px;}
.battle .life {width:15px;height:20px;}
.battle .target {top:14%;left:50%;transform:translateX(-50%);border:0;padding:0;max-width:80%;text-align:center;display:flex;align-items:center;justify-content:center;gap:14px;white-space:nowrap;}
.battle .target .glyph {font-size:42px;line-height:1;margin:0;}
.battle .target .meaning {font-size:18px;margin:0;}
.battle .target .reading {font-size:13px;}
.battle .target .script {display:none;}
.battle .guide .ghost {stroke-width:6;opacity:.12;}
.battle .guide .next-guide {stroke-width:6;opacity:.18;}
.battle .guide .guide-num {font-size:3.4px;opacity:.65;}
.battle .guide .start-dot {r:1;opacity:.7;}
.battle .battle-toolbar {bottom:max(25px,env(safe-area-inset-bottom));left:3.5vw;right:3.5vw;display:flex;justify-content:space-between;align-items:center;gap:15px;}
.battle .brush-tools {gap:10px;}
.battle .tool {border:0;border-radius:50% 45% 46% 40% / 37% 42% 35% 43%;padding:10px 24px;min-height:43px;background:var(--ink);color:var(--paper);font:17px var(--serif);box-shadow:0 0 0 1px var(--paper),0 0 0 2px var(--ink);}
.battle .tool:hover,.battle .tool:focus-visible {background:var(--red);}
.battle .tool:disabled {opacity:.18;}
.battle .freeze-label {min-height:0;max-width:180px;}
.battle .freeze-label small {font:13px var(--serif);letter-spacing:.03em;margin:0;}
.battle .world-reward {top:auto;bottom:19%;font:italic 15px var(--serif);animation:quiet-reward 1.8s both;}
.battle .cinematic-copy {display:none;}
.battle .cinema-bar {height:6%;opacity:.8;}
.battle[data-phase='walking'] canvas,.battle[data-phase='walking'] .guide,.battle[data-phase='walking'] .target {visibility:hidden;}
.battle[data-phase='walking'] .battle-toolbar,.battle[data-phase='strike'] .battle-toolbar,.battle[data-cinematic] .battle-toolbar {opacity:0;pointer-events:none;}
.battle[data-phase='walking'] .world-reward {opacity:0;}
.battle[data-phase='waiting'] .freeze-label,.battle[data-phase='split'] .freeze-label,.battle[data-phase='armor'] .freeze-label {visibility:hidden;}
.battle[data-phase='miss'] .freeze-label {max-width:280px;color:var(--red);}
.battle[data-phase='drawing'] .freeze-label strong:not(:empty) {display:none;}
.high-contrast .battle .guide .ghost {opacity:.23;}
.high-contrast .battle .guide .next-guide {opacity:.34;}
.left-handed .battle-toolbar {flex-direction:row-reverse;}
@keyframes quiet-reward {0%{opacity:0;translate:0 5px}20%,75%{opacity:1;translate:0 0}100%{opacity:0}}
@media(max-width:760px){
 .battle .topbar {padding:22px 6%;}
 .battle .icon-btn {width:42px;height:42px;min-width:42px;min-height:42px;font-size:20px;}
 .battle .lives {left:6%;top:33px;gap:7px;}
 .battle .life {width:13px;height:18px;}
 .battle-title {top:33px;max-width:48%;}
 .battle-title .eyebrow {font-size:8px;letter-spacing:.08em;}
 .battle .target {top:18%;gap:10px;max-width:90%;}
 .battle .target .glyph {font-size:34px;}
 .battle .target .meaning {font-size:16px;}
 .battle .target .reading {font-size:11px;max-width:none;}
 .battle .battle-toolbar {left:6%;right:6%;bottom:max(27px,env(safe-area-inset-bottom));gap:10px;}
 .battle .brush-tools {gap:9px;}
 .battle .tool {padding:9px 13px;font-size:14px;min-width:44px;min-height:44px;}
 .battle .freeze-label {max-width:76px;text-align:right;}
 .battle .freeze-label small {font-size:11px;line-height:1.5;}
 .battle .world-reward {bottom:18%;top:auto;font-size:12px;}
}
@media(max-height:550px) and (min-width:600px){
 .battle .topbar {padding:16px 4%;}.battle .lives{top:26px;}.battle-title{top:24px;}
 .battle .target {top:17%;}.battle .target .glyph{font-size:26px;}.battle .target .reading{font-size:10px;}
 .battle .tool{font-size:14px;min-height:36px;padding:7px 17px;}.battle .battle-toolbar{bottom:18px;}
}
.battle[data-phase='waiting'] .guide,.battle[data-phase='split'] .guide,.battle[data-phase='armor'] .guide,.battle[data-phase='miss'] .guide {opacity:0;}
.battle[data-phase='waiting'] .target {opacity:.35;}

/* v18: one primary prompt, drawn tools, black ink, a moonlit night and restrained washi transitions. */
.battle:is([data-phase='sealed']):not([data-cinematic]) :is(.landscape,.fighters) * {animation-play-state:paused !important;}
.battle[data-phase='sealed'] .guide {opacity:0;}
.battle[data-phase='sealed'] .target {opacity:.35;}

/* Night: paper stays paper, actor and player ink stay black; only the sky and light
   change. The top HUD sits in the ink sky, so it is written in paper-light ink there
   (--hud-ink) instead of floating on pills; the lower toolbar stays on paper in black. */
.battle {--hud-ink:var(--ink);}
.battle .night-sky {display:none;}
body[data-light='night'] .battle {--paper:#d8d6cf;--ink:#1a1c1e;--scene-ink:#161615;--red:#9c3b2c;--hud-ink:#ebe5d5;}
body[data-light='night'] .battle .night-sky {display:inline;}
.battle .target,.battle .battle-title {color:var(--hud-ink);}
.battle .life:not(.empty),.battle .seals span:not(.broken) {background:var(--hud-ink);}
body[data-light='night'] .battle :is(.target .reading,.battle-title .eyebrow) {color:inherit;opacity:.78;}
body[data-light='night'] .battle .life.empty {background:rgba(235,229,213,.14);outline-color:rgba(235,229,213,.42);}
body[data-light='night'] .battle .seals .broken {background:rgba(196,92,70,.55);}
body[data-light='night'] .battle .pause-btn {color:var(--hud-ink);background:transparent;border-color:currentColor;box-shadow:none;}
body[data-light='night'] .battle .pause-btn:hover,body[data-light='night'] .battle .pause-btn:focus-visible {color:#e58a72;}
:where(body[data-light='night']) .battle .guide .ghost {opacity:.16;}

/* Guardian crown and cape: the armor's black ink with dry-brush grain rather than a flat fill */
.battle .fighters :is(.guardian-mantle,.guardian-crown) {filter:url(#actor-dry-ink);}

/* Prompt */
.battle .target .glyph {font-weight:600;}
.battle .target .meaning {font-style:italic;}
.battle .target .glyph + .meaning::before {content:'·';font-style:normal;margin-right:12px;opacity:.5;}
.battle .target[data-mode='mastery'] .meaning,.battle .target[data-mode='recall'] .meaning:only-child {font-size:22px;}

/* Drawn tool icons with touch targets of at least 44px */
.battle .tool {width:48px;height:48px;min-width:44px;min-height:44px;padding:0;display:grid;place-items:center;border:1.5px solid currentColor;border-radius:50% 46% 52% 48%;background:rgba(240,234,220,.88);color:var(--ink);box-shadow:none;}
.battle .tool:hover,.battle .tool:focus-visible {background:rgba(240,234,220,.96);color:var(--red);}
.battle .tool:disabled {opacity:.3;}
.battle .icon {width:26px;height:26px;fill:none;stroke:currentColor;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round;pointer-events:none;}
.battle .pause-btn {color:var(--ink);}
.battle .pause-btn .icon {width:24px;height:24px;stroke-width:3.2;}
.battle .pause-btn:hover,.battle .pause-btn:focus-visible {color:var(--red);}
.battle .brush-tools {flex:none;}

/* Compact stroke progress; the status line appears only for real feedback, as a paper
   label above the dots (out of flow, growing upward), clear of the painted ground and
   beside the tool controls. */
.battle .ink-progress {flex:1 1 auto;min-width:0;display:flex;flex-direction:column;align-items:center;gap:5px;position:relative;}
.battle .stroke-progress {display:flex;flex-wrap:wrap;justify-content:center;gap:6px;max-width:220px;}
.battle .stroke-progress i {width:9px;height:9px;border-radius:50%;border:1.5px solid var(--ink);opacity:.4;transition:background-color .2s,opacity .2s;}
.battle .stroke-progress .done {background:var(--ink);opacity:.9;}
.battle .stroke-progress .next {opacity:.95;border-color:var(--red);}
.battle .stroke-progress .next.active {background:var(--red);}
.battle .ink-status {position:absolute;left:0;right:0;bottom:calc(100% + 10px);width:fit-content;max-width:min(100%,36ch);margin:0 auto;padding:4px 11px;border-radius:12px;background:rgba(240,234,220,.94);font:600 14px/1.3 var(--serif);text-align:center;color:var(--ink);overflow-wrap:anywhere;pointer-events:none;}
.battle .ink-status:empty {display:none;}
.battle[data-phase='miss'] .ink-status {color:var(--red);}
/* Optional Speed: a thin vermilion line under the dots shows the remaining share; it drains
   only while the clock runs and stays still while anything holds it. */
.battle .speed-clock {position:absolute;left:15%;right:15%;bottom:-7px;height:3px;border-radius:2px;background:var(--red);opacity:.85;transform-origin:left center;transform:scaleX(var(--left,1));pointer-events:none;}
.battle .speed-clock[hidden] {display:none;}
.battle .speed-clock[data-running='true'] {animation:speed-drain linear forwards;}
.battle[data-paused='true'] .speed-clock {animation-play-state:paused;}
@keyframes speed-drain {from{transform:scaleX(var(--left,1))}to{transform:scaleX(0)}}

/* Hanko seal of the written character, stamped beside the writing area */
.battle .circular-seal {border:2px solid var(--red);color:var(--red);background:rgba(240,234,220,.55);}
.battle .circular-seal span {font-size:clamp(20px,2.6vw,36px);line-height:1;}
.battle .circular-seal.seal-animate {animation:hanko-stamp .55s cubic-bezier(.2,.9,.25,1) forwards;}
.battle[data-phase='walking'] .circular-seal {visibility:hidden;}
@keyframes hanko-stamp {0%{opacity:0;transform:translate(-50%,-50%) scale(1.45) rotate(-14deg)}55%{opacity:1;transform:translate(-50%,-50%) scale(.94) rotate(-5deg)}100%{opacity:.92;transform:translate(-50%,-50%) scale(1) rotate(-5deg)}}

/* Tactile ink onset at each touch */
.battle .ink-onset {position:absolute;z-index:4;left:0;top:0;width:28px;height:28px;margin:-14px 0 0 -14px;border-radius:50%;background:radial-gradient(circle,rgba(21,21,19,.32) 0,rgba(21,21,19,.12) 45%,rgba(21,21,19,0) 70%);opacity:0;pointer-events:none;}
.battle .ink-onset.show {animation:ink-onset .42s ease-out;}
@keyframes ink-onset {0%{opacity:.9;transform:scale(.3)}100%{opacity:0;transform:scale(1.35)}}

/* Guides: a transient stroke-order draw-on */
.battle .guide .draw-on {opacity:.3;stroke-dasharray:1;stroke-dashoffset:1;animation:guide-draw .5s ease-out forwards;}
.battle .guide .drawn {opacity:.3;}
/* Practice keeps the current stroke and its direction distinct from the quiet outline. */
.battle[data-practice='true'] .guide .next-guide {stroke-width:4;opacity:.62;}
.battle[data-practice='true'] .guide .guide-arrow {stroke:var(--ink);stroke-width:1.1;opacity:.95;}
.battle[data-practice='true'] .guide .start-dot {opacity:1;}
.battle[data-practice='true'] .guide .guide-num {opacity:.95;}
.high-contrast .battle[data-practice='true'] .guide .next-guide {opacity:.9;}

@keyframes guide-draw {to{stroke-dashoffset:0}}

/* A charged life visibly falls once */
.battle .life.lost {animation:life-drop .8s ease-in both;}
@keyframes life-drop {0%{background:var(--hud-ink);transform:rotate(-8deg)}35%{background:var(--red);transform:translateY(-3px) rotate(-14deg)}100%{transform:translateY(0) rotate(-8deg)}}

/* Strike: readable wind-up, a complete slash and impact, then the freeze */
.battle[data-phase='strike']:not([data-cinematic]) :is(.hero-travel,.hero-actor .actor-lean,.hero-head,.hero-sword-arm,.hero-forearm,.hero-sword,.hero-back-arm,.hero-leg-front,.hero-leg-rear,.hero-coat,.hero-scarf,.enemy-sword-arm,.enemy-actor .actor-lean,.slash-streak,.slash-echo,.slash-drybrush,.incoming-position .actor-lean,.incoming-position .enemy-sword-arm) {animation-duration:1.35s;}
.battle[data-phase='strike']:not([data-cinematic]) .impact-brush {animation:strike-impact 1.35s ease-out both;}
@keyframes strike-impact {0%,52%{opacity:0}58%{opacity:.85}92%,100%{opacity:0}}

/* Restrained washi reveals: title to world, retry, and the result panel */
.battle[data-enter]::after {content:'';position:absolute;inset:0;z-index:40;pointer-events:none;background:#efe8d8;-webkit-mask-image:linear-gradient(100deg,transparent 40%,#000 60%);mask-image:linear-gradient(100deg,transparent 40%,#000 60%);-webkit-mask-size:250% 100%;mask-size:250% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;animation:washi-reveal .7s cubic-bezier(.4,.1,.2,1) forwards;}
.battle[data-enter='retry']::after {animation-duration:.45s;}
@keyframes washi-reveal {0%{-webkit-mask-position:100% 0;mask-position:100% 0;opacity:1}85%{opacity:1}100%{-webkit-mask-position:0 0;mask-position:0 0;opacity:0}}
.battle .result-panel {animation:result-unfold .5s ease-out both;}
@keyframes result-unfold {0%{opacity:0;clip-path:inset(0 46% 0 46%)}100%{opacity:1;clip-path:inset(0 0 0 0)}}

@media(max-width:760px){
 .battle .icon-btn {width:44px;height:44px;min-width:44px;min-height:44px;}
 .battle .tool {width:44px;height:44px;}
 .battle .icon {width:24px;height:24px;}
}
@media(max-height:550px) and (min-width:600px){
 .battle .tool {width:44px;height:44px;min-height:44px;padding:0;}
 .battle .icon-btn {width:44px;height:44px;}
 .battle .target {top:12%;}
}
@media(max-height:450px) and (orientation:landscape){
 .battle .battle-toolbar {bottom:max(10px,env(safe-area-inset-bottom));}
 .battle .lives {top:22px;}
 .battle .topbar {padding-top:max(14px,env(safe-area-inset-top));}
 .battle .ink-progress {gap:3px;}
 .battle .ink-status {bottom:calc(100% + 8px);font-size:13px;padding:3px 10px;}
}

/* Reduced motion keeps every state visible without movement */
.reduced-motion .battle[data-enter]::after,.reduced-motion .battle .ink-onset {display:none;}
.reduced-motion .battle .circular-seal.seal-animate {animation:none;opacity:.92;transform:translate(-50%,-50%) rotate(-5deg);}
.reduced-motion .battle .life.lost,.reduced-motion .battle .result-panel {animation:none;}
.reduced-motion .battle .life.lost {outline-color:var(--red);}
.reduced-motion .battle[data-phase='strike'] .slash-streak {opacity:.55 !important;stroke-dasharray:none;}
/* The Speed line holds its share instead of moving; its label still gives the seconds. */
.reduced-motion .battle .speed-clock {animation:none !important;}
@media (prefers-reduced-motion: reduce){
 .battle .speed-clock {animation:none !important;}
 .battle[data-enter]::after,.battle .ink-onset {display:none;}
 .battle .circular-seal.seal-animate {animation:none;opacity:.92;transform:translate(-50%,-50%) rotate(-5deg);}
 .battle .life.lost,.battle .result-panel {animation:none;}
 .battle[data-phase='strike'] .slash-streak {opacity:.55 !important;stroke-dasharray:none;}
}

/* Narrative paintings contain their actors. Hide, never replace, the live duel until the scene ends. */
.battle[data-story] > :is(.landscape,.fighters),.battle[data-story]::before {display:none;}
.battle[data-story] .cinema-bar {display:none;}
.story-painting,.painted-loading img {position:absolute;inset:0;width:100%;height:100%;object-fit:contain;background:#eee7d7;}
.battle[data-story] .story-copy {display:block;inset:0;left:0;top:0;width:100%;height:100%;max-width:none;transform:none;text-align:center;color:#24251f;animation:none;}
.battle[data-story] .story-copy h2 {position:absolute;left:5%;top:5%;margin:0;padding:5px 12px;background:#eee7d7f5;font:600 clamp(26px,3vw,42px)/1.2 var(--serif);}
.battle[data-story] .story-copy .story-line {display:none;position:absolute;left:8%;right:8%;bottom:12%;max-width:none;margin:0;padding:12px 20px;background:#eee7d7f5;}
.battle[data-story] .story-line p {max-width:none;margin:0;font:500 clamp(15px,1.65vw,21px)/1.6 var(--serif);}
.battle[data-story] .story-line .story-subtitle {margin-top:6px;font:14px/1.5 var(--serif);}
.battle[data-story][data-cinematic='boss-defeat'] .story-copy {left:0;top:0;width:100%;max-width:none;transform:none;}
.battle[data-story] .skip-cinematic {color:#24251f;border-color:#24251f;background:#eee7d7f5;min-height:44px;}
.battle[data-story][data-beat='0'] .story-line[data-line='0'],.battle[data-story][data-beat='1'] .story-line[data-line='1'],.battle[data-story][data-beat='2'] .story-line[data-line='2'],.battle[data-story][data-beat='3'] .story-line[data-line='3'],.battle[data-story][data-beat='4'] .story-line[data-line='4'] {display:block;animation:cinema-copy-in .6s ease-out both;}
.battle[data-paused='true'] .story-line {animation-play-state:paused;}
.battle[data-cinematic][data-story]:not([data-art-loading='true']) .topbar {opacity:1;z-index:13;}
/* The opening ambush is fought in rain, using the same rain layer as the katakana valley. */
.battle[data-weather='rain'] .weather-rain {visibility:visible;}
@media(max-height:550px) and (min-width:600px){
 .battle[data-story] .story-copy h2 {font-size:26px;}
 .battle[data-story] .story-copy .story-line {left:7%;right:7%;bottom:14%;padding:8px 14px;}
 .battle[data-story] .story-line p {font-size:15px;line-height:1.45;}
 .battle[data-story] .story-line .story-subtitle {font-size:12px;margin-top:4px;}
}
.reduced-motion .battle[data-story] :is(.story-copy,.story-line) {animation:none;}
@media (prefers-reduced-motion: reduce){ .battle[data-story] :is(.story-copy,.story-line) {animation:none;} }

/* One full-viewport opening: the painting carries the scene; readers control every change. */
.battle[data-story][data-cinematic][data-opening='true'] .topbar{opacity:0;pointer-events:none}
.cinematic-overlay.opening-cinematic{position:fixed;inset:0;z-index:20;pointer-events:auto;background:#eee7d7;border:0;border-radius:0;max-width:none;max-height:none}
.battle[data-opening]>.topbar,.battle[data-opening]>.lives,.battle[data-opening]>.battle-title,.battle[data-opening]>.battle-toolbar{visibility:hidden}
.opening-painting{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.opening-cinematic:after{content:"";position:absolute;inset:45% 0 0;z-index:1;pointer-events:none;background:linear-gradient(0deg,#eee7d7 0%,#eee7d7f2 28%,#eee7d7b8 56%,#eee7d700 100%)}
.opening-cinematic .opening-advance{position:absolute;inset:0;z-index:1;width:100%;height:100%;padding:0;margin:0;border:0;border-radius:0;background:transparent;box-shadow:none;cursor:pointer}
.opening-advance:focus-visible{outline:2px solid #8f3b2a;outline-offset:-8px}
.opening-copy{position:absolute;left:max(5.2%,env(safe-area-inset-left));right:max(6%,env(safe-area-inset-right));bottom:max(10%,72px);z-index:2;pointer-events:none;color:#24251f;background:none;border:0;padding:0;max-width:78ch;text-align:left}
.opening-copy p{margin:0;max-width:none;font-weight:600;animation:opening-text-reveal .45s cubic-bezier(.16,1,.3,1) both}
.opening-copy .opening-japanese{font-family:'Kanji Mincho',var(--serif);font-size:clamp(17px,1.7vw,25px);line-height:1.6;text-wrap:pretty}
.opening-copy .opening-english{font-family:'Cormorant Kanji',var(--serif);font-size:clamp(22px,2.35vw,35px);line-height:1.25;margin-top:8px;text-wrap:pretty}
.opening-cinematic[data-opening-shot='river-mark'] .opening-copy{left:42%;max-width:none}
.opening-cinematic .opening-pause{position:absolute;top:max(16px,env(safe-area-inset-top));right:max(18px,env(safe-area-inset-right));z-index:3;min-width:44px;min-height:44px;color:#24251f;background:transparent;border:0;box-shadow:none;filter:drop-shadow(0 0 2px #eee7d7)}
.opening-cinematic .opening-skip{position:absolute;right:max(4%,env(safe-area-inset-right));bottom:max(8px,env(safe-area-inset-bottom));z-index:3;min-width:60px;min-height:44px;padding:4px 10px;color:#24251f;background:transparent;border:0;box-shadow:none;font:600 23px 'Cormorant Kanji','Kanji Mincho',var(--serif)}
.opening-pause:focus-visible,.opening-skip:focus-visible{outline:2px solid #8f3b2a;outline-offset:2px}
.battle[data-paused='true'] .opening-copy p{animation-play-state:paused}
@keyframes opening-text-reveal{from{opacity:.25;clip-path:inset(0 10% 0 0)}to{opacity:1;clip-path:inset(0)}}
@media(max-height:450px) and (orientation:landscape){
 .opening-copy{bottom:54px}
 .opening-cinematic[data-opening-shot='river-mark'] .opening-copy{left:max(5.2%,env(safe-area-inset-left));max-width:78ch}
 .opening-copy .opening-japanese{font-size:15px;line-height:1.45}
 .opening-copy .opening-english{font-size:20px;line-height:1.15;margin-top:5px}
 .opening-cinematic:after{background:linear-gradient(0deg,#eee7d7 0%,#eee7d7f5 65%,#eee7d7d9 84%,#eee7d700 100%)}
 .opening-cinematic[data-opening-shot='half-seal'] .opening-painting{transform:translateY(-24px)}
 .opening-cinematic .opening-skip{bottom:4px}
}
@media(orientation:portrait){.opening-cinematic .opening-copy,.opening-cinematic[data-opening-shot='river-mark'] .opening-copy{left:max(6%,env(safe-area-inset-left));right:max(6%,env(safe-area-inset-right));bottom:max(10%,80px);max-width:none}.opening-copy .opening-japanese{font-size:18px;line-height:1.55}.opening-copy .opening-english{font-size:25px;line-height:1.2}.opening-cinematic .opening-pause{color:#24251f}}
.reduced-motion .opening-copy p{animation:none}
@media(prefers-reduced-motion:reduce){.opening-copy p{animation:none}}

/* A single Japanese confirmation occupies the prompt space; the player's ink and actors stay untouched. */
.battle:is([data-phase='sealed'],[data-phase='split'],[data-phase='armor']):not([data-cinematic]) .ink-status {position:fixed;top:11vh;bottom:auto;left:50%;right:auto;transform:translateX(-50%);padding:0;margin:0;background:none;border-radius:0;color:var(--hud-ink);font:700 clamp(34px,4.4vw,56px)/1.15 var(--serif);letter-spacing:.06em;white-space:nowrap;}
.battle .target,.battle .target * {transition-property:opacity;}
.battle:is([data-phase='sealed'],[data-phase='split'],[data-phase='armor']) .target {visibility:hidden;}
.battle .circular-seal {border:0;border-radius:16% 20% 15% 18%;background:var(--red);color:var(--paper);}
.battle.finished :is(.ink-status,.circular-seal) {display:none;}
.painted-loading {position:relative;min-height:100dvh;background:#eee7d7;}
.loading-ink {position:absolute;left:8%;bottom:12%;width:36px;height:4px;background:#a43d2b;animation:loading-breath 1.4s ease-in-out infinite alternate;}
@keyframes loading-breath {to{opacity:.35;}}
@media(prefers-reduced-motion:reduce){.loading-ink{animation:none;}}

/* The exact approved painting keeps its native aspect ratio; credits remain live text. */
dialog[data-kind='credits'] {width:min(1120px,calc(100vw - 34px));max-width:1120px;min-height:0;background:#eee7d7;}
dialog[data-kind='credits'] .modal-head {padding:16px 24px;}
dialog[data-kind='credits'] .modal-head h2 {font-size:32px;}
.creator-credits {position:relative;isolation:isolate;padding:0;min-height:min(560px,calc(100dvh - 125px));}
.creator-art {position:absolute;inset:0;z-index:-1;display:block;width:100%;height:100%;object-fit:cover;object-position:left center;}
.creator-copy {margin-left:48%;padding:22px 28px 28px 0;font-size:13px;line-height:1.65;}
.creator-copy .creator-name {font:600 26px/1.3 var(--serif);margin:0 0 16px;}
.creator-links {display:flex;flex-wrap:wrap;gap:4px 24px;margin-bottom:20px;}
.creator-links a {display:inline-flex;align-items:center;gap:9px;min-height:44px;font:600 16px var(--serif);text-underline-offset:5px;}
.creator-social-icon {display:block;width:20px;height:20px;fill:currentColor;flex:none;}
.creator-brands {display:flex;align-items:center;gap:20px;margin-bottom:20px;}
.flowwweb-mark {display:flex;align-items:center;min-height:52px;background:transparent;padding:0;}
.flowwweb-mark img {display:block;width:145px;max-width:100%;height:auto;}
.road-mark {display:block;width:52px;height:auto;border-radius:5px;}
@media(max-height:550px) and (min-width:600px){
 dialog[data-kind='credits'] .modal-head {padding:10px 20px;}
 dialog[data-kind='credits'] .modal-head h2 {font-size:28px;}
 .creator-copy {padding:14px 22px 20px 0;font-size:12px;line-height:1.5;}
 .creator-copy .creator-name {font-size:23px;margin-bottom:8px;}
 .creator-links,.creator-brands {margin-bottom:10px;}
 .creator-copy p {margin-bottom:12px;}
 .creator-art {height:auto;min-height:100%;object-fit:cover;}
}
@media(max-width:599px){
 dialog[data-kind='credits'] {width:calc(100vw - 24px);max-height:calc(100dvh - 24px);}
 dialog[data-kind='credits'] .modal-head {padding:12px 18px;}
 dialog[data-kind='credits'] .modal-head h2 {font-size:28px;}
 .creator-credits {min-height:0;}
 .creator-art {position:static;width:100%;height:auto;min-height:0;object-fit:contain;}
 .creator-copy {margin:0;padding:20px 22px 26px;font-size:13px;}
 .creator-copy .creator-name {font-size:25px;}
 .creator-links {gap:2px 24px;margin-bottom:18px;}
 .creator-links a {font-size:16px;}
}
/* Scenery is one full-frame painting. The live actors keep their original artboard. */
.battle .painted-arena {position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none;filter:none;transform:none;}
.painted-arena img {position:absolute;inset:0;width:100%;height:100%;object-fit:fill;}
.painted-arena .arena-night {display:none;}
body[data-light='night'] .painted-arena .arena-day {display:none;}
body[data-light='night'] .painted-arena .arena-night {display:block;}
.arena-loading {position:absolute;inset:0;z-index:45;min-height:0;height:100%;background:var(--paper);pointer-events:auto;}
.arena-loading img {position:absolute;inset:0;width:100%;height:100%;object-fit:contain;}
.battle[data-art-loading='true'] .topbar {z-index:46;}
.defeat-scene {object-fit:cover;}

/* Active night strokes stay distinct over the painted paper; writing remains black. */
body[data-light='night'] .battle .guide .ghost {opacity:.34;}
body[data-light='night'] .battle .guide .next-guide {opacity:.8;stroke-width:5;}
body[data-light='night'] .battle .guide .guide-arrow {opacity:.95;stroke-width:1.1;}
body[data-light='night'] .battle .guide .guide-num {opacity:1;fill:#63271f;paint-order:stroke;stroke:#eee7d7;stroke-width:.45;stroke-linejoin:round;}
body[data-light='night'] .battle .guide .start-dot {opacity:1;stroke:#eee7d7;stroke-width:.45;}
body.high-contrast[data-light='night'] .battle .guide .ghost {opacity:.56;}
body.high-contrast[data-light='night'] .battle .guide .next-guide {opacity:.95;}
dialog[data-kind='pause'] .pause-actions {gap:12px;}
dialog[data-kind='pause'] .pause-actions button {font-size:16px;line-height:1.35;min-height:52px;padding:12px 18px;}
dialog[data-kind='settings'] .setting-row {display:grid;grid-template-columns:minmax(0,1fr) auto;gap:18px;min-height:56px;padding:12px 0;font-size:15px;line-height:1.4;}
dialog[data-kind='settings'] .setting-row>span {min-width:0;}
dialog[data-kind='settings'] .setting-row select {font-size:15px;max-width:min(190px,44vw);min-height:44px;}
dialog[data-kind='settings'] .setting-note {font-size:12px;line-height:1.65;margin:16px 0;}
@media(max-width:599px){
 dialog[data-kind='settings'] .setting-row {font-size:16px;gap:14px;}
 dialog[data-kind='settings'] .setting-row select {font-size:16px;}
}

@media(max-height:550px) and (min-width:600px){
 dialog[data-kind='pause'] .pause-actions {grid-template-columns:1fr 1fr;}
 dialog[data-kind='pause'] .pause-actions .primary {grid-column:1/-1;}
}

/* A confirmed cut resolves at the planted blade; only that opponent parts. */
.battle[data-phase='split']:not([data-cinematic]) #hero-position .hero-sword-arm {animation:pass-arm .42s ease-in-out both;}
.battle[data-phase='split']:not([data-cinematic]) #hero-position .hero-forearm {animation:pass-forearm .42s ease-in-out both;}
.battle[data-phase='split']:not([data-cinematic]) #hero-position .hero-sword {animation:pass-blade .42s ease-in-out both;}
.battle[data-phase='split']:not([data-cinematic]) #enemy-position :is(.enemy-upper,.enemy-lower,.torso-cut-flash) {animation-delay:.18s;}
.battle[data-phase='split']:not([data-cinematic]) .impact-brush {animation-delay:.18s;}
@media(prefers-reduced-motion:reduce){.battle[data-phase='split']:not([data-cinematic]) #hero-position :is(.hero-sword-arm,.hero-forearm,.hero-sword){animation:none;}}
.reduced-motion .battle[data-phase='split']:not([data-cinematic]) #hero-position :is(.hero-sword-arm,.hero-forearm,.hero-sword){animation:none;}

/* A surviving opponent holds its ground while the accepted cut settles. */
.battle[data-continuity='target'][data-phase='walking'] .fighters * {animation:none !important;}
.battle[data-phase='miss'] .combat-enemy[data-selected='false'] :is(.enemy-travel,.enemy-sword-arm) {animation:none !important;}

/* Chapter scenes keep the full painting, readable story and next action together. */
dialog:is([data-kind='chapter-intro'],[data-kind='chapter-ending']) {width:min(1000px,calc(100vw - 32px));max-width:1000px;max-height:calc(100dvh - 32px);padding:0;}
dialog:is([data-kind='chapter-intro'],[data-kind='chapter-ending'])[open] {display:flex;flex-direction:column;}
dialog:is([data-kind='chapter-intro'],[data-kind='chapter-ending']) .modal-head {flex:none;padding:12px 20px;}
.chapter-scene {display:grid;grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);align-items:center;gap:24px;padding:16px 20px;min-height:0;overflow:auto;}
.chapter-scene-art {display:block;width:auto;height:auto;max-width:100%;max-height:44dvh;object-fit:contain;justify-self:center;}
.chapter-scene-copy p {font-size:15px;line-height:1.6;margin:0 0 16px;}
.chapter-scene-copy p:last-child {margin-bottom:0;}
.chapter-scene-actions {display:flex;gap:16px;align-items:center;flex:none;padding:12px 20px;border-top:1px solid #aaa38c66;}
.chapter-scene-actions button {font-size:16px;min-height:48px;}
@media(max-width:599px){.chapter-scene{grid-template-columns:1fr;gap:16px;}.chapter-scene-art{max-height:34dvh;}}

/* Chapter 2 keeps the shared rig but gives the ferry patrol its own silhouette. */
.battle[data-chapter='salt-signal'] .enemy-head :is(.helmet-horns,.guardian-crown,.reference-pigment) {display:none;}
.battle[data-chapter='salt-signal'] .enemy-head .ferry-hat {display:inline !important;filter:url(#actor-dry-ink);}
.battle[data-chapter='salt-signal'] .guardian-mantle {display:inline;}
.chapter-enemy {display:block;font-size:16px;line-height:1.3;margin-bottom:8px;}
.chapter-script {font-size:15px;line-height:1.3;}
.battle[data-chapter='salt-signal'][data-guidance='recall']:not([data-phase='sealed']):not([data-phase='split']) .circular-seal span,
.battle[data-chapter='salt-signal'][data-guidance='mastery']:not([data-phase='sealed']):not([data-phase='split']) .circular-seal span {visibility:hidden;}

/* Reserve a separate prompt row below Chapter 2 enemy names and progress seals. */
.battle[data-chapter='salt-signal'] .target {top:max(92px,14%);pointer-events:none;}

/* Winter Pass shares the live rig, with a hood and snow-worn mantle. */
.battle[data-chapter='winter-pass'] .enemy-head :is(.helmet-horns,.guardian-crown,.reference-pigment,.enemy-hair) {display:none;}
.battle[data-chapter='winter-pass'] .enemy-head .pass-hood {display:inline !important;filter:url(#actor-dry-ink);}
.battle[data-chapter='winter-pass'] .guardian-mantle {display:inline;}
.battle[data-chapter='winter-pass'] .target {top:max(92px,14%);pointer-events:none;}
.battle[data-chapter='winter-pass'][data-guidance='mastery']:not([data-phase='sealed']):not([data-phase='split']) .circular-seal span {visibility:hidden;}


/* Daylight guidance stays legible against the pale paintings. Night ink is unchanged. */
body[data-light='day'] .battle .guide .ghost {opacity:.52;}
body[data-light='day'] .battle .guide .next-guide {opacity:.8;}
body[data-light='day'] .battle .guide .guide-num {fill:var(--ink);opacity:.9;}
body[data-light='day'] .battle .guide .start-dot {opacity:.95;}
body[data-light='day'] .battle .guide .guide-arrow {stroke-width:1.1;opacity:.95;}
.high-contrast[data-light='day'] .battle .guide .ghost {opacity:.72;}
.high-contrast[data-light='day'] .battle .guide .next-guide {opacity:1;}
/* Completed chapters are readable records; only locked chapters remain faded. */
.lesson-card[data-completed='true']:disabled {opacity:1;cursor:default;}
.lesson-card[data-completed='true'] small {color:var(--ink);}

/* Selector artwork follows the approved painted target; controls remain live text. */
@font-face{font-family:'Cormorant Kanji';src:url('./assets/selector/CormorantGaramond.ttf') format('truetype');font-style:normal;font-weight:300 700;font-display:swap}
@font-face{font-family:'Kanji Mincho';src:url('./assets/selector/KanjiMincho-Semibold.ttf') format('truetype');font-style:normal;font-weight:600 700;font-display:swap}
.chapter-select{--chapter-type:'Cormorant Kanji','Kanji Mincho','Yu Mincho','Hiragino Mincho ProN',serif;--chapter-red:#bd321f;--chapter-paper:#f7e9d4;--ink:#171913;color:var(--ink);background:var(--chapter-paper);padding-bottom:28px}
.chapter-select:before{content:"";position:absolute;z-index:-1;inset:0 0 auto;height:min(290px,50vw);pointer-events:none;background:url('./assets/selector/selector-washi-background.png') center top/100% auto no-repeat;mask:linear-gradient(#000 75%,transparent)}
.chapter-select:after{content:"";position:absolute;z-index:-1;inset:auto 0 0;height:70px;pointer-events:none;background:url('./assets/selector/selector-washi-background.png') center bottom/100% auto no-repeat;mask:linear-gradient(transparent,#000 65%)}
.chapter-select .topbar{max-width:1600px;margin:auto;padding:18px clamp(24px,4vw,64px) 0}
.chapter-utility{position:relative;gap:12px;display:inline-flex;align-items:center;font:700 clamp(22px,2.3vw,36px)/1 var(--chapter-type);letter-spacing:0;min-height:52px;padding:4px 5px 12px;border:0}
.chapter-utility svg{width:30px;height:30px;fill:currentColor;flex:none}
.chapter-utility:after{content:"";position:absolute;left:0;right:0;bottom:2px;height:4px;background:currentColor;mask:url('./assets/menu-brush.svg') center/100% 100% no-repeat}
.chapter-heading{max-width:1600px;margin:22px auto 54px;padding:0 clamp(24px,4vw,64px)}
.chapter-heading h1{position:relative;display:table;margin:0;font:700 clamp(44px,6.1vw,96px)/1 var(--chapter-type);letter-spacing:-.025em}
.chapter-heading h1:after{content:"";position:absolute;left:-6px;bottom:-27px;width:clamp(270px,30vw,470px);height:5px;background:var(--ink);mask:url('./assets/menu-brush.svg') center/100% 100% no-repeat}
.chapter-heading h1:before{content:"";position:absolute;left:clamp(245px,27.3vw,430px);bottom:-31px;width:52px;height:7px;transform:rotate(-13deg);background:var(--chapter-red);mask:url('./assets/level-brush-atlas.png') center top/100% 600% no-repeat}
.chapter-cards{max-width:1600px;margin:0 auto;padding:0 clamp(24px,3.4vw,56px);display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:36px 32px}
.chapter-card{--frame:#5e5b4f;position:relative;isolation:isolate;min-width:0;background:none;display:flex;flex-direction:column;padding:8px 10px 18px}
.chapter-frame{position:absolute;inset:-4.5% -5.5%;z-index:2;pointer-events:none;background:var(--frame);mask:url('./assets/selector/selector-brush-frame.png') center/100% 100% no-repeat;opacity:.7}
.chapter-card:nth-child(2n) .chapter-frame{transform:scaleX(-1)}
.chapter-card:nth-child(3n) .chapter-frame{transform:rotate(180deg)}
.chapter-card[data-available='true']{--frame:var(--chapter-red)}
.chapter-card[data-available='true'] .chapter-frame{opacity:1}
.chapter-art{width:100%;aspect-ratio:2/1;background-image:url('./assets/selector/approved-selector-en.png');background-size:334.4% auto;background-position:4.266% 47.47%;background-repeat:no-repeat;mask:linear-gradient(#000 92%,transparent);border-radius:14px 12px 0 0}
.chapter-art[data-painting='2']{background-position:50.683% 47.47%}
.chapter-art[data-painting='3']{background-position:96.416% 47.47%}
.chapter-card h2{display:flex;align-items:center;gap:13px;font:700 clamp(22px,2.6vw,40px)/1.1 var(--chapter-type);min-height:2.2em;margin:4px 14px 10px;letter-spacing:-.015em}
.chapter-card h2>span{font:500 italic 1.45em/1 var(--chapter-type);color:var(--chapter-red);border-right:1px solid #6f6658;padding-right:13px;flex:none}
.chapter-card .primary{position:relative;isolation:isolate;z-index:3;margin:0 10px 0;min-height:58px;padding:9px 16px 12px;border:0;background:none;color:#fff4e1;font:700 clamp(23px,2.7vw,40px)/1 var(--chapter-type);letter-spacing:0}
.chapter-card .primary:before{content:"";position:absolute;inset:-1px -5px;z-index:-1;background:#272923;mask:url('./assets/level-brush-atlas.png') 52% 5.24%/110% 600% no-repeat}
.chapter-card .primary.red:before{background:var(--chapter-red)}
.chapter-card .primary:hover{background:none;transform:none}
.chapter-card .primary:not(:disabled):hover:before{filter:brightness(1.14)}
.chapter-card .primary:focus-visible{outline:3px solid var(--chapter-red);outline-offset:5px}
.chapter-card[data-locked='true'] .primary{opacity:1;color:#3f392f;font-size:clamp(17px,1.8vw,27px)}
.chapter-card[data-locked='true'] .primary:before{background:#cbbda3}
.chapter-card .primary{margin-top:auto}
.chapter-card[data-future='true'] .chapter-art{opacity:.32;filter:grayscale(1)}
.chapter-card[data-future='true'] .chapter-frame{opacity:.45}
.locale-switch{display:flex;justify-content:center;gap:24px;padding:26px 20px 4px}
.locale-switch button{position:relative;padding:8px 6px 12px;background:none;border:0;font:700 clamp(24px,2.4vw,36px)/1 var(--chapter-type);min-height:48px}
.locale-switch button[aria-pressed='true']:after{content:"";position:absolute;left:-6px;right:-6px;bottom:1px;height:6px;background:var(--chapter-red);mask:url('./assets/level-brush-atlas.png') 52% 5.24%/110% 600% no-repeat}
/* Percentages and drawing grades share the existing imprint animation and outline. */
.ink-seal{isolation:isolate;color:var(--red);width:64px;height:64px;display:grid;place-items:center;transform:rotate(-7deg);animation:seal-imprint .5s cubic-bezier(.2,.7,.3,1) both}
.seal-border{position:absolute;inset:0;width:100%;height:100%;fill:none;stroke:currentColor;stroke-width:2.2;pointer-events:none}
.chapter-stamp{position:absolute;right:16px;top:16px;z-index:4;color:var(--chapter-red);background:#f7e9d4d9;border-radius:0}
.chapter-stamp b{font:700 22px var(--chapter-type);letter-spacing:-.04em}
.chapter-lock{position:absolute;right:20px;top:19px;z-index:4;color:#6b675a;line-height:0}
.chapter-lock svg{width:30px;height:34px;fill:currentColor}
.drawing-grade{position:absolute;pointer-events:none;z-index:7;width:60px;height:60px;text-align:center}
.drawing-grade[hidden]{display:none}.drawing-grade>span{font:700 42px/1 var(--serif)}.drawing-grade>small{position:absolute;top:100%;left:-10px;right:-10px;font:12px/1.2 var(--serif);margin-top:3px}
.drawing-grade[data-grade='excellent']{color:#365b70}
.high-contrast .drawing-grade[data-grade='perfect']{color:#7e2119}.high-contrast .drawing-grade[data-grade='excellent']{color:#173e57}
.battle .brand,.battle .home-nav{display:none}
.battle .lives{--life-ink:#24251f;--life-edge:#eee7d7cc}.battle .lives[data-tone='light']{--life-ink:#f1eadb;--life-edge:#171c20cc}
.battle .lives .life:not(.empty){background:var(--life-ink)}.battle .lives .life{filter:drop-shadow(0 0 1px var(--life-edge))}.battle .lives[data-tone] .life.empty{background:var(--life-ink);opacity:.2;outline-color:var(--life-ink)}
@keyframes seal-imprint{0%{opacity:0;transform:rotate(-13deg) scale(1.3)}65%{opacity:.96;transform:rotate(-7deg) scale(.97)}100%{opacity:.94;transform:rotate(-7deg) scale(1)}}
.reduced-motion .ink-seal{animation:none;opacity:.94}@media(prefers-reduced-motion:reduce){.ink-seal{animation:none;opacity:.94}}
@media(max-width:700px) and (orientation:portrait){
.chapter-select .topbar{padding:14px 24px 0}.chapter-utility{font-size:25px;gap:8px}.chapter-utility svg{width:27px;height:27px}
.chapter-heading{max-width:480px;padding:0 24px;margin:20px auto 48px}.chapter-heading h1{font-size:52px}
.chapter-cards{grid-template-columns:1fr;max-width:480px;gap:34px;padding:0 26px}.chapter-card h2{font-size:34px;min-height:1.8em}.chapter-card .primary{font-size:32px}.chapter-card[data-locked='true'] .primary{font-size:24px}.chapter-stamp{width:62px;height:62px}
}
@media(max-height:500px) and (orientation:landscape){
.chapter-select .topbar{padding:6px 22px 0}.chapter-utility{font-size:22px;min-height:44px;padding-bottom:8px;gap:7px}.chapter-utility svg{width:23px;height:23px}
.chapter-heading{margin:14px auto 32px;padding:0 24px}.chapter-heading h1{font-size:40px}.chapter-heading h1:after{bottom:-15px;width:230px}.chapter-heading h1:before{bottom:-19px;left:210px;width:42px}
.chapter-cards{gap:24px 18px;padding:0 22px}.chapter-card{padding:4px 5px 11px}.chapter-card h2{font-size:clamp(17px,2.5vw,25px);gap:7px;margin:2px 8px 7px;min-height:2.6em}.chapter-card h2>span{padding-right:7px}
.chapter-card .primary{font-size:22px;min-height:44px;margin:0 3px;padding:8px 6px 10px}.chapter-card[data-locked='true'] .primary{font-size:clamp(13px,1.8vw,18px)}
.chapter-stamp{width:43px;height:43px;right:9px;top:9px}.chapter-stamp b{font-size:15px}.chapter-lock{right:10px;top:9px}.chapter-lock svg{width:23px;height:26px}.locale-switch{padding:18px 20px 4px}.locale-switch button{font-size:24px}
}
.score-rules{max-width:720px;margin:0 auto;padding:0 30px 32px;font-size:12px;line-height:1.8;color:var(--ink)}.score-rules summary{cursor:pointer;min-height:44px;display:list-item;padding:10px 0}.score-rules p{margin:10px 0 0}
