* { box-sizing: border-box; }
:root {
  --night: #0D0221; --plum: #261447; --red: #FF3864; --cyan: #2DE2E6; --pink: #F6019D; --sun: #FFD319;
  --ink: #f5ecff; --dim: #b9a6de; --panel: rgba(28, 10, 58, 0.92);
  --font: "Baloo 2", "Nunito", system-ui, "Noto Sans", sans-serif;
  --glow-p: 0 0 12px rgba(246,1,157,.6), 0 0 2px rgba(246,1,157,.9);
  --glow-c: 0 0 12px rgba(45,226,230,.6), 0 0 2px rgba(45,226,230,.9);
}
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #07010f; color: var(--ink); font-family: var(--font);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none;
}
#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; display: block; touch-action: none; }
button, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- neon glass surfaces */
.card {
  position: relative; width: 580px; max-width: 94%; padding: 24px 30px 20px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(48,18,92,.96), rgba(22,6,46,.96));
  border: 2px solid rgba(45,226,230,.55);
  box-shadow: 0 0 0 1px rgba(246,1,157,.35) inset, 0 0 28px rgba(246,1,157,.35), 0 18px 40px rgba(0,0,0,.5);
  animation: cardIn .35s cubic-bezier(.2,1.6,.4,1) both;
}
.card.wide { width: 940px; }
.card.narrow { width: 380px; }
.card h2 {
  margin: 0 0 6px; font-size: 38px; line-height: 1.1; color: #fff; overflow-wrap: anywhere;
  text-shadow: 0 0 10px var(--pink), 3px 3px 0 var(--pink), -1px -1px 0 var(--cyan);
}
.card .sub { margin: 4px 0 12px; font-size: 19px; font-weight: 700; color: var(--dim); line-height: 1.3; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@keyframes cardIn { from { transform: translateY(40px) scale(.85); opacity: 0; } }

.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.overlay.dim { background: rgba(7,1,15,.6); }

/* ---------------------------------------------------------------- buttons */
.btn {
  position: relative; border: 2px solid rgba(45,226,230,.7); cursor: pointer; padding: 8px 22px; min-height: 58px; border-radius: 14px;
  font-size: 23px; font-weight: 800; color: #fff; background: linear-gradient(180deg, #3a1a6e, #24104a);
  box-shadow: var(--glow-c), 0 4px 0 #0b0320; transition: transform .08s, box-shadow .15s;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; line-height: 1.1; text-align: center;
}
.btn > span { display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 0 20px rgba(45,226,230,.8), 0 5px 0 #0b0320; }
.btn:active { transform: translateY(3px); box-shadow: var(--glow-c), 0 1px 0 #0b0320; }
.btn small { font-size: 15px; font-weight: 700; opacity: .85; }
.btn.play { border-color: #ffd0ec; background: linear-gradient(180deg, #ff3fae, var(--pink)); box-shadow: var(--glow-p), 0 4px 0 #6b0046; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.btn.alt { border-color: var(--sun); box-shadow: 0 0 12px rgba(255,211,25,.5), 0 4px 0 #0b0320; }
.btn.daily { border-color: var(--sun); background: linear-gradient(180deg, #ff8a3d, #ff3864); box-shadow: 0 0 14px rgba(255,120,60,.6), 0 4px 0 #5a1020; }
.btn.ghost { background: rgba(255,255,255,.06); border-color: rgba(185,166,222,.5); box-shadow: none; }
.btn.small { font-size: 20px; min-height: 50px; padding: 6px 16px; }
.btn .em { font-size: 22px; }
.btn[disabled] { filter: grayscale(.8); opacity: .55; cursor: default; }
.rbtn {
  width: 52px; height: 52px; border-radius: 50%; border: 2px solid rgba(45,226,230,.7); cursor: pointer; font-size: 22px; font-weight: 800;
  background: rgba(28,10,58,.85); color: #fff; box-shadow: var(--glow-c); display: grid; place-items: center;
}
.rbtn:active { transform: translateY(2px); }
.badge {
  position: absolute; top: -8px; right: -8px; min-width: 24px; height: 24px; border-radius: 12px; background: var(--pink);
  color: #fff; font-style: normal; font-size: 15px; line-height: 24px; box-shadow: var(--glow-p); animation: bob 1s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-4px); } }
.actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 16px 0 10px; border-radius: 21px;
  font-weight: 800; font-size: 21px; background: rgba(20,6,42,.82); border: 2px solid rgba(246,1,157,.55); color: #fff;
}
.pill.big { height: 48px; font-size: 25px; }
.pill.stars span { color: var(--sun); text-shadow: 0 0 8px var(--sun); padding-left: 4px; }
.pill.streak { color: var(--sun); font-size: 18px; padding: 0 14px; }
.pill.lvl { padding: 0 16px; border-color: rgba(45,226,230,.6); }
.pill.time { padding: 0 16px; min-width: 96px; justify-content: center; font-variant-numeric: tabular-nums; }
.pill.time.over { color: #ff9ab0; }
.pill.gold { padding: 0 8px; border-color: var(--sun); box-shadow: 0 0 12px rgba(255,211,25,.7); animation: pop .35s cubic-bezier(.2,2,.4,1); }
.ico-mango, .ico-gold { display: inline-block; width: 30px; height: 30px; background: url(assets/mango.webp) center / contain no-repeat; }
.ico-gold { background-image: url(assets/gold_mango.webp); }
body.noart .ico-mango { background: radial-gradient(circle at 45% 55%, #ff9a2e 55%, transparent 58%); }
body.noart .ico-gold { background: radial-gradient(circle at 45% 55%, #ffd319 55%, transparent 58%); }

/* ---------------------------------------------------------------- HUD */
#hud { position: absolute; left: 0; right: 0; top: 0; height: 90px; pointer-events: none; }
.hud-left { position: absolute; left: 16px; top: 14px; display: flex; gap: 8px; }
.hud-right { position: absolute; right: 16px; top: 14px; display: flex; gap: 10px; pointer-events: auto; }
.pop { animation: pop .25s cubic-bezier(.2,2,.4,1); }
@keyframes pop { 0% { transform: scale(1.4); } 100% { transform: scale(1); } }

#calls { position: absolute; left: 0; right: 0; top: 110px; display: flex; flex-direction: column; align-items: center; pointer-events: none; gap: 6px; }
.call {
  font-size: 54px; font-weight: 800; color: #fff; padding: 0 30px; max-width: 1100px; text-align: center; line-height: 1.1; font-style: italic;
  text-shadow: 0 0 14px var(--pink), 4px 4px 0 var(--pink), -2px -2px 0 var(--cyan);
  animation: callIn 1.4s cubic-bezier(.2,1.6,.4,1) both;
}
.call.gold { color: var(--sun); text-shadow: 0 0 16px var(--sun), 4px 4px 0 #b3006e; }
.call.cyan { text-shadow: 0 0 14px var(--cyan), 4px 4px 0 #0b6d8a; }
.call.small { font-size: 36px; }
@keyframes callIn { 0% { transform: scale(.3) skewX(-10deg); opacity: 0; } 12% { transform: scale(1.15) skewX(-6deg); opacity: 1; } 22% { transform: scale(1); } 80% { opacity: 1; } 100% { transform: translateY(-30px); opacity: 0; } }

.hint {
  position: absolute; left: 50%; bottom: 60px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px;
  font-size: 28px; font-weight: 800; color: #fff; text-shadow: 0 0 10px var(--pink), 0 3px 0 #1a0630;
  pointer-events: none; max-width: 1100px; text-align: center; padding: 8px 22px; border-radius: 18px; background: rgba(13,2,33,.55);
}
.hint .hand { font-size: 38px; animation: tap 1.1s ease-in-out infinite; }
@keyframes tap { 45% { transform: translateY(10px) scale(.9); } }

.toast {
  position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); padding: 12px 28px; border-radius: 16px;
  font-size: 22px; font-weight: 800; background: var(--panel); border: 2px solid var(--sun); box-shadow: 0 0 16px rgba(255,211,25,.5);
  animation: cardIn .3s both; max-width: 80%; text-align: center; pointer-events: none;
}

/* ---------------------------------------------------------------- menu */
#menu { justify-content: flex-start; align-items: flex-start; padding: 70px 0 0 70px; background: linear-gradient(90deg, rgba(7,1,15,.7), rgba(7,1,15,.1) 55%); }
.menu-top { position: absolute; top: 16px; right: 18px; display: flex; gap: 10px; align-items: center; }
.logo h1 {
  margin: 0; font-size: 110px; line-height: .92; color: #fff; letter-spacing: 1px; max-width: 700px; font-style: italic;
  text-shadow: 0 0 18px var(--pink), 5px 5px 0 var(--pink), 10px 10px 0 #5a0ba0, -2px -2px 0 var(--cyan);
  transform: rotate(-4deg); animation: logoSwing 3.4s ease-in-out infinite; transform-origin: 10% 0;
}
.logo p { margin: 16px 0 0 8px; font-size: 30px; font-weight: 800; color: var(--sun); text-shadow: 0 0 10px rgba(255,211,25,.7), 0 3px 0 #3a0a50; max-width: 640px; }
.logo h1.long { font-size: 72px; }
.logo h1 { white-space: nowrap; } /* never break a word (CJK titles have no spaces); fitLogo() shrinks instead */
@keyframes logoSwing { 50% { transform: rotate(-1deg) translateY(-6px); } }
.menu-main { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; width: 400px; }
.menu-main .btn { width: 100%; }
.menu-row { display: flex; gap: 12px; width: 100%; }
.menu-row .btn { flex: 1; padding: 6px 8px; }
#btn-play { font-size: 40px; min-height: 86px; animation: breathe 1.6s ease-in-out infinite; }
#btn-play small { font-size: 18px; }
@keyframes breathe { 50% { transform: scale(1.035) rotate(-.8deg); } }

/* ---------------------------------------------------------------- levels */
.tabs { display: flex; gap: 8px; margin: 8px 0 10px; flex-wrap: wrap; }
.tab {
  border: 2px solid rgba(185,166,222,.4); background: rgba(255,255,255,.05); border-radius: 12px; padding: 6px 16px; cursor: pointer;
  font-size: 19px; font-weight: 800; color: var(--dim);
}
.tab.on { color: #fff; border-color: var(--cyan); box-shadow: var(--glow-c); background: rgba(45,226,230,.12); }
.tab.locked { opacity: .6; }
.level-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 10px; }
.lv {
  position: relative; aspect-ratio: 1 / 1.05; border-radius: 14px; border: 2px solid rgba(45,226,230,.5); background: rgba(45,226,230,.08);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; font-size: 26px; color: #fff;
  transition: transform .1s;
}
.lv:hover { transform: translateY(-3px) scale(1.04); }
.lv .st { font-size: 14px; letter-spacing: 1px; color: rgba(255,255,255,.25); line-height: 1; }
.lv .st b { color: var(--sun); text-shadow: 0 0 6px var(--sun); font-weight: 800; }
.lv.next { border-color: var(--pink); box-shadow: var(--glow-p); animation: bob 1.2s ease-in-out infinite; }
.lv.locked { opacity: .35; cursor: default; border-color: rgba(185,166,222,.3); }
.locked-note { color: var(--sun) !important; }

/* ---------------------------------------------------------------- daily */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: rgba(45,226,230,.1); border: 1px solid rgba(45,226,230,.3); border-radius: 12px; padding: 8px 12px; font-size: 20px; font-weight: 800; }

/* ---------------------------------------------------------------- wardrobe */
.shop-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-top: 4px; }
.item {
  position: relative; border: 2px solid rgba(185,166,222,.35); border-radius: 14px; padding: 8px 4px; cursor: pointer; background: rgba(255,255,255,.05);
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 168px; transition: transform .1s;
}
.item:hover { transform: translateY(-3px); }
.item.on { border-color: var(--pink); box-shadow: var(--glow-p); background: rgba(246,1,157,.12); }
.item canvas { width: 110px; height: 96px; }
.item.locked canvas { filter: grayscale(1) brightness(.5); }
.item .nm { font-size: 16px; font-weight: 800; line-height: 1.1; text-align: center; min-height: 36px; display: flex; align-items: center; }
.item .tag { font-size: 16px; font-weight: 800; padding: 2px 10px; border-radius: 10px; background: rgba(255,255,255,.1); display: inline-flex; align-items: center; gap: 3px; }
.item .tag .ico-mango { width: 20px; height: 20px; }
.item .tag.buy { background: var(--sun); color: #2a0a40; }
.item .tag.use { background: var(--cyan); color: #06203a; }
.item .tag.req { background: transparent; color: var(--dim); font-size: 13px; }

/* ---------------------------------------------------------------- missions */
.mission-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.mission { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; background: rgba(255,255,255,.06); padding: 10px 14px; border-radius: 12px; }
.mission .txt { font-size: 20px; font-weight: 800; line-height: 1.15; }
.mission .txt small { color: var(--dim); }
.mission .bar { grid-column: 1; height: 10px; border-radius: 6px; background: rgba(255,255,255,.1); overflow: hidden; }
.mission .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--pink)); }
.mission .btn { grid-row: 1 / span 2; grid-column: 2; min-height: 46px; font-size: 18px; padding: 4px 14px; flex-direction: row; gap: 4px; }
.mission.done .txt { color: var(--cyan); }

/* ---------------------------------------------------------------- settings */
.set-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.set { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 22px; font-weight: 800; }
.toggle { min-width: 90px; height: 42px; border-radius: 21px; border: 2px solid rgba(185,166,222,.4); cursor: pointer; font-weight: 800; background: rgba(255,255,255,.08); }
.toggle.on { background: var(--cyan); color: #06203a; border-color: var(--cyan); box-shadow: var(--glow-c); }
select { height: 44px; border-radius: 12px; border: 2px solid rgba(45,226,230,.5); background: #1b0b38; font-size: 19px; font-weight: 700; padding: 0 8px; max-width: 260px; }

/* ---------------------------------------------------------------- results */
#result { background: radial-gradient(ellipse at center, rgba(7,1,15,.25), rgba(7,1,15,.65)); }
.card.result { width: 640px; text-align: center; }
.card.result h2 { font-size: 44px; }
.quip { margin: 0 0 6px; font-size: 21px; font-weight: 700; color: var(--dim); }
.res-stars { display: flex; justify-content: center; gap: 18px; margin: 6px 0 8px; }
.rstar { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 150px; }
.rstar i { font-style: normal; font-size: 64px; line-height: 1; color: rgba(255,255,255,.14); }
.rstar.got i { color: var(--sun); text-shadow: 0 0 18px var(--sun), 0 4px 0 #b3006e; animation: stampIn .45s cubic-bezier(.2,2,.4,1) both; }
.rstar.new i { animation: stampIn .5s cubic-bezier(.2,2,.4,1) both, glowPulse 1s 1s ease-in-out infinite; }
.rstar span { font-size: 15px; font-weight: 800; color: var(--dim); line-height: 1.15; }
.rstar.got span { color: #fff; }
@keyframes stampIn { 0% { transform: scale(3) rotate(-30deg); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes glowPulse { 50% { transform: scale(1.12); } }
.res-lines { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.res-line { background: rgba(255,255,255,.07); border-radius: 12px; padding: 6px 14px; font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.res-line b { font-size: 30px; color: #fff; font-variant-numeric: tabular-nums; }
.res-line.m b { color: var(--sun); }
.newbest { display: inline-block; margin-top: 8px; font-size: 26px; font-weight: 800; color: #fff; background: var(--pink); padding: 2px 16px; border-radius: 10px; transform: rotate(-4deg); box-shadow: var(--glow-p); animation: stampIn .4s .6s both, bob 1s 1s infinite; }
.goal { margin: 10px 0 0; font-size: 20px; font-weight: 800; color: var(--cyan); }
.res-missions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 6px; }
.res-missions span { font-size: 15px; font-weight: 800; background: rgba(45,226,230,.2); border: 1px solid var(--cyan); padding: 3px 10px; border-radius: 10px; }

/* ---------------------------------------------------------------- loading / rotate */
.loader { text-align: center; font-size: 26px; font-weight: 800; }
.spin { width: 60px; height: 60px; margin: 0 auto 10px; border-radius: 50%; border: 6px solid rgba(255,255,255,.15); border-top-color: var(--pink); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#rotate {
  display: none; position: fixed; inset: 0; z-index: 9; background: var(--night); color: #fff; font-size: 22px; font-weight: 800;
  flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px;
}
#rotate span { font-size: 60px; animation: bob 1.2s infinite; }
@media (orientation: portrait) and (max-width: 700px) and (pointer: coarse) { body.touch #rotate { display: flex; } }

/* phones: the stage is scaled to ~50%, so small print gets bigger */
@media (max-height: 500px), (max-width: 700px) {
  .rbtn { width: 64px; height: 64px; font-size: 26px; }
  .pill { font-size: 25px; height: 48px; }
  .item .nm { font-size: 20px; }
  .rstar span, .quip, .goal { font-size: 23px; }
  .mission .txt { font-size: 24px; }
  .card .sub, .stat { font-size: 23px; }
  .btn small { font-size: 18px; }
  .hint { font-size: 32px; }
}
:lang(ja) .logo p, :lang(zh) .logo p, :lang(ko) .logo p, :lang(th) .logo p { font-size: 28px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
