/* Ten Finger Quest
   A chunky toy style: thick ink outlines, keycap buttons that press down,
   and one color per finger shared by keys, nails, balloons and labels. */

:root {
  --ink: #1E1A3C;
  --ink-2: #57537A;
  --ink-3: #A5A2C2;
  --paper: #FFFFFF;
  --paper-2: #F2F3FA;
  --lemon: #FFD43B;
  --pinky: #FF6B9A;
  --ring: #FF9F40;
  --middle: #FFD43B;
  --index: #4CD480;
  --thumb: #6CC4FF;
  --good: #1E9E55;
  --bad: #F0444B;
  --display: 'Lilita One', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --body: 'Andika', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  --drop: 0 7px 0 rgba(20, 16, 50, .35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: #3448C5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
button { font: inherit; color: inherit; }
b, strong { font-weight: 700; }
input { user-select: text; }
#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; animation: screenIn .35s ease both; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

.desk {
  background-color: var(--desk, #3448C5);
  background-image: radial-gradient(var(--desk-dot, #3D53D2) 2.4px, transparent 3px);
  background-size: 28px 28px;
}

/* ---------- keycap buttons ---------- */
.kbtn {
  font-family: var(--display);
  font-size: 19px;
  line-height: 1;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 11px 18px 12px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: transform .07s, box-shadow .07s, background-color .15s;
}
.kbtn:hover { background-color: #F3F5FF; }
.kbtn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.kbtn.primary { background: var(--lemon); }
.kbtn.primary:hover { background: #FFDD60; }
.kbtn.big { font-size: 24px; padding: 14px 26px 15px; border-radius: 16px; box-shadow: 0 6px 0 var(--ink); }
.kbtn.small { font-size: 16px; padding: 8px 13px 9px; border-radius: 12px; box-shadow: 0 4px 0 var(--ink); }
.kbtn.small:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.kbtn.ghost { background: rgba(255, 255, 255, .7); }
.kbtn.icon { width: 46px; height: 44px; padding: 0; }
.kbtn.icon svg, .kbtn svg { width: 24px; height: 24px; fill: var(--ink); stroke: var(--ink); }
.kbtn.icon.off { background: var(--paper-2); }
.kbtn.icon.off svg { opacity: .55; }
.kbtn[disabled] { background: var(--paper-2); color: var(--ink-2); cursor: not-allowed; transform: none; box-shadow: 0 5px 0 var(--ink); }
.kbtn.danger { background: #FFD3D5; }
button:focus-visible, .kbtn:focus-visible { outline: 4px solid var(--thumb); outline-offset: 3px; }

.cap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.9em;
  height: 1.9em;
  padding: 0 .35em;
  margin: 0 .1em .2em;
  font-family: var(--display);
  font-weight: 400;
  line-height: 1;
  color: var(--ink);
  background: var(--ft, #fff);
  border: 3px solid var(--ink);
  border-radius: .42em;
  box-shadow: 0 .16em 0 var(--ink);
  vertical-align: middle;
}
.cap.wide { min-width: 4.4em; font-size: .78em; font-family: var(--body); font-weight: 700; }
.cap.big { font-size: clamp(54px, 6vw, 76px); border-width: 5px; border-radius: 18px; box-shadow: 0 9px 0 var(--ink); min-width: 1.5em; height: 1.5em; }
.cap.big.wide { font-size: clamp(34px, 4vw, 48px); min-width: 5em; font-family: var(--display); }

/* ---------- keyboard ---------- */
.kbv { width: 100%; height: 100%; display: flex; justify-content: center; }
.kbv-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.kb-chassis { fill: #2B2852; stroke: var(--ink); stroke-width: 4; }
.key .k-side { fill: var(--fd, #B7BAD0); stroke: var(--ink); stroke-width: 2.5; }
.key .k-top { fill: var(--ft, #EEF0F8); transition: fill .15s; }
.key.mod .k-side { fill: #7E82A3; }
.key.mod .k-top { fill: #BFC3D8; }
.key.locked .k-side { fill: #9FA3BD; }
.key.locked .k-top { fill: #D8DAE7; }
.key .k-bump { fill: var(--ink); opacity: .45; }
.key .k-glow { fill: none; stroke: var(--fc, #fff); stroke-width: 6; opacity: 0; }
.key .kp, .key .kc, .kl .klc { transform-box: fill-box; transform-origin: center; }
.key .kc, .kl .klc { transition: transform .07s ease-out; }
.key.down .kc, .kl.down .klc { transform: translateY(4px); }
.key.target .k-top { fill: var(--fc, #fff); }
.key.target .k-glow { opacity: 1; animation: glow 1s ease-in-out infinite; }
.key.target .kp { animation: keyBob 1s ease-in-out infinite; }
.key.wrong .k-top { fill: #FF5A5F; }
.key.good .k-top { fill: #fff; }
.focus-mode .key:not(.focus):not(.target) { opacity: .5; }
.focus-mode .kl:not(.focus):not(.target) { opacity: .4; }
.key { transition: opacity .3s; }
.kl { transition: opacity .3s; }
.kb-labels text {
  font-family: var(--display);
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, .6);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.kt-main { font-size: 23px; }
.kt-shift { font-size: 13px; opacity: .75; }
.kt-base { font-size: 19px; }
.kb-labels .kt-mod { font-size: 12px; text-anchor: start; font-family: var(--body); font-weight: 700; opacity: .7; stroke: none; }
.kl.locked text { fill: #8A8DA8; stroke: none; }
.kb-hands { transition: opacity .45s; }
.hands-soft { opacity: .7; }
.nail-ring { transform-box: fill-box; transform-origin: center; animation: ring 1s ease-out infinite; }
.kb-arrow { fill: none; stroke-width: 7; stroke-linecap: round; stroke-dasharray: 12 10; animation: dash .7s linear infinite; }
.kb-arrow-back { fill: none; stroke-width: 13; stroke-linecap: round; }
.kb-labels .kb-pop {
  font-size: 36px;
  stroke: #fff;
  stroke-width: 7px;
  transform-box: fill-box;
  transform-origin: center;
  animation: kbPop .85s ease-out forwards;
}

/* ---------- Kip and the speech bubble ---------- */
.coach { display: flex; align-items: flex-end; gap: 12px; flex: 1; min-width: 0; }
.kip { width: 84px; flex: 0 0 auto; }
.kip-svg { width: 100%; display: block; overflow: visible; }
.kip-body { transform-box: fill-box; transform-origin: 50% 100%; animation: kipIdle 3s ease-in-out infinite; }
.kip-eyes { transform-box: fill-box; transform-origin: center; animation: blink 4.6s infinite; }
.kip-arm-l { transform-origin: 20px 70px; }
.kip-arm-r { transform-origin: 100px 70px; }
.kip .kip-mouth.oh, .kip .kip-mouth.grin { display: none; }
.kip[data-mood=oops] .kip-mouth.smile { display: none; }
.kip[data-mood=oops] .kip-mouth.oh { display: inline; }
.kip[data-mood=happy] .kip-mouth.smile, .kip[data-mood=cheer] .kip-mouth.smile { display: none; }
.kip[data-mood=happy] .kip-mouth.grin, .kip[data-mood=cheer] .kip-mouth.grin { display: inline; }
.kip[data-mood=happy] .kip-body { animation: kipHop .45s ease-out 2; }
.kip[data-mood=cheer] .kip-body { animation: kipJump .55s ease-out 2; }
.kip[data-mood=cheer] .kip-arm-l { animation: waveL .25s ease-in-out infinite alternate; }
.kip[data-mood=cheer] .kip-arm-r { animation: waveR .25s ease-in-out infinite alternate; }
.kip[data-mood=oops] .kip-body { animation: kipTilt .5s ease-out; }

.bubble {
  position: relative;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 22px;
  padding: 12px 18px;
  margin-bottom: 30px;
  box-shadow: var(--drop);
  font-size: clamp(17px, 1.6vw, 21px);
  line-height: 1.4;
  min-height: 56px;
  max-width: 760px;
  display: flex;
  align-items: center;
}
.bubble::before {
  content: '';
  position: absolute;
  left: -15px;
  bottom: 12px;
  width: 22px;
  height: 22px;
  background: var(--paper);
  border-left: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  transform: skewY(-35deg) rotate(20deg);
  border-radius: 0 0 0 4px;
}
.bubble p { margin: 0; position: relative; }
.bubble.pop { animation: bubblePop .28s ease-out; }
.ftag { display: inline-flex; align-items: center; gap: .3em; font-weight: 700; white-space: nowrap; }
.ftag::before { content: ''; width: .78em; height: .78em; border-radius: 50%; background: var(--c); border: 2.5px solid var(--ink); flex: 0 0 auto; }
.kname {
  font-family: var(--display);
  font-weight: 400;
  background: var(--paper-2);
  border: 2.5px solid var(--ink);
  border-radius: 7px;
  padding: 0 .32em;
}

/* ---------- level frame ---------- */
.lv { position: absolute; inset: 0; display: flex; flex-direction: column; }
.lv-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--paper);
  border-bottom: 3px solid var(--ink);
  position: relative;
  z-index: 3;
}
.lv-name { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; max-width: 34vw; }
.lv-name span { font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-name strong { font-family: var(--display); font-weight: 400; font-size: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-prog { flex: 1; height: 20px; min-width: 80px; background: var(--paper-2); border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; }
.lv-prog i {
  display: block;
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(-45deg, var(--index) 0 12px, #3DBF6E 12px 24px);
  transition: width .25s;
}
.lv-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}
.coach-row { width: min(1040px, 100%); display: flex; align-items: flex-end; gap: 12px; }
.coach-btns { display: flex; flex-direction: column; gap: 10px; margin-bottom: 30px; }
.lv[data-world=caves] .coach-row .bubble, .lv[data-world=galaxy] .coach-row .bubble { box-shadow: 0 7px 0 rgba(0, 0, 0, .45); }

.strip-card {
  position: relative;
  width: min(1040px, 100%);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow: 0 8px 0 rgba(20, 16, 50, .35);
  padding: 16px 24px 12px;
}
.strip-card.compact { padding: 8px 20px 8px; }
.strip { min-height: 128px; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.strip-card.compact .strip { min-height: 88px; }
.sl.cur { font-size: clamp(28px, 3.5vw, 50px); letter-spacing: .02em; white-space: pre; line-height: 1.55; }
.strip-card.compact .sl.cur { font-size: clamp(24px, 2.8vw, 40px); }
.sl.cur.enter { animation: lineIn .3s ease-out; }
.sl.nxt { font-size: clamp(16px, 1.6vw, 22px); color: var(--ink-3); min-height: 1.4em; white-space: pre; }
.ch { display: inline-block; padding: 0 .04em; border-radius: .18em; position: relative; color: var(--ink); }
.ch.sp { min-width: .42em; }
.ch.done { color: #ABA8C8; }
.ch.done.err { color: var(--bad); text-decoration: underline wavy var(--bad); text-underline-offset: 7px; }
.ch.cur {
  background: var(--ft);
  box-shadow: inset 0 -.13em 0 var(--fc), 0 0 0 3px var(--ink);
  animation: curPulse 1s ease-in-out infinite;
}
.ch.sp.cur::after {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: .38em;
  height: .09em;
  border-radius: 2px;
  background: var(--ink);
  opacity: .55;
}
.ch.miss { animation: shakeX .3s; background: #FFD1D3 !important; }
.strip.single .sl.cur { display: flex; align-items: center; justify-content: center; gap: 26px; white-space: normal; font-size: 24px; line-height: 1.2; }
.strip-msg {
  font-family: var(--display);
  font-size: clamp(22px, 2.5vw, 32px);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  text-align: center;
}
.strip-msg .cap { font-size: .9em; }
.plus { font-family: var(--display); font-size: 40px; color: var(--ink-2); }
.tries { display: flex; gap: 10px; }
.tries i { width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--ink); background: var(--paper-2); }
.tries i.on { background: var(--index); animation: popIn .3s; }
.finger-hint { text-align: center; font-size: 17px; min-height: 26px; color: var(--ink-2); }

.clock { position: absolute; right: 14px; top: 12px; width: 64px; height: 64px; display: grid; place-items: center; }
.clock svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.clock-bg { fill: var(--paper-2); stroke: var(--ink); stroke-width: 3; }
.clock-fg { fill: none; stroke: var(--thumb); stroke-width: 6; stroke-dasharray: 113.1; stroke-dashoffset: 0; }
.clock b { position: relative; font-family: var(--display); font-weight: 400; font-size: 22px; }
.clock.hurry .clock-fg { stroke: var(--bad); }
.clock.hurry b { color: var(--bad); }

.count-ov { position: absolute; inset: 0; display: grid; place-items: center; z-index: 8; pointer-events: none; }
.strip-card .count-ov { background: rgba(255, 255, 255, .9); border-radius: 26px; }
.count-n {
  font-family: var(--display);
  font-size: clamp(80px, 12vw, 140px);
  color: var(--lemon);
  -webkit-text-stroke: 6px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 8px 0 var(--ink);
  animation: countIn .7s ease-out both;
}
.count-n.go { color: var(--index); }

.kb-slot { position: relative; width: min(1040px, 100%); flex: 1 1 auto; min-height: 120px; display: flex; justify-content: center; }
.kb-slot.compact { flex: 0 0 auto; height: clamp(140px, 25vh, 250px); }
.kb-slot .kbv { transition: opacity .35s; }
.kb-slot.kb-hidden .kbv { opacity: 0; }
.kb-slot.kb-hidden.kb-peek .kbv { opacity: 1; }
.kb-slot.kb-hidden::before {
  content: 'The keyboard is hiding. Your fingers know the way!';
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, .85);
  font-family: var(--display);
  font-size: clamp(18px, 2vw, 26px);
  text-align: center;
  width: 90%;
  transition: opacity .3s;
}
.kb-slot.kb-hidden.kb-peek::before { opacity: 0; }

.lv-stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.chip { background: rgba(255, 255, 255, .94); border: 3px solid var(--ink); border-radius: 999px; padding: 3px 14px; font-size: 15px; }
.chip b { font-family: var(--display); font-weight: 400; font-size: 20px; margin-right: 3px; }

.caps-warn {
  position: absolute;
  top: 78px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--lemon);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 8px 16px;
  font-weight: 700;
  z-index: 6;
  box-shadow: var(--drop);
  animation: popIn .3s;
}

.pause-ov { position: absolute; inset: 0; background: rgba(20, 16, 50, .6); display: grid; place-items: center; z-index: 20; padding: 16px; }
.pause-card, .rc-inner {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 28px;
  padding: 26px 32px;
  max-width: 540px;
  text-align: center;
  box-shadow: 0 10px 0 rgba(20, 16, 50, .45);
  animation: popIn .32s cubic-bezier(.2, 1.4, .4, 1);
}
.pause-card h2, .rc-inner h2 { font-family: var(--display); font-weight: 400; font-size: 36px; margin: 0 0 6px; }
.pause-card p, .rc-inner p { font-size: 19px; line-height: 1.4; margin: 0 0 18px; }
.pause-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- game stage ---------- */
.stage {
  position: relative;
  width: min(1180px, 100%);
  flex: 1 1 auto;
  min-height: 200px;
  border: 3px solid var(--ink);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 8px 0 rgba(20, 16, 50, .35);
  background: #9AD4FF;
}
.scene-bg, .scene-bg svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.field { position: absolute; inset: 0; overflow: hidden; }
.hud { position: absolute; left: 12px; right: 12px; top: 10px; display: flex; align-items: center; gap: 12px; z-index: 4; pointer-events: none; }
.hud-hearts, .hud-goal, .hud-score, .boss-bar {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 rgba(20, 16, 50, .3);
}
.hud-hearts { display: flex; gap: 3px; padding: 5px 10px; }
.heart svg { width: 26px; height: 24px; display: block; }
.heart path { fill: #D9DBE8; stroke: var(--ink); stroke-width: 2.6; stroke-linejoin: round; }
.heart.on path { fill: var(--pinky); }
.hud-goal { flex: 1; display: flex; align-items: center; gap: 10px; padding: 6px 14px; }
.goal-bar { flex: 1; height: 16px; border-radius: 9px; background: var(--paper-2); border: 2.5px solid var(--ink); overflow: hidden; }
.goal-bar i { display: block; height: 100%; width: 0; background: var(--index); transition: width .25s; }
.goal-txt { font-weight: 700; font-size: 15px; white-space: nowrap; }
.hud-score { display: flex; align-items: baseline; gap: 6px; padding: 4px 14px; font-size: 14px; }
.hud-score b { font-family: var(--display); font-weight: 400; font-size: 22px; }
.stage.shake { animation: shake .35s; }

.ready-card { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20, 16, 50, .35); z-index: 7; padding: 16px; }
.rc-icon { font-size: 64px; line-height: 1.1; }
.rc-go .cap { font-size: 15px; margin: 0 .2em; }

.balloon { position: absolute; left: 0; top: 0; will-change: transform; }
.balloon .bl-svg, .balloon .bub-svg { width: 100%; display: block; overflow: visible; }
.balloon .bl-ch {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 67%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: calc(var(--s, 90px) * .5);
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255, 255, 255, .7);
  pointer-events: none;
}
.balloon.orb .bl-ch { height: 100%; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: none; }
.balloon.popped { animation: popOut .25s forwards; }

.drop, .fly {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 7px 10px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 5px 0 rgba(20, 16, 50, .35);
  font-weight: 700;
  font-size: clamp(20px, 2.1vw, 28px);
  white-space: nowrap;
  will-change: transform;
  z-index: 1;
}
.fly { padding: 6px 14px 7px; }
.w-ic { font-size: .9em; }
.w-txt i { font-style: normal; display: inline-block; }
.w-txt i.hit { color: var(--good); }
.w-txt i.next { box-shadow: inset 0 -4px 0 var(--ink); }
.drop.locked, .fly.locked { background: var(--lemon); z-index: 2; box-shadow: 0 5px 0 var(--ink), 0 0 0 5px rgba(255, 255, 255, .85); }
.drop.wobble .w-txt, .fly.wobble .w-txt { animation: shakeX .3s; }
.drop.gone, .fly.gone { opacity: 0; transition: opacity .22s; }
.drop.arrive .w-txt, .drop.arrive .w-ic { animation: popIn .3s ease-out; }
.rain-base {
  position: absolute;
  left: 50%;
  bottom: 10px;
  margin-left: -40px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--paper);
  border: 4px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 46px;
  box-shadow: 0 6px 0 rgba(20, 16, 50, .4);
  z-index: 2;
}
.laser { position: absolute; left: 0; top: 0; pointer-events: none; animation: fadeOut .26s forwards; z-index: 3; }

.monster { position: absolute; right: 3%; top: 50%; width: min(30%, 290px); transform: translateY(-46%); z-index: 1; }
.monster-svg { width: 100%; display: block; overflow: visible; }
.monster .m-body { transform-box: fill-box; transform-origin: 50% 100%; animation: monIdle 2.4s ease-in-out infinite; }
.monster.throw .m-body { animation: monThrow .35s ease-out; }
.monster.hurt .monster-svg { animation: monHurt .45s; }
.monster.rage .monster-svg { filter: saturate(1.7) brightness(1.05); }
.monster.rage .m-body { animation-duration: 1.1s; }
.monster.defeated .monster-svg { animation: monDefeat .9s forwards; }
.m-say {
  position: absolute;
  bottom: 96%;
  right: 12%;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 16px;
  width: max-content;
  max-width: 280px;
  box-shadow: var(--drop);
  animation: popIn .3s;
}
.hero {
  position: absolute;
  left: 4%;
  top: calc(50% - 50px);
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--paper);
  border: 4px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 58px;
  box-shadow: 0 6px 0 rgba(20, 16, 50, .4);
  z-index: 2;
}
.hero-shield { position: absolute; inset: -14px; border-radius: 50%; border: 4px dashed var(--thumb); animation: spin 8s linear infinite; }
.hero.ouch { animation: shake .4s; background: #FFD1D3; }
.boss-bar { flex: 1; display: flex; align-items: center; gap: 10px; padding: 5px 14px; }
.boss-name { font-family: var(--display); font-size: 19px; white-space: nowrap; }
.hp { flex: 1; height: 18px; border: 2.5px solid var(--ink); border-radius: 9px; background: #FFE3E3; overflow: hidden; }
.hp i { display: block; height: 100%; background: linear-gradient(#FF7373, #E23D4A); transition: width .3s; }

/* ---------- race ---------- */
.race-stage { flex: 0 0 auto; height: clamp(190px, 35vh, 360px); }
.track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 76%;
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  background: #EDCB93;
  border-top: 4px solid var(--ink);
}
.lv[data-world=caves] .track, .lv[data-world=galaxy] .track { background: #5A4B9A; }
.lv[data-world=mountains] .track { background: #D9E6FA; }
.lane { position: relative; border-bottom: 3px dashed rgba(255, 255, 255, .75); }
.lane:last-child { border-bottom: none; }
.racer { position: absolute; left: 0; top: 50%; height: 56px; margin-top: -30px; display: flex; align-items: center; gap: 6px; will-change: transform; z-index: 2; }
.kart { position: relative; width: 88px; }
.kart-svg { width: 100%; display: block; }
.kart-rider { position: absolute; left: 26px; top: -20px; font-size: 32px; }
.rival-e { font-size: 42px; display: inline-block; transform: scaleX(-1); line-height: 1; }
.racer-tag {
  background: rgba(255, 255, 255, .95);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.racer-tag em { font-style: normal; color: var(--ink-2); font-weight: 400; }
.racer.me .racer-tag { background: var(--lemon); }
.medal { font-size: 28px; }
.racer.me.boost .kart { animation: boost .18s; }
.finish-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 94%;
  width: 20px;
  background: repeating-conic-gradient(var(--ink) 0 25%, #fff 0 50%) 0 0 / 20px 20px;
  border-left: 3px solid var(--ink);
  border-right: 3px solid var(--ink);
}
.start-line { position: absolute; top: 0; bottom: 0; left: 5%; width: 5px; background: rgba(255, 255, 255, .85); }

/* ---------- modal and results ---------- */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 50, .62);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 16px;
  animation: fadeIn .2s;
}
.modal {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 30px;
  box-shadow: 0 12px 0 rgba(20, 16, 50, .5);
  width: 100%;
  max-width: 660px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 24px 30px;
  animation: popIn .32s cubic-bezier(.2, 1.4, .4, 1);
}
.results { text-align: center; }
.rs-kip { width: 104px; margin: -4px auto 0; }
.results h2 { font-family: var(--display); font-weight: 400; font-size: 42px; margin: 2px 0 0; }
.rs-level { margin: 0; color: var(--ink-2); font-size: 17px; }
.rs-stars { margin: 14px 0 8px; }
.stars { display: inline-flex; gap: 4px; align-items: flex-end; }
.star { display: block; width: 28px; height: 27px; }
.star svg { width: 100%; height: 100%; display: block; overflow: visible; }
.star path { fill: #E2E4EF; stroke: var(--ink); stroke-width: 2.6; stroke-linejoin: round; }
.star.on path { fill: var(--lemon); }
.stars.big { gap: 10px; }
.stars.big .star { width: 74px; height: 70px; }
.stars.big .star:nth-child(2) { margin-bottom: 16px; }
.stars.small .star { width: 22px; height: 21px; }
.stars.tiny .star { width: 15px; height: 14px; }
.star.pop { animation: starPop .5s cubic-bezier(.2, 1.6, .4, 1); }
.rs-best {
  display: inline-block;
  background: var(--pinky);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 3px 14px;
  font-family: var(--display);
  font-size: 18px;
  transform: rotate(-3deg);
  margin-bottom: 6px;
}
.rs-stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 12px; }
.rs-stat { background: var(--paper-2); border: 3px solid var(--ink); border-radius: 18px; padding: 8px 14px; min-width: 104px; }
.rs-stat b { display: block; font-family: var(--display); font-weight: 400; font-size: 32px; line-height: 1.1; }
.rs-stat span { font-size: 13px; color: var(--ink-2); }
.rs-tip { background: #FFF4C2; border: 3px solid var(--ink); border-radius: 16px; padding: 10px 14px; font-size: 17px; margin: 8px 0; }
.rs-miss { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; font-weight: 700; margin: 6px 0; }
.rs-miss div { font-size: 18px; }
.rs-stickers { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin: 10px 0 4px; }
.sticker-new { display: flex; align-items: center; gap: 14px; text-align: left; animation: popIn .5s .9s both; }
.rs-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.rs-keys { font-size: 14px; color: var(--ink-2); margin: 12px 0 0; }
.sticker {
  display: inline-grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--lemon);
  border: 4px solid var(--ink);
  font-size: 44px;
  box-shadow: 0 0 0 6px #fff, 0 0 0 9px var(--ink), 0 8px 0 9px rgba(20, 16, 50, .25);
}
.sticker.sm { width: 54px; height: 54px; font-size: 28px; box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--ink); }

/* ---------- title ---------- */
.title-scr {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3vh 16px 2vh;
  gap: 1.8vh;
  overflow: hidden;
}
.title-top { text-align: center; }
.logo { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 30px; }
.lw { display: inline-flex; gap: 7px; }
.lc {
  display: inline-grid;
  place-items: center;
  width: clamp(42px, 5.6vw, 76px);
  height: clamp(46px, 6vw, 82px);
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(28px, 4.2vw, 56px);
  color: var(--ink);
  background: var(--ft);
  border: 4px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 7px 0 var(--ink);
  transform: rotate(var(--rot));
  animation: lcIn .6s cubic-bezier(.2, 1.5, .4, 1) var(--d) both;
}
.tagline { color: #fff; font-size: clamp(17px, 1.8vw, 22px); margin: 14px 0 0; text-shadow: 0 2px 0 rgba(20, 16, 50, .5); }
.demo-strip {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 6px 22px;
  min-width: min(480px, 90vw);
  text-align: center;
  font-size: clamp(22px, 2.5vw, 32px);
  min-height: 1.9em;
  box-shadow: var(--drop);
  white-space: pre;
}
.demo-caret { display: inline-block; width: 3px; height: 1em; background: var(--ink); vertical-align: -.12em; margin-left: 2px; animation: caret 1s steps(1) infinite; }
.title-kb { width: min(920px, 94vw); flex: 1 1 auto; min-height: 150px; }
.title-start {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 24px;
  padding: 12px 18px;
  box-shadow: var(--drop);
}
.title-start p { margin: 0; font-size: 17px; line-height: 1.35; }
.hold { position: relative; width: 76px; height: 76px; display: grid; place-items: center; flex: 0 0 auto; }
.hold-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.hr-bg { fill: none; stroke: var(--paper-2); stroke-width: 7; }
.hr-fg { fill: none; stroke: var(--index); stroke-width: 7; stroke-dasharray: 169.6; stroke-dashoffset: 169.6; stroke-linecap: round; }
.hold-keys { display: flex; font-size: 13px; }
.title-foot { color: rgba(255, 255, 255, .85); font-size: 14px; margin: 0; }

/* ---------- menus ---------- */
.menu-scr { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: 5vh 16px; gap: 24px; }
.menu-scr.scroll { overflow-y: auto; }
.scr-title, .sub-top h1 {
  font-family: var(--display);
  font-weight: 400;
  color: #fff;
  margin: 0;
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--ink);
}
.scr-title { font-size: clamp(36px, 4.4vw, 58px); }
.prof-grid { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; max-width: 1040px; }
.prof-card {
  width: 190px;
  padding: 18px 12px 16px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 26px;
  box-shadow: 0 7px 0 var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform .07s, box-shadow .07s;
}
.prof-card:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.prof-av { width: 104px; height: 104px; border-radius: 50%; background: var(--c, var(--paper-2)); border: 4px solid var(--ink); display: grid; place-items: center; font-size: 60px; }
.prof-card b { font-family: var(--display); font-weight: 400; font-size: 24px; }
.prof-stars { display: inline-flex; align-items: center; gap: 5px; font-size: 15px; color: var(--ink-2); }
.prof-stars svg { width: 18px; height: 18px; }
.prof-stars path { fill: var(--lemon); stroke: var(--ink); stroke-width: 3; }
.prof-card.new .prof-av { background: var(--paper-2); border-style: dashed; font-family: var(--display); color: var(--ink-2); }

.np-card {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 30px;
  box-shadow: 0 10px 0 rgba(20, 16, 50, .45);
  padding: 24px 30px;
  width: min(780px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.np-card h1 { font-family: var(--display); font-weight: 400; font-size: 38px; margin: 0 0 2px; }
.np-label { font-weight: 700; font-size: 18px; margin-top: 8px; }
#np-name {
  font-family: var(--body);
  font-size: 30px;
  font-weight: 700;
  padding: 8px 16px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper-2);
  color: var(--ink);
  outline: none;
}
#np-name:focus { background: #fff; box-shadow: 0 0 0 4px var(--thumb); }
#np-name.nudge { animation: shakeX .35s; border-color: var(--bad); }
.np-avatars { display: flex; flex-wrap: wrap; gap: 8px; }
.av-btn { width: 58px; height: 58px; font-size: 34px; border-radius: 16px; border: 3px solid var(--ink); background: var(--paper-2); cursor: pointer; box-shadow: 0 4px 0 var(--ink); padding: 0; }
.av-btn[aria-checked=true] { background: var(--lemon); transform: translateY(2px) rotate(-5deg); box-shadow: 0 2px 0 var(--ink); }
.np-skins { display: flex; gap: 10px; flex-wrap: wrap; }
.skin-btn { width: 46px; height: 46px; border-radius: 50%; background: var(--c); border: 3px solid var(--ink); cursor: pointer; box-shadow: 0 3px 0 var(--ink); padding: 0; }
.skin-btn[aria-checked=true] { box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--ink); }
.np-skins.small { gap: 8px; justify-content: flex-end; max-width: 260px; }
.np-skins.small .skin-btn { width: 30px; height: 30px; }
.np-preview { height: 180px; margin-top: 6px; }
.np-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }

/* ---------- quest map ---------- */
.map-scr {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto auto minmax(230px, 1fr) auto;
  overflow-y: auto;
  background-color: #3448C5;
  background-image: radial-gradient(#3D53D2 2.4px, transparent 3px);
  background-size: 28px 28px;
}
.map-top { display: flex; align-items: center; gap: 12px; padding: 12px 18px; flex-wrap: wrap; }
.who {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 4px 16px 4px 4px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
}
.who:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.who-av { width: 44px; height: 44px; border-radius: 50%; background: var(--lemon); border: 3px solid var(--ink); display: grid; place-items: center; font-size: 26px; }
.who-name { font-family: var(--display); font-size: 21px; }
.pill { display: flex; align-items: center; gap: 6px; background: var(--paper); border: 3px solid var(--ink); border-radius: 999px; padding: 5px 14px; font-size: 15px; }
.pill b { font-family: var(--display); font-weight: 400; font-size: 21px; }
.pill-star svg { width: 22px; height: 22px; display: block; }
.pill-star path { fill: var(--lemon); stroke: var(--ink); stroke-width: 3; }
.map-nav { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.badge { background: var(--pinky); border: 2px solid var(--ink); border-radius: 999px; font-size: 13px; padding: 2px 7px; font-family: var(--body); font-weight: 700; }
.world-tabs { display: flex; gap: 10px; padding: 0 18px 14px; overflow-x: auto; }
.wtab {
  flex: 1 1 0;
  min-width: 150px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  text-align: left;
  transition: transform .07s, box-shadow .07s;
}
.wtab.on { background: var(--wc); color: #fff; transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.wtab.on .wt-txt b { text-shadow: 0 2px 0 var(--ink); }
.wtab.on .wt-txt span { color: #fff; }
.wtab.locked { background: #CCD0E4; color: var(--ink-2); cursor: not-allowed; }
.wt-ic { font-size: 28px; width: 34px; display: grid; place-items: center; flex: 0 0 auto; }
.wt-ic svg { width: 22px; height: 22px; fill: var(--ink-2); stroke: var(--ink-2); }
.wt-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.wt-txt b { font-family: var(--display); font-weight: 400; font-size: 17px; }
.wt-txt span { font-size: 13px; color: var(--ink-2); }
.world-view {
  position: relative;
  margin: 0 18px;
  border: 3px solid var(--ink);
  border-radius: 30px;
  overflow: hidden;
  box-shadow: 0 8px 0 rgba(20, 16, 50, .35);
}
.map-path { position: absolute; inset: 0; width: 100%; height: 100%; }
.path-back { fill: none; stroke: var(--ink); stroke-width: 26; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.path-dash { fill: none; stroke: #FFF3CC; stroke-width: 18; stroke-linecap: round; stroke-dasharray: 1 26; vector-effect: non-scaling-stroke; }
.world-banner {
  position: absolute;
  left: 16px;
  top: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(255, 255, 255, .95);
  border: 3px solid var(--ink);
  border-radius: 20px;
  padding: 8px 16px;
  max-width: min(540px, 70%);
  box-shadow: 0 5px 0 rgba(20, 16, 50, .3);
  z-index: 1;
}
.wb-ic { font-size: 38px; }
.world-banner h2 { font-family: var(--display); font-weight: 400; font-size: 25px; margin: 0; }
.world-banner p { margin: 1px 0 0; font-size: 15px; color: var(--ink-2); }
.node { position: absolute; transform: translate(-50%, -50%); width: 76px; height: 76px; padding: 0; border: none; background: none; cursor: pointer; z-index: 2; }
.node-cap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--ft);
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 7px 0 var(--ink);
  font-family: var(--display);
  font-size: 25px;
  color: var(--ink);
  transition: transform .07s, box-shadow .07s;
}
.node:active .node-cap { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.node.boss .node-cap { border-radius: 50%; background: #FFB3C2; font-size: 32px; }
.node.locked .node-cap { background: #CCD0E4; }
.node.locked .node-cap svg { width: 28px; height: 28px; fill: #7F83A3; stroke: #7F83A3; }
.node.sel .node-cap { box-shadow: 0 7px 0 var(--ink), 0 0 0 7px #fff, 0 0 0 10px var(--ink); }
.node.current .node-cap { animation: nodePulse 1.4s ease-in-out infinite; }
.node-num {
  position: absolute;
  left: -10px;
  top: -10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink);
  font-family: var(--display);
  font-size: 14px;
  display: grid;
  place-items: center;
  z-index: 1;
}
.node .stars { position: absolute; left: 50%; top: calc(100% + 12px); transform: translateX(-50%); background: #fff; border: 2.5px solid var(--ink); border-radius: 999px; padding: 2px 6px; gap: 2px; }
.node-av { position: absolute; left: 50%; bottom: calc(100% + 6px); font-size: 40px; line-height: 1; animation: avHop 1.2s ease-in-out infinite; filter: drop-shadow(0 3px 0 rgba(20, 16, 50, .4)); }
.level-card {
  margin: 16px 18px 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 26px;
  padding: 14px 18px;
  box-shadow: 0 7px 0 rgba(20, 16, 50, .35);
}
.lc-cap {
  flex: 0 0 auto;
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 30px;
  background: var(--fc);
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 6px 0 var(--ink);
}
.lc-mid { flex: 1; min-width: 0; }
.lc-kind { font-size: 14px; color: var(--ink-2); font-weight: 700; }
.lc-mid h3 { font-family: var(--display); font-weight: 400; font-size: 28px; margin: 0; line-height: 1.1; }
.lc-mid p { margin: 2px 0 6px; font-size: 17px; }
.lc-keys { display: flex; flex-wrap: wrap; gap: 2px; font-size: 16px; align-items: center; margin-bottom: 4px; }
.lc-more { font-size: 14px; color: var(--ink-2); margin-left: 6px; }
.lc-mid .lc-goal { font-size: 14px; color: var(--ink-2); margin: 2px 0 6px; }
.lc-best { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--ink-2); }
.lc-right { text-align: center; flex: 0 0 auto; }
.lc-hint { margin: 12px 0 0; font-size: 13px; color: var(--ink-2); max-width: 190px; }

.world-intro { text-align: center; }
.wi-ic { font-size: 80px; line-height: 1.1; animation: bob 1.4s ease-in-out infinite; }
.world-intro h2 { font-family: var(--display); font-weight: 400; font-size: 36px; margin: 6px 0; }
.world-intro p { font-size: 19px; line-height: 1.4; }
.wi-keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; font-size: 22px; margin: 10px 0 22px; }

/* ---------- settings ---------- */
.settings h2 { font-family: var(--display); font-weight: 400; font-size: 30px; margin: 0 0 6px; }
.settings h3 { font-family: var(--display); font-weight: 400; font-size: 20px; margin: 18px 0 2px; color: var(--ink-2); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 2px dashed #E1E3EE; }
.set-row b { display: block; font-size: 17px; }
.set-row span { font-size: 14px; color: var(--ink-2); }
.switch { width: 64px; height: 36px; border-radius: 999px; border: 3px solid var(--ink); background: #D5D8E8; position: relative; cursor: pointer; flex: 0 0 auto; padding: 0; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); transition: left .15s; }
.switch[aria-checked=true] { background: var(--index); }
.switch[aria-checked=true] i { left: 29px; }
.seg { display: flex; border: 3px solid var(--ink); border-radius: 14px; overflow: hidden; flex: 0 0 auto; }
.seg button { border: none; background: #fff; padding: 8px 11px; font-weight: 700; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 3px solid var(--ink); }
.seg button[aria-pressed=true] { background: var(--lemon); }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 18px; }

/* ---------- report card and stickers ---------- */
.sub-top { width: min(1000px, 100%); display: flex; align-items: center; gap: 16px; }
.sub-top h1 { flex: 1; font-size: clamp(28px, 3.4vw, 44px); }
.sub-av { font-size: 46px; }
.sub-count { background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 4px 14px; font-family: var(--display); font-size: 20px; }
.rep-wrap { width: min(1000px, 100%); display: flex; flex-direction: column; gap: 18px; padding-bottom: 30px; }
.rep-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.rep-tile { background: var(--paper); border: 3px solid var(--ink); border-radius: 22px; padding: 12px 14px; box-shadow: 0 5px 0 rgba(20, 16, 50, .35); display: flex; flex-direction: column; }
.rt-ic { font-size: 24px; }
.rep-tile b { font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1.15; }
.rep-tile span:last-child { font-size: 14px; color: var(--ink-2); }
.rep-card { background: var(--paper); border: 3px solid var(--ink); border-radius: 26px; padding: 18px 22px; box-shadow: 0 7px 0 rgba(20, 16, 50, .35); }
.rep-card h2 { font-family: var(--display); font-weight: 400; font-size: 26px; margin: 0; }
.rep-card > p { margin: 4px 0 14px; color: var(--ink-2); font-size: 16px; }
.finger-bars { display: flex; gap: 8px; align-items: flex-end; }
.fbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.fbar.thumbs { margin: 0 14px; }
.fbar-track { width: 100%; max-width: 56px; height: 140px; background: var(--paper-2); border: 3px solid var(--ink); border-radius: 16px 16px 10px 10px; display: flex; align-items: flex-end; overflow: hidden; }
.fbar-fill { width: 100%; background: var(--c); border-top: 3px solid var(--ink); transition: height .6s; }
.fbar-fill.none { background: #DDE0EC; }
.fbar b { font-family: var(--display); font-weight: 400; font-size: 18px; }
.fbar span { font-size: 12px; color: var(--ink-2); text-align: center; line-height: 1.1; }
.rep-kb { height: 250px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; }
.legend span::before { content: ''; display: inline-block; width: 16px; height: 16px; background: var(--c); border: 2.5px solid var(--ink); border-radius: 5px; vertical-align: -3px; margin-right: 6px; }
.speed-chart { width: 100%; height: auto; display: block; }
.cg { stroke: #E3E5F0; stroke-width: 1.5; }
.ct { font-size: 12px; fill: var(--ink-2); text-anchor: end; }
.cl { fill: none; stroke: var(--thumb); stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; }
.cd { fill: #fff; stroke: var(--ink); stroke-width: 2.5; }
.clast { font-family: var(--display); font-size: 18px; fill: var(--ink); text-anchor: end; }
.chart-cap { font-size: 13px; color: var(--ink-2); margin: 4px 0 0; }
.empty { color: var(--ink-2); }
.rep-actions { display: flex; justify-content: center; }
.sticker-grid { width: min(1000px, 100%); display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 18px; padding-bottom: 30px; }
.st-cell { background: var(--paper); border: 3px solid var(--ink); border-radius: 24px; padding: 22px 12px 14px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; box-shadow: 0 6px 0 rgba(20, 16, 50, .35); }
.st-cell .sticker { transform: rotate(var(--rot)); margin-bottom: 10px; }
.st-cell:not(.has) .sticker { background: #E4E6EF; color: #B5B8CC; font-family: var(--display); border-color: #B5B8CC; box-shadow: 0 0 0 6px #fff, 0 0 0 9px #C9CCDD; }
.st-cell b { font-family: var(--display); font-weight: 400; font-size: 19px; }
.st-cell span:last-child { font-size: 14px; color: var(--ink-2); }

/* ---------- certificate ---------- */
.cert { width: min(880px, 100%); background: #fff; border: 4px solid var(--ink); border-radius: 20px; padding: 14px; box-shadow: 0 12px 0 rgba(0, 0, 0, .45); }
.cert-in {
  border: 3px dashed var(--ink);
  border-radius: 12px;
  padding: 26px 40px;
  text-align: center;
  background: repeating-linear-gradient(45deg, rgba(108, 196, 255, .08) 0 14px, transparent 14px 28px);
}
.cert-seal { width: 120px; height: 120px; }
.cert-kicker { font-family: var(--display); font-size: 18px; color: var(--ink-2); margin: 4px 0; }
.cert h1 { font-family: var(--display); font-weight: 400; font-size: clamp(34px, 5vw, 58px); margin: 0; }
.cert-line { font-size: 18px; margin: 8px 0; }
.cert-name { font-family: var(--display); font-size: clamp(40px, 6vw, 72px); border-bottom: 4px solid var(--ink); display: inline-block; padding: 0 30px 4px; margin: 4px 0; }
.cert-stats { display: flex; justify-content: center; gap: 16px; margin: 18px 0; flex-wrap: wrap; }
.cert-stats div { border: 3px solid var(--ink); border-radius: 18px; padding: 10px 18px; min-width: 150px; background: #fff; }
.cert-stats b { display: block; font-family: var(--display); font-size: 34px; font-weight: 400; }
.cert-stats span { font-size: 14px; color: var(--ink-2); }
.cert-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 14px; font-size: 16px; }
.cert-sign { font-family: var(--display); font-size: 22px; border-top: 3px solid var(--ink); padding: 4px 20px 0; }
.cert-actions { display: flex; gap: 12px; }

/* ---------- toasts and floating text ---------- */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 70; pointer-events: none; }
.toast { background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; padding: 10px 16px; font-weight: 700; box-shadow: var(--drop); display: flex; gap: 10px; align-items: center; animation: toastIn .3s ease-out; }
.toast.out { opacity: 0; transform: translateY(10px); transition: .4s; }
.toast-ic { font-size: 22px; }
.float-txt {
  position: fixed;
  transform: translate(-50%, -50%);
  font-family: var(--display);
  font-size: 26px;
  color: #fff;
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
  pointer-events: none;
  z-index: 65;
  animation: floatUp 1s ease-out forwards;
  white-space: nowrap;
}
.float-txt.big { font-size: 38px; color: var(--lemon); }

/* ---------- scenery motion ---------- */
.spin-slow { transform-box: fill-box; transform-origin: center; animation: spin 50s linear infinite; }
.drift { animation: drift 40s ease-in-out infinite alternate; }
.twinkle { animation: twinkle 2.4s ease-in-out infinite; }
.glow-pulse { animation: twinkle 3s ease-in-out infinite; }
.snow { animation: snowFall 9s linear infinite; }

/* ---------- keyframes ---------- */
@keyframes screenIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes keyBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes glow { 0%, 100% { opacity: .95; } 50% { opacity: .3; } }
@keyframes ring { 0% { transform: scale(.9); opacity: .9; } 100% { transform: scale(1.8); opacity: 0; } }
@keyframes dash { to { stroke-dashoffset: -22; } }
@keyframes kbPop { 0% { transform: translateY(6px) scale(.6); opacity: 0; } 20% { opacity: 1; transform: translateY(-6px) scale(1.15); } 100% { transform: translateY(-44px) scale(1); opacity: 0; } }
@keyframes kipIdle { 0%, 100% { transform: translateY(0) scaleY(1); } 50% { transform: translateY(-3px) scaleY(1.02); } }
@keyframes kipHop { 0% { transform: translateY(0); } 40% { transform: translateY(-12px) scaleY(1.05); } 100% { transform: translateY(0); } }
@keyframes kipJump { 0% { transform: translateY(0) scale(1, 1); } 20% { transform: translateY(0) scale(1.08, .9); } 55% { transform: translateY(-22px) scale(.95, 1.08) rotate(-4deg); } 100% { transform: translateY(0) scale(1, 1); } }
@keyframes kipTilt { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-8deg); } 60% { transform: rotate(6deg); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes waveL { from { transform: rotate(-10deg); } to { transform: rotate(25deg); } }
@keyframes waveR { from { transform: rotate(10deg); } to { transform: rotate(-25deg); } }
@keyframes bubblePop { 0% { transform: scale(.94); } 60% { transform: scale(1.02); } 100% { transform: scale(1); } }
@keyframes lineIn { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes curPulse { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes shakeX { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes shake { 0%, 100% { transform: translate(0, 0); } 20% { transform: translate(-8px, 2px); } 40% { transform: translate(7px, -2px); } 60% { transform: translate(-5px, 1px); } 80% { transform: translate(4px, 0); } }
@keyframes popIn { 0% { transform: scale(.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes popOut { to { transform: scale(1.5); opacity: 0; } }
@keyframes starPop { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes countIn { 0% { transform: scale(2.2); opacity: 0; } 35% { transform: scale(.95); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes lcIn { 0% { transform: translateY(-60px) rotate(0); opacity: 0; } 100% { transform: translateY(0) rotate(var(--rot)); opacity: 1; } }
@keyframes caret { 50% { opacity: 0; } }
@keyframes nodePulse { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes avHop { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -8px); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drift { from { transform: translateX(-70px); } to { transform: translateX(70px); } }
@keyframes twinkle { 0%, 100% { opacity: .95; } 50% { opacity: .25; } }
@keyframes snowFall { from { transform: translateY(-60px); } to { transform: translateY(320px); } }
@keyframes boost { 0% { transform: translateX(0); } 50% { transform: translateX(5px); } 100% { transform: translateX(0); } }
@keyframes monIdle { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-6px) scale(1.02, .98); } }
@keyframes monThrow { 0% { transform: scale(1, 1); } 40% { transform: scale(1.08, .9) translateX(-8px); } 100% { transform: scale(1, 1); } }
@keyframes monHurt { 0%, 100% { transform: translateX(0); filter: none; } 20% { transform: translateX(14px); filter: brightness(2.2); } 50% { transform: translateX(-8px); } 70% { transform: translateX(5px); filter: brightness(1.6); } }
@keyframes monDefeat { 0% { transform: scale(1) rotate(0); opacity: 1; } 40% { transform: scale(1.15) rotate(-10deg); } 100% { transform: scale(0) rotate(200deg); opacity: 0; } }

/* ---------- smaller screens ---------- */
@media (max-height: 760px) {
  .kip { width: 66px; }
  .bubble { margin-bottom: 22px; min-height: 48px; padding: 9px 15px; }
  .coach-btns { margin-bottom: 22px; }
  .strip { min-height: 100px; }
  .lv-main { gap: 10px; padding: 10px 14px; }
  .lv-top { padding: 8px 14px; }
  .kb-slot.compact { height: clamp(120px, 23vh, 200px); }
  .race-stage { height: clamp(170px, 31vh, 300px); }
  .level-card { padding: 10px 16px; margin: 12px 18px; }
  .lc-cap { width: 70px; height: 70px; font-size: 26px; }
  .world-tabs { padding-bottom: 10px; }
  .title-start { padding: 8px 14px; }
}
@media (max-width: 1180px) {
  .pill span:last-child { display: none; }
  .map-nav { gap: 8px; }
  .map-nav .kbtn.small { font-size: 15px; padding: 7px 10px 8px; }
}
@media (max-width: 900px) {
  .map-nav { margin-left: 0; }
  .wt-txt span { display: none; }
  .wtab { min-width: 120px; }
  .level-card { flex-wrap: wrap; }
  .lc-right { width: 100%; }
  .lv-name { max-width: 44vw; }
  .coach-row { flex-wrap: wrap; }
  .coach-btns { flex-direction: row; margin-bottom: 0; }
  .world-banner p { display: none; }
  .title-start { flex-wrap: wrap; justify-content: center; text-align: center; }
}
@media (max-width: 600px) {
  .lv-top [data-top=voice] { display: none; }
  .node { width: 56px; height: 56px; }
  .node-cap { font-size: 18px; border-radius: 14px; }
  .node .stars { display: none; }
  .finger-bars { gap: 3px; }
  .fbar.thumbs { margin: 0 4px; }
  .modal { padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- printing the certificate ---------- */
@media print {
  @page { size: landscape; margin: 12mm; }
  body { background: #fff; overflow: visible; }
  body * { visibility: hidden; }
  #certificate, #certificate * { visibility: visible; }
  #certificate { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; }
  #app, .screen, .menu-scr { position: static; overflow: visible; }
  #fx, #toasts { display: none; }
}
