:root {
  --bg: #0b1220;
  --ink: #ffffff;
  --accent: #8ee02a;
  --gold: #ffd23f;
  --panel: #173a4f;
  --danger: #e04848;
  --outline: #1b1030;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  overflow: hidden; overscroll-behavior: none;
  font-family: "Fredoka", "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}

#viewport { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #070b14; }
#stage {
  position: relative; width: 768px; height: 1136px; flex: none;
  transform-origin: center center; overflow: hidden; background: #000;
  box-shadow: 0 0 80px rgba(0,0,0,.7);
}
#game { position: absolute; inset: 0; width: 768px; height: 1136px; display: block; }
#screens { position: absolute; inset: 0; pointer-events: none; }

.screen { position: absolute; inset: 0; pointer-events: auto; }
.screen.passthrough { pointer-events: none; }
.screen.passthrough > * { pointer-events: auto; }
.screen.enter { animation: screenIn .28s cubic-bezier(.2,.9,.3,1.2) both; }
.screen.leave { animation: screenOut .2s ease-in both; }
@keyframes screenIn { from { opacity: 0; transform: scale(1.06); } to { opacity: 1; transform: none; } }
@keyframes screenOut { to { opacity: 0; transform: scale(.97); } }
.bgimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.abs { position: absolute; }
.btn { position: absolute; cursor: pointer; transition: transform .12s cubic-bezier(.3,1.6,.5,1), filter .12s; filter: drop-shadow(0 6px 0 rgba(0,0,0,.35)); }
.btn:hover { transform: scale(1.06); filter: drop-shadow(0 8px 0 rgba(0,0,0,.35)) brightness(1.08); }
.btn:active, .btn.pressed { transform: scale(.9); filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)) brightness(.95); }
img { -webkit-user-drag: none; user-select: none; }

.center-x { left: 50%; transform: translateX(-50%); }
.btn.center-x:active { transform: translateX(-50%) scale(.92); }

.title-font { font-family: "Luckiest Guy", "Fredoka", Impact, sans-serif; letter-spacing: 1px; }
.label {
  position: absolute; color: #fff; text-align: center; font-weight: 700;
  text-shadow: 0 3px 0 var(--outline), 0 0 8px rgba(0,0,0,.6);
}
.big-title { color: var(--gold); -webkit-text-stroke: 3px var(--outline); paint-order: stroke fill; text-shadow: 0 6px 0 var(--outline); }

