@font-face {
  font-family: 'Noto Serif KR';
  font-style: normal;
  font-weight: 400;
  src: url(./assets/noto-serif-kr-0.ttf) format('truetype');
}
@font-face {
  font-family: 'Noto Serif KR';
  font-style: normal;
  font-weight: 500;
  src: url(./assets/noto-serif-kr-1.ttf) format('truetype');
}
@font-face {
  font-family: 'Noto Serif KR';
  font-style: normal;
  font-weight: 600;
  src: url(./assets/noto-serif-kr-2.ttf) format('truetype');
}
@font-face {
  font-family: 'Noto Serif KR';
  font-style: normal;
  font-weight: 700;
  src: url(./assets/noto-serif-kr-3.ttf) format('truetype');
}
@font-face {
  font-family: 'Noto Serif KR';
  font-style: normal;
  font-weight: 900;
  src: url(./assets/noto-serif-kr-4.ttf) format('truetype');
}

:root{--ink:#273e3b;--muted:#6b756c;--paper:#eee8da;--red:#a34c38;--line:#45574a33}*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden}body{background:var(--paper);color:var(--ink);font-family:'Noto Serif KR',Batang,serif}button,a{-webkit-tap-highlight-color:transparent}button{font:inherit;cursor:pointer}button:focus-visible,a:focus-visible{outline:2px solid var(--red);outline-offset:5px}button{transition:background .2s,transform .2s}button:hover{transform:translateY(-2px)}#app{width:100%;height:100%;position:relative;isolation:isolate}canvas{position:absolute;inset:0;width:100%;height:100%;object-fit:contain}.grain{position:absolute;inset:0;pointer-events:none;opacity:.08;background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' opacity='.55' filter='url(%23n)'/%3E%3C/svg%3E");mix-blend-mode:multiply}header{position:absolute;top:0;left:0;right:0;padding:28px 42px;display:flex;justify-content:space-between;align-items:center;z-index:5}.brand{display:flex;align-items:center;gap:11px;text-decoration:none;color:var(--ink);font-size:17px;font-weight:700;letter-spacing:3px}.brand i{font-family:Arial,sans-serif;font-size:9px;letter-spacing:3px;font-style:normal;margin-left:13px;opacity:.65}.seal{display:inline-flex;align-items:center;justify-content:center;border:2px solid var(--red);color:var(--red);font-weight:700;padding:7px;transform:rotate(-4deg);font-size:17px;letter-spacing:3px;line-height:1.4}.seal.small{width:29px;height:31px;font-size:21px;padding:0;letter-spacing:0}.top-actions{display:flex;gap:22px;align-items:center}.icon-button{border:0;background:transparent;color:var(--ink);font-size:20px;padding:5px}.icon-button span{font-family:Arial,sans-serif;font-size:11px;margin-left:5px;letter-spacing:1px}.screen{position:absolute;inset:0}.title-screen{background:linear-gradient(90deg,#eee8dacf 0%,#eee8da70 33%,transparent 60%)}.title-copy{position:absolute;left:10%;top:22%;}.eyebrow{font-family:Arial,sans-serif;font-size:11px;letter-spacing:4px;display:flex;align-items:center;gap:14px}.eyebrow>span{height:1px;width:35px;background:var(--red)}h1{font-size:clamp(76px,9vw,146px);letter-spacing:12px;font-weight:900;line-height:1.3;margin:17px 0 0;text-shadow:2px 2px #f4eddb88}.hanja{display:inline-block;writing-mode:vertical-rl;font-size:21px;letter-spacing:9px;vertical-align:middle;color:var(--red);font-weight:400;margin-left:15px}.subtitle{font-size:21px;letter-spacing:10px;margin:7px 0 24px}.fine-rule{width:210px;height:1px;background:linear-gradient(90deg,var(--ink),transparent);opacity:.3}.story{font-size:13px;line-height:2.15;letter-spacing:2px;color:#546159;margin:23px 0 18px}.chapters{display:flex;flex-direction:column;gap:4px;width:min(360px,72vw);margin:0 0 22px}.chapter{display:grid;grid-template-columns:auto 1fr auto auto;align-items:baseline;gap:8px 14px;width:100%;padding:7px 8px;border:0;border-left:2px solid transparent;background:transparent;color:var(--ink);text-align:left}.chapter:hover{transform:translateX(3px)}.chapter.on{border-left-color:var(--red);background:#273e3b08}.chapter:disabled,.chapter.locked{opacity:.4;cursor:not-allowed}.chapter:disabled:hover,.chapter.locked:hover{transform:none}.chapter-num{font-size:11px;letter-spacing:3px;color:var(--red);min-width:3.6em}.chapter-title{font-size:15px;font-weight:500;letter-spacing:4px}.chapter-tag{font-size:10px;letter-spacing:2px;color:#657268}.chapter-lock{font-style:normal;font-size:12px;color:var(--red);letter-spacing:1px}.primary{border:1px solid var(--ink);background:var(--ink);color:#f4edde;min-width:215px;padding:17px 24px;display:inline-flex;justify-content:space-between;gap:45px;align-items:center;font-size:14px;letter-spacing:3px;box-shadow:4px 4px 0 #253c3515}.primary:hover{background:#395c53}.primary:disabled{opacity:.55;cursor:wait;transform:none}.arrow{font-size:25px;line-height:15px}.start-hint,.best{font-family:Arial,sans-serif;font-size:10px;letter-spacing:1px;color:#657268;margin-top:15px}.vertical-poem{position:absolute;right:8%;top:25%;display:flex;flex-direction:row-reverse;gap:22px;align-items:start}.vertical-poem>span{writing-mode:vertical-rl;font-size:20px;letter-spacing:12px;line-height:1.6}.vertical-poem>span:nth-child(2){padding-top:52px;opacity:.65}.vertical-poem .seal{writing-mode:vertical-rl;font-size:13px;margin-top:170px;letter-spacing:4px}.title-bottom{position:absolute;bottom:35px;left:42px;right:42px;display:flex;justify-content:space-between;align-items:center;border-top:1px solid var(--line);padding-top:18px;font-size:11px;letter-spacing:3px}.title-bottom b{font-weight:500;padding-left:20px;font-size:15px}.title-bottom>span:last-child{font-family:Arial,sans-serif;font-size:9px}.title-bottom i{font-style:normal;margin-left:40px;opacity:.5}.hidden{display:none!important}#hud{position:absolute;inset:0;pointer-events:none}.player-hud{position:absolute;top:110px;left:42px;width:170px}.hud-label{font-size:19px;letter-spacing:5px;margin-bottom:13px}.hud-label small{font-size:11px;opacity:.5;letter-spacing:3px}#health{display:flex;gap:8px;margin-bottom:13px}#health i{height:12px;width:12px;background:var(--red);transform:rotate(45deg);border:1px solid var(--red)}#health i.empty{background:transparent;opacity:.35}.qi-track{height:3px;width:150px;background:#253c3525}#qi{height:100%;background:#427568;transition:width .15s}.qi-label{font-size:10px;margin-top:7px;letter-spacing:2px}.qi-label small{float:right;font-size:9px;opacity:.65}.chapter-hud{position:absolute;right:42px;top:112px;text-align:right;display:grid;gap:8px}.chapter-hud>span{font-size:10px;letter-spacing:5px;color:var(--red)}.chapter-hud b{font-weight:500;font-size:23px;letter-spacing:6px}.chapter-hud small{font-size:10px;letter-spacing:1px;color:var(--muted)}.bottom-hud{position:absolute;bottom:27px;left:42px;right:42px;display:flex;gap:25px;align-items:center;font-size:11px;letter-spacing:2px}.progress-track{height:1px;background:#324b3625;flex:1}#progress{height:2px;background:#627d6b;width:0}#boss-hud{position:absolute;bottom:124px;width:min(450px,60%);left:50%;transform:translateX(-50%);text-align:center}#boss-hud>span{font-size:12px;letter-spacing:4px}#boss-hud b{font-weight:500;font-size:20px;margin-left:15px}#boss-hud>div{margin-top:14px;height:5px;background:#a34c3825}#boss-health{display:block;height:100%;background:var(--red);transition:width .1s}#hint{position:absolute;bottom:124px;width:100%;text-align:center;font-size:12px;letter-spacing:2px;color:#354e43;text-shadow:0 1px 6px var(--paper)}#toast{position:absolute;top:24%;left:max(24px,env(safe-area-inset-left));max-width:calc(50% - 36px);padding:12px 23px;background:#eee8dae8;border-left:2px solid var(--red);font-size:13px;letter-spacing:3px;opacity:0;transition:opacity .4s;pointer-events:none;white-space:normal;text-align:left}#toast.show{opacity:1}.modal{position:absolute;inset:0;z-index:10;background:#213a3455;backdrop-filter:blur(8px);display:grid;place-items:center;padding:24px}.modal-paper{background:#eee8daf7;border:1px solid #fcf5e7;padding:42px 48px;width:min(520px,100%);box-shadow:0 20px 100px #183c3425;text-align:center}.modal-paper .eyebrow{justify-content:center;color:var(--red);font-size:10px;letter-spacing:3px}.modal-paper h2{font-size:38px;font-weight:500;letter-spacing:5px;margin:18px 0 25px}#modal-content{font-size:13px;line-height:2;color:#5b695e}#modal-buttons{display:flex;flex-direction:column;align-items:center;gap:15px;margin-top:26px}.secondary{background:transparent;border:0;color:#516256;font-size:12px;letter-spacing:2px;padding:8px}.controls{display:grid;grid-template-columns:1fr 1fr;text-align:left;gap:11px 25px;font-size:12px}.controls kbd{background:#364c3d0c;border:1px solid #364c3d30;min-width:25px;display:inline-block;text-align:center;padding:0 5px;font-family:Arial,sans-serif;font-size:11px}.controls span{display:flex;justify-content:space-between;align-items:center;gap:8px}.control-note{border-top:1px solid var(--line);margin-top:20px;padding-top:16px;font-size:11px}.result-stats{display:flex;justify-content:center;flex-wrap:wrap;gap:35px;margin:25px 0}.result-stats span{font-size:11px}.result-stats b{display:block;font-size:28px;color:var(--ink);font-weight:400}#touch{position:absolute;right:calc(14px + env(safe-area-inset-right));bottom:calc(14px + env(safe-area-inset-bottom));width:142px;height:142px;pointer-events:none;z-index:6}#touch button{pointer-events:auto;touch-action:none;user-select:none;-webkit-user-select:none;position:absolute;border-radius:50%;border:1px solid #334e4055;background:#eee8dab8;color:var(--ink);letter-spacing:1px}#touch .touch-attack{width:76px;height:76px;right:0;bottom:0;font-size:15px;letter-spacing:2px;background:#eee8dae6;border-color:#a34c3866;color:var(--red)}#touch .touch-dash{width:58px;height:58px;right:84px;bottom:9px;font-size:13px}#touch .touch-jump{width:58px;height:58px;right:9px;bottom:84px;font-size:13px}#stick-zone{display:none;position:absolute;left:0;bottom:0;width:42%;height:70%;padding:0 0 env(safe-area-inset-bottom) env(safe-area-inset-left);pointer-events:auto;touch-action:none;user-select:none;z-index:6;background:transparent}#stick{position:absolute;width:120px;height:120px;margin:-60px 0 0 -60px;border-radius:50%;border:1px solid #334e4066;background:#eee8da88;box-shadow:inset 0 0 0 10px #f4eddb33,0 4px 18px #273e3b18;pointer-events:none}#stick i{position:absolute;left:50%;top:50%;width:52px;height:52px;margin:-26px;border-radius:50%;background:#eee8daf2;border:1px solid #a34c3844;box-shadow:0 2px 10px #273e3b22}#rotate-gate{position:absolute;inset:0;z-index:30;background:var(--paper);display:grid;place-items:center;color:var(--ink)}.rotate-card{text-align:center}.rotate-phone{display:block;width:48px;height:76px;margin:0 auto 22px;border:2px solid var(--red);border-radius:8px;transform:rotate(-28deg);position:relative;box-shadow:3px 3px 0 #a34c3822}.rotate-phone i{position:absolute;left:50%;bottom:8px;width:14px;height:3px;margin-left:-7px;background:var(--red);border-radius:2px}.rotate-card p{margin:0;font-size:22px;letter-spacing:8px;font-weight:500}.touch-title{font-size:11px;letter-spacing:4px;color:var(--red);margin:0 0 12px}.touch-note{margin-top:12px}.controls b{font-weight:500;font-size:11px;letter-spacing:1px}@media(pointer:coarse){#touch:not(.hidden){display:block}#stick-zone:not(.hidden){display:block}#skills{pointer-events:auto}#hint{bottom:148px}#boss-hud{bottom:150px}}@media(max-height:650px){header{padding:18px 28px}.title-copy{top:18%;left:8%}h1{font-size:80px;margin-top:5px}.subtitle{font-size:17px;margin:0 0 12px}.story{margin:13px 0 12px;font-size:11px}.chapters{margin:0 0 14px;gap:2px}.chapter{padding:4px 6px}.chapter-title{font-size:13px}.primary{padding:13px 22px}.title-bottom{bottom:18px;left:28px;right:28px;padding-top:10px}.start-hint{font-size:9px;margin-top:10px}.player-hud{top:80px;left:28px}.chapter-hud{top:80px;right:28px}.modal-paper{padding:24px 35px}.modal-paper h2{font-size:28px;margin:12px 0}.vertical-poem{top:23%}}@media(max-width:600px) and (orientation:portrait){header{padding:23px}.brand i{display:none}.top-actions{gap:12px}.icon-button span{display:none}.title-copy{top:24%;left:9%}.eyebrow{font-size:9px;letter-spacing:2px}h1{font-size:100px}.subtitle{font-size:17px;letter-spacing:7px}.chapters{width:min(280px,78vw);margin:0 0 16px}.chapter{padding:5px 4px;gap:6px 8px}.chapter-title{font-size:13px;letter-spacing:2px}.chapter-tag{font-size:9px}.vertical-poem{right:5%;top:18%;gap:5px;opacity:.5}.vertical-poem>span{font-size:13px;letter-spacing:7px}.vertical-poem .seal{display:none}.title-bottom{bottom:37px;left:23px;right:23px}.title-bottom>span:last-child{display:none}.player-hud{top:87px;left:23px}.chapter-hud{top:87px;right:23px}.chapter-hud small{max-width:125px;line-height:1.8}.bottom-hud{left:23px;right:23px;bottom:35px;gap:14px}.controls{gap:12px}.modal-paper{padding:28px 22px}.modal-paper h2{font-size:30px}#toast{font-size:10px;letter-spacing:1px;max-width:calc(100% - 48px)}#hint{font-size:10px;letter-spacing:0;padding:0 20px}}
/* Keep touch controls exclusive to touch devices. */
#touch{display:none}
@media(pointer:coarse){#touch:not(.hidden){display:block}#stick-zone:not(.hidden){display:block}}
@media(pointer:coarse){#boss-hud{bottom:150px}}
@media(max-height:500px){
 .modal{padding:12px}.modal-paper{width:min(700px,100%);padding:18px 28px}.modal-paper h2{font-size:25px;margin:7px 0 12px}.modal-paper .eyebrow{font-size:8px}#modal-content{font-size:11px;line-height:1.6}.controls{gap:7px 25px}.control-note{margin:10px 0 0;padding-top:8px;font-size:10px;line-height:1.6}#modal-buttons{flex-direction:row;justify-content:center;gap:18px;margin-top:16px}#modal-buttons .primary{min-width:135px;padding:12px 18px;font-size:12px;letter-spacing:1px}#modal-buttons .secondary{font-size:10px;letter-spacing:1px}.result-stats{margin:10px 0;gap:30px}.result-stats b{font-size:22px}
 .title-copy{top:17%}h1{font-size:64px;line-height:1.2}.title-copy .eyebrow{font-size:8px}.title-copy .story{font-size:10px;line-height:1.8;margin:8px 0 8px}.title-copy .subtitle{font-size:15px;margin:4px 0 10px}.title-copy .start-hint{margin-top:9px}.title-copy .best{display:none}.title-copy .chapters{flex-direction:row;flex-wrap:wrap;width:min(420px,80vw);gap:6px;margin:0 0 8px}.title-copy .chapter{grid-template-columns:1fr;gap:2px;padding:3px 6px;min-width:0}.title-copy .chapter-tag{display:none}.vertical-poem .seal{margin-top:115px}
}
#skills{position:absolute;left:50%;bottom:50px;transform:translateX(-50%);display:flex;gap:8px;z-index:3}
button.skill{font:inherit;color:inherit;cursor:pointer;transition:none}button.skill:hover{transform:none}.skill{position:relative;width:58px;height:66px;overflow:hidden;display:flex;flex-direction:column;align-items:center;padding:11px 3px 3px;background:#eee8dacf;border:1px solid var(--line)}
.skill.dim{opacity:.42}
.skill-icon{position:relative;width:32px;height:32px;display:grid;place-items:center}
.skill-hanja{font-size:11px;font-weight:500;letter-spacing:0;line-height:1;color:var(--ink)}
.skill-icon img{position:absolute;inset:0;width:100%;height:100%;object-fit:contain}
.skill-icon img.missing{display:none}
.skill kbd{position:absolute;top:2px;left:3px;min-width:13px;padding:0 3px;border:1px solid #a34c3855;background:#eee8daee;color:var(--red);font:700 9px Arial,sans-serif;line-height:1.35;text-align:center}
.skill em{margin-top:3px;font-style:normal;font-size:9px;letter-spacing:0;color:var(--ink);white-space:nowrap}
.skill-cd{position:absolute;left:0;right:0;bottom:0;height:0;background:#273e3bcc;pointer-events:none}
.skill-cd-text{position:absolute;inset:0;display:grid;place-items:center;z-index:1;color:#f4edde;font:600 12px Arial,sans-serif;text-shadow:0 1px 2px #213a34;pointer-events:none}
@media(pointer:coarse) and (orientation:landscape){
 header{padding:10px calc(22px + env(safe-area-inset-right)) 0 calc(22px + env(safe-area-inset-left))}
 .player-hud{top:40px;left:calc(16px + env(safe-area-inset-left));width:148px}
 .hud-label{font-size:13px;margin-bottom:3px;letter-spacing:3px}
 #health{margin-bottom:3px;gap:6px}
 .qi-track{width:132px}
 .qi-label{margin-top:3px}
 .chapter-hud{top:44px;right:calc(16px + env(safe-area-inset-right));gap:3px}
 .chapter-hud b{font-size:18px;letter-spacing:4px}
 .chapter-hud small{max-width:160px}
 #hits{top:auto;bottom:0;right:calc(100% + 8px)}
 #hits b{font-size:28px}
 #hits i{font-size:12px;letter-spacing:2px}
 .bottom-hud{left:calc(42% + 8px);right:calc(158px + env(safe-area-inset-right));bottom:calc(8px + env(safe-area-inset-bottom));gap:10px;font-size:10px}
 #skills{left:auto;right:calc(14px + env(safe-area-inset-right));bottom:calc(164px + env(safe-area-inset-bottom));transform:none;pointer-events:auto;z-index:6}
 .skill{pointer-events:auto;touch-action:none;user-select:none}
 #boss-hud{left:44%;width:min(240px,28%);transform:none;bottom:calc(228px + env(safe-area-inset-bottom))}
}
@media(pointer:coarse) and (orientation:landscape) and (max-height:480px){
 #touch{right:calc(10px + env(safe-area-inset-right));bottom:calc(8px + env(safe-area-inset-bottom))}
 #skills{bottom:calc(158px + env(safe-area-inset-bottom));gap:5px}
 .skill{width:46px;height:52px;padding:8px 2px 2px}
 .skill-icon{width:24px;height:24px}
 .skill-hanja{font-size:9px}
 .skill em{font-size:8px;margin-top:1px}
 .skill-cd-text{font-size:10px}
 #boss-hud{bottom:calc(218px + env(safe-area-inset-bottom));width:min(220px,26%)}
 #boss-hud>span{font-size:10px}
 #boss-hud b{font-size:15px;margin-left:8px}
 #boss-hud>div{margin-top:6px;height:3px}
}
@media(max-width:600px) and (orientation:portrait){
 #skills{gap:5px}
 .skill{width:48px;height:56px;padding:9px 2px 2px}
 .skill-icon{width:26px;height:26px}
 html,body,#app{overflow:hidden}
}
/* Combo counter hangs under the chapter card so it never sits on the fight chrome. */
#hits{position:absolute;right:0;top:calc(100% + 8px);display:flex;align-items:baseline;justify-content:flex-end;gap:5px;opacity:0;transition:opacity .5s ease;pointer-events:none;isolation:isolate;transform-origin:right center}
#hits.show{opacity:1}
#hits.pop{animation:hits-pop .3s cubic-bezier(.16,1.4,.4,1)}
#hits b{font-size:54px;font-weight:900;line-height:.88;letter-spacing:1px;color:var(--red);text-shadow:1px 1px 0 #f4eddb88}
#hits i{font-style:normal;font-size:22px;letter-spacing:4px;color:var(--red);font-weight:500}
@keyframes hits-pop{0%{transform:scale(1.3)}68%{transform:scale(.96)}100%{transform:scale(1)}}
@media(prefers-reduced-motion:reduce){#hits{transition:opacity .2s}#hits.pop{animation:none}}

/* Keep combat notices readable without masking the left-side action. */
#toast{width:max-content;line-height:1.55;background:#eee8da61;backdrop-filter:none;-webkit-backdrop-filter:none;box-shadow:0 3px 12px #273e3b0d}
#toast.two-line{white-space:pre-line}
#hint{top:auto;left:50%;right:auto;bottom:124px;width:min(520px,48%);padding:0;transform:translateX(-50%);z-index:4;line-height:1.5;font-weight:700}
@media(max-height:650px){#hits b{font-size:40px}}
@media(pointer:coarse){#hint{bottom:148px}}
@media(pointer:coarse) and (max-height:480px){#hits b{font-size:28px}#hits i{font-size:12px;letter-spacing:2px}#hint{font-size:10px;letter-spacing:1px}}
@media(max-width:600px) and (orientation:portrait){#hits b{font-size:36px}#hits i{font-size:13px}}
@media(pointer:coarse) and (orientation:landscape){
 #hits{top:auto;bottom:0;right:calc(100% + 8px)}
}

/* Night chapters flip the HUD to light ink on dark paper so text stays readable over the burning temple. */
body[data-theme=night]{--ink:#f1e3cd;--muted:#c9b4a0;--paper:#1c1411;--red:#e0664a;--line:#f1e3cd33;color:var(--ink)}
body[data-theme=night] #toast{background:#1c141161;color:var(--ink)}
body[data-theme=night] #hint{color:#f1e3cd;text-shadow:0 1px 8px #1c1411}
body[data-theme=night] .skill,body[data-theme=night] #touch button{background:#2a1c16cf;color:var(--ink);border-color:#f1e3cd44}
body[data-theme=night] .qi-track{background:#f1e3cd30}
body[data-theme=night] #progress{background:#e0a36a}
body[data-theme=night] .progress-track{background:#f1e3cd30}
body[data-theme=night] #boss-hud>div{background:#e0664a30}
body[data-theme=night] #hits{color:var(--red)}
body[data-theme=night] .icon-button{color:var(--ink)}
body[data-theme=night] .brand{color:var(--ink)}
body[data-theme=night] .modal-paper{color:#273e3b}
body[data-theme=night] .modal-paper h2,body[data-theme=night] .result-stats b{color:#273e3b}
body[data-theme=night] .modal-paper .primary{background:#273e3b;border-color:#273e3b;color:#f4edde}
body[data-theme=night] .modal-paper .secondary{color:#516256}
body[data-theme=night] .modal-paper .controls kbd{color:#273e3b}
body[data-theme=night] .modal-paper .eyebrow{color:#a34c38}
/* The snow ridge is nearly white, so the HUD gets a denser paper wash and darker ink to stay legible. */
body[data-theme=snow]{--ink:#1f2b31;--muted:#4c5a63;--red:#9b3b2e;--line:#1f2b3140}
body[data-theme=snow] #hint{color:#1f2b31;text-shadow:0 0 6px #ffffff,0 0 14px #ffffff,0 1px 2px #ffffff}
body[data-theme=snow] #toast{background:#eef1f561;color:#1f2b31}
body[data-theme=snow] .skill,body[data-theme=snow] #touch button{background:#eef1f5e6;border-color:#1f2b3155}
body[data-theme=snow] .qi-track{background:#1f2b3138}#qi{position:relative}
body[data-theme=snow] .qi-label,body[data-theme=snow] .hud-label,body[data-theme=snow] .chapter-hud small,body[data-theme=snow] .bottom-hud{color:#1f2b31}
body[data-theme=snow] .progress-track{background:#1f2b3138}
body[data-theme=snow] #hits{text-shadow:0 0 10px #ffffff}
/* River mist: cool gray-green paper so HUD ink stays readable over wet cliffs. */
body[data-theme=mist]{--ink:#2a3d3a;--muted:#5a6e68;--paper:#e4ebe8;--red:#a34c38;--line:#2a3d3a40;color:var(--ink)}
body[data-theme=mist] #hint{color:#2a3d3a;text-shadow:0 0 6px #e4ebe8,0 1px 2px #d5e0dc}
body[data-theme=mist] #toast{background:#e4ebe861;color:#2a3d3a}
body[data-theme=mist] .skill,body[data-theme=mist] #touch button{background:#e4ebe8e6;border-color:#2a3d3a44}
body[data-theme=mist] .qi-track{background:#2a3d3a30}
body[data-theme=mist] #qi{background:#4a6e78}
body[data-theme=mist] .qi-label,body[data-theme=mist] .hud-label,body[data-theme=mist] .chapter-hud small,body[data-theme=mist] .bottom-hud{color:#2a3d3a}
body[data-theme=mist] .progress-track{background:#2a3d3a30}
body[data-theme=mist] #progress{background:#4a6e78}
body[data-theme=mist] #hits{text-shadow:0 0 8px #e4ebe8}
/* Dawn shrine: warm ivory paper and darker brown ink over gold cloud haze. */
body[data-theme=dawn]{--ink:#3a3228;--muted:#7a6b55;--paper:#f3ead6;--red:#c45a3a;--line:#3a322840;color:var(--ink)}
body[data-theme=dawn] #hint{color:#3a3228;text-shadow:0 0 6px #fbf6ea,0 1px 2px #efe4c8}
body[data-theme=dawn] #toast{background:#f3ead661;color:#3a3228}
body[data-theme=dawn] .skill,body[data-theme=dawn] #touch button{background:#f3ead6e8;border-color:#3a322844}
body[data-theme=dawn] .qi-track{background:#3a322830}
body[data-theme=dawn] #qi{background:#c45a3a}
body[data-theme=dawn] .qi-label,body[data-theme=dawn] .hud-label,body[data-theme=dawn] .chapter-hud small,body[data-theme=dawn] .bottom-hud{color:#3a3228}
body[data-theme=dawn] .progress-track{background:#3a322830}
body[data-theme=dawn] #progress{background:#c45a3a}
body[data-theme=dawn] #hits{text-shadow:0 0 8px #fbf6ea}
.music-credit{white-space:normal;line-height:1.7}.music-credit a{color:inherit}
/* Landscape phones (height ≤ 480px): five chapter slots plus the start button stay on one screen. */
@media(max-height:480px){.title-copy{top:12%;left:6%;right:6%}.title-copy .eyebrow{display:none}h1{font-size:40px;line-height:1.1;margin:4px 0 0;letter-spacing:6px}.hanja{font-size:13px;letter-spacing:4px;margin-left:8px}.subtitle,.story,.fine-rule,.start-hint,.best,.vertical-poem,.title-bottom{display:none}#chapters,.title-copy .chapters{display:flex;flex-direction:row;flex-wrap:nowrap;width:min(680px,92vw);max-width:none;gap:4px;margin:6px 0 8px}.title-copy .chapter,.chapter{flex:1 1 0;min-width:0;display:grid;grid-template-columns:1fr;gap:1px;padding:4px 3px;border-left:0;border-bottom:2px solid transparent;text-align:center}.chapter.on{border-bottom-color:var(--red)}.chapter-num{font-size:8px;letter-spacing:1px;min-width:0}.chapter-title{font-size:11px;letter-spacing:1px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chapter-tag{display:none}.chapter-lock{font-size:9px}.primary{padding:9px 18px;min-width:180px;font-size:12px;gap:24px}}
@media(max-height:480px) and (max-width:760px){.title-copy{top:10%}h1{font-size:34px;letter-spacing:4px;margin:2px 0 0}.hanja{font-size:11px;letter-spacing:3px;margin-left:6px}#chapters,.title-copy .chapters{width:min(700px,94vw);gap:3px;margin:4px 0 6px}.chapter-num{font-size:7px;letter-spacing:0}.chapter-title{font-size:10px;letter-spacing:0}.primary{min-width:156px;padding:8px 14px;font-size:11px;gap:16px}}
@media(max-height:380px){.title-copy{top:8%}h1{font-size:30px}#chapters,.title-copy .chapters{margin:3px 0 5px}.primary{padding:7px 12px}}
/* Keep controls legible where the gorge painting has dark branches in its upper corners. */
body[data-theme=mist] header{background:linear-gradient(#e4ebe8d9,#e4ebe800);text-shadow:0 1px 5px #e4ebe8}
/* Chapter selection changes labels below this button, never its position. */
#start{margin-bottom:12px}#start:hover{transform:none}
@media(min-height:651px){.title-copy{top:14%}h1{font-size:clamp(76px,14vh,126px)}.title-copy .chapter{padding-top:5px;padding-bottom:5px}}
@media(max-height:480px){#start{margin-bottom:4px}}
@media(min-height:651px) and (max-height:800px){.title-copy{top:12%}h1{font-size:84px}.title-copy .story{margin:12px 0}.title-copy .subtitle{margin-bottom:16px}.title-copy .start-hint,.title-copy .best{display:none}}

/* Keep dialog actions in view; only the long instructions and credits scroll. */
.modal{padding:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))}
.modal-paper{display:flex;flex-direction:column;max-height:100%;min-height:0;overflow:hidden}
.modal-paper>.eyebrow,.modal-paper>h2,#modal-buttons{flex-shrink:0}
#modal-content{min-height:0;overflow-y:auto;overscroll-behavior:contain}
#modal-buttons{flex-wrap:wrap}
#modal-buttons button{min-height:44px}
.pause-menu #modal-buttons{margin:0 0 16px}
@media(max-height:500px){.pause-menu #modal-buttons{margin-bottom:12px}}

.art-loading{position:absolute;inset:0;z-index:20;display:grid;place-items:center;background:#eee8dae8;backdrop-filter:blur(6px);color:#273e3b;text-align:center}
.loading-card{padding:24px}.loading-card p{margin:18px 0 8px;font-size:18px;letter-spacing:4px}.loading-card small{font-size:11px;letter-spacing:2px;color:#5b695e}
.loading-spinner{display:block;margin:auto;width:40px;height:40px;border:3px solid #273e3b25;border-top-color:#a34c38;border-radius:50%;animation:art-loading-spin 1s linear infinite}
@keyframes art-loading-spin{to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){.loading-spinner{animation-duration:3s}}

/* The journey button stays above a scrollable chapter index. */
#chapters,.title-copy #chapters{display:grid;grid-template-columns:1fr 1fr;gap:3px 8px;max-height:210px;overflow-y:auto;width:min(520px,80vw);margin-bottom:8px}
.title-copy .chapter{grid-template-columns:auto 1fr auto;gap:5px;padding:6px}.title-copy .chapter-tag{display:none}.title-copy .chapter-title{font-size:12px;letter-spacing:2px}.title-copy .chapter-num{font-size:9px;letter-spacing:1px}
.world-map{z-index:8;background:#eee8daf5;color:#273e3b;padding:28px max(28px,env(safe-area-inset-right)) 20px max(28px,env(safe-area-inset-left));display:flex;flex-direction:column;gap:14px}
.map-heading{display:flex;align-items:center;justify-content:space-between;flex-shrink:0}.map-heading h2{font-size:32px;font-weight:500;letter-spacing:7px;margin:6px 0 0}.map-heading .eyebrow{font-size:9px;color:#7b6552;letter-spacing:3px}.world-map .secondary{color:#516256;min-height:44px}
.map-controls{display:flex;align-items:center;gap:15px;border-top:1px solid #273e3b30;border-bottom:1px solid #273e3b30;padding:14px 0;flex-shrink:0}.map-destination{flex:1;display:grid;gap:7px}.map-destination b{font-size:18px;font-weight:500;letter-spacing:2px}.map-destination span{font-size:11px;line-height:1.7;color:#637368}.map-step{width:44px;height:44px;flex-shrink:0;background:#e6dfce;border:1px solid #273e3b40;color:#273e3b;font-size:22px}.map-step:disabled{opacity:.3;cursor:default}.world-map .primary{min-width:170px;background:#273e3b;border-color:#273e3b;color:#f4edde;padding:13px 18px;justify-content:center;font-size:12px;letter-spacing:2px}
.map-status{margin:0;font-size:11px;color:#6a715e;letter-spacing:1px;flex-shrink:0}.map-scroll{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:8px 12px 22px}#map-chapters{max-width:1050px;margin:auto}.map-region{position:relative;padding:18px 28px 24px;margin-bottom:14px;background:linear-gradient(90deg,#eee8daf2,#eee8dabd),var(--map-art) center 45%/cover;border:1px solid #273e3b20;border-radius:2px}.map-region h3{font-weight:500;margin:0 0 24px;font-size:14px;letter-spacing:3px;color:#46564b}.map-region h3 span{font-size:9px;color:#947c63;margin-right:14px}.map-path{display:flex;position:relative;justify-content:space-between;gap:10px}.map-region:nth-child(even) .map-path{flex-direction:row-reverse}.map-path::before{content:'';position:absolute;left:8%;right:8%;top:24px;border-top:2px dashed #66775c80}.map-node{position:relative;z-index:1;flex:1;max-width:160px;min-height:78px;padding:10px 4px 5px;display:flex;flex-direction:column;align-items:center;gap:7px;border:0;background:transparent;color:#273e3b}.map-node:hover{transform:none}.map-node b{display:grid;place-items:center;width:48px;height:48px;background:#f5efdf;border:1px solid #64715f;border-radius:50%;font:600 13px Arial,sans-serif;box-shadow:0 0 0 5px #eee8da}.map-node span{font-size:10px;letter-spacing:1px;white-space:nowrap}.map-node.boss b{border-radius:4px;border:2px solid #a34c38;color:#963e30}.map-node.cleared b{background:#d5dfcb}.map-node.locked{opacity:.35}.map-node.current b{background:#273e3b;color:#f3ebd8;border-color:#273e3b}.map-node:disabled{cursor:default}.map-node .map-traveller{position:absolute;top:-16px;width:29px;height:29px;display:grid;place-items:center;background:#a34c38;color:#fff4de;font-style:normal;font-size:16px;border-radius:2px;box-shadow:2px 2px #273e3b30}.map-node .map-traveller::after{content:'';position:absolute;bottom:-5px;border:5px solid transparent;border-top-color:#a34c38;border-bottom:0}
.map-node b{position:relative;overflow:hidden}
.map-boss-portrait{position:absolute;inset:0;background:#ded5c3;overflow:hidden}
.map-boss-portrait img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.map-boss-portrait:not(.sprite) img{transform:scale(1.4);transform-origin:50% 30%}
.map-boss-portrait.sprite img{left:-50%;top:-50%;width:1200%;height:800%;max-width:none;object-fit:fill}
.map-boss-node em{position:absolute;right:2px;bottom:2px;z-index:1;padding:1px 2px;background:#eee8dad9;color:#7d3026;font:700 8px Arial,sans-serif;font-style:normal;line-height:1}
.map-node.cleared:not(.boss) b{background:#d5dfcb}
.map-node.cleared .map-boss-portrait{filter:saturate(.72)}
.map-node.current:not(.boss) b{background:#273e3b;color:#f3ebd8;border-color:#273e3b}
.map-node.current.boss b{border-color:#273e3b;box-shadow:0 0 0 5px #273e3b}
#objectives-list{margin:2px 0 0;padding:0;list-style:none;font-size:11px;line-height:1.9;color:var(--ink);max-width:310px}#objectives-list li.done{opacity:.55;text-decoration:line-through}#objective{max-width:310px}
.dialogue{position:absolute;inset:0;z-index:12;background:linear-gradient(transparent 20%,#17201bdd);display:flex;align-items:flex-end;padding:32px max(24px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left))}.dialogue-paper{width:min(1000px,100%);margin:0 auto;display:flex;align-items:flex-end;gap:26px;background:#eee8daf5;border:1px solid #c0b69a;box-shadow:8px 8px #111a1833;min-height:235px;padding:22px 30px;color:#273e3b}#dialogue-portrait{position:static;inset:auto;width:180px;height:190px;object-fit:contain;flex-shrink:0}.dialogue-body{flex:1;min-width:0}#dialogue-kicker{font-size:9px;letter-spacing:3px;color:#9b503c}#dialogue-speaker{font-size:23px;font-weight:500;letter-spacing:4px;margin:8px 0 13px}#dialogue-text{font-size:16px;line-height:2;letter-spacing:1px;min-height:64px;margin:0;word-break:keep-all}.dialogue-actions{display:flex;justify-content:space-between;align-items:center;margin-top:18px;gap:16px}#dialogue-count{font:11px Arial,sans-serif;color:#7b7668}.dialogue .primary{min-width:160px;min-height:44px;padding:10px 16px;background:#273e3b;color:#f4edde;border-color:#273e3b;font-size:12px;letter-spacing:2px}
#touch .touch-interact{width:54px;height:44px;right:84px;bottom:82px;border-radius:8px;font-size:11px;pointer-events:auto}.touch-interact:disabled{opacity:.3}
#touch .touch-dash{font-size:11px;letter-spacing:0}
@media(max-height:600px){.world-map{padding:14px 20px;gap:7px}.map-heading h2{font-size:22px}.map-heading .eyebrow{font-size:8px}.map-controls{padding:8px 0;gap:9px}.map-destination b{font-size:14px}.map-destination span{font-size:9px}.map-region{padding:12px 16px 15px}.map-region h3{margin-bottom:19px;font-size:12px}.map-node span{font-size:9px}.map-status{font-size:9px}.dialogue{padding:12px}.dialogue-paper{padding:15px 20px;min-height:170px;gap:18px}#dialogue-portrait{width:126px;height:146px}#dialogue-speaker{font-size:18px;margin:4px 0 8px}#dialogue-text{font-size:13px;min-height:45px;line-height:1.85}.dialogue-actions{margin-top:10px}.chapter-hud #objectives-list{font-size:9px;line-height:1.65;max-width:240px}.chapter-hud>small{font-size:9px}}
@media(max-height:480px){#chapters,.title-copy #chapters{grid-template-columns:repeat(5,1fr);max-height:126px;width:min(680px,90vw)}.title-copy .chapter{display:flex;flex-direction:column;padding:4px;gap:1px}.title-copy .chapter-title{font-size:10px;letter-spacing:0}.title-copy .chapter-num{font-size:8px}.map-controls .primary{min-width:120px;padding:11px 9px;font-size:10px}.map-destination span{max-width:300px}.map-status{letter-spacing:0}.map-scroll{padding:6px 2px 12px}}
@media(max-width:600px) and (orientation:portrait){.map-controls{flex-wrap:wrap}.map-destination{min-width:180px}.map-controls .primary{width:100%}.world-map{padding:20px 12px}.map-region{padding:15px 7px}.map-node span{font-size:8px;white-space:normal}.map-node b{width:39px;height:39px}.map-path{gap:3px}.map-path::before{top:28px}.dialogue-paper{gap:8px;padding:12px}#dialogue-portrait{width:75px;height:130px}#dialogue-text{font-size:12px}.dialogue .primary{min-width:125px}}
@media(prefers-reduced-motion:reduce){.map-node,.map-traveller{animation:none!important;transition:none!important}}

.map-actions{display:flex;align-items:center;flex-wrap:wrap;justify-content:flex-end;gap:10px}.map-actions .icon-button{min-width:40px;min-height:44px;color:#273e3b;flex-shrink:0}.map-actions .muted{opacity:.45}.map-actions .secondary{flex-shrink:0}

/* Stage stars, account achievements, and the independent top-right unlock toast. */
.stage-stars{display:inline-flex;align-items:center;justify-content:center;gap:2px;color:var(--red);font-size:13px;line-height:1;letter-spacing:1px;white-space:nowrap}
.stage-stars .star{font-style:normal}
.stage-stars .star.empty{opacity:.28;color:var(--ink)}
.stage-stars .star.half{position:relative;color:#273e3b47}
.stage-stars .star.half::after{content:'★';position:absolute;inset:0 auto 0 0;width:50%;overflow:hidden;color:var(--red)}
.stage-stars.unrated{display:grid;gap:2px;white-space:normal;text-align:center;color:var(--muted);font-size:10px;letter-spacing:0;line-height:1.45}
.stage-stars.unrated .unrated-copy{max-width:11em}
.map-node .stage-stars{margin-top:2px;font-size:11px}
.map-destination .stage-stars{justify-content:flex-start;margin-top:2px}
.result-stats .stage-stars{justify-content:center;margin-top:6px;font-size:18px}
.clear-rating{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:8px;margin:12px 0;color:#273e3b}
.clear-rating>.stage-stars{font-size:24px}
.clear-rating>strong{font-size:16px;font-weight:500}
.clear-rating>small{width:100%;font-size:10px;line-height:1.7;color:#637368}
.rank-guide{display:flex;flex-wrap:wrap;justify-content:center;gap:2px 12px;margin-top:4px}
.rank-guide>span{white-space:nowrap}

#achievement-toast{position:absolute;top:max(10px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right));left:auto;z-index:16;max-width:min(240px,34vw);padding:8px 12px;background:#eee8dae8;border-right:2px solid var(--red);font-size:12px;letter-spacing:1px;opacity:0;visibility:hidden;transition:opacity .35s;pointer-events:none;text-align:left;line-height:1.45;isolation:isolate;box-shadow:0 0 0 #d3a44b00}
#achievement-toast.show{opacity:1;visibility:visible;animation:achievement-glow 1.1s ease-out}
.achievement-sparkles{position:absolute;inset:-10px;z-index:2;pointer-events:none}
.achievement-sparkles::before,.achievement-sparkles::after{content:'✦';position:absolute;color:#d69f21;text-shadow:0 0 3px #fff,0 0 9px #ffe89a;font:20px Arial,sans-serif;opacity:0;animation:achievement-spark 1.25s ease-out}
.achievement-sparkles::before{top:6px;left:2px;animation-delay:.08s}
.achievement-sparkles::after{right:2px;bottom:5px;font-size:15px;animation-delay:.28s}
@keyframes achievement-glow{0%{box-shadow:0 0 0 #d3a44b00}30%{box-shadow:0 0 24px 6px #d3a44b99}100%{box-shadow:0 0 0 #d3a44b00}}
@keyframes achievement-spark{0%{opacity:0;transform:scale(.25) rotate(0)}25%{opacity:1}100%{opacity:0;transform:translateY(-18px) scale(1.25) rotate(65deg)}}
#achievement-toast strong{display:block;font-size:9px;font-weight:500;letter-spacing:2px;color:var(--red)}
#achievement-toast b{display:block;margin:3px 0 2px;font-size:13px;font-weight:500;letter-spacing:1px}
#achievement-toast span{display:block;font-size:11px;letter-spacing:0;color:#5b695e}
body[data-theme=night] #achievement-toast{background:#1c1411e8;color:var(--ink)}
body[data-theme=night] #achievement-toast span{color:var(--muted)}
body[data-theme=snow] #achievement-toast{background:#eef1f5f2;color:#1f2b31}
body[data-theme=snow] #achievement-toast span{color:#5a6a72}
body[data-theme=mist] #achievement-toast{background:#e4ebe8f2;color:#2a3d3a}
body[data-theme=mist] #achievement-toast span{color:#5b6d68}
body[data-theme=dawn] #achievement-toast{background:#f3ead6f2;color:#3a3228}
body[data-theme=dawn] #achievement-toast span{color:#6b5d4c}

#modal.achievements-menu .modal-paper{width:min(720px,100%);height:min(100%,820px);text-align:left}
#modal.achievements-menu .modal-paper h2{letter-spacing:4px}
#modal.achievements-menu #modal-content{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;text-align:left}
#modal.achievements-menu #modal-buttons{flex-shrink:0;margin-top:14px}
#modal.achievements-menu #modal-content:focus-visible{outline:1px solid var(--red);outline-offset:-1px}
.achievement-board{display:grid;gap:10px}
.achievement-summary{margin:0;font-size:13px;letter-spacing:2px;color:var(--ink)}
.achievement-summary b{font-weight:500;color:var(--red)}
.achievement-storage{margin:0;font-size:11px;letter-spacing:1px;color:#7b7668}
.achievement-cards{display:grid;gap:8px;margin:0;padding:0;list-style:none}
.achievement-card{display:grid;gap:4px;padding:10px 12px;border:1px solid #273e3b20;background:#f4eddb73;text-align:left}
.achievement-card.done{background:#dfe6d373;border-color:#273e3b18}
.achievement-card-head{display:flex;justify-content:space-between;align-items:baseline;gap:10px}
.achievement-card-head b{font-size:14px;font-weight:500;letter-spacing:1px;color:var(--ink)}
.achievement-state{flex-shrink:0;font-size:10px;letter-spacing:1px;color:var(--red)}
.achievement-card.done .achievement-state{color:#3f5a46}
.achievement-desc{margin:0;font-size:11px;line-height:1.55;letter-spacing:0;color:#5b695e}

@media(max-height:480px){
 .top-actions{gap:10px;flex-wrap:wrap;justify-content:flex-end}
 .map-actions{gap:6px}
 .map-actions .icon-button{min-width:36px;min-height:40px;font-size:16px}
 .world-map .secondary{padding:6px 10px;font-size:11px;letter-spacing:1px}
 #achievement-toast{top:max(6px,env(safe-area-inset-top));right:max(8px,env(safe-area-inset-right));max-width:min(220px,32vw);padding:5px 9px}
 #achievement-toast strong{font-size:8px}
 #achievement-toast b{font-size:11px;margin:1px 0}
 #achievement-toast span{font-size:10px}
 #modal.achievements-menu .modal-paper{padding:12px 16px;height:100%}
 #modal.achievements-menu .modal-paper h2{font-size:20px;margin:4px 0 8px;letter-spacing:3px}
 .achievement-cards{grid-template-columns:1fr 1fr;gap:6px}
 .achievement-card{padding:6px 8px;gap:2px}
 .achievement-card-head b{font-size:12px}
 .achievement-desc{font-size:10px;line-height:1.4}
}
@media(max-height:400px){
 #modal.achievements-menu .modal-paper{padding:10px 12px}
 #modal.achievements-menu .modal-paper h2{font-size:18px;margin:2px 0 6px}
 #modal.achievements-menu #modal-buttons{margin-top:8px}
 .map-destination .stage-stars,.map-node .stage-stars{font-size:10px}
 .stage-stars.unrated{font-size:9px}
}
@media(prefers-reduced-motion:reduce){
 #achievement-toast{transition:none}
 #achievement-toast.show,.achievement-sparkles::before,.achievement-sparkles::after{animation:none}
}
