@charset "UTF-8";
:root{color-scheme:dark;--ink:#eef2ed;--muted:#b6c4c6;--gold:#e2c99d;--blue:#b0eeff;--line:rgba(216,232,227,.22);font-family:"PingFang SC","Microsoft YaHei",system-ui,sans-serif;background:#071015;color:var(--ink)}
*{box-sizing:border-box}body{margin:0}button,a{-webkit-tap-highlight-color:transparent}button{font:inherit;cursor:pointer}a{color:inherit;text-decoration:none}button:focus-visible,a:focus-visible,canvas:focus-visible{outline:2px solid #def7ff;outline-offset:5px}button:disabled{cursor:default}.scene{position:relative;width:100%;min-height:100svh;height:100dvh;overflow:hidden;isolation:isolate;background:#17232a}.backdrop,.veil,#magic{position:absolute;inset:0;width:100%;height:100%}.backdrop{z-index:-3;background:url('assets/hogwarts-courtyard-v2.webp') center 58%/cover no-repeat;transform:scale(1.025);transition:filter 2.2s,transform 4s;filter:brightness(.64) saturate(.5)}.veil{z-index:-2;background:linear-gradient(180deg,rgba(3,13,20,.62),rgba(10,23,32,.16) 38%,rgba(2,10,16,.12) 58%,rgba(4,12,17,.89));pointer-events:none}#magic{z-index:-1;pointer-events:none;touch-action:none}header{position:absolute;top:0;left:0;right:0;z-index:5;display:flex;align-items:center;justify-content:space-between;padding:calc(23px + env(safe-area-inset-top)) 24px 0}.brand{display:flex;gap:10px;align-items:center}.brand img{width:33px;height:33px}.brand span{font:16px/1.5 "Songti SC","STSong","SimSun",serif;letter-spacing:.15em}.brand small{display:block;letter-spacing:.22em;font:8px/1.8 Georgia,serif;color:var(--gold)}.sound{background:rgba(8,25,36,.28);border:1px solid var(--line);border-radius:50%;width:42px;height:42px;display:grid;place-items:center;color:#d5e1e0}.sound svg{width:19px;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}.sound-waves{display:none}.sound[aria-pressed=true] .sound-waves{display:block}.sound[aria-pressed=true] .sound-off{display:none}main{position:relative;height:100%;pointer-events:none}main button,main a,main input{pointer-events:auto}footer{position:absolute;bottom:calc(18px + env(safe-area-inset-bottom));left:20px;right:20px;text-align:center;font:11px/1.8 "Songti SC","STSong",serif;letter-spacing:.16em;color:#aab6b8;z-index:2;pointer-events:none}.eyebrow{font:10px/1.8 Georgia,"Songti SC",serif;letter-spacing:.26em;color:var(--gold);margin:0 0 16px}.serif{font-family:"Songti SC","STSong","SimSun",serif;font-weight:400}h1,h2,p{margin-top:0}h1{font-size:clamp(36px,9.8vw,52px);line-height:1.5;letter-spacing:.08em;font-weight:400;margin-bottom:16px;text-shadow:0 3px 30px #091a29}h1 em{font-style:normal;color:var(--gold)}.intro{position:absolute;inset:16% 22px auto;text-align:center}.intro .desc{font-size:12px;line-height:2;letter-spacing:.12em;color:#c4d1d2}.gate-bottom{position:absolute;left:28px;right:28px;bottom:calc(73px + env(safe-area-inset-bottom));text-align:center}.cta{width:100%;min-height:57px;border:1px solid rgba(239,215,173,.75);border-radius:3px;background:linear-gradient(110deg,#dbc59c,#f1dfbb 55%,#cfb489);color:#28302e;font:17px/1.5 "Songti SC","STSong",serif;letter-spacing:.12em;box-shadow:0 5px 35px #0004;position:relative}.cta:hover{filter:brightness(1.08)}.cta:active{transform:translateY(1px)}.cta .arrow{position:absolute;right:20px;font:24px/1 Georgia}.hint{font-size:11px;line-height:1.8;letter-spacing:.08em;color:#c6d2d1;margin:12px 0 0}.decor-orbit{position:absolute;width:98px;height:98px;border:1px solid #c5e7ee44;border-radius:50%;left:calc(50% - 49px);top:51%;display:grid;place-items:center;box-shadow:0 0 80px #90d9ef11,inset 0 0 60px #b5f4ff08}.decor-orbit:before,.decor-orbit:after{content:"";position:absolute;inset:10px;border:1px dashed #d9d5b53d;border-radius:50%;transform:rotate(25deg)}.decor-orbit:after{inset:-10px;border-style:solid;border-color:transparent #b6dfea33;animation:orbit 20s linear infinite}.decor-orbit img{width:45px;filter:drop-shadow(0 0 9px #8ad8e6)}
.guide{position:absolute;top:20%;left:25px;right:25px}.guide h1{font-size:34px;line-height:1.55;margin-bottom:22px}.guide .eyebrow{margin-bottom:8px}.steps{list-style:none;margin:0 0 27px;padding:0;display:grid;gap:18px}.steps li{display:flex;gap:13px;align-items:center;font-size:13px;line-height:1.8;color:#e1e8e6}.step-no{flex-shrink:0;width:26px;height:26px;border:1px solid #d2bd953e;border-radius:50%;display:grid;place-items:center;color:var(--gold);font:13px Georgia}.steps b{font-weight:500;color:#f1dcb5}.guide .cta{font-size:15px}.guide .hint{text-align:center}.copy-field{margin-top:12px;width:100%;min-height:40px;background:#091620d9;border:1px solid var(--line);border-radius:3px;color:#d1e5e8;padding:8px;font-size:12px;pointer-events:auto}.guide-title-star{position:absolute;right:0;top:10px;width:50px;opacity:.5}.back-button{position:absolute;left:24px;bottom:calc(62px + env(safe-area-inset-bottom));border:0;background:none;color:#b8c8c7;font-size:12px;padding:8px;pointer-events:auto}
.game-copy{position:absolute;left:20px;right:20px;top:calc(112px + env(safe-area-inset-top));text-align:center}.game-copy .eyebrow{margin:0 0 10px;font-size:9px}.game-copy h1{font-size:31px;line-height:1.55;margin-bottom:9px}.game-copy .desc{font-size:12px;color:#c3d8dd;letter-spacing:.05em;line-height:1.7}.game-copy h1 span{color:var(--gold)}.game-bottom{position:absolute;bottom:calc(70px + env(safe-area-inset-bottom));left:25px;right:25px;text-align:center}.gesture-label{font-size:13px;letter-spacing:.08em;color:#d7ecf0;margin:0 0 20px}.stage-track{display:flex;align-items:center;gap:10px;justify-content:center}.stage-track .dot{width:6px;height:6px;background:#809393;border-radius:50%;box-shadow:0 0 0 3px #80939312}.stage-track .dot.active{background:#d7edee;box-shadow:0 0 12px #b4ecff}.stage-track .line{width:38px;height:1px;background:#c3dadd45}.stage-track span{font-size:10px;color:#b4c5c6;letter-spacing:.1em}.stage-track .current{color:#e2d2af}.progress-caption{position:absolute;top:75%;left:20px;right:20px;text-align:center;font:11px/1.8 Georgia,"Songti SC",serif;letter-spacing:.18em;color:#d0edf2}.progress-caption b{font-size:20px;font-weight:400;color:#ecfaff}.tiny-tip{font-size:10px;color:#8ca5aa;letter-spacing:.05em;margin:15px 0 0}.game-mode #magic{z-index:1;pointer-events:auto}.game-mode main{z-index:2}.game-mode header{z-index:4}.game-mode .backdrop{filter:brightness(.55) saturate(.48)}.game-mode .veil{background:linear-gradient(180deg,#03101fd9 0%,#0d24344a 30%,#081a2922 60%,#06111cf2 100%)}
.success-mode .backdrop{filter:brightness(.95) saturate(.65);transform:scale(1)}.success-mode .veil{background:linear-gradient(180deg,#031019b5,#0c203422 45%,#06131be6)}.success-copy{position:absolute;left:20px;right:20px;top:18%;text-align:center}.success-copy h1{font-size:36px;line-height:1.5}.success-copy .desc{font:13px/2.1 "Songti SC","STSong",serif;color:#d4e9ed;letter-spacing:.07em}.result-note{position:absolute;left:24px;right:24px;bottom:calc(79px + env(safe-area-inset-bottom));text-align:center}.result-note .small-serif{font:14px/1.9 "Songti SC","STSong",serif;color:#d9e6e5;margin:0 0 25px;letter-spacing:.09em}.outline-button{border:1px solid #decea567;background:rgba(9,30,42,.6);color:#f1dfbb;padding:14px 30px;min-height:48px;border-radius:3px;font-size:13px;letter-spacing:.12em;backdrop-filter:blur(8px)}.toast{position:absolute;z-index:10;left:50%;bottom:120px;transform:translateX(-50%);width:max-content;max-width:88%;padding:12px 18px;background:#152a32f5;border:1px solid #cbe4e34d;border-radius:4px;text-align:center;font-size:12px;color:#edf4ef;pointer-events:none}.preview-nav{position:fixed;bottom:22px;left:24px;z-index:20;display:flex;gap:16px;align-items:center;color:#c9d3d4;font-size:11px}.preview-nav[hidden]{display:none}.preview-nav span{color:#778e94}.preview-nav a{padding:8px 0;border-bottom:1px solid #d1bb8d4f}.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.noscript{position:fixed;bottom:0;width:100%;background:#243c43;padding:20px;text-align:center}
@keyframes orbit{to{transform:rotate(385deg)}}
@media(min-width:700px){body{display:flex;min-height:100dvh;justify-content:center;align-items:center;background:radial-gradient(ellipse at center,#22343e,#050c11 70%)}.scene{width:min(480px,calc(100dvh * .61));min-width:340px;min-height:0;height:100dvh;max-height:1000px;box-shadow:0 0 130px #0009;border-left:1px solid #bacfd212;border-right:1px solid #bacfd212}h1{font-size:45px}.intro{top:15.5%}.guide{top:21%}}
@media(max-height:680px){header{padding-top:calc(15px + env(safe-area-inset-top))}.intro{top:16%}h1{font-size:32px;line-height:1.38}.intro .desc{font-size:11px}.gate-bottom{bottom:calc(57px + env(safe-area-inset-bottom))}.cta{min-height:48px}.decor-orbit{top:48%;width:76px;height:76px;left:calc(50% - 38px)}.guide{top:18%}.guide h1{font-size:28px;line-height:1.4;margin-bottom:17px}.steps{gap:12px;margin-bottom:20px}.game-copy{top:calc(83px + env(safe-area-inset-top))}.game-copy h1{font-size:26px;margin-bottom:4px}.game-copy .eyebrow{margin-bottom:4px}.game-bottom{bottom:calc(53px + env(safe-area-inset-bottom))}.gesture-label{margin-bottom:12px}.tiny-tip{display:none}.success-copy{top:17%}.success-copy h1{font-size:30px}.result-note{bottom:calc(58px + env(safe-area-inset-bottom))}footer{bottom:calc(12px + env(safe-area-inset-bottom));font-size:10px}}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important}}
/* V2: battlefield contrast and visible three-stage feedback */
.backdrop{background-position:center center;transform:scale(1.01);filter:brightness(.88) saturate(.76)}.veil{background:linear-gradient(180deg,#07101bcf 0%,#09132115 42%,#07132008 65%,#041019e8 100%)}.game-mode .backdrop{filter:brightness(.8) saturate(.75)}.game-mode .veil{background:linear-gradient(180deg,#03111de8 0%,#07132475 24%,#0713240d 40%,#07132410 65%,#041018e8 100%)}.scene[data-stage=trace-win] .backdrop,.scene[data-stage=shield-win] .backdrop{filter:brightness(1.05) saturate(.7)}.scene[data-stage=casting] .backdrop{filter:brightness(1.2) saturate(.65);transition:filter 1s}.success-mode .backdrop{filter:brightness(1.15) saturate(.85)}.success-mode .veil{background:linear-gradient(180deg,#031019bb,#12273805 45%,#06131bf0 100%)}.game-copy{top:calc(102px + env(safe-area-inset-top))}.game-copy h1{font-size:31px;letter-spacing:.02em}.game-copy .desc{font-size:12px;color:#d5e1e6;text-shadow:0 2px 12px #000}.game-bottom{bottom:calc(65px + env(safe-area-inset-bottom))}.game-bottom .gesture-label{font-size:13px;margin-bottom:18px;text-shadow:0 1px 8px #000}.stage-track{gap:9px}.stage-track span{display:flex;gap:5px;align-items:center;font-size:10px;letter-spacing:0;color:#99aeb7;white-space:nowrap}.stage-track span i{display:grid;place-items:center;width:18px;height:18px;border:1px solid #9ab8c34a;border-radius:50%;font:10px Georgia;font-style:normal}.stage-track .current{color:#f2dfb9}.stage-track .current i{background:#e8d3a9;color:#193039;box-shadow:0 0 16px #dbc48b55}.stage-track .done{color:#d2f6ff}.stage-track b{width:17px;height:1px;background:#c3dadd35}.progress-caption{top:75%;font-size:12px;display:flex;gap:14px;justify-content:center;align-items:center;letter-spacing:.08em;text-shadow:0 2px 10px #000}.progress-caption b{font-size:25px;line-height:1}.progress-caption small{font-size:12px;font-weight:400;margin-left:3px}.stage-seal{font:15px/1.5 "Songti SC","SimSun",serif;letter-spacing:.15em;color:#ddfaff;border:1px solid #b5e9fc66;background:#13313c99;padding:9px 18px;border-radius:3px;box-shadow:0 0 22px #a2e8ff22}.level-feedback{position:absolute;top:28%;left:20px;right:20px;text-align:center;opacity:0;font-size:14px;color:#f4e6c7;letter-spacing:.09em;text-shadow:0 0 14px #9bdfff}.level-feedback.show{animation:feedback 1.2s both}.scene[data-stage=trace-win] .level-feedback,.scene[data-stage=shield-win] .level-feedback{top:34%;font-size:21px;color:#e7fcff}.copy-status{min-height:24px;font-size:12px;line-height:1.8;color:#ddf8ed;text-align:center;margin:15px 0 0}.gate-sigil{position:absolute;left:calc(50% - 29px);top:54%;width:58px;height:58px;border:1px solid #dbefff44;transform:rotate(45deg);display:grid;place-items:center;box-shadow:0 0 30px #d6f6ff22}.gate-sigil span{transform:rotate(-45deg);color:#f3dfb8;font-size:30px;text-shadow:0 0 20px #a1e5ff}.gate-sigil i{position:absolute;inset:-9px;border:1px solid #dbefff22}.victory-stats{display:flex;justify-content:center;gap:18px;margin-top:26px}.victory-stats span{display:flex;flex-direction:column;gap:4px;font-size:10px;color:#d7e2e3}.victory-stats b{font:24px Georgia;color:#ecd6ad}.success-copy{top:18%}.success-copy h1{font-size:34px}.success-copy .desc{text-shadow:0 2px 15px #000;color:#d5e7eb}.success-copy .eyebrow{font-size:9px}.result-note{bottom:calc(70px + env(safe-area-inset-bottom))}.result-note .small-serif{font-size:13px;margin-bottom:18px}.toast{bottom:calc(160px + env(safe-area-inset-bottom))}.tiny-tip{font-size:9px;letter-spacing:0}.preview-nav{background:#07121ba8;padding:3px 12px;border-radius:3px;backdrop-filter:blur(10px)}
@keyframes feedback{0%{opacity:0;transform:translateY(8px)}20%,80%{opacity:1;transform:translateY(0)}100%{opacity:0;transform:translateY(-5px)}}
@media(max-height:680px){.game-copy{top:calc(80px + env(safe-area-inset-top))}.game-copy h1{font-size:26px;line-height:1.4;margin-bottom:5px}.game-copy .desc{font-size:11px}.game-copy .eyebrow{font-size:8px;margin-bottom:4px}.game-bottom{bottom:calc(48px + env(safe-area-inset-bottom))}.game-bottom .gesture-label{font-size:12px;margin-bottom:13px}.progress-caption{top:74%;font-size:10px}.progress-caption b{font-size:23px}.level-feedback{top:31%;font-size:12px}.scene[data-stage=trace-win] .level-feedback,.scene[data-stage=shield-win] .level-feedback{top:33%;font-size:18px}.success-copy{top:16%}.success-copy h1{font-size:29px}.success-copy .desc{font-size:12px}.victory-stats{margin-top:15px}.result-note{bottom:calc(52px + env(safe-area-inset-bottom))}.guide h1{font-size:30px}.gate-sigil{top:53%}}
@media(prefers-reduced-motion:reduce){.level-feedback.show{animation:none;opacity:1}.scene .backdrop{transition:none}}
.next-stage{display:block;margin:0 auto 18px;width:min(100%,310px);min-height:48px;background:linear-gradient(115deg,#ddc79f,#f0dfb9);border:1px solid #f1e0bc;color:#1c303a;border-radius:3px;font:14px/1.5 "Songti SC","SimSun",serif;letter-spacing:.07em;padding:10px 15px;box-shadow:0 0 30px #d3eefd19}.next-stage span{margin-left:12px}.next-stage:hover{filter:brightness(1.08)}.scene[data-stage=trace-win] .progress-caption,.scene[data-stage=shield-win] .progress-caption{top:68.5%}.scene[data-stage=trace-win] .gesture-label,.scene[data-stage=shield-win] .gesture-label{display:none}.scene[data-stage=trace-win] .level-feedback,.scene[data-stage=shield-win] .level-feedback{animation:none;opacity:1}
@media(max-height:680px){.next-stage{min-height:42px;margin-bottom:13px;font-size:13px}.scene[data-stage=trace-win] .progress-caption,.scene[data-stage=shield-win] .progress-caption{top:68%}.stage-seal{padding:6px 13px;font-size:13px}}
/* V3 cinematic composition and failure states */
.backdrop{background-image:url('assets/wand-idle-v3.webp');background-position:center center;filter:brightness(.9) saturate(.85);transform:none}.game-mode .backdrop{filter:brightness(.88) saturate(.82)}.sky-film,.story-film{position:absolute;pointer-events:none;z-index:-1;left:0;top:8%;width:100%;height:58%;object-fit:cover;opacity:0;mix-blend-mode:screen;mask-image:linear-gradient(transparent,#000 20%,#000 75%,transparent);-webkit-mask-image:linear-gradient(transparent,#000 20%,#000 75%,transparent);transition:opacity .25s}.story-film{z-index:0;top:8%;height:67%;mix-blend-mode:normal;opacity:0;transition:opacity .7s}.story-film.visible{opacity:.94}.scene[data-stage=casting] .backdrop,.scene[data-stage=complete] .backdrop{background-image:url('assets/castle-shield-v3.webp');filter:brightness(.92) saturate(.8)}.scene[data-stage=ready] #magic,.scene[data-stage=gate] #magic,.scene[data-stage=guide] #magic{pointer-events:none}.level-hud{position:absolute;left:26px;right:26px;top:calc(82px + env(safe-area-inset-top));height:30px;display:flex;align-items:center;justify-content:space-between;color:#d6e6eb;font-size:10px;letter-spacing:.05em}.level-hud:empty{display:none}.level-hud b{font:20px/1 Georgia;color:#eee0bc}.level-hud small{font:10px system-ui;margin-left:5px}.level-hud i{position:absolute;bottom:0;left:0;right:0;height:2px;background:#d9edff24}.level-hud i:after{content:"";display:block;height:2px;width:calc(var(--remaining)*100%);background:#d9edff}.level-hud.danger b{color:#ffc0a3}.level-hud.danger i:after{background:#ffb597}.game-copy{top:calc(132px + env(safe-area-inset-top))}.game-copy h1{font-size:29px;line-height:1.5}.game-copy .desc{font-size:11px;line-height:1.8}.scene[data-stage=trace-win] .game-copy,.scene[data-stage=shield-win] .game-copy{top:calc(112px + env(safe-area-inset-top))}.level-feedback{top:27%;font-size:12px}.scene[data-stage=trace-win] .level-feedback{top:46%}.scene[data-stage=shield-win] .level-feedback{top:31%}.progress-caption{top:74%;font-size:11px}.miss-count{font:10px/1.5 system-ui;color:#d9c5b9;margin-left:6px}.failure-copy{position:absolute;top:25%;left:26px;right:26px;text-align:center}.failure-copy h1{font-size:33px;color:#e5d6ca;line-height:1.55}.failure-copy .desc{font-size:12px;line-height:2;color:#c4d1d5}.failure-level{font-size:11px;letter-spacing:.15em;color:#d7ab98;margin-top:23px}.scene[data-stage=failed] .backdrop{filter:brightness(.32) saturate(.25)}.scene[data-stage=failed] .veil{background:linear-gradient(#040b13aa,#02060ba6)}.scene[data-stage=failed] #magic{pointer-events:none}.scene[data-stage=failed] .result-note{bottom:calc(95px + env(safe-area-inset-bottom))}.ready-summary{position:absolute;top:56%;left:24px;right:24px;display:flex;justify-content:center;gap:14px;font:11px/1.8 "Songti SC","SimSun",serif;color:#d1dce0;letter-spacing:.06em}.ready-summary span{padding:9px 7px;border-top:1px solid #c7dbe83d;border-bottom:1px solid #c7dbe83d}.scene[data-stage=ready] .intro .desc{font-size:12px;line-height:2.2}.scene[data-stage=ready] .intro{top:17%}.scene[data-stage=casting] .game-copy,.scene[data-stage=complete] .success-copy{text-shadow:0 2px 25px #000}.scene[data-stage=complete] .backdrop{transform:none}.scene[data-stage=ready] .veil{background:linear-gradient(#07121da6,#07132415 48%,#041019ec)}
@media(max-height:680px){.level-hud{top:calc(73px + env(safe-area-inset-top));height:23px;left:22px;right:22px}.level-hud b{font-size:17px}.game-copy{top:calc(108px + env(safe-area-inset-top))}.game-copy h1{font-size:24px;margin-bottom:3px}.game-copy .desc{font-size:10px}.scene[data-stage=trace-win] .game-copy,.scene[data-stage=shield-win] .game-copy{top:calc(86px + env(safe-area-inset-top))}.level-feedback{top:30%;font-size:11px}.scene[data-stage=trace-win] .level-feedback{top:46%;font-size:17px}.scene[data-stage=shield-win] .level-feedback{top:32%;font-size:16px}.failure-copy{top:24%}.failure-copy h1{font-size:27px}.scene[data-stage=failed] .result-note{bottom:calc(67px + env(safe-area-inset-bottom))}.ready-summary{top:56%;font-size:10px;gap:8px}.scene[data-stage=ready] .intro{top:17%}.scene[data-stage=ready] .intro h1{font-size:31px}}

.scene[data-stage=complete] .backdrop{filter:brightness(1.1) saturate(.82)}.scene[data-stage=complete] .veil{background:linear-gradient(180deg,#031019b8,#0c203408 42%,#06131bb0 72%,#06131bf0)}

/* V4: timing defence, linked ward anchors, original-film stages */
.guard-controls{position:absolute;inset:0;pointer-events:none}.guard-sector{position:absolute;width:70px;height:70px;transform:translate(-50%,-50%);border:0;border-radius:50%;color:#d9f1f4;background:transparent;pointer-events:auto;touch-action:manipulation;display:grid;place-items:center;font:22px Georgia;text-shadow:0 0 12px #04202b}.guard-sector:active{background:#bfefff35}.guard-sector:focus-visible{outline:1px solid #d9f7ff}.guard-sector span{opacity:.65}.lane-0{left:24%;top:50%}.lane-1{left:50%;top:39%}.lane-2{left:76%;top:50%}.combo{position:absolute;top:30px;left:0;right:0;font:11px Georgia;color:#f3dba8}.scene[data-stage=defend] .game-copy,.scene[data-stage=cast] .game-copy{top:calc(123px + env(safe-area-inset-top))}.scene[data-stage=defend] .level-feedback,.scene[data-stage=cast] .level-feedback{top:61%;font-size:13px}.scene[data-stage=defend] .progress-caption,.scene[data-stage=cast] .progress-caption{top:70%}.scene[data-stage=defend] .game-bottom,.scene[data-stage=cast] .game-bottom{bottom:calc(62px + env(safe-area-inset-bottom))}.scene[data-stage=cast] .gesture-label,.scene[data-stage=defend] .gesture-label{font-size:11px;line-height:1.8;max-width:300px;margin:0 auto 15px}.scene[data-stage=defend] .backdrop,.scene[data-stage=shield-win] .backdrop,.scene[data-stage=cast] .backdrop{filter:brightness(.7) saturate(.7)}.battle-film{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:50% 50%;z-index:-2;opacity:0;transition:opacity .4s;pointer-events:none}.battle-film.visible{opacity:.86}.scene[data-stage=defend] .veil,.scene[data-stage=shield-win] .veil,.scene[data-stage=cast] .veil{z-index:-1;background:linear-gradient(180deg,#03101bf5 0%,#03101bb5 27%,#03101b25 39%,#03101b10 56%,#03101bbb 71%,#03101bf7 100%)}.scene[data-stage=defend] .sky-film,.scene[data-stage=cast] .sky-film{display:none}.scene[data-stage=cast] .backdrop{background-image:url('assets/castle-shield-v3.webp')}.scene[data-stage=defend] .tiny-tip,.scene[data-stage=cast] .tiny-tip{line-height:1.8;max-width:340px;margin:12px auto 0}
@media(max-height:680px){.guard-sector{width:60px;height:60px}.scene[data-stage=defend] .game-copy,.scene[data-stage=cast] .game-copy{top:calc(109px + env(safe-area-inset-top))}.scene[data-stage=defend] .game-copy h1,.scene[data-stage=cast] .game-copy h1{font-size:24px;margin-bottom:5px}.scene[data-stage=defend] .game-copy .desc,.scene[data-stage=cast] .game-copy .desc{font-size:10px}.scene[data-stage=defend] .game-bottom,.scene[data-stage=cast] .game-bottom{bottom:calc(48px + env(safe-area-inset-bottom))}.scene[data-stage=defend] .gesture-label,.scene[data-stage=cast] .gesture-label{font-size:10px;margin-bottom:9px}.scene[data-stage=defend] .tiny-tip,.scene[data-stage=cast] .tiny-tip{font-size:8px;margin-top:8px}.scene[data-stage=defend] .level-feedback,.scene[data-stage=cast] .level-feedback{font-size:11px;top:61%}.scene[data-stage=defend] .progress-caption,.scene[data-stage=cast] .progress-caption{top:69%}}

.guard-cue{position:absolute;top:29.7%;left:12px;right:12px;text-align:center;color:#f5d8bb;font:12px/1.6 system-ui;text-shadow:0 2px 8px #07111f;pointer-events:none;margin:0}.guard-controls{z-index:3}.guard-cue{z-index:2}

.battle-film{top:25%;height:40%;object-fit:cover;mask-image:linear-gradient(transparent,#000 13%,#000 83%,transparent);-webkit-mask-image:linear-gradient(transparent,#000 13%,#000 83%,transparent)}.scene[data-stage=defend] .backdrop,.scene[data-stage=shield-win] .backdrop,.scene[data-stage=cast] .backdrop{background-image:var(--battle-poster);filter:blur(9px) brightness(.42) saturate(.72);transform:scale(1.05)}.battle-film.visible{opacity:1}.scene[data-stage=defend] .veil,.scene[data-stage=shield-win] .veil,.scene[data-stage=cast] .veil{background:linear-gradient(180deg,#03101bf5 0%,#03101b9c 26%,#03101b0d 38%,#03101b00 55%,#03101bba 72%,#03101bf7 100%)}

/* V5: exact-shape spell guide and fast random light bubbles */
.trace-requirement{font:10px/1.6 system-ui;color:#d7cfb5}.scene[data-stage=draw] .progress-caption{gap:10px}.scene[data-stage=draw] .gesture-label{font-size:11px;line-height:1.8}.scene[data-stage=draw] .tiny-tip{font-size:9px}.scene[data-stage=cast] .level-feedback{top:62%;font-size:12px}.scene[data-stage=cast] .progress-caption{top:71%}.spell-bubble{position:absolute;z-index:6;display:grid;place-items:center;padding:0;transform:translate(-50%,-50%);border:1px solid #e9ffffc7;border-radius:50%;color:#f3ffff;background:radial-gradient(circle at 32% 26%,#f2ffffa6,#9edff742 35%,#153a5b87 65%,#b5f2ff6b);box-shadow:0 0 21px #a0eaff77,inset 0 0 14px #c4f9ff55;pointer-events:auto;touch-action:manipulation;text-shadow:0 1px 5px #08202d}.spell-bubble:before{content:'';position:absolute;inset:-6px;border-radius:50%;background:conic-gradient(#e5faff var(--bubble-left,360deg),#b6d6e129 0);mask:radial-gradient(transparent 64%,#000 67%);-webkit-mask:radial-gradient(transparent 64%,#000 67%)}.spell-bubble span{font:22px Georgia;position:absolute;top:17%}.spell-bubble small{position:absolute;top:58%;font:10px/1.3 system-ui;color:#f4ffff}.spell-bubble:active{filter:brightness(1.7)}.spell-bubble.pop-in{animation:none}.spell-bubble[hidden]{display:none}#startBubbles{margin-bottom:14px}.scene[data-stage=cast] .gesture-label{margin-bottom:12px}.scene[data-stage=cast] .game-bottom{bottom:calc(59px + env(safe-area-inset-bottom))}@keyframes bubble-in{from{opacity:.2;scale:.65}to{opacity:1;scale:1}}@media(prefers-reduced-motion:reduce){.spell-bubble.pop-in{animation:none}}@media(max-height:680px){.scene[data-stage=draw] .game-copy{top:109px}.scene[data-stage=draw] .game-copy h1{font-size:24px}.scene[data-stage=draw] .game-copy .desc{font-size:10px;line-height:1.7}.scene[data-stage=cast] .game-bottom{bottom:48px}.scene[data-stage=cast] .progress-caption{top:70%}#startBubbles{min-height:39px;margin-bottom:9px;font-size:12px}.scene[data-stage=cast] .gesture-label{font-size:10px;margin-bottom:8px}}

/* V6: compact multilingual layout. Physical spell directions remain LTR. */
:root{font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",sans-serif}
.header-actions{display:flex;align-items:center;gap:8px;flex-shrink:0}
#languageSelect{width:114px;min-height:40px;max-width:30vw;background:#0d2235d9;color:#f1e0ba;border:1px solid #c6dbe84d;border-radius:4px;font:12px/1.4 system-ui;padding:8px 5px;cursor:pointer;pointer-events:auto}
#languageSelect option{background:#0d2235;color:#fff;font:14px system-ui}
#languageSelect:focus-visible{outline:2px solid #def7ff;outline-offset:3px}
.brand{min-width:0;gap:7px;margin-inline-end:8px}.brand span{font-size:14px;letter-spacing:0;line-height:1.4}.brand small{font-size:7px;letter-spacing:.06em}.brand img{width:26px;height:26px;flex-shrink:0}.sound{width:38px;height:38px;flex-shrink:0}
.serif,.cta,.next-stage,.small-serif,.success-copy .desc,.ready-summary,.stage-seal,footer{font-family:Georgia,"Times New Roman",system-ui,serif}
h1,.desc,.eyebrow,.cta,.hint,.gesture-label,.tiny-tip,.progress-caption,.stage-seal,.failure-level,.ready-summary,.small-serif,footer{letter-spacing:0}
.intro h1,.success-copy h1{font-size:clamp(28px,7vw,36px);line-height:1.3;overflow-wrap:break-word}
.intro .desc,.scene[data-stage=ready] .intro .desc{line-height:1.75;font-size:12px}.eyebrow{line-height:1.5}
.guide{top:17%;max-height:calc(100% - 220px);overflow-y:auto;padding:0 2px 12px;pointer-events:auto;scrollbar-width:thin}
.guide h1{font-size:29px;line-height:1.25}.steps li{align-items:flex-start;font-size:13px;line-height:1.6}.steps{gap:15px}.cta{padding:12px 15px;font-size:16px;line-height:1.4}.guide .cta{font-size:14px}
.game-copy h1{font-size:25px;line-height:1.2;margin-bottom:7px}.game-copy .eyebrow{font-size:9px;margin-bottom:6px}.game-copy .desc{font-size:11px;line-height:1.5;margin-bottom:0}
.scene[data-stage=draw] .game-copy{top:122px}.scene[data-stage=defend] .game-copy,.scene[data-stage=cast] .game-copy{top:120px}
.game-bottom .gesture-label{font-size:11px;line-height:1.5;max-width:340px;margin:0 auto 14px}.tiny-tip{line-height:1.5}.stage-track{gap:5px}.stage-track span{white-space:normal;line-height:1.3;text-align:start;font-size:10px;max-width:30%;min-width:0}.stage-track span i{flex-shrink:0}.stage-track b{width:8px;flex-shrink:0}.next-stage{font-size:13px;letter-spacing:0;line-height:1.4;min-height:44px;margin-bottom:12px}
.progress-caption{gap:8px;flex-wrap:wrap;line-height:1.4;font-size:11px}.trace-requirement{font-size:10px}.level-feedback{letter-spacing:0;line-height:1.4}.scene[data-stage=trace-win] .level-feedback,.scene[data-stage=shield-win] .level-feedback{font-size:18px}.guard-cue{line-height:1.4;font-size:11px;top:30%}
.guard-controls{direction:ltr}.guard-sector{direction:ltr}.spell-bubble{direction:ltr}.level-hud b{white-space:nowrap}.level-hud small{margin-inline-start:4px}
.ready-summary{gap:8px;font-size:11px;line-height:1.5}.ready-summary span{flex:1;text-align:center;padding:8px 4px;max-width:32%}.victory-stats{gap:12px}.victory-stats span{flex:1;max-width:32%;line-height:1.5}.failure-copy{top:23%}.failure-copy h1{font-size:29px;line-height:1.3}.failure-copy .desc{line-height:1.7}.failure-level{line-height:1.5}.result-note .small-serif{line-height:1.5}footer{font-size:10px;line-height:1.5}
html[dir=rtl] .back-button{left:auto;right:24px}html[dir=rtl] .level-hud i:after{margin-left:auto}html[dir=rtl] .serif,html[dir=rtl] .cta,html[dir=rtl] .next-stage,html[dir=rtl] .small-serif,html[dir=rtl] .stage-seal,html[dir=rtl] footer,html[dir=rtl] .brand span,html[dir=rtl] .ready-summary{font-family:system-ui,-apple-system,"Segoe UI",sans-serif}
html:lang(th) .serif,html:lang(km) .serif,html:lang(si) .serif,html:lang(ta) .serif,html:lang(bn) .serif{font-family:system-ui,sans-serif;line-height:1.5}
@media(max-width:370px){header{padding-left:16px;padding-right:16px}.brand img{width:22px;height:22px}.brand span{font-size:12px}.brand small{display:none}#languageSelect{width:106px}.header-actions{gap:6px}.sound{width:34px;height:34px}}
@media(max-height:720px){header{padding-top:calc(14px + env(safe-area-inset-top))}.game-copy h1,.scene[data-stage=draw] .game-copy h1,.scene[data-stage=defend] .game-copy h1,.scene[data-stage=cast] .game-copy h1{font-size:21px;line-height:1.15;margin-bottom:4px}.game-copy .eyebrow{font-size:8px;margin-bottom:4px}.scene[data-stage=draw] .game-copy,.scene[data-stage=defend] .game-copy,.scene[data-stage=cast] .game-copy{top:104px}.game-copy .desc,.scene[data-stage=draw] .game-copy .desc,.scene[data-stage=defend] .game-copy .desc,.scene[data-stage=cast] .game-copy .desc{font-size:10px;line-height:1.4}.scene[data-stage=ready] .intro h1,.intro h1,.success-copy h1{font-size:28px;line-height:1.3}.guide{top:17%;max-height:calc(100% - 180px)}.guide h1{font-size:25px}.steps{gap:12px;margin-bottom:15px}.guide .eyebrow{font-size:9px}.scene[data-stage=failed] .failure-copy{top:22%}.failure-copy h1{font-size:25px}.failure-level{margin-top:13px}.guard-cue{font-size:10px;top:30%}.game-bottom .gesture-label{margin-bottom:9px}.stage-track span{font-size:9px}.scene[data-stage=cast] .game-bottom .tiny-tip,.scene[data-stage=defend] .game-bottom .tiny-tip{display:none}.ready-summary{top:57%;font-size:10px}.result-note .small-serif{font-size:12px}}

@media(max-height:720px){#startBubbles{margin-bottom:6px}}

@media(max-height:720px){.gate-sigil{top:57%}}

/* V6.2: keep instructions readable and out of the physical play field. */
.scene[data-stage=gate] .hint{font-size:13px;line-height:1.6;color:#eef3ed}
.scene:is([data-stage=draw],[data-stage=defend],[data-stage=cast]) .game-copy{overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#dac7a0 #102632;pointer-events:auto;padding:0 5px 5px;touch-action:pan-y;background:linear-gradient(#07132166,#07132122);border-radius:4px}
.scene:is([data-stage=draw],[data-stage=defend],[data-stage=cast]) .game-copy .desc{font-size:12px;line-height:1.5}
.scene:is([data-stage=draw],[data-stage=defend],[data-stage=cast]) .game-copy h1{font-size:23px;line-height:1.2}
@media(max-height:720px){
 .scene:is([data-stage=draw],[data-stage=defend],[data-stage=cast]) .game-copy{top:100px;left:15px;right:15px}
 .scene:is([data-stage=draw],[data-stage=defend],[data-stage=cast]) .game-copy .eyebrow{display:none}
 .scene:is([data-stage=draw],[data-stage=defend],[data-stage=cast]) .game-copy h1{font-size:19px;line-height:1.25;margin-bottom:5px}
 .scene[data-stage=defend] .guard-cue{top:57.5%;font-size:12px;line-height:1.35;max-height:4.05em;overflow-y:auto;pointer-events:auto;margin:0 12px;left:0;right:0}
 .scene[data-stage=defend] .level-feedback{top:66%;font-size:11px;line-height:1.3}
 .scene[data-stage=defend] .progress-caption{top:72%}
}
.scene[data-stage=draw] .level-feedback{top:67%}
.scene[data-stage=cast] .level-feedback{top:75%;font-size:11px;line-height:1.3}

/* Startup remains visible even when a host rejects the application script. */
.startup{position:fixed;z-index:30;top:38%;left:50%;transform:translateX(-50%);width:min(86vw,390px);padding:25px 20px;background:#0b1a24f5;border:1px solid #dac7a080;border-radius:6px;text-align:center;color:#f1e6d1;font:15px/1.7 system-ui;box-shadow:0 10px 50px #0008}
.startup[hidden]{display:none}.startup p{margin:0 0 16px}.startup a{display:inline-block;min-height:44px;padding:9px 16px;border:1px solid #ddc99b88;border-radius:3px;color:#f2dfb6;font-size:14px}.startup[data-status=error]{border-color:#e6b68b}