/* ---------- motion ---------- */
.spin { animation: spin 18s linear infinite; }
.spin.slow { animation-duration: 40s; }
@keyframes spin { to { transform: rotate(360deg); } }
.sunburst { position: absolute; opacity: .35; pointer-events: none; }
.logo-bob { animation: logoBob 3.2s ease-in-out infinite; }
@keyframes logoBob { 0%,100% { transform: translateX(-50%) translateY(0) rotate(-1deg); } 50% { transform: translateX(-50%) translateY(-14px) rotate(1deg); } }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.pulse:active { animation: none; transform: scale(.9); }
.pulse-text { animation: pulseText 1.2s ease-in-out infinite; }
@keyframes pulseText { 50% { opacity: .55; transform: scale(1.05); } }
.spin-hover:hover { transform: rotate(60deg) scale(1.08); }
.bob { animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-16px); } }
.nudge-left { animation: nudgeL 1.6s ease-in-out infinite; }
.nudge-right { animation: nudgeR 1.6s ease-in-out infinite; }
@keyframes nudgeL { 50% { transform: translateX(-6px); } }
@keyframes nudgeR { 50% { transform: translateX(6px); } }
.fade-in { animation: fadeIn .25s ease-out both; }
@keyframes fadeIn { from { opacity: 0; } }
.drop-in { animation: dropIn .5s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-120px) scale(.85); } }
.title-drop { animation: titleDrop .55s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes titleDrop { from { opacity: 0; transform: translateX(-50%) translateY(-60px) scale(1.6); } to { transform: translateX(-50%); } }
.shake-in { animation: shakeIn .6s ease-out both; }
@keyframes shakeIn { 0% { opacity: 0; transform: translateX(-50%) scale(1.4); } 30% { opacity: 1; transform: translateX(-50%) scale(1); } 40%,60%,80% { transform: translateX(calc(-50% - 10px)); } 50%,70%,90% { transform: translateX(calc(-50% + 10px)); } 100% { transform: translateX(-50%); } }
.pop-in { animation: popIn .45s cubic-bezier(.2,1.7,.4,1) both; }
@keyframes popIn { from { opacity: 0; transform: scale(.3) rotate(-8deg); } }

/* ---------- loading ---------- */
.loading-label { position: absolute; top: 860px; width: 100%; text-align: center; font-size: 40px; color: #8ee02a; -webkit-text-stroke: 2px var(--outline); paint-order: stroke fill; text-shadow: 0 4px 0 var(--outline); }
.loading-bar { position: absolute; left: 209px; top: 920px; width: 350px; height: 22px; border-radius: 11px; background: #13202d; border: 3px solid var(--outline); box-shadow: 0 4px 0 rgba(0,0,0,.4); overflow: hidden; }
.loading-bar > i { display: block; height: 100%; width: 0; background: #8ee02a; box-shadow: inset 0 4px 0 rgba(255,255,255,.35); transition: width .15s; }
.screen.leave { pointer-events: none; }

.screen-title { position: absolute; top: 46px; width: 100%; text-align: center; font-size: 46px; color: #fff; -webkit-text-stroke: 3px var(--outline); paint-order: stroke fill; text-shadow: 0 5px 0 var(--outline); pointer-events: none; }

/* ---------- world select ---------- */
.world-track { position: absolute; left: 0; top: 150px; width: 768px; height: 780px; overflow: hidden; }
.world-strip { position: absolute; top: 0; left: 0; height: 100%; display: flex; transition: transform .45s cubic-bezier(.2,1.2,.3,1); }
.world-card { position: relative; width: 768px; height: 100%; flex: none; display: flex; align-items: center; justify-content: center; }
.world-card .card-burst { left: 64px; top: 50px; opacity: .45; }
.world-card .dim-burst { opacity: .12; }
.world-card img.island { position: relative; max-width: 600px; max-height: 600px; margin-top: -70px; cursor: pointer; filter: drop-shadow(0 18px 24px rgba(0,0,0,.55)); transition: filter .15s; }
.world-card img.island:hover { filter: drop-shadow(0 18px 24px rgba(0,0,0,.55)) brightness(1.08); }
.world-card img.locked-island { filter: grayscale(.6) brightness(.7) drop-shadow(0 18px 24px rgba(0,0,0,.55)); }
.world-card .soon {
  position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%) rotate(-4deg);
  background: var(--outline); border: 4px solid #ffb13d; border-radius: 14px; padding: 10px 26px;
  font-size: 34px; color: #ffd23f; box-shadow: 0 6px 0 rgba(0,0,0,.4);
}
.world-stars { position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; background: rgba(27,16,48,.88); border: 4px solid #ffd23f; border-radius: 40px; padding: 8px 22px 8px 12px; box-shadow: 0 6px 0 rgba(0,0,0,.4); }
.world-stars .vstar { width: 44px; height: 44px; }
.world-stars span { font-size: 32px; color: #fff; }
.world-bar { width: 150px; height: 16px; border-radius: 8px; background: #2b2442; overflow: hidden; }
.world-bar > i { display: block; height: 100%; background: #ffd23f; }
.world-dots { position: absolute; top: 960px; left: 0; width: 100%; display: flex; justify-content: center; gap: 10px; }
.world-dots img { cursor: pointer; transition: transform .2s cubic-bezier(.3,1.6,.5,1); }
.world-dots img.dot-on { transform: scale(1.22); }

/* ---------- level select ---------- */
.diff-tabs { position: absolute; top: 205px; left: 0; width: 100%; display: flex; justify-content: center; gap: 26px; }
.diff-tabs img { cursor: pointer; opacity: .45; transition: opacity .15s, transform .2s cubic-bezier(.3,1.6,.5,1); }
.diff-tabs img.on { opacity: 1; transform: scale(1.12); filter: drop-shadow(0 4px 0 rgba(0,0,0,.4)); }
.tomb { position: absolute; width: 171px; height: 214px; cursor: pointer; transition: transform .15s cubic-bezier(.3,1.6,.5,1); }
.tomb:hover { transform: translateY(-6px) scale(1.04); }
.tomb:active { transform: scale(.92); }
.tomb > .stone { position: absolute; left: 0; top: 0; filter: drop-shadow(0 8px 0 rgba(0,0,0,.35)); }
.tomb > .num { position: absolute; left: 50%; top: 40px; transform: translateX(-50%); }
.tomb > .lock { position: absolute; left: 50%; top: 28px; transform: translateX(-50%); }
.tomb-stars { position: absolute; left: 50%; top: 160px; transform: translateX(-50%); display: flex; gap: 2px; }
.tomb-stars .vstar { width: 40px; height: 40px; }
.tomb-stars .vstar:nth-child(2) { transform: translateY(-6px); }
.tomb-best { position: absolute; left: 50%; top: 116px; transform: translateX(-50%); font: 700 18px "Fredoka", sans-serif; color: #1b2a38; background: rgba(255,255,255,.75); border-radius: 10px; padding: 1px 8px; }
.tomb.locked { cursor: default; }
.tomb.locked:hover { transform: none; }
.tomb.locked > .stone { filter: grayscale(.7) brightness(.6) drop-shadow(0 8px 0 rgba(0,0,0,.35)); }
.tomb.next > .stone, .boss-tomb.next > .rock { animation: glow 1.2s ease-in-out infinite; }
@keyframes glow { 0%,100% { filter: drop-shadow(0 0 0 #8ee02a) drop-shadow(0 8px 0 rgba(0,0,0,.35)); } 50% { filter: drop-shadow(0 0 16px #8ee02a) drop-shadow(0 8px 0 rgba(0,0,0,.35)); } }
.boss-tomb { position: absolute; width: 299px; height: 480px; cursor: pointer; transform: scale(.62); transform-origin: top center; }
.boss-tomb > .rock { position: absolute; left: 0; top: 0; filter: drop-shadow(0 10px 0 rgba(0,0,0,.35)); }
.boss-tomb > .boss { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); }
.boss-breathe { animation: breathe 2.2s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.05, .97); } }
.boss-tomb > .lock { position: absolute; left: 50%; top: 110px; transform: translateX(-50%); }
.boss-stars { top: 418px; }
.boss-stars .vstar { width: 66px; height: 66px; }
.boss-tomb.locked { cursor: default; }
.boss-tomb.locked > .rock, .boss-tomb.locked > .boss { filter: grayscale(.7) brightness(.6); }
.boss-tomb.pop-in { animation-name: popInBoss; }
@keyframes popInBoss { from { opacity: 0; transform: scale(.2) rotate(-8deg); } to { transform: scale(.62); } }

.vstar { display: block; filter: drop-shadow(0 3px 0 rgba(0,0,0,.35)); }

/* ---------- HUD ---------- */
.keypad { position: absolute; left: 0; top: 968px; width: 768px; height: 168px; }
.keypad > img.base { position: absolute; left: 0; top: 0; }
.key { position: absolute; top: 40px; width: 72px; height: 90px; cursor: pointer; transition: transform .06s; }
.key img { display: block; }
.key.down { top: -18px; height: 167px; filter: drop-shadow(0 0 12px rgba(80,220,255,.9)); }
.monitor { position: absolute; left: 258px; top: 874px; width: 252px; height: 68px; transition: transform .1s; }
.monitor > img { position: absolute; inset: 0; }
.monitor > .answer {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 700 50px/1 "Fredoka", "Arial Black", Arial, sans-serif; color: #9ff6ff; letter-spacing: 2px;
  text-shadow: 0 0 12px rgba(80,220,255,.95), 0 0 2px #fff;
}
.monitor > .answer.bump { animation: bump .16s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { from { transform: scale(1.35); } }
.monitor.good { animation: monGood .4s ease-out; }
.monitor.good > .answer { color: #c8ffd9; text-shadow: 0 0 14px rgba(80,255,150,.95); }
.monitor.bad { animation: monBad .35s ease-out; }
.monitor.bad > .answer { color: #ffc2c2; text-shadow: 0 0 14px rgba(255,60,60,.95); }
@keyframes monGood { 30% { transform: scale(1.12); } }
@keyframes monBad { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }

/* ---------- overlays ---------- */
.dim { position: absolute; inset: 0; background: rgba(5,8,18,.68); }
.panel-wrap { position: absolute; left: 48px; top: 330px; width: 672px; }
.panel-wrap > img.panel { display: block; }
.stat-line { position: absolute; left: 0; width: 100%; text-align: center; font-size: 26px; font-weight: 700; color: #bfe9ff; text-shadow: 0 2px 0 #000; }
.result-stars { position: absolute; left: 0; width: 100%; top: 28px; display: flex; justify-content: center; gap: 14px; align-items: flex-end; }
.result-stars .rs .vstar { width: 86px; height: 86px; }
.result-stars .rs:nth-child(2) .vstar { width: 104px; height: 104px; transform: translateY(-14px); }
.result-stars .rs.pop { animation: starPop .45s cubic-bezier(.2,1.8,.4,1); }
@keyframes starPop { 0% { transform: scale(2.2) rotate(-30deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.result-score { position: absolute; left: 0; width: 100%; top: 132px; text-align: center; font-size: 56px; color: #ffd23f; -webkit-text-stroke: 3px var(--outline); paint-order: stroke fill; text-shadow: 0 5px 0 var(--outline); }
.result-score.pop { animation: bump .3s cubic-bezier(.3,1.8,.5,1); }
.health-bonus { position: absolute; left: 0; width: 100%; text-align: center; top: 236px; font-size: 22px; color: #ff9fb6; -webkit-text-stroke: 1.5px var(--outline); paint-order: stroke fill; animation: fadeIn .3s both; }
.new-best { position: absolute; left: 24px; top: 128px; font-size: 30px; color: #fff; background: #e0365f; border: 4px solid var(--outline); border-radius: 12px; padding: 4px 12px; transform: rotate(-10deg); box-shadow: 0 5px 0 rgba(0,0,0,.4); animation: stamp .4s cubic-bezier(.2,1.8,.4,1) both; }
@keyframes stamp { from { transform: rotate(-10deg) scale(2.5); opacity: 0; } }
.result-btns { position: absolute; inset: 0; pointer-events: none; animation: fadeUp .4s cubic-bezier(.2,1.4,.4,1) both; }
.result-btns > * { pointer-events: auto; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(40px); } }
.pause-box { position: absolute; inset: 0; }

.toggle { padding: 2px 16px; border-radius: 12px; border: 3px solid var(--outline); }
.toggle.on { color: #fff; background: #3cb043; }
.toggle.off { color: #fff; background: #c0392b; }

.tutorial { position: absolute; inset: 0; background: rgba(0,0,0,.4); cursor: pointer; }
.tutorial img { position: absolute; left: 0; top: 40px; width: 768px; height: 1024px; }
.tap-hint { position: absolute; bottom: 30px; width: 100%; text-align: center; font-size: 32px; color: #fff; -webkit-text-stroke: 2px var(--outline); paint-order: stroke fill; }

.toast { position: absolute; left: 50%; top: 140px; transform: translateX(-50%); background: var(--outline); border: 3px solid #ffb13d; border-radius: 14px; padding: 10px 22px; font-size: 26px; white-space: nowrap; animation: dropIn .4s cubic-bezier(.2,1.5,.4,1) both; box-shadow: 0 5px 0 rgba(0,0,0,.4); }

/* ---------- report ---------- */
.report { position: absolute; inset: 0; background: #0d1d2b; overflow: hidden; }
.report h1 { position: absolute; top: 40px; width: 100%; text-align: center; margin: 0; font-size: 60px; color: var(--accent); -webkit-text-stroke: 3px var(--outline); paint-order: stroke fill; text-shadow: 0 5px 0 var(--outline); }
.report .list { position: absolute; top: 150px; left: 40px; right: 40px; bottom: 40px; overflow-y: auto; padding-right: 6px; }
.report .card { background: #173a4f; border: 3px solid #3e6f8c; border-radius: 18px; padding: 18px 22px; margin-bottom: 16px; box-shadow: 0 6px 0 rgba(0,0,0,.35); }
.report .card h2 { margin: 0 0 10px; font-size: 34px; }
.report .bar { height: 18px; background: #0b1a26; border-radius: 9px; overflow: hidden; margin: 6px 0 4px; }
.report .bar > i { display: block; height: 100%; background: var(--accent); }
.report .row { display: flex; justify-content: space-between; font-size: 22px; color: #cfe7f5; margin-top: 8px; gap: 12px; }
.report .row span:first-child { flex: 1; }
.report .muted { color: #8fb3c7; font-size: 20px; }

@media (prefers-reduced-motion: reduce) {
  .spin, .logo-bob, .pulse, .bob, .nudge-left, .nudge-right, .boss-breathe, .tomb.next > .stone { animation: none !important; }
}
