@font-face { font-family: "Andika"; src: url("fonts/andika-bold.woff2") format("woff2"); font-weight: 100 900; font-display: block; }
@font-face { font-family: "LXGW WenKai"; src: url("fonts/lxgw-wenkai-medium.woff2") format("woff2"); font-weight: 100 900; font-display: block; }
@font-face { font-family: "ZCOOL QingKe HuangYou"; src: url("fonts/zcool-qingke-huangyou.woff2") format("woff2"); font-weight: 100 900; font-display: block; }
/* Dela only draws Latin and digits, so Chinese in the same line comes from ZCOOL instead of a Japanese kanji face. */
@font-face { font-family: "Dela Latin"; src: url("fonts/dela-gothic-one.woff2") format("woff2"); font-display: block; unicode-range: U+0000-00FF, U+2010-2027; }

:root {
  --ink: #1b1d4d;
  --paper: #fff8ec;
  --blue: #3b6bff;
  --pink: #ff7ab6;
  --pink-soft: #ffd0e4;
  --blue-soft: #d9e4ff;
  --yellow: #ffd23f;
  --yellow-soft: #fff0b8;
  --mint: #3fdcb0;
  --mint-soft: #c9f5e8;
  --violet: #a77bff;
  --red: #ff4f6d;
  --chunky: "Dela Latin", "ZCOOL QingKe HuangYou", "PingFang SC", "Microsoft YaHei", sans-serif;
  --round: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --card-latin: "Andika", "Comic Sans MS", sans-serif;
  --card-han: "LXGW WenKai", "Kaiti SC", "STKaiti", "KaiTi", serif;
  --E: 0;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--round);
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
/* Layers: paper 0 → backdrop and back particles 1 → screens 2 → pages 30 → finale 40 → mascot 45 → cut-ins 47 → flash 48 → particles 50. */
#paper {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 122, 182, .16) 0 120px, transparent 121px),
    radial-gradient(circle at 88% 78%, rgba(59, 107, 255, .12) 0 160px, transparent 161px),
    linear-gradient(rgba(59, 107, 255, .11) 1.5px, transparent 1.5px) 0 0 / 26px 26px,
    linear-gradient(90deg, rgba(59, 107, 255, .11) 1.5px, transparent 1.5px) 0 0 / 26px 26px,
    var(--paper);
}
#rays-fallback { display: none; position: fixed; inset: -50vmax; z-index: 1; opacity: 0; pointer-events: none; background: repeating-conic-gradient(from 0deg at 50% 50%, #3b6bff 0 9deg, #ff7ab6 9deg 18deg); }
#bg, #fx-back { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
#cutins { position: fixed; inset: 0; z-index: 47; pointer-events: none; overflow: hidden; }
#flash { position: fixed; inset: 0; z-index: 48; pointer-events: none; background: #fff; opacity: 0; }
#actors { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 45; pointer-events: none; overflow: visible; }
.dk-digit { font-family: var(--card-latin); font-weight: 700; fill: var(--ink); stroke: #fff; stroke-width: 6px; paint-order: stroke; }
body[data-set="han"] .dk-digit { font-family: var(--card-han); }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

.screen {
  position: fixed; inset: 0; z-index: 2; display: none; flex-direction: column; align-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.screen.on { display: flex; }

/* ---------- title ---------- */
#title { justify-content: space-evenly; gap: 8px; }
.logo { margin: 0; display: flex; flex-direction: column; align-items: center; line-height: 1; font-family: var(--chunky); font-weight: 400; }
.logo .l1 { font-family: var(--round); font-weight: 900; font-size: clamp(44px, 12vw, 76px); color: var(--pink); text-shadow: 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 3px 0 var(--ink), 0 -3px 0 var(--ink), 0 7px 0 var(--ink); transform: rotate(-4deg); }
.logo .l2 { margin-top: 6px; font-size: clamp(30px, 8vw, 48px); background: var(--blue); color: #fff; padding: 6px 22px 8px; border: 4px solid var(--ink); border-radius: 14px; box-shadow: 0 5px 0 var(--ink); transform: rotate(2deg); }
.mascot-spot { position: relative; width: 150px; height: 150px; flex: none; }
#play-spot { width: var(--spot); height: var(--spot); }
#title .mascot-spot { width: 130px; height: 130px; }
.sets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; width: min(100%, 520px); }
.set-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 118px; padding: 10px; border: 5px solid var(--ink); border-radius: 26px; background: var(--c, #fff);
  box-shadow: 0 7px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.set-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.set-btn .ico { font-size: 44px; line-height: 1; font-family: var(--card-latin); }
.set-btn .ico.han { font-family: var(--card-han); }
.set-btn .nm { font-family: var(--chunky); font-weight: 400; font-size: 22px; }
.set-btn .prog { position: absolute; top: 8px; right: 12px; font-size: 12px; opacity: .6; }
.title-foot { display: flex; gap: 12px; }
.pill { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border: 4px solid var(--ink); border-radius: 999px; background: #fff; box-shadow: 0 4px 0 var(--ink); font-size: 16px; overflow: hidden; }
.credit { margin: 0; font-size: 10px; font-weight: 600; opacity: .4; }
.credit-full { margin: 4px 0 24px; font-size: 12px; font-weight: 600; line-height: 1.6; opacity: .6; }
.credit-full a { color: inherit; }
.pill b { background: var(--yellow); border: 2px solid var(--ink); border-radius: 999px; padding: 0 8px; font-size: 14px; }
.pill-ico { font-size: 20px; }

/* Long-press buttons fill a ring while held. */
.hold-ring { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: conic-gradient(rgba(59, 107, 255, .35) calc(var(--hold, 0) * 360deg), transparent 0); }

/* ---------- play ---------- */
#play { justify-content: space-between; }
.play-top { display: flex; align-items: center; justify-content: space-between; width: min(100%, 720px); gap: 10px; }
.round-btn { position: relative; width: 52px; height: 52px; flex: none; border: 4px solid var(--ink); border-radius: 50%; background: #fff; box-shadow: 0 4px 0 var(--ink); font-size: 24px; display: grid; place-items: center; overflow: hidden; padding: 0; }
.round-btn.big { width: 68px; height: 68px; font-size: 32px; background: var(--yellow); }
.round-btn.big.talking { animation: talk .5s ease-in-out infinite alternate; }
@keyframes talk { to { transform: scale(1.12); } }
.dots { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; flex-wrap: wrap; justify-content: center; }
.dots li { width: 18px; height: 18px; border: 3px solid var(--ink); border-radius: 50%; background: #fff; transition: background .3s, transform .3s; }
.dots li.now { transform: scale(1.3); background: var(--yellow-soft); }
.dots li.done { background: var(--c, var(--pink)); }
.dots li.rainbow { background: conic-gradient(#ff4f6d, #ffb000, #3fdcb0, #3b6bff, #a77bff, #ff4f6d); }

/* Dopakichi stands at the bottom of the stage; the reward picture uses the space above him. */
.stage { --spot: 150px; position: relative; flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 10px; min-height: 0; }
.tray { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px 10px; padding: 14px 18px; border: 4px solid var(--ink); border-radius: 22px; background: #fff; box-shadow: 0 5px 0 var(--ink); }
.tray[hidden] { display: none; }
.tray span { font-size: clamp(34px, 9vw, 52px); line-height: 1.1; text-align: center; animation: pop .35s cubic-bezier(.3, 1.6, .5, 1) both; }
.tray span.tapped { filter: drop-shadow(0 0 0 var(--yellow)) drop-shadow(0 0 6px var(--yellow)); transform: scale(1.15); }
.reward { position: absolute; inset: 0 0 calc(var(--spot) + 6px) 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; z-index: 5; }
.reward[hidden] { display: none; }
.reward-pic { font-size: clamp(90px, 26vw, 150px); line-height: 1; animation: pop .5s cubic-bezier(.3, 1.6, .5, 1) both; filter: drop-shadow(0 6px 0 rgba(27, 29, 77, .25)); }
.reward-pic.many { font-size: clamp(30px, 8vw, 48px); max-width: 90%; text-align: center; line-height: 1.2; word-break: break-all; }
.reward-word { margin-top: 6px; font-family: var(--card-latin); font-size: clamp(26px, 7vw, 40px); background: #fff; border: 4px solid var(--ink); border-radius: 16px; padding: 2px 16px 4px; box-shadow: 0 4px 0 var(--ink); animation: pop .5s .12s cubic-bezier(.3, 1.6, .5, 1) both; }
.reward-word.han { font-family: var(--card-han); }

.choices { display: grid; gap: 16px; width: max-content; max-width: 100%; justify-content: center; padding-bottom: 8px; grid-template-columns: repeat(var(--cols, 2), minmax(0, var(--size, 190px))); }
.card {
  position: relative; aspect-ratio: 1; display: grid; place-items: center;
  border: 6px solid var(--ink); border-radius: 30px; background: var(--c, #fff); box-shadow: 0 8px 0 var(--ink);
  font-family: var(--card-latin); font-size: calc(var(--size, 190px) * .56); line-height: 1; padding: 0;
  animation: deal .45s cubic-bezier(.3, 1.5, .5, 1) both; animation-delay: calc(var(--i, 0) * 90ms);
  transition: transform .1s, box-shadow .1s, opacity .3s;
}
.card.long { font-size: calc(var(--size, 190px) * .42); }
.choices.odd .card:last-child { grid-column: 1 / -1; justify-self: center; width: var(--size); }
.card.han { font-family: var(--card-han); font-size: calc(var(--size, 190px) * .62); }
.card:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--ink); }
.card.wrong { animation: shake .45s; opacity: .45; }
.card.right { animation: win .6s cubic-bezier(.3, 1.6, .5, 1) both; background: var(--yellow); z-index: 2; }
.card.hint { animation: hint 1s ease-in-out infinite; }
.card.gone { opacity: 0; transform: scale(.6); transition: opacity .25s, transform .25s; pointer-events: none; }
@keyframes deal { from { transform: translateY(40px) scale(.6); opacity: 0; } }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
@keyframes shake { 20% { transform: translateX(-12px) rotate(-4deg); } 40% { transform: translateX(10px) rotate(3deg); } 60% { transform: translateX(-7px); } 80% { transform: translateX(4px); } }
@keyframes win { 50% { transform: scale(1.18) rotate(-4deg); } to { transform: scale(1.08); } }
@keyframes hint { 50% { transform: scale(1.08); box-shadow: 0 8px 0 var(--ink), 0 0 0 10px rgba(255, 210, 63, .7); } }

/* ---------- finale ---------- */
.overlay { background: rgba(27, 29, 77, .35); justify-content: center; z-index: 40; }
.finale-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 26px; width: min(100%, 420px); border: 5px solid var(--ink); border-radius: 30px; background: var(--paper); box-shadow: 0 8px 0 var(--ink); animation: pop .5s cubic-bezier(.3, 1.6, .5, 1) both; }
.finale-title { margin: 0; font-family: var(--chunky); font-weight: 400; font-size: 44px; color: var(--pink); text-shadow: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink), 0 5px 0 var(--ink); }
.finale-sticker { font-size: 110px; line-height: 1.1; animation: spinin .9s .2s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes spinin { from { transform: scale(0) rotate(-200deg); } }
.finale-sub { margin: 0; font-size: 18px; }
.finale-btns { display: flex; gap: 12px; margin-top: 8px; }
.btn { padding: 12px 22px; border: 4px solid var(--ink); border-radius: 18px; background: #fff; box-shadow: 0 5px 0 var(--ink); font-size: 20px; font-family: var(--chunky); font-weight: 400; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.blue { background: var(--blue); color: #fff; }
.btn.big { font-size: 26px; padding: 14px 28px; }
.btn.danger { background: #fff; color: var(--red); font-family: var(--round); font-size: 15px; font-weight: 800; margin: 18px auto 6px; display: block; }

/* ---------- pages ---------- */
.page { background: var(--paper); z-index: 30; overflow-y: auto; justify-content: flex-start; }
.page-top { display: flex; align-items: center; gap: 12px; width: min(100%, 620px); margin-bottom: 12px; }
.page-top h2 { margin: 0; font-family: var(--chunky); font-weight: 400; font-size: 28px; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 12px; width: min(100%, 620px); }
.sticker-grid span { aspect-ratio: 1; display: grid; place-items: center; font-size: 46px; border: 4px dashed rgba(27, 29, 77, .25); border-radius: 22px; background: rgba(255, 255, 255, .6); }
.sticker-grid span.got { border: 4px solid var(--ink); background: #fff; box-shadow: 0 4px 0 var(--ink); }
.sticker-grid span:not(.got) { filter: grayscale(1) opacity(.18); }
.parent-body { width: min(100%, 620px); font-size: 16px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 2px dashed rgba(27, 29, 77, .15); }
.seg { display: flex; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; flex: none; }
.seg button { border: 0; padding: 7px 14px; background: #fff; font-weight: 800; }
.seg button + button { border-left: 3px solid var(--ink); }
.seg button.on { background: var(--blue); color: #fff; }
.voice-note { font-size: 13px; opacity: .7; margin: 10px 0 0; }
.parent-body h3 { margin: 20px 0 6px; font-size: 18px; }
.prog-set { margin: 10px 0 14px; }
.prog-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.prog-head button { border: 3px solid var(--ink); border-radius: 10px; background: #fff; padding: 4px 10px; font-size: 13px; font-weight: 800; }
.prog-items { display: flex; flex-wrap: wrap; gap: 6px; }
.prog-items span { min-width: 38px; padding: 4px 6px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; text-align: center; font-family: var(--card-latin); font-size: 18px; line-height: 1.1; }
.prog-items span.han { font-family: var(--card-han); }
.prog-items span.locked { opacity: .25; border-style: dashed; }
.prog-items span small { display: block; font-size: 9px; color: #e0a200; letter-spacing: -1px; }

@media (min-width: 700px) and (min-height: 600px) {
  .sets { grid-template-columns: repeat(4, minmax(0, 1fr)); width: min(100%, 860px); }
  .set-btn { min-height: 150px; }
  .set-btn .ico { font-size: 56px; }
}
@media (max-height: 640px) {
  .mascot-spot, #title .mascot-spot { width: 96px; height: 96px; }
  .stage { --spot: 96px; }
  .set-btn { min-height: 92px; }
}

/* ---------- the show, after Dopa Drill: stage dressing by level, reach, hanamaru, cut-ins, finales ---------- */
.bunting { position: absolute; left: -2%; right: -2%; top: 0; width: 104%; height: 34px; opacity: 0; transform: translateY(-20px); transition: opacity .5s, transform .5s cubic-bezier(.3, 1.6, .5, 1); pointer-events: none; }
body.lv3 .bunting { opacity: 1; transform: none; }
.spot { position: absolute; top: -30px; width: 140px; height: 190px; opacity: 0; transition: opacity .6s; mix-blend-mode: screen; filter: blur(2px); pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 246, 200, .95), rgba(255, 246, 200, 0)); clip-path: polygon(44% 0, 56% 0, 100% 100%, 0 100%); }
.spot-l { left: 0; transform-origin: 50% 0; animation: spot-l 3s ease-in-out infinite; }
.spot-r { right: 0; transform-origin: 50% 0; animation: spot-r 3.4s ease-in-out infinite; }
body.lv5 .spot { opacity: .7; }
@keyframes spot-l { 0%, 100% { transform: rotate(-24deg); } 50% { transform: rotate(10deg); } }
@keyframes spot-r { 0%, 100% { transform: rotate(24deg); } 50% { transform: rotate(-12deg); } }
/* Marquee lights around the answer cards (Dopa Drill puts them around the problem card). */
.choices { position: relative; }
.choices::before { content: ''; position: absolute; inset: -12px; border-radius: 38px; pointer-events: none; opacity: 0; transition: opacity .6s; padding: 5px;
  background: radial-gradient(circle, #fff 0 2.5px, var(--yellow) 3px 4.5px, transparent 5px) 0 0 / 16px 16px;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: marquee .5s linear infinite; }
body.lv6 .choices::before { opacity: 1; }
body.lv8 .choices::before { background: radial-gradient(circle, #fff 0 2.5px, var(--pink) 3px 4.5px, transparent 5px) 0 0 / 16px 16px, radial-gradient(circle, #fff 0 2.5px, var(--yellow) 3px 4.5px, transparent 5px) 8px 8px / 16px 16px; }
@keyframes marquee { to { background-position: 16px 0, 24px 8px; } }
/* Cards bob to the beat from level 4 and glow from level 9 (`translate` keeps the card animations free). */
body.lv4 .card { translate: 0 calc(var(--kick) * -3px); }
body.lv8 .card:not(.gone) { box-shadow: 0 8px 0 var(--ink), 0 0 calc(var(--kick) * 18px) rgba(255, 210, 63, .9); }
body.lv9 .card:not(.gone) { box-shadow: 0 8px 0 var(--ink), 0 0 0 5px var(--pink), 0 0 40px 10px rgba(255, 210, 63, calc(.4 + var(--kick) * .6)); }
body.reach .card:not(.gone):not(.wrong)::after { content: ''; position: absolute; inset: -12px; border-radius: 38px; border: 5px solid var(--yellow); pointer-events: none; animation: reach-card .25s steps(2) infinite; }
@keyframes reach-card { 50% { border-color: var(--pink); box-shadow: 0 0 30px 12px rgba(255, 122, 182, .6); } }
.stamp { position: absolute; left: 50%; top: 50%; width: 118%; height: 118%; margin: -59% 0 0 -59%; pointer-events: none; z-index: 3; }
.stamp.flower { width: 135%; height: 135%; margin: -67.5% 0 0 -67.5%; }
.cutin-band { position: absolute; left: -20%; width: 140%; display: flex; align-items: center; justify-content: center; transform-origin: center; }
.cutin-band .band-bg { position: absolute; inset: 0; border-top: 4px solid var(--ink); border-bottom: 4px solid var(--ink);
  background: repeating-linear-gradient(-45deg, var(--c1) 0 22px, var(--c2) 22px 44px); }
.cutin-band .band-text { position: relative; font-family: var(--chunky); color: #fff; font-size: 44px; letter-spacing: .08em; white-space: nowrap;
  text-shadow: 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 3px 0 var(--ink), 0 -3px 0 var(--ink), 0 7px 0 var(--ink); }
.unit-slam { position: absolute; font-family: var(--chunky); color: var(--yellow); white-space: nowrap; transform-origin: center;
  text-shadow: 4px 0 0 var(--ink), -4px 0 0 var(--ink), 0 4px 0 var(--ink), 0 -4px 0 var(--ink), 3px 3px 0 var(--ink), -3px 3px 0 var(--ink), 3px -3px 0 var(--ink), -3px -3px 0 var(--ink), 0 10px 0 var(--pink); }
.finale-rocket { position: absolute; left: 0; top: 0; width: 180px; height: 120px; transform-origin: 90px 60px; filter: drop-shadow(0 6px 0 rgba(27, 29, 77, .8)); }
.finale-rocket svg { width: 100%; height: 100%; }
.finale-banner { position: absolute; left: 0; top: 0; width: 180px; padding: 8px 0; border: 4px solid var(--ink); border-radius: 12px; background: #fff; color: var(--pink); font-family: var(--chunky); font-size: 30px; text-align: center; box-shadow: 0 6px 0 var(--ink); }
