* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #2a0f45; color: #3a1d55;
  font-family: 'Baloo 2', 'Nunito', system-ui, 'Noto Sans', sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#viewport { position: fixed; inset: 0; }
#stage { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 1280px; height: 720px; touch-action: none; display: block; }
.hidden { display: none !important; }

.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: radial-gradient(ellipse at center, rgba(90,20,110,.45), rgba(40,8,60,.8));
  animation: fade .22s ease; z-index: 10;
}
.overlay.clear { background: none; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { 0% { transform: scale(.7); opacity: 0 } 70% { transform: scale(1.05); opacity: 1 } 100% { transform: scale(1) } }
@keyframes wiggle { 0%, 100% { transform: rotate(0) } 25% { transform: rotate(-4deg) } 75% { transform: rotate(4deg) } }
@keyframes bounce { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
@keyframes shine { 0% { background-position: -200% 0 } 100% { background-position: 200% 0 } }

.loader { text-align: center; font-size: 24px; color: #fff; font-weight: 800; }
.spin { width: 60px; height: 60px; margin: 0 auto 10px; border-radius: 50%; border: 7px solid rgba(255,255,255,.2); border-top-color: #ff4fa3; animation: rot .9s linear infinite; }
@keyframes rot { to { transform: rotate(360deg) } }
.loader .bar { width: 260px; height: 12px; border-radius: 6px; background: rgba(255,255,255,.2); margin: 8px auto 0; overflow: hidden; }
.loader .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff4fa3, #ffd83a, #26d0ce); transition: width .2s; }

/* ---------------------------------------------------------------- buttons */
.btn {
  font: inherit; font-weight: 800; font-size: 21px; color: #fff; border: 0; cursor: pointer;
  padding: 10px 24px 12px; border-radius: 18px; position: relative; line-height: 1.1;
  box-shadow: 0 6px 0 rgba(0,0,0,.25), inset 0 3px 0 rgba(255,255,255,.35), inset 0 -4px 0 rgba(0,0,0,.12);
  transition: transform .1s cubic-bezier(.3,1.6,.5,1), filter .15s;
  text-shadow: 0 2px 0 rgba(0,0,0,.2);
}
.btn:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.08); }
.btn:active { transform: translateY(4px) scale(.97); box-shadow: 0 2px 0 rgba(0,0,0,.25), inset 0 3px 0 rgba(255,255,255,.35); }
.btn:disabled { filter: grayscale(.9) brightness(.8); cursor: not-allowed; transform: none; }
.btn.pink { background: linear-gradient(#ff7ab8, #e8157f); }
.btn.gold { background: linear-gradient(#ffe45c, #ffac00); color: #5a3400; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.btn.green { background: linear-gradient(#5ff0b0, #1fb877); }
.btn.teal { background: linear-gradient(#5ce8e0, #0fa6b4); }
.btn.orange { background: linear-gradient(#ffb35c, #ff6a1f); }
.btn.blue { background: linear-gradient(#5fb8ff, #1f6fe0); }
.btn.purple { background: linear-gradient(#b98cff, #7b2ff7); }
.btn.dark { background: linear-gradient(#7a4aa6, #4b1f78); }
.btn.round { width: 54px; height: 54px; padding: 0; border-radius: 50%; font-size: 22px; }
.btn.big { width: 100%; font-size: 30px; padding: 11px 16px 13px; display: flex; flex-direction: column; align-items: center; }
.btn.big small { font-size: 16px; font-weight: 700; opacity: .92; margin-top: 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.big.half { font-size: 25px; }
.btn.big-cta { font-size: 28px; padding: 10px 40px 12px; animation: bounce 1.2s ease-in-out infinite; }
.btn .badge, .badge { position: absolute; top: -8px; right: -8px; background: #ff3b5c; color: #fff; border-radius: 12px; min-width: 24px; height: 24px; font-size: 15px; display: grid; place-items: center; padding: 0 6px; animation: bounce 1s infinite; }
.btn.toggle { min-width: 110px; font-size: 18px; padding: 6px 16px 8px; background: linear-gradient(#5ff0b0, #1fb877); }
.btn.toggle.off { background: linear-gradient(#b9a8cf, #8a76a6); }

/* ---------------------------------------------------------------- menu */
#menu { align-items: flex-start; justify-content: center; padding-left: 44px; }
.menu-col { width: 470px; display: flex; flex-direction: column; gap: 11px; background: rgba(255,250,240,.8); border-radius: 30px; padding: 18px 26px 22px; box-shadow: 0 16px 40px rgba(60,20,90,.35); border: 4px solid rgba(255,255,255,.95); animation: pop .4s ease both; }
.logo { display: flex; flex-direction: column; align-items: center; line-height: .82; margin-bottom: 2px; }
.logo .l1 { font-size: 66px; font-weight: 800; color: #fff; -webkit-text-stroke: 2px #b0306a; paint-order: stroke fill; letter-spacing: 6px; text-shadow: 0 6px 0 #7b2ff7; animation: wiggle 3s ease-in-out infinite; }
.logo .l2 { font-size: 86px; font-weight: 800; background: linear-gradient(90deg, #ff3b5c, #ff9a1f 20%, #ffd83a 38%, #3ed16b 55%, #2f8cff 72%, #b04dff 90%); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 1.5px #4b1d7a; filter: drop-shadow(0 6px 0 rgba(75,29,122,.55)); }
.tagline { margin: 0; text-align: center; font-size: 18px; font-weight: 700; color: #7a3a8a; }
.menu-btns { display: flex; flex-direction: column; gap: 10px; }
.menu-btns .row { display: flex; gap: 10px; }
.menu-btns .half { flex: 1; min-width: 0; }
.menu-row { display: flex; gap: 10px; }
.menu-row .btn { flex: 1; font-size: 18px; padding: 9px 10px 11px; min-width: 0; }
.menu-row.small { justify-content: center; margin-top: 12px; }
.menu-row.small .btn { flex: none; }
.icon-btn span { white-space: nowrap; }
.wallet-row { position: absolute; top: 50px; right: 22px; display: flex; gap: 10px; }
.pill { background: rgba(80,20,110,.8); color: #fff; font-size: 24px; font-weight: 800; padding: 4px 18px; border-radius: 26px; border: 3px solid rgba(255,255,255,.55); }
.pill b { color: #ffe066; }

/* ---------------------------------------------------------------- HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#panel { position: absolute; left: 18px; top: 52px; width: 330px; background: rgba(255,250,240,.9); border: 4px solid #fff; border-radius: 26px; padding: 10px 16px 14px; box-shadow: 0 10px 30px rgba(40,0,60,.35); display: flex; flex-direction: column; gap: 8px; }
.lvl-title { text-align: center; font-size: 24px; font-weight: 800; color: #7b2ff7; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.moves-box { display: flex; align-items: center; justify-content: space-between; background: linear-gradient(#ff7ab8, #e8157f); color: #fff; border-radius: 18px; padding: 2px 18px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.15); }
.moves-box small { font-size: 20px; font-weight: 800; }
.moves-box b { font-size: 46px; line-height: 1.1; text-shadow: 0 3px 0 rgba(120,0,60,.5); }
.moves-box.low { animation: wiggle .5s ease-in-out infinite; background: linear-gradient(#ff9b5c, #e83a15); }
.moves-box.bump b { animation: pop .3s ease; }
#goals { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.goal { position: relative; width: 92px; height: 86px; background: #fff; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 3px 0 rgba(123,47,247,.18); }
.goal canvas { width: 50px; height: 50px; }
.goal b { font-size: 22px; font-weight: 800; color: #5b2a86; line-height: 1; }
.goal.done b { color: #1fb877; }
.goal.done::after { content: '✔'; position: absolute; right: 4px; top: 0; color: #1fb877; font-size: 24px; font-weight: 800; }
.goal.bump { animation: pop .3s ease; }
.goal.score { width: 190px; flex-direction: row; gap: 8px; }
.score-box { display: flex; flex-direction: column; align-items: center; }
.score-box small { font-size: 16px; font-weight: 800; color: #9a6ab0; }
.score-box > b { font-size: 34px; line-height: 1; color: #e8157f; }
.starbar { position: relative; width: 100%; height: 16px; border-radius: 8px; background: #efe3fb; margin-top: 10px; }
.starbar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 8px; background: linear-gradient(90deg, #ffd83a, #ff9a1f); transition: width .25s; }
.starbar .st { position: absolute; top: -12px; transform: translateX(-50%); font-size: 30px; line-height: 1; color: #d9c7ec; -webkit-text-stroke: 2px #a58cc2; }
.starbar .st.on { color: #ffd83a; -webkit-text-stroke: 2px #b36b00; animation: pop .4s ease; }

#boosters { position: absolute; right: 18px; top: 92px; width: 176px; display: flex; flex-direction: column; gap: 12px; }
.boost {
  height: 86px; border: 0; border-radius: 22px; cursor: pointer; font: inherit; color: #fff;
  background: linear-gradient(#b98cff, #7b2ff7); position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 6px 0 rgba(60,10,120,.45), inset 0 3px 0 rgba(255,255,255,.35); transition: transform .1s cubic-bezier(.3,1.6,.5,1);
}
.boost:hover { transform: translateY(-3px) scale(1.04); }
.boost:active { transform: translateY(3px) scale(.95); }
.boost .ic { font-size: 36px; line-height: 1; }
.boost small { font-size: 15px; font-weight: 800; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boost .n { position: absolute; top: -8px; right: -6px; background: #ffd83a; color: #5a3400; border-radius: 14px; min-width: 30px; height: 30px; display: grid; place-items: center; font-size: 18px; box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.boost.empty { filter: grayscale(.8) brightness(.85); }
.boost.active { background: linear-gradient(#ff9ed0, #e8157f); animation: wiggle .5s ease-in-out infinite; }
.boost.off { display: none; }
#btn-pause { position: absolute; right: 18px; top: 22px; font-size: 18px; }
.modebar { position: absolute; left: 372px; width: 676px; top: 680px; text-align: center; color: #fff; font-weight: 800; font-size: 20px; background: rgba(123,47,247,.9); border-radius: 16px; padding: 4px 12px; animation: pop .3s ease both; pointer-events: none !important; }

.toast { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); background: rgba(255,255,255,.96); color: #5b2a86; font-weight: 800; font-size: 21px; padding: 8px 22px; border-radius: 20px; box-shadow: 0 8px 20px rgba(0,0,0,.25); animation: pop .3s ease both; z-index: 30; max-width: 900px; text-align: center; pointer-events: none; }

/* ---------------------------------------------------------------- modals */
.modal {
  background: linear-gradient(180deg, #fffaf2, #ffe9f4); border: 5px solid #fff; border-radius: 30px; padding: 20px 34px 22px;
  min-width: 460px; max-width: 900px; text-align: center; box-shadow: 0 24px 60px rgba(40,0,70,.5), inset 0 -6px 0 rgba(232,21,127,.12);
  animation: pop .35s ease both; max-height: 690px; overflow-y: auto;
}
.modal.wide { width: 880px; }
.modal h2 { margin: 0 0 4px; font-size: 42px; line-height: 1.1; color: #e8157f; text-shadow: 0 3px 0 rgba(123,47,247,.3); }
.modal h3 { margin: 12px 0 6px; font-size: 22px; color: #9b4dca; text-align: left; }
.modal .sub { margin: 4px 0 8px; color: #7a5a90; font-size: 19px; font-weight: 700; }
.modal .sub.small { font-size: 16px; margin: 8px 0 4px; }
.modal .diff { margin: 0; font-size: 20px; font-weight: 800; color: #e83a15; min-height: 4px; }
.stack { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.goal-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.goal-row .goal { width: 100px; }
.tip-card { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: 20px; padding: 8px 16px; margin: 8px 0; text-align: left; border: 3px dashed #ffb3d9; }
.tip-card canvas { width: 72px; height: 72px; flex: none; }
.tip-card p { margin: 0; font-size: 19px; font-weight: 700; color: #5b2a86; max-width: 440px; }
.start-row { display: flex; gap: 12px; justify-content: center; }
.start { width: 110px; border: 3px solid transparent; border-radius: 18px; background: #fff; padding: 6px 4px; cursor: pointer; font: inherit; color: #5b2a86; position: relative; box-shadow: 0 3px 0 rgba(123,47,247,.18); }
.start .ic { font-size: 32px; display: block; }
.start small { font-size: 13px; font-weight: 800; display: block; line-height: 1.1; }
.start .n { position: absolute; top: -8px; right: -6px; background: #ffd83a; color: #5a3400; border-radius: 12px; min-width: 26px; height: 26px; font-size: 15px; font-weight: 800; display: grid; place-items: center; }
.start.on { border-color: #1fb877; background: #e9fff3; }
.start.on::after { content: '✔'; position: absolute; left: 6px; top: 2px; color: #1fb877; font-weight: 800; }
.start:disabled { opacity: .45; cursor: not-allowed; }

.list { display: grid; gap: 10px; margin-top: 10px; text-align: left; }
.mission { display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: center; background: #fff; border-radius: 18px; padding: 10px 14px; box-shadow: 0 3px 0 rgba(123,47,247,.15); }
.mission .ic { font-size: 34px; text-align: center; }
.mission .nm { font-size: 20px; font-weight: 800; }
.mission .pb { height: 12px; border-radius: 6px; background: #efe3fb; overflow: hidden; margin-top: 4px; }
.mission .pb i { display: block; height: 100%; background: linear-gradient(90deg, #ff4fa3, #ffd83a); border-radius: 6px; }
.mission .rw { font-size: 15px; color: #9a7ab0; font-weight: 700; }
.mission .btn { font-size: 17px; padding: 6px 16px 8px; min-width: 110px; }
.login-row { display: flex; gap: 8px; justify-content: center; margin: 6px 0 4px; flex-wrap: wrap; }
.login-row .day { width: 96px; border-radius: 14px; background: #efe3fb; padding: 4px 0; font-weight: 800; font-size: 14px; color: #9a7ab0; }
.login-row .day b { display: block; font-size: 18px; color: #7b2ff7; }
.login-row .day.on { background: linear-gradient(#ffe45c, #ffb300); color: #5a3400; }
.login-row .day.today { outline: 3px solid #ff4fa3; }

.shop-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.card { background: #fff; border-radius: 18px; padding: 8px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 3px 0 rgba(123,47,247,.15); }
.card .ic { font-size: 42px; height: 54px; line-height: 54px; }
.card .nm { font-weight: 800; font-size: 17px; line-height: 1.1; min-height: 38px; display: flex; align-items: center; }
.card .ds { font-size: 13px; font-weight: 700; color: #9a7ab0; line-height: 1.15; min-height: 45px; }
.card .have { font-size: 14px; font-weight: 800; color: #7b2ff7; }
.card .btn { font-size: 16px; padding: 5px 12px 7px; width: 100%; }

.chest-big { font-size: 110px; line-height: 1.1; animation: wiggle .6s ease-in-out infinite; }
.chest-got { display: flex; gap: 12px; justify-content: center; font-size: 22px; font-weight: 800; color: #5b2a86; flex-wrap: wrap; }
.chest-got div { background: #fff; border-radius: 14px; padding: 6px 12px; animation: pop .4s ease both; }

.howto { text-align: left; font-size: 19px; line-height: 1.45; margin: 8px 0; padding-left: 26px; font-weight: 600; }
.howto li { margin: 5px 0; }
.keys { color: #9a7ab0; font-size: 15px; font-weight: 700; }
.set-grid { display: grid; grid-template-columns: 1fr auto; gap: 12px 24px; align-items: center; text-align: left; font-size: 20px; font-weight: 800; margin: 14px 0; }
select { font: inherit; font-size: 18px; font-weight: 700; padding: 6px 10px; border-radius: 12px; border: 3px solid #ffb3d9; color: #5b2a86; background: #fff; }

.quip { margin: 0 0 6px; font-size: 20px; font-weight: 700; color: #9b4dca; font-style: italic; }
.big-score { font-size: 70px; font-weight: 800; color: #ff4fa3; line-height: 1; -webkit-text-stroke: 3px #7b2ff7; margin: 4px 0; }
.badge-new { display: inline-block; background: linear-gradient(#ffe45c, #ffb300); color: #5a3400; font-weight: 800; font-size: 20px; padding: 3px 18px; border-radius: 16px; animation: wiggle .6s ease-in-out infinite; }
.stars { font-size: 76px; letter-spacing: 12px; line-height: 1; margin: 2px 0 6px; }
.stars span { display: inline-block; color: #ffd83a; -webkit-text-stroke: 3px #b36b00; animation: pop .45s ease both; }
.stars span.off { color: #eadcf5; -webkit-text-stroke: 3px #c7b2dd; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.stats div { background: #fff; border-radius: 14px; padding: 6px 8px; }
.stats b { display: block; font-size: 26px; color: #7b2ff7; }
.stats small { color: #9a7ab0; font-size: 14px; font-weight: 700; line-height: 1.1; display: block; }
.reward { font-size: 26px; font-weight: 800; color: #e8157f; }

/* ---------------------------------------------------------------- map */
#map { justify-content: flex-start; }
.map-head { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 48px 18px 0; }
.map-title { background: rgba(255,255,255,.9); border-radius: 22px; padding: 4px 26px; text-align: center; box-shadow: 0 6px 16px rgba(0,0,0,.18); min-width: 320px; }
.map-title b { display: block; font-size: 28px; color: #e8157f; }
.map-title small { font-size: 16px; font-weight: 800; color: #b36b00; }
.map-nav { display: flex; gap: 10px; }
#map-nodes { position: absolute; inset: 0; pointer-events: none; }
.node {
  position: absolute; width: 70px; height: 70px; margin: -35px 0 0 -35px; border-radius: 50%; border: 5px solid #fff; pointer-events: auto;
  background: radial-gradient(circle at 35% 30%, #ffb3d3, #e8157f); color: #fff; font: inherit; font-size: 27px; font-weight: 800; cursor: pointer;
  box-shadow: 0 6px 0 rgba(120,0,80,.4), 0 8px 18px rgba(0,0,0,.25); transition: transform .12s cubic-bezier(.3,1.6,.5,1); text-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.node:hover { transform: scale(1.12); }
.node.done { background: radial-gradient(circle at 35% 30%, #9cf0ff, #0fa6b4); }
.node.hard { border-color: #ff9a1f; }
.node.boss { border-color: #ff3b5c; width: 84px; height: 84px; margin: -42px 0 0 -42px; }
.node.next { animation: bounce 1s ease-in-out infinite; background: radial-gradient(circle at 35% 30%, #fff39a, #ffac00); color: #6a3a00; }
.node.locked { background: radial-gradient(circle at 35% 30%, #ddd, #9a8aac); cursor: not-allowed; font-size: 22px; }
.node .st { position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); font-size: 17px; color: #ffd83a; -webkit-text-stroke: 1px #8a5200; white-space: nowrap; letter-spacing: 1px; }
.chest-btn { position: absolute; right: 26px; bottom: 26px; width: 150px; border: 4px solid #fff; border-radius: 22px; background: linear-gradient(#ffe45c, #ffac00); font: inherit; cursor: pointer; padding: 4px 6px 8px; box-shadow: 0 6px 0 rgba(0,0,0,.25); color: #5a3400; }
.chest-btn .ic { font-size: 46px; display: block; line-height: 1.1; }
.chest-btn small { font-size: 14px; font-weight: 800; display: block; line-height: 1.1; }
.chest-btn.ready { animation: wiggle .6s ease-in-out infinite; }
.chest-btn:not(.ready) { filter: saturate(.5); }
.map-wallet { position: absolute; left: 26px; bottom: 26px; }

#rotate { display: none; }
@media (orientation: portrait) and (max-width: 820px) and (pointer: coarse) {
  #rotate { display: block; position: fixed; left: 0; right: 0; bottom: 0; background: rgba(232,21,127,.95); color: #fff; text-align: center; padding: 12px; font-weight: 800; z-index: 50; }
}
.coin { display: inline-block; width: .9em; height: .9em; border-radius: 50%; vertical-align: -0.12em; background: radial-gradient(circle at 35% 30%, #fff6b0, #ffd23a 45%, #d98a00); box-shadow: inset 0 0 0 2px rgba(150,80,0,.55); }
.goal-row .need { align-self: center; font-size: 20px; font-weight: 800; color: #e8157f; }
#result-left .goal { width: 84px; height: 78px; }
/* phones: the 1280×720 stage is scaled ~0.55×, so the small menu buttons get finger-sized heights */
@media (pointer: coarse) {
  .menu-row .icon-btn { min-height: 66px; }
}
@media (pointer: coarse) {
  #btn-pause { min-width: 80px; min-height: 80px; }
  #pause .btn, #map .btn, #intro .btn { min-height: 66px; }
  .btn.round { min-width: 66px; }
}
