/* =========================================================
   迷雾探险 · MISTWOOD EXPEDITION
   移动端优先 · 卡通夜色森林 · 主色 #FF8A3D
   ========================================================= */
:root{
  --amber:#FF8A3D;
  --amber-2:#FFB25C;
  --amber-3:#FFD79B;
  --cream:#FFF4E3;
  --ink:#2A1406;
  --night:#041015;
  --night-2:#071B21;
  --teal:#0D3439;
  --glass:rgba(10,31,36,.78);
  --glass-deep:rgba(5,19,24,.9);
  --line:rgba(255,196,140,.16);
  --line-soft:rgba(255,196,140,.09);
  --good:#7BE0C0;
  --bad:#FF6A52;
  --safe-top:env(safe-area-inset-top,0px);
  --safe-bottom:env(safe-area-inset-bottom,0px);
  --font:-apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Noto Sans SC","Microsoft YaHei",sans-serif;
  --shadow-card:0 22px 60px rgba(0,0,0,.5),0 2px 0 rgba(255,255,255,.03) inset;
}
*{box-sizing:border-box}
html,body{height:100%;margin:0;padding:0}
html{background:#030c10;overflow:hidden}
body{
  min-height:100vh;min-height:100dvh;
  background:#030c10;
  color:var(--cream);
  font-family:var(--font);
  overflow:hidden;
  -webkit-tap-highlight-color:transparent;
  -webkit-touch-callout:none;
  user-select:none;-webkit-user-select:none;
  overscroll-behavior:none;
}
button{font-family:inherit;border:0;background:none;color:inherit;cursor:pointer}
b,em,span{font-style:normal}
.svg-defs{position:absolute;width:0;height:0;overflow:hidden}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}

.stage{
  position:relative;
  width:100%;max-width:520px;
  height:100vh;height:100dvh;
  margin:0 auto;
  overflow:hidden;
  background:#06171d;
  isolation:isolate;
}
@media (min-width:600px) and (min-height:700px){
  body{
    display:grid;place-items:center;
    background:
      radial-gradient(90% 70% at 50% 0%,#12343a 0%,#07181e 52%,#030b0f 100%);
  }
  .stage{
    height:min(930px,calc(100dvh - 44px));
    border-radius:30px;
    border:1px solid rgba(255,196,140,.14);
    box-shadow:0 50px 130px rgba(0,0,0,.72),0 0 0 1px rgba(0,0,0,.55);
  }
}
@media (max-width:599px){
  .stage{border-radius:0}
}

/* ---------- canvas & atmosphere ---------- */
#world{
  position:absolute;inset:0;
  width:100%;height:100%;
  display:block;
  touch-action:none;
  outline:none;
}
.fx-grain,.fx-vignette,.hit-flash{
  position:absolute;inset:0;pointer-events:none;z-index:5;
}
.fx-grain{
  opacity:.05;
  mix-blend-mode:overlay;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}
.fx-vignette{
  background:
    radial-gradient(125% 86% at 50% 42%,transparent 48%,rgba(1,7,10,.24) 80%,rgba(1,6,9,.52) 100%),
    linear-gradient(180deg,rgba(2,10,13,.2) 0%,transparent 20%,transparent 84%,rgba(2,9,12,.36) 100%);
}
.hit-flash{
  background:radial-gradient(closest-side,rgba(255,72,44,.42),rgba(255,72,44,.06) 70%,transparent);
  opacity:0;
  transition:opacity .5s ease;
  z-index:6;
}
.hit-flash.on{opacity:1;transition:opacity .06s ease}

