@font-face { font-family: Andika; src: url(../fonts/Andika-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Andika; src: url(../fonts/Andika-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }
:root {
  --ink: #2b2d42; --cream: #fffdf5; --orange: #ff9f1c; --orange-d: #e07a00; --green: #21a35a; --sky: #6ccbff;
  --shadow: 0 6px 0 rgba(0,0,0,0.18); --r: 22px;
  --kb-h: clamp(150px, 27vh, 250px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d1b3a; color: var(--ink); font-family: Andika, "Comic Sans MS", system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: 0; color: var(--ink); }
a { color: #1971c2; }

/* buttons */
.big, .mid, .small { border-radius: 999px; font-weight: 700; box-shadow: var(--shadow); transition: transform .08s; background: #fff; }
.big { font-size: clamp(22px, 3.4vh, 32px); padding: .5em 1.6em; }
.mid { font-size: clamp(16px, 2.3vh, 21px); padding: .55em 1.2em; }
.small { font-size: 15px; padding: .5em 1em; }
.go { background: var(--orange); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.ghost { background: transparent; box-shadow: none; text-decoration: underline; }
button:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.18); }
button:focus-visible, input:focus-visible { outline: 4px solid #ffd23f; outline-offset: 2px; }
.round { width: 44px; height: 44px; border-radius: 50%; background: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.18); font-size: 20px; display: grid; place-items: center; }
.round.off { opacity: .45; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

/* HUD */
#hud { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 12px; gap: 10px; pointer-events: none; }
#hud button { pointer-events: auto; }
.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hud-right { justify-content: flex-end; }
.hud-mid { flex: 1; max-width: 460px; display: flex; flex-direction: column; gap: 6px; align-items: stretch; margin-top: 4px; }
.pill { background: rgba(255,253,245,.94); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: clamp(14px, 2.1vh, 19px); box-shadow: 0 3px 0 rgba(0,0,0,.15); white-space: nowrap; }
.pill .lbl { font-size: .7em; text-transform: uppercase; letter-spacing: .06em; opacity: .65; }
.hearts { letter-spacing: 2px; font-size: clamp(16px, 2.4vh, 22px); padding: 3px 12px; }
.combo { background: #ffd23f; animation: pop .3s; }
.power { background: #74c0fc; color: #fff; }
.track-progress { position: relative; height: 26px; }
.tp-line { position: absolute; left: 14px; right: 18px; top: 12px; height: 6px; border-radius: 6px; background: repeating-linear-gradient(90deg, rgba(255,255,255,.95) 0 10px, rgba(255,255,255,.45) 10px 16px); }
.tp-train { position: absolute; top: -2px; left: 0; font-size: 22px; transition: left .4s; transform: scaleX(-1); }
.tp-station { position: absolute; right: 0; top: -2px; font-size: 20px; }
.boss-bar { display: flex; gap: 8px; align-items: center; background: rgba(43,45,66,.85); color: #fff; padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 15px; }
.bb-track { flex: 1; height: 12px; border-radius: 8px; background: rgba(255,255,255,.25); overflow: hidden; }
.bb-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff595e, #ffca3a); transition: width .4s; }

#banner { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; animation: bannerIn .5s cubic-bezier(.2,1.6,.4,1); width: min(92vw, 900px); }
.b-title { font-size: clamp(34px, 7vh, 72px); font-weight: 700; color: #fff; -webkit-text-stroke: 4px #2b2d42; paint-order: stroke fill; text-shadow: 0 5px 0 #2b2d42; }
.b-sub { display: inline-block; margin-top: 10px; font-size: clamp(18px, 3vh, 28px); font-weight: 700; background: rgba(255,253,245,.95); padding: 8px 20px; border-radius: 18px; box-shadow: var(--shadow); }
#hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: #fff; border-radius: 16px; padding: 8px 18px; font-weight: 700; font-size: clamp(16px, 2.5vh, 22px); box-shadow: var(--shadow); white-space: nowrap; }
#hint .k { display: inline-block; min-width: 1.6em; text-align: center; background: var(--orange); color: #fff; border-radius: 8px; padding: 0 .3em; margin: 0 .15em; }
#toast { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); background: #fff; padding: 10px 22px; border-radius: 999px; font-weight: 700; font-size: 22px; box-shadow: var(--shadow); animation: pop .35s; pointer-events: none; }

/* screens */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.screen.dim { background: rgba(20,18,50,.45); backdrop-filter: blur(2px); }
.card { background: var(--cream); border-radius: 28px; padding: 22px 26px; box-shadow: 0 10px 0 rgba(0,0,0,.18), 0 20px 50px rgba(0,0,0,.25); max-width: 560px; width: 100%; text-align: center; max-height: 100%; overflow: auto; }
.card.wide { max-width: 1040px; }
.card.results { max-width: 640px; }
.small-card { max-width: 440px; }
.card h2 { margin: 0 0 8px; font-size: clamp(26px, 4vh, 36px); }
.card h2 small { font-size: .55em; opacity: .6; }
.card h3 { margin: 16px 0 8px; font-size: 18px; text-align: left; }
.sub { margin-top: 0; opacity: .75; }

.title-card { text-align: center; background: rgba(255,253,245,.9); border-radius: 36px; padding: 26px 36px 18px; box-shadow: 0 12px 0 rgba(0,0,0,.15), 0 30px 60px rgba(0,0,0,.2); max-width: 640px; animation: floaty 4s ease-in-out infinite; }
.logo { font-weight: 700; line-height: .9; font-size: clamp(56px, 12vh, 120px); }
.logo .l1 { color: #4caf50; display: block; -webkit-text-stroke: 3px #2b2d42; paint-order: stroke fill; text-shadow: 0 6px 0 #2b2d42; transform: rotate(-4deg); display: inline-block; }
.logo .l2 { color: var(--orange); display: block; -webkit-text-stroke: 3px #2b2d42; paint-order: stroke fill; text-shadow: 0 6px 0 #2b2d42; }
.tagline { font-size: clamp(17px, 2.6vh, 24px); font-weight: 700; margin: 14px 0 18px; }
.foot { font-size: 14px; opacity: .8; margin: 16px 0 0; }

.profile-list { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 10px 0; }
.profile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 16px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); min-width: 110px; font-weight: 700; font-size: 18px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 26px; background: var(--orange); text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.map-head .avatar { width: 38px; height: 38px; font-size: 20px; }
.new-profile { display: flex; flex-direction: column; gap: 10px; align-items: center; margin: 12px 0; padding: 14px; border-radius: 20px; background: #fff3df; }
.new-profile label { font-weight: 700; }
input { font-family: inherit; font-size: 24px; padding: 10px 16px; border-radius: 16px; border: 3px solid #e3d5b8; width: min(320px, 90%); text-align: center; font-weight: 700; }
.colors { display: flex; gap: 10px; }
.colors button { width: 40px; height: 40px; border-radius: 50%; box-shadow: 0 3px 0 rgba(0,0,0,.2); }
.colors button.sel { outline: 4px solid var(--ink); outline-offset: 2px; }

/* map */
.map-wrap { width: min(1180px, 100%); height: 100%; display: flex; flex-direction: column; gap: 12px; }
.map-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: rgba(255,253,245,.92); border-radius: 22px; padding: 8px 12px; box-shadow: var(--shadow); }
.who { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.map-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.map-tools button:disabled { opacity: .45; cursor: not-allowed; }
.worlds { flex: 1; overflow: auto; display: grid; align-content: start; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; padding-bottom: 12px; }
.world { border-radius: 24px; padding: 14px 16px; box-shadow: var(--shadow); color: #fff; position: relative; overflow: hidden; }
.world.locked h3::after { content: ' 🔒'; }
.world h3 { margin: 0; font-size: 24px; text-shadow: 0 2px 0 rgba(0,0,0,.25); text-align: left; }
.world p { margin: 2px 0 12px; font-weight: 700; opacity: .95; text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.world.locked { filter: grayscale(.8) brightness(.8); }
.stops { display: flex; align-items: center; gap: 6px; position: relative; }
.stops::before { content: ''; position: absolute; left: 20px; right: 20px; top: 26px; height: 6px; background: repeating-linear-gradient(90deg, #5a3b22 0 6px, transparent 6px 12px), rgba(255,255,255,.5); border-radius: 4px; }
.stop { position: relative; z-index: 1; width: 54px; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; box-shadow: none; padding: 0; color: #fff; font-weight: 700; }
.stop .dot { width: 50px; height: 50px; border-radius: 50%; background: #fff; color: var(--ink); display: grid; place-items: center; font-size: 20px; box-shadow: 0 4px 0 rgba(0,0,0,.25); border: 4px solid #fff; }
.stop.boss .dot { width: 58px; height: 58px; background: #ffd23f; font-size: 26px; }
.stop.next .dot { border-color: var(--orange); animation: pulse 1.2s infinite; }
.stop:disabled .dot { background: rgba(255,255,255,.45); color: rgba(0,0,0,.35); }
.stop:disabled { cursor: not-allowed; }
.stop .st { font-size: 15px; letter-spacing: -1px; color: #ffe066; text-shadow: 0 1px 0 rgba(0,0,0,.5); min-height: 16px; }
.w-meadow { background: linear-gradient(160deg, #6ccbff, #74d152 70%); }
.w-jungle { background: linear-gradient(160deg, #4fbfa6, #2c9640 70%); }
.w-desert { background: linear-gradient(160deg, #ff9f5a, #e9b86a 70%); }
.w-snow { background: linear-gradient(160deg, #7dbbff, #b9d9f0 70%); }
.w-ocean { background: linear-gradient(160deg, #4cc0ff, #1f88c2 70%); }
.w-space { background: linear-gradient(160deg, #0d0826, #5b2aa0 70%); }

/* results */
.stars { font-size: 64px; letter-spacing: 8px; color: #ddd; text-shadow: 0 4px 0 rgba(0,0,0,.12); }
.stars span.on { color: #ffc300; animation: starPop .5s cubic-bezier(.2,1.8,.4,1) both; display: inline-block; }
.r-stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.stat { background: #fff; border-radius: 16px; padding: 8px 10px; box-shadow: 0 3px 0 rgba(0,0,0,.12); flex: 1; min-width: 84px; }
.stat b { display: block; font-size: 26px; }
.stat span { font-size: 13px; opacity: .7; }
.friend { display: flex; gap: 12px; align-items: center; background: #e9fbe3; border-radius: 18px; padding: 10px 14px; margin: 10px 0; text-align: left; animation: pop .5s; }
.friend canvas { flex: none; }
.friend b { font-size: 18px; }
.r-tip { font-weight: 700; opacity: .8; }

/* dex */
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 10px 0 14px; }
.dex-card { background: #fff; border-radius: 18px; padding: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; font-size: 15px; }
.dex-card.locked { opacity: .55; }
.dex-card .w { font-size: 12px; opacity: .65; }
.dex-card p { font-size: 13px; font-weight: 400; margin: 2px 0 0; }
.dex-card.boss { background: #fff6d6; }

.trains { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 12px 0; }
.train-card { background: #fff; border-radius: 18px; padding: 12px; box-shadow: var(--shadow); font-weight: 700; }
.train-card.sel { outline: 4px solid var(--orange); }
.train-card:disabled { opacity: .5; }

/* toggles */
.toggles { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.tog { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 8px 12px; font-weight: 700; }
.tog .opts { display: flex; gap: 4px; }
.tog .opts button { padding: 5px 10px; border-radius: 999px; background: #eee; font-weight: 700; }
.tog .opts button.sel { background: var(--orange); color: #fff; }
.g-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; text-align: left; }
.how { padding-left: 20px; margin: 0; } .how li { margin-bottom: 6px; }
.g-totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.heat { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.heat .hr { display: flex; gap: 4px; }
.heat .hk { width: 40px; height: 44px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.3); line-height: 1; }
.heat .hk small { font-size: 10px; opacity: .9; }
.g-sessions table { width: 100%; border-collapse: collapse; font-size: 14px; }
.g-sessions td, .g-sessions th { padding: 4px 6px; border-bottom: 1px solid #eee; text-align: left; }

/* keyboard */
#kbwrap { flex: none; height: var(--kb-h); background: linear-gradient(#3d2f5c, #2a2147); display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 8px 22px; position: relative; border-top: 4px solid #ffd23f; }
#kb { display: flex; flex-direction: column; gap: 5px; align-items: center; height: 100%; justify-content: center; }
.krow { display: flex; gap: 5px; }
.krow:nth-child(2) { margin-left: 18px; } .krow:nth-child(3) { margin-left: 48px; }
.key { width: clamp(30px, 5.2vw, 60px); height: clamp(28px, 5.4vh, 50px); border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: clamp(15px, 2.6vh, 24px); color: var(--ink); background: var(--fc, #eee); box-shadow: 0 4px 0 rgba(0,0,0,.35); position: relative; user-select: none; touch-action: manipulation; transition: transform .05s; }
.key.home::after { content: ''; position: absolute; bottom: 6px; width: 30%; height: 3px; border-radius: 2px; background: rgba(0,0,0,.45); }
.key.space { width: clamp(180px, 34vw, 380px); }
.key.dimk { filter: saturate(.35) brightness(.75); }
.key.next { background: #fff; outline: 4px solid var(--orange); transform: translateY(-3px) scale(1.08); animation: keyPulse .9s infinite; z-index: 2; }
.key.down { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.key.wrong { animation: shake .3s; background: #ff8fa3; }
.hand { height: 92%; width: auto; flex: none; }
.hand .fg { stroke: rgba(0,0,0,.35); stroke-width: 2; transition: transform .15s; transform-box: fill-box; transform-origin: 50% 100%; }
.hand .palm { fill: #ffd8b5; stroke: rgba(0,0,0,.35); stroke-width: 2; }
.hand .fg.on { transform: translateY(-8px); stroke: #ff6b00; stroke-width: 4; }
#finger-tip { position: absolute; bottom: 3px; left: 0; right: 0; text-align: center; color: #fff; font-weight: 700; font-size: clamp(12px, 1.9vh, 16px); opacity: .95; }
.nohands .hand { display: none; }

@keyframes pop { 0% { transform: translateX(-50%) scale(.6); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }
.combo, .friend { animation-name: popc; } @keyframes popc { 0% { transform: scale(.6); } 100% { transform: scale(1); } }
@keyframes bannerIn { 0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; } 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes keyPulse { 0%, 100% { box-shadow: 0 4px 0 rgba(0,0,0,.35), 0 0 0 0 rgba(255,159,28,.7); } 50% { box-shadow: 0 4px 0 rgba(0,0,0,.35), 0 0 0 10px rgba(255,159,28,0); } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes starPop { 0% { transform: scale(0) rotate(-90deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

@media (max-width: 760px) {
  .hand { display: none; }
  .g-grid { grid-template-columns: 1fr; }
  .g-totals { grid-template-columns: repeat(2, 1fr); }
  .hud-mid { display: none; }
  .krow:nth-child(2) { margin-left: 10px; } .krow:nth-child(3) { margin-left: 24px; }
  .key { width: 8.6vw; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
