:root {
  --font: 'ZikoRound', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --ink: #1a1030; --gold: #ffd23f; --orange: #ff8a1a; --red: #e8322a; --sky: #5ab4ff; --green: #57c23a;
  --panel: rgba(26, 16, 48, 0.82); --panel2: rgba(255, 255, 255, 0.1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e0820; font-family: var(--font); color: #fff; touch-action: none; }
#app, canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud-l, .hud-r { position: absolute; top: max(14px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 8px; }
.hud-l { left: 16px; align-items: flex-start; } .hud-r { right: 16px; align-items: flex-end; }
.pill { display: flex; align-items: center; gap: 10px; padding: 6px 16px 6px 8px; border-radius: 999px; background: rgba(20, 10, 40, 0.45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 2px solid rgba(255,255,255,0.18); box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
.pill b { font-size: 34px; font-weight: 900; letter-spacing: 1px; text-shadow: 0 3px 0 rgba(0,0,0,0.45); min-width: 1.5ch; }
.pill.small b { font-size: 22px; }
.pill.bump { animation: bump 0.25s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
.ico { width: 44px; height: 44px; display: inline-block; background-size: contain; background-repeat: no-repeat; background-position: center; filter: drop-shadow(0 3px 0 rgba(0,0,0,0.35)); }
.pill.small .ico { width: 30px; height: 30px; }
.ico-fruit { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-50 -50 100 100'%3E%3Cpath d='M0,-44 L12,-15 L42,-14 L19,6 L27,36 L0,19 L-27,36 L-19,6 L-42,-14 L-12,-15Z' fill='%23ffb21e' stroke='%23b85a00' stroke-width='7' stroke-linejoin='round'/%3E%3Cpath d='M-4,-28 L4,-12 L-14,-10Z' fill='%23fff3b0'/%3E%3C/svg%3E"); }
.ico-crate { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='6' y='6' width='88' height='88' rx='8' fill='%23d48b42' stroke='%236b3a17' stroke-width='10'/%3E%3Cpath d='M18 18 L82 82 M82 18 L18 82' stroke='%236b3a17' stroke-width='8'/%3E%3C/svg%3E"); }
.ico-ziko { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M18 40 L10 6 L40 24Z M82 40 L90 6 L60 24Z' fill='%23dc5a26' stroke='%23fff1dc' stroke-width='5' stroke-linejoin='round'/%3E%3Cellipse cx='50' cy='56' rx='40' ry='34' fill='%23dc5a26'/%3E%3Cellipse cx='30' cy='66' rx='15' ry='12' fill='%23fff1dc'/%3E%3Cellipse cx='70' cy='66' rx='15' ry='12' fill='%23fff1dc'/%3E%3Cellipse cx='50' cy='72' rx='13' ry='10' fill='%23fff1dc'/%3E%3Cellipse cx='36' cy='50' rx='7' ry='9' fill='%231b0f0a'/%3E%3Cellipse cx='64' cy='50' rx='7' ry='9' fill='%231b0f0a'/%3E%3Ccircle cx='38' cy='47' r='2.5' fill='%23fff'/%3E%3Ccircle cx='66' cy='47' r='2.5' fill='%23fff'/%3E%3Cellipse cx='50' cy='64' rx='6' ry='4' fill='%231b0f0a'/%3E%3C/svg%3E"); }
.pips { display: flex; gap: 5px; padding: 6px 2px 6px 8px; }
.pips i { width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,0.15); border: 2px solid rgba(255,255,255,0.3); transition: all .25s; }
.pips i.on { background: radial-gradient(circle at 40% 35%, #fffbd0, #ffd21a 55%, #ff9a1a); border-color: #fff3a0; box-shadow: 0 0 12px #ffd21a; }
.pips.rainbow i.on { animation: rb 0.6s linear infinite; }
@keyframes rb { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } }
#pauseBtn { pointer-events: auto; position: absolute; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3); background: rgba(20,10,40,0.45); color: #fff; font: 900 18px var(--font); cursor: pointer; }
#camBtn { pointer-events: auto; position: absolute; top: max(14px, env(safe-area-inset-top)); left: calc(50% + 34px); width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3); background: rgba(20,10,40,0.45); color: #fff; font-size: 20px; cursor: pointer; }
#pauseBtn { left: calc(50% - 28px) !important; transform: none !important; }
.langs { position: fixed; top: 16px; right: 16px; display: flex; gap: 6px; }
.langs button { font: 900 16px var(--font); padding: 8px 14px; border-radius: 999px; border: 2px solid rgba(255,255,255,0.5); background: rgba(20,10,40,0.45); color: #fff; cursor: pointer; }
.langs button.on { background: #ffd23f; color: var(--ink); border-color: #ffd23f; }
#bossBar { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); text-align: center; }
#bossBar .bname { font-size: 22px; font-weight: 900; text-shadow: 0 3px 0 #000; margin-bottom: 4px; color: #ffd0a0; }
.hearts { display: flex; gap: 8px; justify-content: center; }
.hearts i { width: 34px; height: 30px; background: #e8322a; clip-path: path('M17 30 L3 16 C-3 9 3 0 10 1 C14 1 16 4 17 6 C18 4 20 1 24 1 C31 0 37 9 31 16 Z'); transition: all .3s; filter: drop-shadow(0 2px 0 #000); }
.hearts i.off { background: rgba(255,255,255,0.18); transform: scale(0.8); }

/* ---------- popups ---------- */
#pops { position: fixed; inset: 0; pointer-events: none; z-index: 12; overflow: hidden; }
.pop { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 26px; color: #fff; text-shadow: 0 3px 0 #1a1030, 0 0 10px rgba(0,0,0,0.4); animation: popup 1.1s ease-out forwards; white-space: nowrap; }
.pop.big { font-size: 40px; color: #7aff8a; } .pop.gold { font-size: 32px; color: var(--gold); }
@keyframes popup { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }
.flyer { position: absolute; width: 36px; height: 36px; transform: translate(-50%, -50%) scale(1.2); transition: left .5s cubic-bezier(.55,0,.8,.4), top .5s cubic-bezier(.3,.7,.4,1), transform .5s; background-size: contain; background-repeat: no-repeat; }
.fly-fruit { background-image: inherit; } .flyer.fly-fruit { background-image: var(--fruit-img); }
.flyer.fly-life { width: 48px; height: 48px; background-image: var(--ziko-img); }
#flash { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 72px; font-weight: 900; color: #fff; text-shadow: 0 6px 0 #e8322a, 0 0 30px rgba(0,0,0,0.5); z-index: 14; pointer-events: none; animation: flashIn 1.4s ease-out forwards; }
@keyframes flashIn { 0% { opacity: 0; transform: translate(-50%, -50%) scale(2.5); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1); } }

/* ---------- level card ---------- */
#card { position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%); text-align: center; z-index: 13; pointer-events: none; animation: cardIn 2.8s ease-in-out forwards; }
#card .c-num { font-size: 30px; font-weight: 900; color: var(--gold); text-shadow: 0 3px 0 #000; letter-spacing: 3px; }
#card .c-name { font-size: 64px; font-weight: 900; text-shadow: 0 5px 0 var(--ink), 0 0 30px rgba(0,0,0,0.5); line-height: 1.1; }
#card .c-sub { font-size: 20px; margin-top: 6px; opacity: 0.95; text-shadow: 0 2px 0 #000; }
@keyframes cardIn { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.8); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%); } }

/* ---------- Lampi tip ---------- */
#tip { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 14px; max-width: min(760px, 92vw);
  padding: 14px 22px 14px 14px; border-radius: 26px; background: rgba(255, 250, 225, 0.95); color: #3a2a10; z-index: 13; font-size: 22px; font-weight: 800; line-height: 1.3;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35), 0 0 0 4px #ffd21a; animation: tipIn .35s cubic-bezier(.2,1.6,.4,1); pointer-events: none; }
@keyframes tipIn { from { transform: translateX(-50%) translateY(40px) scale(0.8); opacity: 0; } }
.lampi-face { flex: 0 0 58px; height: 58px; border-radius: 50%; background: radial-gradient(circle at 50% 70%, #fff36b 0 28%, transparent 30%), radial-gradient(circle at 36% 38%, #111 0 7%, #fff 8% 14%, transparent 15%), radial-gradient(circle at 64% 38%, #111 0 7%, #fff 8% 14%, transparent 15%), radial-gradient(circle at 50% 45%, #6a4a9a 0 46%, transparent 47%), radial-gradient(circle, #fff6a0, #ffd21a 60%, #ff9a1a);
  box-shadow: 0 0 20px #ffd21a; animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }

#portalCard { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 13; pointer-events: none; text-align: center; padding: 14px 28px; border-radius: 24px;
  background: var(--panel); border: 3px solid rgba(255,255,255,0.25); box-shadow: 0 10px 30px rgba(0,0,0,0.4); min-width: 280px; }
#portalCard .pc-num { font-size: 18px; color: var(--gold); font-weight: 900; letter-spacing: 2px; }
#portalCard .pc-name { font-size: 32px; font-weight: 900; margin: 2px 0 6px; }
#portalCard .pc-row { font-size: 20px; display: flex; gap: 14px; justify-content: center; align-items: center; }
.stars { letter-spacing: 3px; color: rgba(255,255,255,0.25); font-size: 26px; } .stars .on { color: var(--gold); text-shadow: 0 0 10px rgba(255,210,63,0.7); }
.gem { font-size: 22px; opacity: .25; } .gem.on { opacity: 1; filter: drop-shadow(0 0 6px #5ad7ff); }

/* ---------- screens ---------- */
#screen { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 20px; overflow: auto; }
#screen.dim { background: radial-gradient(ellipse at center, rgba(26,16,48,0.55), rgba(10,6,24,0.88)); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.panel { background: var(--panel); border-radius: 30px; padding: 28px 34px; border: 3px solid rgba(255,255,255,0.18); box-shadow: 0 20px 60px rgba(0,0,0,0.5); max-width: min(720px, 94vw); width: 100%; text-align: center; animation: panelIn .35s cubic-bezier(.2,1.4,.4,1); }
@keyframes panelIn { from { transform: scale(0.85); opacity: 0; } }
.panel h1 { margin: 0 0 6px; font-size: 44px; font-weight: 900; text-shadow: 0 4px 0 #000; }
.panel h2 { margin: 0 0 16px; font-size: 22px; font-weight: 800; color: var(--gold); }
.panel p { font-size: 20px; line-height: 1.45; margin: 10px 0; font-weight: 500; }
.menu { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; align-items: center; }
.btn { font: 900 24px var(--font); color: var(--ink); background: linear-gradient(#ffe36b, #ffb21e); border: none; border-radius: 999px; padding: 14px 38px; min-width: 280px; cursor: pointer;
  box-shadow: 0 6px 0 #b85a00, 0 10px 20px rgba(0,0,0,0.35); transition: transform .1s, box-shadow .1s, filter .15s; }
.btn.sec { background: linear-gradient(#ffffff, #cfd8ea); box-shadow: 0 6px 0 #6a7894, 0 10px 20px rgba(0,0,0,0.35); }
.btn:hover, .btn.sel { filter: brightness(1.08); transform: translateY(-2px) scale(1.04); outline: 4px solid rgba(255,255,255,0.8); outline-offset: 3px; }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b85a00; }
.btn[disabled] { filter: grayscale(1) opacity(.5); }
.logo { font-size: clamp(56px, 11vw, 140px); font-weight: 900; line-height: 0.9; letter-spacing: 4px; color: #ff8a1a;
  text-shadow: 0 6px 0 #b8400a, 0 12px 0 #5a1a05, 0 18px 30px rgba(0,0,0,0.5); -webkit-text-stroke: 4px #fff3d8; animation: logoBob 2.4s ease-in-out infinite; }
@keyframes logoBob { 50% { transform: translateY(-8px) rotate(-1.5deg); } }
.logo-sub { font-size: clamp(20px, 3.2vw, 34px); font-weight: 900; margin-top: 14px; text-shadow: 0 3px 0 #000; color: #fff; }
.press { margin-top: 40px; font-size: 26px; font-weight: 900; animation: blink 1.2s infinite; text-shadow: 0 3px 0 #000; }
@keyframes blink { 50% { opacity: 0.35; } }
.title-wrap { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 4vh 16px 5vh; text-align: center; pointer-events: none; }
.title-wrap > * { pointer-events: auto; }
.title-wrap .menu { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.title-wrap .btn { min-width: 200px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 12px 0; font-size: 20px; font-weight: 800; }
.row input[type=range] { width: 50%; accent-color: #ffb21e; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.seg button { font: 800 16px var(--font); border-radius: 999px; padding: 8px 14px; border: 2px solid rgba(255,255,255,0.3); background: transparent; color: #fff; cursor: pointer; }
.seg button.on { background: #ffd23f; color: var(--ink); border-color: #ffd23f; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; text-align: left; font-size: 18px; margin: 12px auto; max-width: 480px; }
.keys kbd { font: 800 15px var(--font); background: #fff; color: var(--ink); padding: 3px 9px; border-radius: 8px; box-shadow: 0 3px 0 #999; white-space: nowrap; }
.tally { display: grid; gap: 10px; margin: 18px 0; }
.tally .t { display: flex; justify-content: space-between; align-items: center; font-size: 26px; font-weight: 900; padding: 10px 18px; border-radius: 16px; background: var(--panel2); opacity: 0; animation: tIn .4s forwards; }
.tally .t .v { color: var(--gold); }
@keyframes tIn { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; } }
.bigstars { font-size: 70px; letter-spacing: 8px; margin: 6px 0; }
.bigstars span { display: inline-block; color: rgba(255,255,255,0.18); transform: scale(0.6); transition: all .4s cubic-bezier(.2,1.8,.4,1); }
.bigstars span.on { color: var(--gold); transform: scale(1); text-shadow: 0 0 24px rgba(255,210,63,0.8), 0 5px 0 #b85a00; }
.gemBig { font-size: 64px; display: inline-block; animation: gemSpin 2s ease-in-out infinite; filter: drop-shadow(0 0 16px #5ad7ff); }
@keyframes gemSpin { 50% { transform: translateY(-8px) rotate(8deg) scale(1.08); } }
.story { max-width: 760px; }
.story .art { font-size: 90px; margin: 4px 0 10px; }
.story p { font-size: 25px; font-weight: 700; }
.wardrobe { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.wardrobe button { font: 800 18px var(--font); padding: 16px 8px; border-radius: 18px; background: var(--panel2); color: #fff; border: 3px solid transparent; cursor: pointer; }
.wardrobe button.on { border-color: var(--gold); background: rgba(255,210,63,0.2); }
.wardrobe button[disabled] { opacity: 0.4; cursor: default; }
.wardrobe small { display: block; margin-top: 6px; color: var(--gold); font-size: 15px; }
.power-ico { font-size: 96px; animation: gemSpin 1.6s ease-in-out infinite; }

/* ---------- loading ---------- */
#loading { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, #3a1a6a, #0e0820); transition: opacity .6s; }
#loading.out { opacity: 0; pointer-events: none; }
.ld-logo { font-size: clamp(56px, 14vw, 110px); font-weight: 900; color: #ff8a1a; -webkit-text-stroke: 3px #fff3d8; text-shadow: 0 8px 0 #5a1a05; }
.ld-bar { width: min(420px, 80vw); height: 16px; border-radius: 99px; background: rgba(255,255,255,0.15); margin-top: 26px; overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #ffe36b, #ff8a1a); border-radius: 99px; transition: width .3s; }
.ld-t { margin-top: 12px; font-size: 20px; opacity: .85; }

/* ---------- touch ---------- */
#touch { display: none; }
body.touch.playing #touch { display: block; }
body:not(.shooter) .tb.shoot { display: none; }
#stickZone { position: fixed; left: 0; bottom: 0; width: 45vw; height: 60vh; z-index: 9; }
#stick { position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.35); background: rgba(255,255,255,0.08); z-index: 9; pointer-events: none; opacity: 0; transition: opacity .2s; }
#stick.on { opacity: 1; }
#knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,0.7); }
.tbtns { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 9; width: 250px; height: 220px; }
.tb { position: absolute; border-radius: 50%; border: 3px solid rgba(255,255,255,0.6); color: #fff; font: 900 16px var(--font); text-shadow: 0 2px 0 rgba(0,0,0,0.5); background: rgba(255,255,255,0.14); }
.tb.down { background: rgba(255,210,63,0.6); transform: scale(0.92); }
.tb.jump { width: 104px; height: 104px; right: 0; bottom: 10px; background: rgba(90,180,255,0.35); }
.tb.spin { width: 92px; height: 92px; right: 116px; bottom: 0; background: rgba(255,138,26,0.35); }
.tb.crouch { width: 64px; height: 64px; right: 20px; bottom: 128px; }
.tb.shoot { width: 64px; height: 64px; right: 100px; bottom: 110px; font-size: 26px; }
@media (max-width: 700px) { .pill b { font-size: 26px; } .ico { width: 34px; height: 34px; } #card .c-name { font-size: 40px; } .btn { min-width: 220px; font-size: 20px; } .panel h1 { font-size: 34px; } #tip { font-size: 18px; } }
