* { 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(70,20,110,.45), rgba(40,10,70,.78));
  animation: fade .22s ease;
}
.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) } }

.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: #ff5fa2; animation: rot 0.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, #ff5fa2, #ffd60a); 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, #f107a3); }
.btn.gold { background: linear-gradient(#ffe45c, #ffb300); color: #5a3400; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.btn.green { background: linear-gradient(#5ff0b0, #1fb877); }
.btn.blue { background: linear-gradient(#5fd3ff, #0a8fd0); }
.btn.purple { background: linear-gradient(#a877ff, #7b2ff7); }
.btn.dark { background: linear-gradient(#7a5aa6, #4b2f78); }
.btn.round { width: 54px; height: 54px; padding: 0; border-radius: 50%; font-size: 22px; }
.btn.big { width: 100%; font-size: 30px; padding: 12px 20px 14px; display: flex; flex-direction: column; align-items: center; }
.btn.big small { font-size: 16px; font-weight: 700; opacity: .9; margin-top: 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.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: 40px; }
.menu-col { width: 470px; display: flex; flex-direction: column; gap: 12px; background: rgba(255,255,255,.72); border-radius: 30px; padding: 20px 26px 22px; box-shadow: 0 16px 40px rgba(60,20,90,.3); border: 4px solid rgba(255,255,255,.9); animation: pop .4s ease both; }
.logo { display: flex; flex-direction: column; align-items: center; line-height: .85; margin-bottom: 2px; }
.logo .l1 { font-size: 58px; font-weight: 800; color: #ffd60a; -webkit-text-stroke: 1.5px #b0306a; paint-order: stroke fill; letter-spacing: 3px; text-shadow: 0 6px 0 #7b2ff7; animation: wiggle 3s ease-in-out infinite; }
.logo .l2 { font-size: 88px; font-weight: 800; background: linear-gradient(90deg, #ff5fa2, #ffc933 35%, #2fcb6e 65%, #2f8cff); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 1.5px #5b1a7a; filter: drop-shadow(0 6px 0 rgba(91,26,122,.5)); }
.tagline { margin: 0; text-align: center; font-size: 18px; font-weight: 700; color: #6a3f8a; }
.menu-btns { display: flex; flex-direction: column; gap: 10px; }
.menu-btns .row { display: flex; gap: 8px; }
.menu-btns .grow { flex: 1; }
.small-new { width: 64px; font-size: 30px; padding: 0; }
.menu-row { display: flex; gap: 10px; }
.menu-row .btn { flex: 1; font-size: 18px; padding: 9px 10px 11px; }
.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: 18px; right: 22px; display: flex; gap: 10px; }
.pill { background: rgba(80,30,110,.78); color: #fff; font-size: 24px; font-weight: 800; padding: 4px 18px; border-radius: 26px; border: 3px solid rgba(255,255,255,.5); }
.pill b { color: #ffe066; }

/* ---------------------------------------------------------------- HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#btn-pause { position: absolute; right: 18px; top: 18px; font-size: 18px; }
#powers { position: absolute; left: 1150px; top: 96px; display: flex; flex-direction: column; gap: 14px; }
.power {
  width: 92px; height: 100px; border: 0; border-radius: 22px; cursor: pointer; font: inherit; color: #fff;
  background: linear-gradient(#b88cff, #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);
}
.power:hover { transform: translateY(-3px) scale(1.05); }
.power:active { transform: translateY(3px) scale(.95); }
.power .ic { font-size: 34px; line-height: 1; }
.power kbd { position: absolute; left: 6px; top: 4px; font: inherit; font-size: 12px; opacity: .6; }
.power small { font-size: 13px; font-weight: 800; max-width: 86px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.power .n { position: absolute; top: -8px; right: -6px; background: #ffd60a; color: #5a3400; border-radius: 14px; min-width: 28px; height: 28px; display: grid; place-items: center; font-size: 17px; box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.power.empty { filter: grayscale(.8) brightness(.85); }
.power.active { background: linear-gradient(#ff9ed0, #f107a3); animation: wiggle .5s ease-in-out infinite; }
.power.bump { animation: pop .45s ease; }
.power.off { display: none; }
.hint { position: absolute; left: 22px; width: 330px; top: 474px; text-align: center; color: #fff; font-weight: 800; font-size: 19px; background: rgba(123,47,247,.85); border-radius: 16px; padding: 4px 12px; animation: pop .3s ease both; pointer-events: none !important; }

.toast { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); background: rgba(255,255,255,.95); 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: 20; max-width: 900px; text-align: center; pointer-events: none; }

/* ---------------------------------------------------------------- modals */
.modal {
  background: linear-gradient(180deg, #fff9fd, #f3e6ff); border: 5px solid #fff; border-radius: 30px; padding: 22px 34px 24px;
  min-width: 440px; max-width: 900px; text-align: center; box-shadow: 0 24px 60px rgba(40,0,70,.5), inset 0 -6px 0 rgba(123,47,247,.12);
  animation: pop .35s ease both; max-height: 690px; overflow-y: auto;
}
.modal.wide { width: 880px; }
.modal h2 { margin: 0 0 6px; font-size: 40px; line-height: 1.1; color: #7b2ff7; text-shadow: 0 3px 0 rgba(255,95,162,.35); }
.modal h3 { margin: 12px 0 6px; font-size: 22px; color: #9b4dca; text-align: left; }
.modal .sub { margin: 0 0 10px; color: #7a5a90; font-size: 18px; font-weight: 700; }
.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; }

.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, #ff5fa2, #ffd60a); 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: 88px; 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 #ff5fa2; }

.shop-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.shop-grid.three { grid-template-columns: repeat(3, 1fr); }
.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 .pic { width: 96px; height: 80px; background-repeat: no-repeat; background-size: 400% 100%; background-position-y: center; }
.card .ic { font-size: 40px; 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 .btn { font-size: 16px; padding: 5px 12px 7px; width: 100%; }
.card.owned { background: #e9fff3; }

.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 #c9a6ff; color: #5b2a86; background: #fff; }

.goal-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.goal-list div { background: #fff; border-radius: 16px; padding: 8px 18px; font-size: 22px; font-weight: 800; }
.quip { margin: 0 0 6px; font-size: 20px; font-weight: 700; color: #9b4dca; font-style: italic; }
.big-score { font-size: 72px; font-weight: 800; color: #ff5fa2; line-height: 1; -webkit-text-stroke: 3px #7b2ff7; margin: 6px 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: 72px; letter-spacing: 10px; line-height: 1; margin: 2px 0 6px; }
.stars span { display: inline-block; color: #ffd60a; -webkit-text-stroke: 3px #b36b00; animation: pop .45s ease both; }
.stars span.off { color: #e5d8f2; -webkit-text-stroke: 3px #c7b2dd; }
.stats { display: grid; grid-template-columns: repeat(4, 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: #f107a3; }
.tip { font-size: 16px; color: #9a7ab0; font-weight: 700; margin: 6px 0 0; }

/* ---------------------------------------------------------------- map */
#map { justify-content: flex-start; }
.map-head { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 0; }
.map-title { background: rgba(255,255,255,.85); border-radius: 22px; padding: 4px 26px; text-align: center; box-shadow: 0 6px 16px rgba(0,0,0,.18); }
.map-title b { display: block; font-size: 28px; color: #7b2ff7; }
.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: 74px; height: 74px; margin: -37px 0 0 -37px; border-radius: 50%; border: 5px solid #fff; pointer-events: auto;
  background: radial-gradient(circle at 35% 30%, #ffb3d3, #f107a3); color: #fff; font: inherit; font-size: 30px; 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%, #a6f4d0, #1fb877); }
.node.next { animation: bounce 1s ease-in-out infinite; }
.node.locked { background: radial-gradient(circle at 35% 30%, #ddd, #9a8aac); cursor: not-allowed; font-size: 24px; }
.node .st { position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); font-size: 16px; color: #ffd60a; -webkit-text-stroke: 1px #8a5200; white-space: nowrap; letter-spacing: 1px; }

#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(123,47,247,.95); color: #fff; text-align: center; padding: 12px; font-weight: 800; z-index: 50; }
}

.new-thing { background: #fff3c4; border-radius: 14px; padding: 8px 14px; font-weight: 800; color: #8a4b00; font-size: 18px; margin: 8px 0 0; }
.card .bub { width: 64px; height: 64px; }
.power.armed { background: linear-gradient(#ffe45c, #ff8a2b); animation: wiggle .5s ease-in-out infinite; }
.node .gi { position: absolute; top: -16px; right: -14px; font-size: 24px; font-style: normal; text-shadow: none; }
/* 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; }
}
