:root{--ink:#f8fbff;--muted:#a9bad8;--panel:rgba(8,20,45,.88);--panel-strong:#0b1d40;--gold:#ffd76a;--gold-deep:#f0a629;--cyan:#66e8ff;--violet:#aa8cff;--danger:#ff7692;--success:#6bf0ba;--line:#536a9b;--border:rgba(182,211,255,.2);font-family:Inter,ui-rounded,"Segoe UI",system-ui,sans-serif;color:var(--ink);background:#051126}
*{box-sizing:border-box}
html,body{margin:0;min-width:320px;background:#051126;color:var(--ink)}
html{overflow-y:auto!important;overscroll-behavior-y:auto!important}
body{min-height:100vh}
body[data-screen="main"]{height:auto!important;overflow-y:visible!important;overscroll-behavior-y:auto!important}
button,select{font:inherit}
button{cursor:pointer}
button:focus-visible,select:focus-visible,[role="button"]:focus-visible{outline:3px solid #fff48b;outline-offset:3px}
[hidden]{display:none!important}
.sr-only,.sr-only:not(:focus):not(:active){position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

.main-screen{width:min(100%,940px);min-height:100svh;margin:0 auto;padding:12px;background:radial-gradient(circle at 25% 20%,#263c76 0,transparent 34%),linear-gradient(180deg,#07172f,#061126);display:grid;grid-template-rows:64px minmax(0,1fr);gap:12px}
.main-header{display:grid;grid-template-columns:58px minmax(0,1fr) 142px;align-items:center;gap:10px;min-width:0;padding:6px 8px;border:1px solid var(--border);border-radius:18px;background:rgba(7,20,45,.88);box-shadow:0 16px 40px rgba(0,0,0,.25)}
.main-header>strong{min-width:0;text-align:center;font-size:clamp(16px,3vw,24px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.main-return{display:grid!important}.locale-control select{width:100%;height:44px;border:1px solid var(--border);border-radius:12px;background:#122852;color:var(--ink);padding:0 8px;font-weight:800}
.main-hero{display:grid;grid-template-columns:minmax(280px,1fr) minmax(260px,.82fr);align-items:center;gap:18px;padding:8px 18px 18px}
.main-poster{display:block;width:min(100%,520px);aspect-ratio:1;object-fit:cover;justify-self:center;border-radius:28px;border:2px solid rgba(255,215,106,.45);box-shadow:0 22px 60px rgba(0,0,0,.42)}
.main-copy{display:grid;gap:14px;align-content:center}.main-copy small{color:var(--gold);font-weight:900;letter-spacing:.08em;text-transform:uppercase}.main-copy h1{margin:0;font-size:clamp(34px,6vw,62px);line-height:.95}.main-copy p{margin:0;color:#c4d2ec;font-size:clamp(16px,2vw,20px);line-height:1.55}.main-progress{min-height:68px;padding:12px 14px;border:1px solid var(--border);border-radius:16px;background:rgba(8,20,45,.76);display:grid;gap:5px}.main-progress strong{color:var(--gold);font-size:18px}.main-progress span{color:var(--muted);font-size:13px}
.primary-action{min-height:54px;border:0;border-radius:14px;background:linear-gradient(180deg,#ffe58a,#f6b52e);color:#2b1b08;font-weight:950;box-shadow:0 6px 0 #a96417,0 14px 30px rgba(246,181,46,.22);transition:transform .15s}.primary-action:active{transform:translateY(4px);box-shadow:0 2px 0 #a96417}
.game-page-info{width:min(100%,940px);margin:0 auto}
body[data-screen="stage"] .game-page-info,body[data-screen="battle"] .game-page-info{display:none!important}

.stage-shell{position:fixed;inset:0 0 56px;overflow:hidden;background:#061126}
.stage-canvas{width:390px;height:788px;padding:10px;display:grid;grid-template-rows:66px minmax(0,1fr) 198px;gap:10px;background-color:#07172f;background-image:linear-gradient(rgba(4,15,38,.4),rgba(4,15,38,.75)),url('../../assets/animal-starlight-trails-bg.webp');background-position:center;background-size:cover;overflow:hidden}
.stage-header{display:grid;grid-template-columns:48px minmax(0,1fr) 52px;align-items:center;gap:10px;padding:8px;border:1px solid var(--border);border-radius:16px;background:rgba(5,17,38,.88)}
.stage-header>div{min-width:0;display:grid;gap:2px}.stage-header strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.stage-header span{color:var(--muted);font-size:12px}.stage-header>img{width:52px;height:52px;object-fit:cover;object-position:center 22%;border-radius:50%;border:2px solid var(--gold)}
.chapter-panel{align-self:center;justify-self:center;width:min(100%,520px);min-height:210px;padding:24px;display:grid;align-content:center;gap:9px;text-align:center;border:1px solid rgba(255,215,106,.35);border-radius:24px;background:linear-gradient(145deg,rgba(8,24,58,.9),rgba(24,32,72,.84));box-shadow:0 18px 50px rgba(0,0,0,.28)}
.chapter-panel small{color:var(--gold);font-weight:900;letter-spacing:.1em;text-transform:uppercase}.chapter-panel strong{font-size:28px}.chapter-panel p{margin:0;color:#c7d6ef;line-height:1.5}
.stage-rail{height:198px}
.stage-card{position:relative;padding:16px;text-align:left;color:var(--ink);border:2px solid rgba(129,171,230,.28);border-radius:20px;background:linear-gradient(145deg,rgba(13,33,70,.96),rgba(20,25,60,.96));display:grid;grid-template-rows:auto auto 1fr auto;gap:8px;box-shadow:0 12px 28px rgba(0,0,0,.26)}
.stage-card.selected{border-color:var(--cyan);box-shadow:0 0 0 3px rgba(102,232,255,.15),0 12px 28px rgba(0,0,0,.26)}.stage-card.cleared{background:linear-gradient(145deg,rgba(17,61,70,.96),rgba(18,31,62,.96))}.stage-card.locked{filter:saturate(.5);opacity:.62}
.stage-card small{color:var(--gold);font-weight:900}.stage-card strong{font-size:21px}.stage-card p{margin:0;color:#c2d1ea;font-size:13px;line-height:1.35}.stage-card footer{display:flex;justify-content:space-between;align-items:center;color:var(--muted);font-size:12px}.stage-card .card-stars{color:var(--gold);letter-spacing:2px;font-size:16px}

.battle-screen{position:fixed;inset:0;background:#041020;overflow:hidden}
.trail-battle-canvas{position:relative;width:390px;height:788px;padding:8px;display:grid;grid-template-rows:62px 38px minmax(0,1fr) 42px 58px;gap:6px;background-color:#07172f;background-image:linear-gradient(rgba(4,13,34,.58),rgba(4,13,34,.8)),url('../../assets/animal-starlight-trails-bg.webp');background-position:center;background-size:cover;overflow:hidden}
.battle-header{display:grid;grid-template-columns:48px minmax(0,1fr) 72px 64px;gap:8px;align-items:center;padding:6px 8px;border:1px solid var(--border);border-radius:14px;background:rgba(5,17,38,.9)}
.battle-progress{min-width:0;display:grid;gap:5px}.battle-progress>span{font-weight:900;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.battle-progress>div{height:7px;border-radius:999px;background:#1a315e;overflow:hidden}.battle-progress i{display:block;width:0;height:100%;border-radius:inherit;background:linear-gradient(90deg,var(--cyan),var(--gold));transition:width .22s}
.battle-stat{min-width:0;text-align:center;display:grid;gap:1px}.battle-stat small{color:var(--muted);font-size:10px}.battle-stat strong{font-size:16px;white-space:nowrap}
.objective-row{display:flex;align-items:center;justify-content:center;padding:5px 12px;border:1px solid rgba(170,140,255,.3);border-radius:12px;background:rgba(15,22,60,.85);color:#d9d2ff;font-size:13px;font-weight:800;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.puzzle-scene{position:relative;min-width:0;min-height:0;display:grid;place-items:center;border:1px solid rgba(148,190,255,.25);border-radius:22px;background:radial-gradient(circle at center,rgba(43,70,126,.2),rgba(3,12,30,.62));overflow:hidden;touch-action:none}
#graphSvg{display:block;width:min(100%,610px);height:min(100%,610px);min-width:340px;min-height:340px;touch-action:none;user-select:none;overflow:visible}
.graph-edge{stroke:var(--line);stroke-width:2.1;stroke-linecap:round;vector-effect:non-scaling-stroke;filter:drop-shadow(0 0 2px rgba(79,128,215,.35));transition:stroke .18s,opacity .18s}.graph-edge.used{stroke:var(--gold);stroke-width:3;filter:drop-shadow(0 0 3px rgba(255,215,106,.58))}.graph-edge.directed:not(.used){stroke:var(--violet);stroke-width:3}.graph-edge.gate:not(.used){stroke:var(--danger);stroke-dasharray:5 3}.graph-edge.gate.open:not(.used){stroke:var(--success);stroke-dasharray:none}.direction-arrow{fill:#fff7ff;stroke:#5d2aa8;stroke-width:1.15;paint-order:stroke fill;vector-effect:non-scaling-stroke;filter:drop-shadow(0 0 3px rgba(229,185,255,.95));pointer-events:none}
.graph-node{cursor:pointer;outline:none}.graph-node[role="button"]:focus-visible{outline:none}.node-halo{fill:transparent;stroke:transparent;opacity:0}.node-core{fill:#eaf6ff;stroke:#5c8fd4;stroke-width:1.35;filter:drop-shadow(0 0 3px rgba(120,190,255,.72));transition:fill .16s,stroke .16s,filter .16s}.graph-node.current .node-core{fill:var(--gold);stroke:#fff4bd;filter:drop-shadow(0 0 5px rgba(255,215,106,.82))}.graph-node.start .node-core{stroke:var(--success);stroke-width:2}.graph-node.key .node-core{fill:#ffe083;stroke:#fff2b0;stroke-width:1.8}.graph-node.checkpoint .node-core{stroke:var(--violet);stroke-width:2}.graph-node.hinted .node-core{fill:var(--cyan);stroke:#fff;animation:hintTwinkle .9s ease-in-out infinite}.graph-node:focus-visible .node-core{stroke:#fff;stroke-width:2}.node-label{fill:#102142;font-size:5px;font-weight:950;text-anchor:middle;dominant-baseline:central;pointer-events:none}
.battle-feedback{min-width:0;padding:5px 10px;display:flex;align-items:center;justify-content:space-between;gap:8px;border-radius:12px;background:rgba(5,17,38,.88)}.battle-feedback strong{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px}.battle-feedback span{flex:none;color:var(--muted);font-size:11px}.battle-feedback.error strong{color:#ffafbd}.battle-feedback.success strong{color:var(--success)}
.battle-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.battle-actions button,.result-actions button{border:1px solid rgba(158,195,255,.28);border-radius:12px;background:linear-gradient(180deg,#183665,#10254c);color:var(--ink);font-weight:900}.battle-actions button:disabled{opacity:.42;cursor:default}.battle-actions button:active:not(:disabled){transform:translateY(2px)}
.battle-ad-reserve{position:fixed;left:0;bottom:0;width:100%;height:56px;background:#071329;pointer-events:none}

.result-overlay{position:absolute;inset:0;z-index:20;display:grid;place-items:center;padding:16px;background:rgba(2,8,22,.76);backdrop-filter:blur(8px)}
.battle-leave-overlay{position:absolute;inset:0;z-index:25;display:grid;place-items:center;padding:16px;background:rgba(2,8,22,.8);backdrop-filter:blur(8px)}
.battle-leave-card{width:min(100%,460px);max-height:100%;overflow:auto;padding:22px;border:1px solid rgba(158,195,255,.38);border-radius:20px;background:linear-gradient(155deg,rgba(18,44,83,.98),rgba(7,21,47,.98));box-shadow:0 20px 54px rgba(0,0,0,.5);text-align:center}.battle-leave-card h2{margin:0;color:#fff;font-size:clamp(21px,5.5vw,30px);line-height:1.12}.battle-leave-card p{margin:12px 0 18px;color:var(--muted);font-size:14px;line-height:1.45}.battle-leave-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.battle-leave-actions button{min-height:48px;padding:8px;border:1px solid rgba(158,195,255,.34);border-radius:12px;background:linear-gradient(180deg,#1c4278,#112a55);color:var(--ink);font-weight:900}.battle-leave-actions button:last-child{background:linear-gradient(180deg,#71344f,#482139)}
.result-card{width:min(100%,520px);max-height:100%;overflow:auto;padding:18px;display:grid;grid-template-columns:74px minmax(0,1fr);gap:8px 14px;border:2px solid rgba(255,215,106,.54);border-radius:24px;background:linear-gradient(155deg,#122c59,#0a1735);box-shadow:0 24px 80px rgba(0,0,0,.48);animation:resultIn .35s cubic-bezier(.2,.8,.2,1)}
.result-card>img{grid-row:1/5;width:74px;height:96px;object-fit:cover;object-position:center 22%;border-radius:18px}.result-card>small{color:var(--gold);font-weight:900;text-transform:uppercase;letter-spacing:.08em}.result-card h2,.result-card p{margin:0}.result-card h2{font-size:27px}.result-stars{color:var(--gold);font-size:28px;letter-spacing:4px}.skill-grid{grid-column:1/-1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}.skill-grid div{padding:9px 6px;text-align:center;border:1px solid var(--border);border-radius:12px;background:rgba(255,255,255,.05)}.skill-grid small{display:block;color:var(--muted);font-size:10px}.skill-grid strong{display:block;margin-top:3px;font-size:13px}.comparison{grid-column:1/-1;color:#c7d6ef;text-align:center;font-size:12px}.result-actions{grid-column:1/-1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;min-height:48px}.result-actions .primary-action{border:1px solid #ffe89a;background:linear-gradient(180deg,#ffe58a,#f6b52e);color:#2b1b08;box-shadow:inset 0 -3px 0 rgba(151,86,9,.32),0 0 18px rgba(246,181,46,.2)}
.hint-pulse{position:absolute;width:50px;height:50px;border:3px solid var(--cyan);border-radius:50%;pointer-events:none;animation:hintRing .8s ease-out infinite}
.shake{animation:shake .28s linear}
.sparkle{animation:sparkle .45s ease-out}
.sr-status{position:absolute;left:-9999px}
@keyframes hintTwinkle{50%{filter:drop-shadow(0 0 6px rgba(102,232,255,.95))}}
@keyframes resultIn{from{opacity:0;transform:translateY(18px) scale(.96)}to{opacity:1;transform:none}}
@keyframes hintRing{from{transform:scale(.45);opacity:1}to{transform:scale(1.25);opacity:0}}
@keyframes shake{25%{transform:translateX(-5px)}50%{transform:translateX(5px)}75%{transform:translateX(-3px)}}
@keyframes sparkle{50%{filter:brightness(1.8)}}

@media(max-width:720px){.main-screen{padding:8px;grid-template-rows:60px auto}.main-header{grid-template-columns:58px minmax(0,1fr) 112px}.main-hero{grid-template-columns:1fr;gap:10px;padding:2px 4px 16px}.main-poster{width:min(100%,340px);border-radius:20px}.main-copy{gap:9px}.main-copy h1{font-size:30px;text-align:center}.main-copy small,.main-copy p{text-align:center}.main-copy p{font-size:14px}.main-progress{min-height:54px;padding:8px 12px}.primary-action{min-height:52px}}
@media (orientation:landscape) and (max-height:430px){
  .trail-battle-canvas{padding:12px;grid-template-columns:minmax(0,1fr) 650px;grid-template-rows:124px minmax(0,1fr);gap:14px 18px}
  .battle-header{grid-column:1/-1;grid-row:1;grid-template-columns:112px minmax(0,1fr) 170px 150px;gap:18px;padding:12px 18px;border-radius:24px}
  .battle-header button{font-size:36px}.battle-progress{gap:10px}.battle-progress>span{font-size:34px}.battle-progress>div{height:16px}.battle-stat{gap:4px}.battle-stat small{font-size:24px}.battle-stat strong{font-size:34px}
  .puzzle-scene{grid-column:1;grid-row:2;border-radius:30px}.puzzle-scene #graphSvg{width:100%;height:100%;min-width:0;min-height:0}
  .objective-row{grid-column:2;grid-row:2;align-self:start;min-height:90px;padding:12px 22px;border-radius:20px;font-size:26px;line-height:1.2;white-space:normal;overflow:visible}
  .battle-feedback{grid-column:2;grid-row:2;align-self:center;min-height:110px;padding:14px 20px;border-radius:20px}.battle-feedback strong{font-size:32px}.battle-feedback span{font-size:26px}
  .battle-actions{grid-column:2;grid-row:2;align-self:end;height:104px;gap:14px}.battle-actions button{border-radius:20px;font-size:32px}
  .battle-leave-card{width:min(1500px,100%);padding:32px 44px}.battle-leave-card h2{font-size:48px}.battle-leave-card p{margin:18px 0 28px;font-size:32px;line-height:1.3}.battle-leave-actions{gap:24px}.battle-leave-actions button{min-height:104px;font-size:32px}
  .result-overlay{padding:24px}
  .result-card{width:min(1800px,100%);height:700px;padding:28px;grid-template-columns:180px minmax(0,1fr) 600px;grid-template-rows:auto auto auto 1fr 112px;gap:14px 28px;border-radius:34px}
  .result-card>img{grid-row:1/5;width:160px;height:210px;border-radius:26px}.result-card>small{font-size:26px}.result-card h2{font-size:48px}.result-card p{font-size:30px;line-height:1.35}.result-stars{font-size:48px}
  .skill-grid{grid-column:3;grid-row:1/5;gap:14px;align-content:center}.skill-grid div{padding:22px 12px;border-radius:20px}.skill-grid small{font-size:22px}.skill-grid strong{font-size:30px}
  #resultText{grid-column:2;grid-row:4;align-self:start}.comparison{grid-column:2;grid-row:4;align-self:end;font-size:26px}.result-actions{grid-column:1/-1;grid-row:5;height:112px;min-height:112px;gap:16px}.result-actions button{border-radius:20px;font-size:30px}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:.01ms!important}}
