:root{
  --cream:#FFF4E2;
  --plum:#2B1B3D;
  --plum-soft:#4A2E6E;
  --pink:#FF4F8B;
  --amber:#FFB03A;
  --teal:#37C7B6;
  --moss:#7BC043;
  --violet:#6C4BD8;
  --safe-top:max(14px, env(safe-area-inset-top));
  --safe-left:max(14px, env(safe-area-inset-left));
  --safe-right:max(14px, env(safe-area-inset-right));
  --safe-bottom:max(14px, env(safe-area-inset-bottom));
}
*{box-sizing:border-box;}
html,body{
  margin:0;padding:0;height:100%;width:100%;
  background:#241534;
  overflow:hidden;
  font-family:'Figtree',system-ui,sans-serif;
  color:var(--plum);
  -webkit-tap-highlight-color:transparent;
  overscroll-behavior:none;
}
body{position:fixed;inset:0;}
#stage{position:absolute;inset:0;overflow:hidden;}
#scene{
  position:absolute;inset:0;width:100%;height:100%;display:block;
  touch-action:none;user-select:none;-webkit-user-select:none;
  cursor:crosshair;
  filter:saturate(1.12) contrast(1.03) brightness(1.0);
}
.grade{
  position:absolute;inset:0;z-index:1;pointer-events:none;
  background:
    radial-gradient(ellipse at 50% 46%, rgba(43,27,61,0) 42%, rgba(43,27,61,.16) 100%),
    linear-gradient(180deg, rgba(255,206,140,.05) 0%, rgba(255,244,226,0) 34%, rgba(43,27,61,.08) 100%);
}
.hud{position:absolute;inset:0;pointer-events:none;z-index:5;transition:opacity .35s ease, visibility .35s ease;}
.hud.hud-hidden{display:none;opacity:0;visibility:hidden;pointer-events:none;}
.hud.hud-hidden .icon-button{pointer-events:none;}
.hud-top{
  position:absolute;top:calc(var(--safe-top) + 2px);left:var(--safe-left);right:var(--safe-right);
  display:flex;align-items:flex-start;justify-content:space-between;gap:10px;
}
.stat-row{display:flex;align-items:stretch;gap:8px;flex-wrap:wrap;max-width:72vw;}
.chip{
  background:linear-gradient(180deg,#FFF9EC 0%, var(--cream) 60%, #FFE9C8 100%);
  border:2px solid rgba(255,255,255,.6);
  border-radius:16px;
  box-shadow:0 4px 0 rgba(85,48,110,.30), 0 10px 22px rgba(43,27,61,.22);
  color:var(--plum);
  display:flex;align-items:center;
}
.chip.stat-chip{padding:7px 14px 8px 13px;flex-direction:column;align-items:flex-start;line-height:1;transform:rotate(-1.4deg);}
.stat-label{
  font-size:10px;letter-spacing:.12em;text-transform:uppercase;font-weight:700;
  color:#8a5a92;margin-bottom:3px;
}
.stat-value{font-family:'Fredoka',system-ui,sans-serif;font-weight:600;font-size:22px;letter-spacing:.01em;}
.stat-value.small{font-size:19px;}
.spore-chip{
  gap:2px;padding:4px 13px 4px 3px;transform:rotate(1.2deg);
  min-width:74px;
}
.chip-icon{width:34px;height:34px;display:block;filter:drop-shadow(0 2px 2px rgba(43,27,61,.18));}
.icon-button{
  position:relative;z-index:2;
  pointer-events:auto;background:none;border:0;padding:0;margin:0;
  width:56px;height:56px;cursor:pointer;
  filter:drop-shadow(0 4px 0 rgba(85,48,110,.30)) drop-shadow(0 9px 16px rgba(43,27,61,.25));
  transition:transform .16s cubic-bezier(.2,.9,.3,1.3);
  transform:rotate(1.5deg);
}
.icon-button img{width:100%;height:100%;display:block;}
.icon-button:active{transform:scale(.92) rotate(1.5deg);}
.icon-button:focus-visible{outline:3px solid var(--teal);outline-offset:4px;border-radius:18px;}

.ink-wrap{
  position:absolute;left:calc(var(--safe-left) - 4px);bottom:calc(var(--safe-bottom) + 8px);
  width:min(238px,52vw);pointer-events:none;
  filter:drop-shadow(0 6px 10px rgba(43,27,61,.32));
}
.ink-label{
  display:block;padding-left:12px;margin-bottom:-3px;
  font-family:'Fredoka',system-ui,sans-serif;font-size:11px;font-weight:600;
  letter-spacing:.16em;text-transform:uppercase;color:var(--cream);
  text-shadow:0 2px 0 rgba(58,33,80,.65), 0 0 10px rgba(43,27,61,.6);
}
.ink-line{width:100%;height:auto;display:block;overflow:visible;}
.ink-track{
  fill:none;stroke:rgba(255,244,226,.42);stroke-width:10;stroke-linecap:round;
}
.ink-fill{
  fill:none;stroke:var(--amber);stroke-width:7;stroke-linecap:round;
  stroke-linejoin:round;
}
.ink-nib{fill:#FFE6AE;stroke:#FFF9EC;stroke-width:2.5;}

.hints{
  position:absolute;left:0;right:0;bottom:calc(var(--safe-bottom) + 74px);
  display:flex;justify-content:center;align-items:flex-end;gap:8px;
  padding:0 12px;pointer-events:none;
  transition:opacity .6s ease, transform .6s ease;
}
.hints.gone{opacity:0;transform:translateY(14px);}
.hint{
  display:flex;align-items:center;gap:6px;
  background:linear-gradient(180deg,#FFF9EC, #FFEBCB);
  border-radius:14px;padding:5px 12px 5px 5px;
  box-shadow:0 3px 0 rgba(85,48,110,.28), 0 8px 18px rgba(43,27,61,.22);
  color:var(--plum);font-weight:700;font-size:12.5px;line-height:1;
  opacity:0;transform:translateY(10px);
  transition:opacity .4s ease, transform .4s ease;
  max-width:46vw;
}
.hint.show{opacity:1;transform:translateY(0);}
.hint.hot{animation:hintPulse 1.5s ease-in-out infinite;}
@keyframes hintPulse{0%,100%{transform:translateY(0) scale(1);}50%{transform:translateY(-3px) scale(1.035);}}
.hint.done{opacity:0;transform:translateY(-10px);}
.hint img{width:32px;height:32px;display:block;flex:none;}
.hint span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}

.overlay{position:absolute;inset:0;z-index:6;}
.hidden{display:none !important;}
.title-screen{
  display:flex;align-items:flex-start;justify-content:center;
  pointer-events:none;
  background:
    radial-gradient(ellipse at 50% 22%, rgba(43,27,61,.30) 0%, rgba(43,27,61,0) 48%),
    linear-gradient(180deg, rgba(43,27,61,.20) 0%, rgba(43,27,61,0) 30%, rgba(43,27,61,0) 60%, rgba(43,27,61,.24) 100%);
}
.title-block{
  width:min(760px,94vw);
  margin-top:calc(var(--safe-top) + 6vh);
  display:flex;flex-direction:column;align-items:center;text-align:center;
  pointer-events:none;
}
.game-title{
  margin:0;line-height:.82;font-family:'Fredoka',system-ui,sans-serif;font-weight:700;
  display:flex;flex-direction:column;align-items:center;gap:.01em;
  user-select:none;
}
.title-line{
  display:flex;justify-content:center;align-items:flex-end;
  color:var(--cream);
  font-size:clamp(38px, 10.8vw, 92px);
  letter-spacing:.015em;
  -webkit-text-stroke:.072em #4A2E6E;
  paint-order:stroke fill;
  text-shadow:
    0 .04em 0 #5B3C94,
    0 .085em 0 #4A2E7E,
    0 .13em 0 #3A2365,
    0 .17em 0 #2C1A4C,
    0 .21em .12em rgba(26,14,44,.55),
    0 .30em .34em rgba(43,27,61,.32);
  transform:rotate(-1.2deg);
}
.title-line span{display:inline-block;}
.line-one span:nth-child(2){transform:translateY(-.03em) rotate(-2deg);}
.line-one span:nth-child(3){transform:translateY(.02em) rotate(1.5deg);}
.line-one span:nth-child(4){transform:translateY(-.015em) rotate(-1deg);}
.line-one span:nth-child(5){transform:translateY(.02em) rotate(2deg);}
.line-one span:nth-child(6){transform:translateY(-.025em) rotate(-1.5deg);}
.line-one span:nth-child(7){transform:translateY(.015em) rotate(1deg);}
.line-one span:nth-child(8){transform:translateY(-.01em) rotate(-2deg);}
.line-two{
  transform:rotate(1deg);
  font-size:clamp(40px, 11.6vw, 98px);
  margin-top:-.02em;
}
.line-two span:nth-child(2){transform:translateY(.02em) rotate(-1.5deg);}
.line-two span:nth-child(3){transform:translateY(-.02em) rotate(1.5deg);}
.line-two span:nth-child(4){transform:translateY(.01em) rotate(-1deg);}
.line-two span:nth-child(5){transform:translateY(-.01em) rotate(1.4deg);}
.line-two span:nth-child(6){transform:translateY(.02em) rotate(-1.8deg);}
.cap-accent{
  position:absolute;transform:translate(-.98em,-.64em) rotate(-14deg);
  width:.66em;height:.44em;border-radius:.34em .34em .1em .1em;
  background:linear-gradient(180deg,#FF74A5, var(--pink) 65%, #D93A72);
  border:.05em solid #4A2E6E;
  box-shadow:inset 0 .04em 0 rgba(255,255,255,.55), 0 .05em 0 #4A2E6E;
}
.cap-accent i{
  position:absolute;width:.11em;height:.09em;border-radius:50%;
  background:#FFF4E2;top:.12em;
}
.cap-accent i:nth-child(1){left:.12em;}
.cap-accent i:nth-child(2){left:.32em;top:.22em;width:.09em;height:.07em;}
.cap-accent i:nth-child(3){left:.46em;top:.1em;width:.08em;height:.06em;}
.title-line.line-one{position:relative;}
.tagline{
  margin:.72em 0 1.15em;
  font-family:'Figtree',system-ui,sans-serif;font-weight:700;
  font-size:clamp(14px,3.6vw,19px);letter-spacing:.02em;
  color:#FFF9EC;
  text-shadow:0 2px 0 rgba(58,33,80,.5),0 8px 18px rgba(43,27,61,.55);
}
.play-chip{
  pointer-events:auto;
  font-family:'Fredoka',system-ui,sans-serif;font-weight:600;
  font-size:clamp(22px,5.6vw,30px);
  letter-spacing:.04em;
  color:var(--plum);
  background:linear-gradient(180deg,#FFFDF5 0%,#FFF3DA 55%,#FFE2B0 100%);
  border:3px solid rgba(255,255,255,.72);
  border-radius:22px;
  padding:.44em 1.5em .55em;
  box-shadow:
    0 6px 0 #C58A3C,
    0 12px 0 rgba(74,46,110,.25),
    0 22px 38px rgba(43,27,61,.38);
  cursor:pointer;
  transition:transform .14s cubic-bezier(.2,.9,.3,1.35), box-shadow .16s ease;
  transform:rotate(-1deg);
}
.play-chip:hover{transform:translateY(-2px) rotate(-1deg);}
.play-chip:active{transform:translateY(3px) scale(.975);box-shadow:0 3px 0 rgba(85,48,110,.3),0 8px 16px rgba(43,27,61,.3);}
.play-chip:focus-visible{outline:3px solid var(--teal);outline-offset:4px;}
.title-hints{
  display:flex;justify-content:center;gap:8px;flex-wrap:wrap;
  margin-top:1.5em;max-width:min(92vw,660px);
}
.mini-hint{
  display:flex;align-items:center;gap:6px;
  background:linear-gradient(180deg,#FFF9EC,#FFEBCB);
  border-radius:14px;padding:5px 12px 5px 5px;
  box-shadow:0 3px 0 rgba(85,48,110,.28),0 8px 16px rgba(43,27,61,.2);
  font-weight:700;font-size:12.5px;color:var(--plum);
}
.mini-hint img{width:31px;height:31px;display:block;flex:none;}
.key-note{
  display:none;margin:14px 0 0;font-size:11.5px;font-weight:700;letter-spacing:.02em;
  color:#FFF7E6;text-shadow:0 2px 0 rgba(58,33,80,.45),0 6px 14px rgba(43,27,61,.5);
}
.key-note.show{display:block;}
.best-chip{
  margin-top:16px;padding:8px 16px;font-weight:700;font-size:13px;gap:6px;
  transform:rotate(.8deg);
}
.best-chip b{font-family:'Fredoka',system-ui,sans-serif;font-weight:600;font-size:16px;}

.card-overlay{
  display:flex;align-items:center;justify-content:center;
  background:rgba(30,16,48,.34);
  backdrop-filter:blur(2px);
  -webkit-backdrop-filter:blur(2px);
  animation:fadeIn .25s ease both;
}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
.card{
  width:min(400px,88vw);
  background:linear-gradient(180deg,#FFFDF6 0%, #FFF4E2 62%, #FFE8C6 100%);
  border:3px solid rgba(255,255,255,.8);
  border-radius:26px;
  padding:26px 26px 20px;
  text-align:center;
  box-shadow:
    0 8px 0 rgba(74,46,110,.42),
    0 26px 60px rgba(20,10,36,.5),
    inset 0 2px 0 rgba(255,255,255,.9);
  transform:rotate(-.6deg);
  animation:cardUp .38s cubic-bezier(.18,.9,.28,1.2) both;
}
@keyframes cardUp{from{transform:translateY(34px) rotate(-.6deg) scale(.96);opacity:0}to{transform:translateY(0) rotate(-.6deg) scale(1);opacity:1}}
.card h2{
  margin:0 0 6px;font-family:'Fredoka',system-ui,sans-serif;font-weight:700;
  font-size:34px;color:var(--plum);letter-spacing:.01em;line-height:1;
}
.card-sub{margin:0 0 18px;font-size:14px;color:#7a5386;font-weight:600;line-height:1.45;}
.card-actions{display:flex;flex-direction:column;align-items:center;gap:10px;}
.small-chip{font-size:23px;padding:.4em 1.6em .5em;}
.ghost-chip{
  pointer-events:auto;display:flex;align-items:center;gap:6px;
  background:rgba(255,244,226,.55);border:2px solid rgba(108,75,216,.36);
  border-radius:16px;padding:8px 18px 8px 8px;color:var(--plum);
  font-family:'Figtree',system-ui,sans-serif;font-weight:700;font-size:14px;cursor:pointer;
  box-shadow:0 3px 0 rgba(74,46,110,.2);
}
.ghost-chip img{width:28px;height:28px;display:block;}
.ghost-chip:active{transform:translateY(2px);box-shadow:none;}
.sound-chip{
  pointer-events:auto;margin-top:16px;display:inline-flex;align-items:center;gap:8px;
  background:transparent;border:0;color:#8a5a92;font-family:'Figtree',system-ui,sans-serif;
  font-weight:700;font-size:12.5px;cursor:pointer;padding:8px 12px;border-radius:12px;
}
.sound-chip:focus-visible{outline:3px solid var(--teal);outline-offset:2px;}
.sound-dot{width:12px;height:12px;border-radius:50%;background:var(--teal);box-shadow:0 0 0 3px rgba(55,199,182,.22);}
.sound-chip[aria-pressed="false"] .sound-dot{background:#c9b7cf;box-shadow:0 0 0 3px rgba(120,100,130,.16);}
.result-row{display:flex;justify-content:center;gap:10px;margin:0 0 18px;}
.result{
  flex:1;background:rgba(255,255,255,.46);border-radius:16px;padding:10px 6px 11px;
  border:1px solid rgba(255,255,255,.7);
}
.result-label{display:block;font-size:10px;letter-spacing:.13em;text-transform:uppercase;font-weight:700;color:#9a6a9e;}
.result-value{display:block;font-family:'Fredoka',system-ui,sans-serif;font-weight:600;font-size:25px;color:var(--plum);margin-top:2px;}
.dead-card .play-chip{font-size:23px;padding:.42em 1.5em .52em;}
.inline-icon{width:24px;height:24px;vertical-align:-5px;margin-right:5px;}
.card-foot{margin:13px 0 0;font-size:12px;font-weight:700;color:#9a6a9e;}
.text-button{
  pointer-events:auto;margin-top:9px;background:none;border:0;padding:8px;
  color:#8a5a92;font-family:'Figtree',system-ui,sans-serif;font-weight:700;font-size:12.5px;
  text-decoration:underline;text-decoration-thickness:1.5px;text-underline-offset:3px;cursor:pointer;
}
.text-button:focus-visible{outline:3px solid var(--teal);outline-offset:2px;border-radius:8px;}

.toast{
  position:absolute;left:50%;top:22%;transform:translate(-50%,-8px);
  z-index:8;pointer-events:none;
  background:var(--cream);color:var(--plum);
  padding:10px 18px;border-radius:16px;
  font-family:'Fredoka',system-ui,sans-serif;font-weight:600;font-size:17px;
  box-shadow:0 4px 0 rgba(74,46,110,.35),0 14px 26px rgba(43,27,61,.3);
  opacity:0;transition:opacity .25s ease, transform .25s ease;
  white-space:nowrap;
}
.toast.show{opacity:1;transform:translate(-50%,0);}

@media (max-width:420px){
  .stat-chip{padding:6px 11px 7px;}
  .stat-value{font-size:19px;}
  .spore-chip{min-width:64px;padding-right:10px;}
  .chip-icon{width:29px;height:29px;}
  .icon-button{width:47px;height:47px;}
  .hints{bottom:calc(var(--safe-bottom) + 88px);gap:6px;}
  .hint{font-size:11.5px;padding:4px 9px 4px 4px;gap:4px;}
  .hint img{width:27px;height:27px;}
  .ink-wrap{width:min(200px,55vw);}
  .title-block{margin-top:calc(var(--safe-top) + 8vh);}
  .title-hints{gap:6px;}
  .mini-hint{font-size:11px;padding:4px 9px 4px 4px;}
  .mini-hint img{width:26px;height:26px;}
  .card{padding:22px 20px 17px;}
  .card h2{font-size:29px;}
}
@media (max-height:560px) and (orientation:landscape){
  .title-block{margin-top:calc(var(--safe-top) + 2vh);}
  .title-hints{display:none;}
  .hints{top:calc(var(--safe-top) + 8px);bottom:auto;}
  .toast{top:30%;}
  .hint{font-size:11.5px;padding:4px 10px 4px 4px;}
  .hint img{width:27px;height:27px;}
  .line-one{font-size:clamp(34px,7.4vh,60px);}
  .line-two{font-size:clamp(36px,8vh,64px);}
  .tagline{margin:.4em 0 .7em;}
  .play-chip{font-size:21px;padding:.3em 1.3em .4em;}
  .ink-wrap{width:min(180px,38vw);}
}

.brush-sprite{
  position:absolute;left:0;top:0;z-index:5;
  width:66px;height:auto;pointer-events:none;
  transform:translate(-82%,-78%) rotate(4deg);
  opacity:0;transition:opacity .12s linear;
  filter:drop-shadow(0 6px 10px rgba(43,27,61,.35));
  will-change:left,top;
}
.brush-sprite.show{opacity:1;}

.title-sound{
  position:absolute;top:calc(var(--safe-top) + 2px);right:var(--safe-right);
  pointer-events:auto;z-index:7;
  width:48px;height:48px;padding:9px;
  border:2px solid rgba(255,255,255,.68);border-radius:16px;
  background:linear-gradient(180deg,#FFF9EC,#FFEBCB);
  box-shadow:0 4px 0 rgba(85,48,110,.3),0 9px 18px rgba(43,27,61,.22);
  cursor:pointer;transform:rotate(1.5deg);
  transition:transform .14s ease;
}
.title-sound:active{transform:scale(.92) rotate(1.5deg);}
.title-sound:focus-visible{outline:3px solid var(--teal);outline-offset:4px;}
.title-sound svg{width:100%;height:100%;display:block;overflow:visible;}
.title-sound .spk{fill:var(--plum);}
.title-sound .wave{fill:none;stroke:var(--teal);stroke-width:2;stroke-linecap:round;}
.title-sound .slash{fill:none;stroke:var(--pink);stroke-width:2.6;stroke-linecap:round;opacity:0;}
.title-sound.muted .wave{opacity:0;}
.title-sound.muted .slash{opacity:1;}
@media (max-width:420px){.title-sound{width:42px;height:42px;border-radius:14px;padding:8px;}}
@media (max-width:420px){.brush-sprite{width:52px;}}