/* ---------- HUD ---------- */
.hud{
  position:absolute;inset:0;z-index:20;
  pointer-events:none;
  padding:calc(var(--safe-top) + 12px) 14px calc(var(--safe-bottom) + 16px);
  opacity:0;transform:translateY(-6px);
  transition:opacity .35s ease,transform .35s ease;
}
.stage[data-screen="play"] .hud{opacity:1;transform:none}
.hud-top{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}
.hud-left{display:flex;flex-direction:column;gap:8px;min-width:0}
.hud-right{display:flex;align-items:flex-start;gap:7px}
.panel{
  background:
    linear-gradient(152deg,rgba(17,43,48,.84) 0%,rgba(7,23,28,.76) 58%,rgba(5,18,22,.82) 100%);
  border:1px solid var(--line);
  box-shadow:0 10px 26px rgba(0,0,0,.32),inset 0 1px 0 rgba(255,255,255,.07);
  -webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);
}
.hp-panel{
  display:flex;align-items:center;gap:10px;
  padding:8px 12px 8px 9px;
  border-radius:17px;
}
.hearts{display:flex;align-items:center;gap:3px}
.heart{
  position:relative;
  width:23px;height:26px;
  display:grid;place-items:center;
  color:rgba(255,196,140,.2);
  transition:color .3s ease,transform .3s ease,filter .3s ease;
}
.heart .mp-icon{width:21px;height:21px;transition:transform .25s ease}
.heart.on{color:#FFB25C;filter:drop-shadow(0 0 6px rgba(255,150,60,.6))}
.heart.on .mp-icon{transform:scale(1.04)}
.heart.just-lost{animation:heartBreak .5s ease}
@keyframes heartBreak{
  0%{transform:scale(1.25) rotate(-8deg);color:#FF6A52}
  60%{transform:scale(.86) rotate(4deg)}
  100%{transform:scale(1)}
}
.hearts.small .heart{width:19px;height:22px}
.hearts.small .heart .mp-icon{width:18px;height:18px}
.level-tag{display:flex;flex-direction:column;gap:1px;line-height:1.15;min-width:0}
.level-tag span{
  font-size:8px;letter-spacing:.2em;text-transform:uppercase;
  color:rgba(255,217,176,.5);
}
.level-tag b{
  font-size:12.5px;font-weight:700;color:#FFE6C6;
  letter-spacing:.04em;white-space:nowrap;
  max-width:76px;overflow:hidden;text-overflow:ellipsis;
}
.keys-card{padding:8px 10px;border-radius:17px;min-width:106px}
.keys-head{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:3px}
.keys-head span{font-size:8px;letter-spacing:.1em;color:rgba(255,217,176,.5)}
.keys-head b{font-size:11px;font-weight:800;color:#FFD9A8;font-variant-numeric:tabular-nums}
.key-slots{display:flex;gap:5px}
.key-slot{
  width:24px;height:24px;border-radius:8px;
  display:grid;place-items:center;
  background:rgba(255,255,255,.035);
  border:1px solid rgba(255,196,140,.1);
  color:rgba(255,214,170,.18);
  transition:all .3s ease;
}
.key-slot svg{width:14px;height:14px;fill:currentColor;display:block}
.key-slot.got{
  color:#3A1C06;
  background:linear-gradient(155deg,#FFDFA3,#FF9F4A);
  border-color:rgba(255,232,190,.75);
  box-shadow:0 0 14px rgba(255,150,60,.5),inset 0 1px 0 rgba(255,255,255,.55);
  animation:keyPop .45s ease;
}
@keyframes keyPop{0%{transform:scale(.55)}60%{transform:scale(1.16)}100%{transform:scale(1)}}
.icon-btn{
  width:42px;height:42px;padding:0;
  display:grid;place-items:center;
  border-radius:15px;
  color:rgba(255,232,205,.84);
  transition:transform .12s ease,background .2s ease;
  pointer-events:auto;
}
.icon-btn .mp-icon{width:19px;height:19px}
.icon-btn:active{transform:scale(.93)}
.icon-btn .sound-off{display:none}
.icon-btn.muted{color:rgba(255,232,205,.4)}
.icon-btn.muted .sound-off{display:inline-block}
.icon-btn.muted i:not(.sound-off){display:none}

.tool-dock{display:flex;gap:6px;margin-left:2px}
.tool-slot{
  position:relative;
  width:36px;height:36px;border-radius:12px;
  display:grid;place-items:center;
  background:rgba(7,24,29,.72);
  border:1px solid rgba(255,196,140,.13);
  color:rgba(255,214,170,.26);
  -webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);
  transition:all .3s ease;
}
.tool-slot svg{width:17px;height:17px;fill:currentColor;display:block}
.tool-slot em{
  position:absolute;top:calc(100% + 3px);left:50%;transform:translateX(-50%);
  font-size:8px;letter-spacing:.06em;color:rgba(255,222,184,.35);
  opacity:0;transition:opacity .3s ease;white-space:nowrap;
}
.tool-slot.owned{
  color:#2C1607;
  background:linear-gradient(155deg,#FFE1A7,#FFA24F);
  border-style:solid;border-color:rgba(255,232,190,.7);
  box-shadow:0 0 18px rgba(255,150,60,.35),0 6px 16px rgba(0,0,0,.3);
  animation:keyPop .45s ease;
}
.tool-slot.owned em{opacity:1;color:rgba(255,226,192,.6)}

.objective{
  position:absolute;left:50%;bottom:calc(var(--safe-bottom) + 82px);
  transform:translate(-50%,10px);
  display:flex;align-items:center;gap:8px;
  padding:7px 13px 7px 8px;
  border-radius:999px;
  background:rgba(5,20,25,.78);
  border:1px solid rgba(255,201,146,.22);
  box-shadow:0 12px 30px rgba(0,0,0,.4),inset 0 1px 0 rgba(255,255,255,.06);
  -webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);
  opacity:0;pointer-events:none;
  transition:opacity .3s ease,transform .3s ease;
  white-space:nowrap;
}
.objective.show{opacity:1;transform:translate(-50%,0)}
.obj-arrow{
  width:26px;height:26px;flex:0 0 26px;
  display:grid;place-items:center;
  border-radius:50%;
  color:#FFB25C;
  background:rgba(255,138,61,.1);
  border:1px solid rgba(255,190,130,.18);
}
.obj-arrow svg{width:14px;height:14px;fill:currentColor;display:block;transition:transform .18s linear;filter:drop-shadow(0 0 5px rgba(255,150,60,.5))}
.obj-label{display:flex;align-items:baseline;gap:7px}
.obj-label b{font-size:11px;font-weight:700;color:#FFE1BC;letter-spacing:.03em}
.obj-label em{font-size:9px;color:rgba(255,217,176,.46);font-variant-numeric:tabular-nums;letter-spacing:.04em}

.hint-pill{
  position:absolute;left:50%;bottom:calc(var(--safe-bottom) + 22px);
  transform:translateX(-50%);
  display:inline-flex;align-items:center;gap:8px;
  padding:9px 15px;
  border-radius:999px;
  font-size:11px;letter-spacing:.02em;
  color:rgba(255,240,222,.82);
  background:rgba(5,20,25,.68);
  border:1px solid rgba(255,200,150,.13);
  box-shadow:0 10px 26px rgba(0,0,0,.34);
  -webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);
  white-space:nowrap;max-width:calc(100% - 28px);
  overflow:hidden;text-overflow:ellipsis;
  transition:opacity .5s ease,transform .5s ease;
  pointer-events:none;
}
.hint-pill.hide{opacity:0;transform:translate(-50%,8px)}
.hint-dot{
  width:6px;height:6px;flex:0 0 6px;border-radius:50%;
  background:var(--amber-2);
  box-shadow:0 0 9px rgba(255,180,100,.9);
  animation:hintBlink 1.7s ease-in-out infinite;
}
@keyframes hintBlink{0%,100%{opacity:.4;transform:scale(.82)}50%{opacity:1;transform:scale(1)}}

.toast{
  position:absolute;left:50%;top:calc(var(--safe-top) + 24%);
  transform:translate(-50%,-8px) scale(.96);
  padding:10px 16px;
  max-width:88%;
  border-radius:14px;
  background:linear-gradient(150deg,rgba(255,180,96,.96),rgba(255,138,61,.96));
  color:#2B1507;
  font-size:12.5px;font-weight:800;letter-spacing:.01em;
  text-align:center;
  box-shadow:0 14px 36px rgba(0,0,0,.4),0 0 28px rgba(255,138,61,.22);
  opacity:0;pointer-events:none;
  transition:opacity .22s ease,transform .22s ease;
}
.toast.show{opacity:1;transform:translate(-50%,0) scale(1)}
.toast.soft{
  background:rgba(6,23,28,.92);
  color:#FFE3C0;
  border:1px solid rgba(255,196,140,.24);
  font-weight:600;
  box-shadow:0 14px 36px rgba(0,0,0,.4);
}
.toast.warn{
  background:linear-gradient(150deg,#FF7F64,#FF5B45);
  color:#2B0B04;
  box-shadow:0 14px 36px rgba(0,0,0,.4),0 0 30px rgba(255,80,60,.3);
}

.stick{
  position:absolute;
  width:88px;height:88px;
  margin:-44px 0 0 -44px;
  border-radius:50%;
  border:1.5px solid rgba(255,214,170,.24);
  background:radial-gradient(closest-side,rgba(255,196,140,.09),rgba(255,196,140,.02) 72%,transparent);
  box-shadow:0 0 0 1px rgba(0,0,0,.15) inset;
  opacity:0;pointer-events:none;
  transition:opacity .12s ease;
  z-index:21;
}
.stick.show{opacity:1}
.stick-knob{
  position:absolute;left:50%;top:50%;
  width:38px;height:38px;margin:-19px 0 0 -19px;
  border-radius:50%;
  background:linear-gradient(155deg,#FFC77D,#FF8A3D);
  box-shadow:0 4px 14px rgba(0,0,0,.4),inset 0 1px 0 rgba(255,255,255,.6),0 0 18px rgba(255,150,60,.45);
  transform:translate(0,0);
}

/* ---------- overlays ---------- */
.overlay{
  position:absolute;inset:0;z-index:40;
  display:flex;align-items:center;justify-content:center;
  padding:22px;
  opacity:0;visibility:hidden;pointer-events:none;
  transition:opacity .32s ease,visibility .32s;
}
.overlay.show{opacity:1;visibility:visible;pointer-events:auto}
.overlay[aria-hidden="true"]{pointer-events:none}

/* ---------- 首页主视觉 ---------- */
.keyart{
  position:absolute;inset:0;z-index:2;
  overflow:hidden;pointer-events:none;
  opacity:1;
  transition:opacity .55s ease,visibility .55s;
}
.keyart::after{
  content:"";position:absolute;inset:0;
  background:
    radial-gradient(120% 76% at 50% 36%,transparent 46%,rgba(2,8,10,.3) 82%,rgba(2,7,9,.58) 100%);
}
.keyart-svg{
  width:100%;height:100%;display:block;
  transform-origin:50% 36%;
  animation:kaBreathe 28s ease-in-out infinite alternate;
}
.stage:not([data-screen="intro"]) .keyart{opacity:0;visibility:hidden}
@keyframes kaBreathe{from{transform:scale(1)}to{transform:scale(1.045)}}
@keyframes kaBreatheUp{from{transform:translateY(-5.5%) scale(1)}to{transform:translateY(-5.5%) scale(1.045)}}
@media (max-height:740px) and (min-height:621px){
  .keyart-svg{animation-name:kaBreatheUp}
}
.ka-stars{animation:kaTwinkle 5.5s ease-in-out infinite alternate}
@keyframes kaTwinkle{from{opacity:.5}to{opacity:.95}}
.ka-cloud{animation:kaCloud 26s ease-in-out infinite alternate}
@keyframes kaCloud{from{transform:translateX(-9px)}to{transform:translateX(11px)}}
.ka-portal-rune{transform-origin:195px 352px;animation:kaSpin 42s linear infinite}
@keyframes kaSpin{to{transform:rotate(360deg)}}
.ka-flame{transform-origin:114px 452px;animation:kaFlame 2.6s ease-in-out infinite}
.ka-flame-2{transform-origin:276px 452px;animation-delay:-1.2s}
@keyframes kaFlame{
  0%,100%{transform:scale(1);opacity:.9}
  50%{transform:scaleY(1.14) scaleX(.92);opacity:1}
}
.ka-lamp-glow{transform-origin:55.5px 62px;animation:kaLamp 3.6s ease-in-out infinite}
@keyframes kaLamp{
  0%,100%{opacity:.8;transform:scale(1)}
  50%{opacity:1;transform:scale(1.07)}
}
.ka-fog-band{animation:kaFog 20s ease-in-out infinite alternate}
.ka-fog-band-2{animation-duration:27s;animation-delay:-7s}
.ka-fog-band-3{animation-duration:34s;animation-delay:-14s}
@keyframes kaFog{from{transform:translateX(-16px)}to{transform:translateX(18px)}}
.ka-fly{animation:kaFly 5.6s ease-in-out infinite alternate}
.ka-fly-2{animation-delay:-1.4s;animation-duration:6.4s}
.ka-fly-3{animation-delay:-2.6s;animation-duration:5.1s}
.ka-fly-4{animation-delay:-3.4s;animation-duration:7.2s}
.ka-fly-5{animation-delay:-.8s;animation-duration:6.8s}
.ka-fly-6{animation-delay:-2.1s;animation-duration:5.4s}
.ka-fly-7{animation-delay:-4s;animation-duration:6.1s}
.ka-fly-8{animation-delay:-3s;animation-duration:5.8s}
@keyframes kaFly{
  0%{transform:translate(0,0);opacity:.22}
  45%{opacity:.9}
  100%{transform:translate(7px,-15px);opacity:.38}
}

/* ---------- intro ---------- */
.intro{
  align-items:flex-end;
  padding:calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 22px);
  background:
    linear-gradient(180deg,rgba(3,12,16,.5) 0%,rgba(3,12,16,.14) 13%,transparent 30%,transparent 43%,rgba(3,12,15,.5) 62%,rgba(3,13,15,.9) 78%,#040f11 100%);
}
.home-top{
  position:absolute;top:calc(var(--safe-top) + 14px);left:16px;right:16px;
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  z-index:2;
}
.chapter-chip,.best-chip{
  display:inline-flex;align-items:center;gap:7px;
  padding:7px 12px;
  border-radius:999px;
  font-size:9.5px;letter-spacing:.12em;
  color:rgba(255,232,205,.78);
  background:rgba(5,20,25,.55);
  border:1px solid rgba(255,196,140,.16);
  box-shadow:0 6px 18px rgba(0,0,0,.24),inset 0 1px 0 rgba(255,255,255,.05);
  -webkit-backdrop-filter:blur(9px);backdrop-filter:blur(9px);
  white-space:nowrap;
}
.best-chip{color:#FFCF95;letter-spacing:.06em;font-variant-numeric:tabular-nums}
.best-chip:empty{display:none}
.tag-dot{
  width:5px;height:5px;border-radius:50%;background:#FFB25C;
  box-shadow:0 0 8px rgba(255,180,100,.9);
  animation:hintBlink 1.8s ease-in-out infinite;
}
.home-body{
  width:100%;max-width:390px;margin:0 auto;
  text-align:center;
  animation:introUp .75s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes introUp{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:none}}
@keyframes floaty{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}
.kicker{
  margin:6px 0 7px;
  font-size:9px;font-weight:700;
  letter-spacing:.34em;
  color:#FFC98B;opacity:.68;
  text-transform:uppercase;
}
.home-body .kicker{
  margin:0 0 7px;
  letter-spacing:.38em;text-indent:.38em;
}
.home-title{
  margin:0 0 9px;
  font-size:46px;line-height:1.06;font-weight:900;
  letter-spacing:.14em;text-indent:.14em;
  color:#FFF8EA;
  background:linear-gradient(180deg,#FFFDF4 0%,#FFEFC7 50%,#FFBE72 100%);
  -webkit-background-clip:text;background-clip:text;
  -webkit-text-fill-color:transparent;
  filter:drop-shadow(0 2px 0 rgba(59,25,4,.45)) drop-shadow(0 0 30px rgba(255,150,60,.28));
}
@supports not ((-webkit-background-clip:text) or (background-clip:text)){
  .home-title{
    color:#FFF3D6;-webkit-text-fill-color:#FFF3D6;
    background:none;
    text-shadow:0 2px 0 rgba(59,25,4,.45),0 0 26px rgba(255,150,60,.26);
  }
}
.sub{
  margin:0 auto 16px;
  max-width:300px;
  font-size:12.5px;line-height:1.9;
  color:rgba(255,238,218,.68);
  letter-spacing:.01em;
  text-shadow:0 1px 8px rgba(0,0,0,.45);
}
.home-goals{
  display:grid;grid-template-columns:repeat(3,1fr);
  margin:0 0 16px;
  padding:11px 4px 12px;
  border-radius:20px;
  background:linear-gradient(158deg,rgba(18,44,46,.72),rgba(6,22,25,.58));
  border:1px solid rgba(255,196,140,.14);
  box-shadow:0 16px 38px rgba(0,0,0,.32),inset 0 1px 0 rgba(255,255,255,.06);
  -webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);
}
.goal{
  position:relative;
  display:flex;flex-direction:column;align-items:center;gap:3px;
  min-width:0;padding:0 2px;
}
.goal + .goal{border-left:1px solid rgba(255,196,140,.12)}
.goal-ico{
  width:38px;height:38px;margin-bottom:2px;
  border-radius:13px;
  display:grid;place-items:center;
  color:#FFC178;
  background:radial-gradient(120% 120% at 30% 20%,rgba(255,174,88,.28),rgba(255,138,61,.06));
  border:1px solid rgba(255,190,130,.2);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.08),0 4px 12px rgba(0,0,0,.18);
}
.goal-ico .mp-icon{width:19px;height:19px}
.goal b{font-size:11px;font-weight:700;letter-spacing:.02em;color:#FFE7C9;white-space:nowrap}
.goal small{font-size:8.5px;line-height:1.3;color:rgba(255,222,184,.42);white-space:nowrap}
.fineprint{
  margin:11px 0 0;
  font-size:9px;line-height:1.5;letter-spacing:.03em;
  color:rgba(255,235,215,.3);
}
.start-btn{
  height:58px;padding:0 54px;
  border-radius:19px;
  font-size:17px;letter-spacing:.08em;
}
.start-btn > .mp-icon{width:21px;height:21px}
.start-arrow{
  position:absolute;right:0;top:0;bottom:0;width:46px;
  display:grid;place-items:center;
  border-left:1px solid rgba(120,52,8,.16);
  background:linear-gradient(180deg,rgba(255,255,255,.15),rgba(255,255,255,0));
  border-radius:0 19px 19px 0;
}
.start-arrow .mp-icon{width:18px;height:18px;opacity:.82}

/* ---------- buttons ---------- */
.btn{
  position:relative;
  width:100%;
  display:flex;align-items:center;justify-content:center;gap:8px;
  border-radius:17px;
  font-size:16.5px;font-weight:800;letter-spacing:.06em;
  transition:transform .12s ease,filter .2s ease,box-shadow .2s ease;
  overflow:hidden;
  -webkit-tap-highlight-color:transparent;
}
.btn .mp-icon{width:19px;height:19px}
.btn.primary{
  height:54px;
  color:#311706;
  background:linear-gradient(180deg,#FFC06B 0%,#FF8A3D 54%,#FF7A2E 100%);
  box-shadow:0 14px 30px rgba(255,110,40,.3),inset 0 1px 0 rgba(255,255,255,.6),inset 0 -2px 0 rgba(140,55,8,.22);
}
.btn.primary::after{
  content:"";position:absolute;left:-40%;top:-60%;
  width:27%;height:220%;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.24),transparent);
  transform:rotate(20deg);
  animation:sheen 5.4s ease-in-out infinite;
}
@keyframes sheen{0%,72%{left:-40%}88%,100%{left:132%}}
.btn:active{transform:translateY(1px) scale(.988);filter:brightness(.97)}
.btn:focus-visible{outline:2px solid #FFD9A8;outline-offset:3px}
.btn[disabled]{opacity:.6;pointer-events:none}

/* ---------- modal puzzle ---------- */
.overlay.puzzle,.overlay.battle{
  background:
    radial-gradient(90% 60% at 50% 8%,rgba(22,54,58,.4),transparent 62%),
    rgba(2,10,13,.7);
  -webkit-backdrop-filter:blur(7px);backdrop-filter:blur(7px);
  padding:18px;
}
.modal{
  position:relative;
  width:min(372px,100%);
  max-height:calc(100dvh - 36px);
  overflow-y:auto;
  padding:24px 22px 20px;
  border-radius:28px;
  background:
    radial-gradient(120% 80% at 50% 0%,rgba(43,82,76,.42),transparent 56%),
    linear-gradient(160deg,rgba(21,44,45,.98) 0%,rgba(9,25,28,.99) 56%,rgba(5,17,20,1) 100%);
  border:1px solid rgba(255,196,140,.2);
  box-shadow:0 34px 90px rgba(0,0,0,.65),inset 0 1px 0 rgba(255,255,255,.08);
  text-align:center;
  scrollbar-width:none;
  animation:cardIn .4s cubic-bezier(.2,.8,.2,1) both;
}
.modal::-webkit-scrollbar{display:none}
.modal::before,.modal::after{
  content:"";position:absolute;pointer-events:none;
  width:8px;height:8px;border:1px solid rgba(255,196,140,.3);
  transform:rotate(45deg);top:16px;
}
.modal::before{left:16px}
.modal::after{right:16px}
@keyframes cardIn{from{opacity:0;transform:translateY(14px) scale(.97)}to{opacity:1;transform:none}}
.modal-close{
  position:absolute;right:12px;top:12px;
  width:34px;height:34px;border-radius:11px;
  display:grid;place-items:center;
  color:rgba(255,226,190,.55);
  background:rgba(255,255,255,.045);
  border:1px solid rgba(255,196,140,.1);
  transition:transform .12s ease,background .2s ease;
  z-index:2;
}
.modal-close .mp-icon{width:16px;height:16px}
.modal-close:active{transform:scale(.92);background:rgba(255,255,255,.09)}
.modal h2{
  margin:0 0 8px;
  font-size:27px;font-weight:900;letter-spacing:.1em;text-indent:.1em;
  color:#FFF4E2;
  text-shadow:0 0 30px rgba(255,150,70,.2);
}
.modal-sub{
  margin:0 auto 18px;
  font-size:12px;line-height:1.6;
  color:rgba(255,233,208,.58);
  min-height:20px;
  transition:color .2s ease;
}
.modal-sub.wrong{color:#FF8F7A}
.modal-sub.good{color:#8FE9C8}
.modal-foot{
  display:flex;align-items:center;justify-content:center;gap:7px;
  margin:16px 0 0;
  font-size:10px;letter-spacing:.04em;
  color:rgba(255,226,192,.34);
}
.dot-amber{
  width:5px;height:5px;border-radius:50%;
  background:#FFB25C;box-shadow:0 0 7px rgba(255,170,90,.8);
}

.runes{
  display:grid;grid-template-columns:1fr 1fr;gap:11px;
  margin:0 auto;
}
.rune{
  position:relative;
  height:86px;
  border-radius:19px;
  display:grid;place-items:center;
  color:rgba(165,205,193,.52);
  background:
    radial-gradient(90% 90% at 32% 22%,rgba(70,112,100,.32),transparent 62%),
    linear-gradient(160deg,rgba(29,57,56,.9),rgba(10,27,30,.94));
  border:1px solid rgba(158,205,188,.16);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.05),0 8px 20px rgba(0,0,0,.24);
  transition:transform .1s ease,background .22s ease,color .22s ease,box-shadow .22s ease,border-color .22s ease;
  overflow:hidden;
}
.rune::after{
  content:"";position:absolute;inset:7px;border-radius:14px;
  border:1px dashed rgba(198,232,218,.1);
  pointer-events:none;
}
.rune .mp-icon{width:32px;height:32px;position:relative;z-index:1;transition:transform .2s ease}
.rune .rune-no{
  position:absolute;right:8px;bottom:5px;
  font-size:8px;letter-spacing:.14em;color:rgba(255,226,192,.18);
}
.rune:active{transform:scale(.96)}
.rune.lit{
  color:#2B1405;
  background:
    radial-gradient(90% 90% at 32% 22%,rgba(255,255,255,.55),transparent 58%),
    linear-gradient(160deg,#FFDda1,#FF9A4A);
  border-color:rgba(255,232,190,.7);
  box-shadow:0 0 34px rgba(255,150,60,.42),inset 0 1px 0 rgba(255,255,255,.5);
}
.rune.lit .mp-icon{transform:scale(1.12)}
.rune.lit .rune-no{color:rgba(60,28,6,.35)}
.rune.pressed{animation:runePress .3s ease}
@keyframes runePress{0%{transform:scale(1)}40%{transform:scale(.93)}100%{transform:scale(1)}}
.modal.shake{animation:shakeCard .42s ease}
@keyframes shakeCard{
  0%,100%{transform:translateX(0)}
  18%{transform:translateX(-7px) rotate(-.4deg)}
  38%{transform:translateX(6px) rotate(.4deg)}
  58%{transform:translateX(-4px)}
  78%{transform:translateX(3px)}
}
.seq-dots{display:flex;align-items:center;justify-content:center;gap:7px;margin-top:16px;min-height:10px}
.seq-dot{
  width:7px;height:7px;border-radius:50%;
  background:rgba(255,255,255,.12);
  transition:all .25s ease;
}
.seq-dot.done{background:#FFB25C;box-shadow:0 0 8px rgba(255,170,90,.7)}
.seq-dot.now{background:rgba(255,210,160,.35);transform:scale(1.15)}

/* ---------- battle ---------- */
.battle-card{
  width:min(392px,100%);
  max-height:calc(100dvh - 24px);
  overflow-y:auto;
  padding:14px 15px 15px;
  border-radius:27px;
  background:
    radial-gradient(120% 70% at 50% 0%,rgba(55,72,62,.32),transparent 58%),
    linear-gradient(165deg,rgba(18,41,44,.985) 0%,rgba(7,22,26,.99) 62%,rgba(4,15,18,1) 100%);
  border:1px solid rgba(255,196,140,.18);
  box-shadow:0 34px 90px rgba(0,0,0,.68),inset 0 1px 0 rgba(255,255,255,.07);
  scrollbar-width:none;
  animation:cardIn .35s cubic-bezier(.2,.8,.2,1) both;
}
.battle-card::-webkit-scrollbar{display:none}
.battle-card.shake{animation:shakeCard .38s ease}
.battle-top{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:2px 4px 10px}
.foe-info{text-align:right}
.foe-info > span{display:block;font-size:11.5px;font-weight:700;letter-spacing:.08em;color:#FFDCAF;margin-bottom:4px}
.foe-hp{display:flex;justify-content:flex-end;gap:4px}
.hp-pip{width:15px;height:5px;border-radius:99px;background:rgba(255,255,255,.1);transition:all .25s ease}
.hp-pip.on{background:linear-gradient(90deg,#FF6A52,#FF9A5C);box-shadow:0 0 8px rgba(255,100,70,.4)}
.battle-arena{
  position:relative;
  height:216px;
  border-radius:17px;
  overflow:hidden;
  background:#06161b;
  border:1px solid rgba(255,196,140,.1);
  box-shadow:inset 0 0 40px rgba(0,0,0,.5);
}
#battle-canvas{width:100%;height:100%;display:block}
.battle-msg{
  position:absolute;left:50%;bottom:9px;
  transform:translateX(-50%);
  padding:6px 13px;
  border-radius:999px;
  background:rgba(4,16,20,.72);
  border:1px solid rgba(255,196,140,.14);
  color:#FFE4C0;font-size:10.5px;letter-spacing:.03em;
  white-space:nowrap;
  -webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);
  transition:opacity .2s ease;
}
.timing{margin-top:12px}
.timing-track{
  position:relative;
  height:15px;border-radius:999px;
  background:linear-gradient(180deg,rgba(0,0,0,.4),rgba(255,255,255,.04));
  border:1px solid rgba(255,196,140,.12);
  box-shadow:inset 0 1px 2px rgba(0,0,0,.55);
  overflow:hidden;
}
.timing-zone{
  position:absolute;top:0;bottom:0;
  left:60%;width:17%;
  background:linear-gradient(180deg,#FFE0A3,#FF9C45);
  box-shadow:0 0 18px rgba(255,170,80,.55);
}
.timing-zone::before,.timing-zone::after{
  content:"";position:absolute;top:-2px;bottom:-2px;width:1.5px;background:rgba(255,244,224,.85);
}
.timing-zone::before{left:0}
.timing-zone::after{right:0}
.timing-marker{
  position:absolute;top:-3px;bottom:-3px;left:0;
  width:5px;border-radius:3px;
  background:#FFF8E8;
  box-shadow:0 0 12px rgba(255,240,200,.9),0 0 22px rgba(255,160,70,.5);
  transform:translateX(-50%);
  z-index:2;
}
.timing-marker::after{
  content:"";position:absolute;left:50%;top:-6px;
  width:7px;height:7px;margin-left:-3.5px;
  background:#FFF8E8;transform:rotate(45deg);border-radius:1px;
}
.charge-row{display:flex;align-items:center;gap:8px;margin-top:7px}
.charge-row > span{font-size:8.5px;letter-spacing:.12em;color:rgba(255,220,180,.38);white-space:nowrap}
.charge{flex:1;height:3px;border-radius:99px;background:rgba(255,255,255,.07);overflow:hidden}
.charge-fill{
  height:100%;width:100%;
  transform-origin:0 50;transform:scaleX(1);
  background:linear-gradient(90deg,#FF6A52,#FF9A5C);
  border-radius:99px;
  transition:transform .1s linear;
}
.strike{margin-top:12px;height:52px;font-size:16px}
.battle-tip{margin:9px 0 0;text-align:center;font-size:8.5px;letter-spacing:.04em;color:rgba(255,235,215,.28)}

/* ---------- results ---------- */
.overlay.result{
  background:
    radial-gradient(85% 55% at 50% 18%,rgba(27,60,62,.36),transparent 64%),
    rgba(2,9,12,.74);
  -webkit-backdrop-filter:blur(7px);backdrop-filter:blur(7px);
}
.result-card{
  width:min(366px,100%);
  max-height:calc(100dvh - 36px);
  overflow-y:auto;
  padding:24px 22px 20px;
  border-radius:28px;
  background:
    radial-gradient(110% 70% at 50% 0%,rgba(255,150,70,.13),transparent 58%),
    linear-gradient(160deg,rgba(21,43,44,.985),rgba(8,23,26,.99) 58%,rgba(4,16,19,1));
  border:1px solid rgba(255,196,140,.2);
  box-shadow:0 34px 90px rgba(0,0,0,.66),inset 0 1px 0 rgba(255,255,255,.08);
  text-align:center;
  scrollbar-width:none;
  animation:cardIn .45s cubic-bezier(.2,.8,.2,1) both;
}
.result-card::-webkit-scrollbar{display:none}
.result-badge{
  width:64px;height:64px;margin:0 auto 10px;
  display:grid;place-items:center;
  border-radius:21px;
  color:#FFE7BE;
  background:linear-gradient(160deg,rgba(255,178,92,.24),rgba(255,110,50,.08));
  border:1px solid rgba(255,200,140,.28);
  box-shadow:0 0 34px rgba(255,150,70,.2),inset 0 1px 0 rgba(255,255,255,.1);
}
.result-badge .mp-icon{width:28px;height:28px}
.result-card h2{
  margin:2px 0 9px;
  font-size:28px;font-weight:900;letter-spacing:.1em;text-indent:.1em;
  color:#FFF4E2;
}
.result-desc{
  margin:0 auto 17px;
  max-width:262px;
  font-size:12px;line-height:1.75;
  color:rgba(255,238,218,.6);
}
.stats{display:flex;gap:8px;margin-bottom:16px}
.stats > div{
  flex:1;
  padding:10px 6px 9px;
  border-radius:14px;
  background:rgba(255,255,255,.035);
  border:1px solid rgba(255,200,150,.1);
}
.stats span{display:block;font-size:8.5px;letter-spacing:.1em;color:rgba(255,230,205,.42);margin-bottom:4px;white-space:nowrap}
.stats b{font-size:16px;color:#FFD9A8;font-weight:800;font-variant-numeric:tabular-nums;white-space:nowrap}
.tiny{margin:11px 0 0;font-size:8.5px;line-height:1.5;letter-spacing:.03em;color:rgba(255,235,215,.3)}
.best-row{
  display:flex;align-items:center;justify-content:center;gap:6px;
  margin:-2px 0 13px;
  font-size:9.5px;letter-spacing:.08em;color:#FFCB8E;
}
.best-row:empty{display:none}
.best-row .mp-icon{width:13px;height:13px}

.result.win .result-card{border-color:rgba(255,208,140,.34)}
.result.win .result-badge{
  color:#3A1D06;
  background:linear-gradient(160deg,#FFE7B0,#FFB25C);
  border-color:rgba(255,235,190,.75);
  box-shadow:0 0 46px rgba(255,180,90,.45),inset 0 1px 0 rgba(255,255,255,.75);
  animation:floaty 4.5s ease-in-out infinite;
}
.result.lose .result-card{border-color:rgba(130,168,172,.22)}
.result.lose .result-badge{
  color:#A9C4C4;
  background:linear-gradient(160deg,rgba(96,130,132,.24),rgba(18,38,42,.5));
  border-color:rgba(160,195,195,.2);
  box-shadow:0 0 28px rgba(80,130,135,.14),inset 0 1px 0 rgba(255,255,255,.07);
}
.result.lose h2{color:#DCE8E4}
.result.lose .stats b{color:#CFE2DC}

/* ---------- short screens ---------- */
@media (max-height:760px){
  .home-title{font-size:41px}
  .sub{font-size:12px;margin-bottom:13px;line-height:1.75}
  .home-goals{padding:9px 4px 10px;margin-bottom:13px}
  .goal-ico{width:35px;height:35px}
  .start-btn{height:54px;font-size:16px}
  .battle-arena{height:188px}
  .runes{gap:9px}
  .rune{height:76px}
}
@media (max-height:680px){
  .home-title{font-size:36px;margin-bottom:6px}
  .home-body .kicker{font-size:8px;margin-bottom:4px}
  .sub{font-size:11px;margin-bottom:11px;line-height:1.62}
  .home-goals{padding:8px 3px 9px;margin-bottom:11px;border-radius:17px}
  .goal{gap:2px}
  .goal-ico{width:32px;height:32px;border-radius:11px;margin-bottom:1px}
  .goal-ico .mp-icon{width:17px;height:17px}
  .goal b{font-size:10px}
  .goal small{font-size:8px}
  .start-btn{height:50px;font-size:15.5px;border-radius:17px}
  .start-arrow{border-radius:0 17px 17px 0}
  .battle-arena{height:160px}
  .battle-card{padding:11px 12px 12px}
  .result-card{padding:18px 18px 16px}
  .result-badge{width:52px;height:52px;border-radius:17px;margin-bottom:6px}
  .result-card h2{font-size:24px}
  .result-desc{margin-bottom:12px;font-size:11px}
  .stats{margin-bottom:12px}
}
@media (max-height:620px){
  .intro{padding-top:calc(var(--safe-top) + 10px)}
  .home-title{font-size:31px;margin-bottom:5px}
  .home-body .kicker{font-size:7.5px}
  .sub{display:none}
  .home-goals{margin-bottom:9px;padding:7px 3px 8px}
  .goal-ico{width:29px;height:29px}
  .goal b{font-size:9.5px}
  .goal small{display:none}
  .start-btn{height:48px}
  .fineprint{display:none}
  .battle-arena{height:148px}
}
@media (max-width:360px){
  .intro{padding-left:14px;padding-right:14px}
  .home-title{font-size:40px}
  .home-goals{padding:10px 2px 11px}
  .goal b{font-size:10px}
  .goal small{font-size:7.5px}
  .goal-ico{width:34px;height:34px}
  .start-btn{font-size:16px;padding:0 50px}
  .level-tag b{max-width:62px;font-size:11px}
  .keys-card{min-width:98px;padding:7px 8px}
  .key-slot{width:22px;height:22px}
  .icon-btn{width:38px;height:38px}
  .modal{padding:20px 16px 17px}
}
@media (prefers-reduced-motion:reduce){
  .result.win .result-badge,.hint-dot,.tag-dot{animation:none}
  .keyart-svg,.ka-stars,.ka-cloud,.ka-portal-rune,.ka-flame,.ka-lamp-glow,.ka-fog-band,.ka-fly{animation:none}
  .btn.primary::after{display:none}
  .home-body,.modal,.battle-card,.result-card{animation:none}
  .overlay,.toast,.hint-pill,.objective{transition:none}
}

.replay-seq{
  margin-left:2px;
  padding:4px 8px;
  border-radius:7px;
  border:1px solid rgba(255,196,140,.18);
  background:rgba(255,196,140,.07);
  color:#FFCB8E;
  font-size:9px;letter-spacing:.06em;
  transition:transform .12s ease,background .2s ease;
}
.replay-seq:active{transform:scale(.94);background:rgba(255,196,140,.14)}
