:root {
  color-scheme: light;
  font-family: "Arial Rounded MT Bold", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #241649;
  color: #2b1b51;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; overscroll-behavior: none; }
body {
  min-height: 100svh; display: grid; place-items: start center;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,111,145,.3), transparent 24%),
    radial-gradient(circle at 84% 76%, rgba(76,221,191,.22), transparent 28%),
    #241649;
}
button { font: inherit; touch-action: manipulation; }

#game-app {
  width: min(100vw, 540px); min-height: 100svh; position: relative; overflow: hidden;
  background: #f9f4ff; box-shadow: 0 0 55px rgba(11,7,31,.45);
}
.screen { display: none; min-height: 100svh; }
.screen.is-active { display: block; }

/* Original home */
.menu-screen {
  min-height: 100svh; padding: max(34px, env(safe-area-inset-top)) 26px max(24px, env(safe-area-inset-bottom));
  position: relative; overflow: hidden; text-align: center;
  background:
    radial-gradient(circle at 13% 18%, #ff779d 0 8px, transparent 9px),
    radial-gradient(circle at 86% 35%, #ffd258 0 6px, transparent 7px),
    radial-gradient(circle at 20% 75%, #6be1c3 0 7px, transparent 8px),
    linear-gradient(155deg, #fbf7ff 0 51%, #eee8ff 51%);
}
.menu-orbit { position: absolute; border: 2px dashed rgba(69,42,125,.13); border-radius: 50%; pointer-events: none; }
.orbit-one { width: 320px; height: 320px; right: -180px; top: -100px; }
.orbit-two { width: 250px; height: 250px; left: -160px; bottom: 65px; }
.menu-badge {
  width: max-content; margin: 0 auto 14px; padding: 6px 12px; border: 2px solid #432c76; border-radius: 16px;
  color: #432c76; background: #fff; box-shadow: 3px 3px 0 #ffd258; font-size: 11px; font-weight: 900; letter-spacing: 1px;
}
.brand-mark,
.result-character { width: 78px; height: 54px; position: relative; display: flex; justify-content: center; gap: 4px; transform: rotate(-3deg); }
.brand-mark { margin: 0 auto 5px; }
.brand-mark i,
.result-character i { width: 35px; height: 35px; border: 5px solid #291950; border-radius: 50%; background: #fff; }
.brand-mark i::after,
.result-character i::after { content: ""; width: 12px; height: 12px; margin: 7px auto; display: block; border-radius: 50%; background: #291950; }
.brand-mark b,
.result-character b { position: absolute; right: -5px; top: -8px; color: #ff5f8b; font-size: 25px; }
.menu-screen h1 { margin: 0; color: #2b1b51; font-size: clamp(43px, 12vw, 64px); line-height: 1; letter-spacing: -3px; }
.menu-screen h1 span { color: #ff5f8b; }
.menu-screen > p { margin: 9px 0 22px; color: #695b83; font-size: 15px; font-weight: 700; }
.stage-stack { height: 292px; margin: 0 auto 19px; position: relative; perspective: 700px; }
.stage-stack article {
  width: 54%; max-width: 255px; height: 275px; overflow: hidden; position: absolute; left: 50%; top: 0;
  border: 5px solid #2b1b51; border-radius: 23px; background: white; box-shadow: 0 13px 0 rgba(43,27,81,.14);
}
.stage-stack article:nth-child(1) { z-index: 3; transform: translateX(-50%) rotate(-2deg); }
.stage-stack article:nth-child(2) { z-index: 2; transform: translateX(-91%) rotate(-11deg) scale(.88); }
.stage-stack article:nth-child(3) { z-index: 1; transform: translateX(-9%) rotate(10deg) scale(.88); }
.stage-stack img { width: 100%; height: 218px; display: block; object-fit: cover; }
.stage-stack b {
  position: absolute; left: 9px; top: 9px; width: 35px; height: 35px; display: grid; place-items: center;
  border-radius: 50%; color: #2b1b51; background: #ffd258; box-shadow: 2px 3px 0 #2b1b51; font-size: 12px;
}
.stage-stack span { height: 48px; display: grid; place-items: center; color: #2b1b51; font-size: 15px; font-weight: 900; }
.menu-start {
  width: min(100%, 330px); height: 58px; border: 4px solid #2b1b51; border-radius: 29px;
  color: #2b1b51; background: #63dfc1; box-shadow: 0 7px 0 #2b1b51; cursor: pointer; font-size: 20px; font-weight: 900;
}
.menu-start span { margin-left: 12px; font-size: 24px; }
.menu-start:active { transform: translateY(5px); box-shadow: 0 2px 0 #2b1b51; }
.menu-start:focus-visible { outline: 5px solid #ff5f8b; outline-offset: 4px; }
.menu-meta { margin-top: 20px; display: flex; align-items: center; justify-content: center; gap: 8px; color: #75688c; font-size: 10px; }
.menu-meta i { width: 4px; height: 4px; border-radius: 50%; background: #ff5f8b; }
.menu-meta b { color: #ff5f8b; }

/* Play surface */
.play-screen {
  --accent: #ff5f8b; --accent-soft: #ffe6ee; --surface: #f6fff9; --deep: #2b1b51; --good: #47d6b3;
  position: relative; min-height: 100svh; background: var(--surface);
}
.play-screen.theme-camp { --accent: #ffb62e; --accent-soft: #fff0cf; --surface: #fff8ee; --good: #ff7f69; }
.play-screen.theme-space { --accent: #9ce659; --accent-soft: #eaffd7; --surface: #f5f0ff; --good: #6d5ce8; }
.play-header {
  min-height: 190px; padding: max(17px, env(safe-area-inset-top)) 15px 14px; position: relative;
  border-bottom: 5px solid var(--deep);
  background:
    radial-gradient(circle at 8% 73%, var(--accent) 0 4px, transparent 5px),
    radial-gradient(circle at 91% 60%, var(--good) 0 5px, transparent 6px),
    var(--surface);
}
.back-button {
  position: absolute; left: 13px; top: max(18px, env(safe-area-inset-top)); z-index: 2;
  width: 46px; height: 46px; border: 4px solid var(--deep); border-radius: 15px;
  transform: rotate(180deg); color: white; background: var(--accent); box-shadow: 0 4px 0 var(--deep); font-size: 25px; cursor: pointer;
}
.timer {
  width: 144px; height: 48px; margin: 0 auto 13px; border: 4px solid var(--deep); border-radius: 24px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  color: var(--deep); background: #fff; box-shadow: 0 4px 0 var(--deep); font-size: 21px; transition: .2s;
}
.clock-face { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--deep); background: var(--accent-soft); font-size: 24px; }
.timer.is-warning { color: #a66000; background: #fff5b5; transform: scale(1.03); }
.timer.is-danger { color: #d82545; background: #ffe0e5; animation: timer-pulse .55s infinite alternate; }
.score-box {
  position: absolute; right: 13px; top: max(18px, env(safe-area-inset-top)); min-width: 76px; height: 46px;
  padding: 6px 10px; border: 3px solid var(--deep); border-radius: 14px; display: flex; flex-direction: column; justify-content: center;
  color: var(--deep); background: var(--accent-soft); text-align: center; box-shadow: 0 4px 0 var(--deep);
}
.score-box small { font-size: 9px; line-height: 1; }
.score-box b { font-size: 17px; line-height: 1.2; }
.target-row { display: flex; align-items: center; justify-content: center; gap: 18px; }
.mission-label { min-width: 84px; display: flex; flex-direction: column; text-align: left; }
.mission-label small { color: #817598; font-size: 10px; }
.mission-label strong { color: var(--deep); font-size: 24px; line-height: 1.15; }
[data-slots] { display: flex; gap: 7px; }
.target-slot {
  width: 48px; height: 48px; border: 3px solid var(--deep); border-radius: 15px; display: grid; place-items: center;
  color: var(--deep); background: #fff; box-shadow: 0 4px 0 var(--deep); font-size: 26px; font-weight: 900; line-height: 1;
}
.target-slot.is-filled { color: var(--deep); background: var(--good); animation: slot-pop .35s ease; }

.board { position: relative; line-height: 0; overflow: hidden; border-bottom: 5px solid var(--deep); background: var(--deep); cursor: crosshair; }
.board > img { width: 100%; height: auto; aspect-ratio: 2 / 3; display: block; object-fit: cover; user-select: none; pointer-events: none; }
.hotspot {
  position: absolute; left: var(--x); top: var(--y); width: var(--w); height: var(--h); transform: translate(-50%, -50%);
  border: 0; border-radius: 48%; background: transparent; cursor: crosshair;
}
.hotspot:focus-visible { outline: 5px dashed #fff; outline-offset: 3px; }
.hotspot.is-hint::after {
  content: ""; position: absolute; inset: -8px; border: 6px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 6px var(--accent), 0 0 28px #fff; animation: hint-ring .5s infinite alternate;
}
.hotspot.is-found { pointer-events: none; animation: found-pop .4s ease both; }
.hotspot.is-found::after {
  content: "✓"; position: absolute; inset: 14%; display: grid; place-items: center; border: 5px solid #fff; border-radius: 50%;
  color: #fff; background: color-mix(in srgb, var(--good) 86%, #18224a); box-shadow: 0 4px 0 var(--deep), 0 0 0 6px rgba(255,255,255,.35);
  font-size: clamp(20px, 6vw, 36px); line-height: 1;
}
.miss-mark {
  position: absolute; width: 42px; height: 42px; transform: translate(-50%, -50%); display: grid; place-items: center;
  color: #ff335b; -webkit-text-stroke: 3px white; paint-order: stroke; font-size: 42px; font-weight: 900;
  line-height: 1; pointer-events: none; animation: miss .55s ease forwards;
}
.score-fly {
  position: absolute; z-index: 5; transform: translate(-50%, -50%); color: #fff;
  -webkit-text-stroke: 4px var(--deep); paint-order: stroke; font-size: 24px; font-weight: 900; line-height: 1;
  pointer-events: none; animation: score-fly .8s ease forwards;
}

.power-bar {
  min-height: 126px; padding: 12px 12px max(15px, env(safe-area-inset-bottom)); display: grid;
  grid-template-columns: 1fr 1.1fr 1fr; align-items: center; gap: 8px; background: var(--surface);
}
.power-bar > button {
  min-width: 0; height: 76px; padding: 6px; border: 3px solid var(--deep); border-radius: 18px; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--deep); background: #fff;
  box-shadow: 0 4px 0 var(--deep); cursor: pointer;
}
.power-bar > button > i { color: var(--accent); font-size: 24px; font-style: normal; font-weight: 900; }
.power-bar > button > b { margin-top: 2px; font-size: 11px; }
.power-bar > button > small {
  position: absolute; right: -5px; top: -7px; min-width: 26px; padding: 3px 5px; border: 2px solid var(--deep); border-radius: 10px;
  color: #fff; background: var(--accent); font-size: 9px;
}
.power-bar > button.is-used { filter: grayscale(.8); opacity: .48; box-shadow: none; transform: translateY(4px); }
.combo-meter { display: flex; flex-direction: column; align-items: center; color: var(--deep); text-align: center; }
.combo-meter small { color: #827594; font-size: 9px; }
.combo-meter b { font-size: 25px; line-height: 1.15; }
.combo-meter > span { width: 90%; height: 8px; overflow: hidden; border: 2px solid var(--deep); border-radius: 6px; background: #fff; }
.combo-meter > span i { width: var(--combo-progress, 0%); height: 100%; display: block; background: linear-gradient(90deg, var(--good), var(--accent)); transition: width .25s; }

.intro-card {
  position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px;
  background: rgba(36,22,73,.86); cursor: pointer; backdrop-filter: blur(4px);
}
.paper-card {
  width: min(100%, 390px); padding: 32px 28px 28px; border: 5px solid var(--deep); border-radius: 30px;
  color: var(--deep); background: #fff; box-shadow: 0 12px 0 rgba(0,0,0,.25); text-align: center; transform: rotate(-1deg);
}
.paper-card small { padding: 7px 16px; border-radius: 14px; color: var(--deep); background: var(--accent-soft); font-size: 13px; font-weight: 900; }
.paper-card h1 { margin: 18px 0 7px; color: var(--accent); font-size: 38px; }
.paper-card p { margin: 0 0 27px; color: var(--deep); font-size: 20px; font-weight: 900; }
.paper-card > b { display: block; padding: 13px; border: 3px solid var(--deep); border-radius: 18px; background: var(--good); font-size: 13px; }
.category-splash {
  position: absolute; inset: 190px 0 126px; z-index: 8; display: grid; place-items: center; pointer-events: none;
  background: rgba(43,27,81,.12); backdrop-filter: blur(2px);
}
.category-splash > div {
  min-width: 230px; padding: 22px 30px; border: 5px solid var(--deep); border-radius: 25px;
  color: var(--deep); background: #fff; box-shadow: 0 8px 0 var(--deep); text-align: center; font-size: 24px; font-weight: 900;
}
.category-splash small { display: block; margin-bottom: 7px; color: #877b98; font-size: 11px; }
.category-splash span { color: var(--accent); }
.combo-pop {
  position: absolute; left: 50%; top: 235px; z-index: 9; transform: translateX(-50%) rotate(-4deg); padding: 9px 18px;
  border: 4px solid var(--deep); border-radius: 18px; color: var(--deep); background: #ffd258; box-shadow: 0 5px 0 var(--deep);
  font-size: 18px; font-weight: 900; animation: combo-bounce .55s ease;
}

.result-layer {
  position: absolute; inset: 0; z-index: 20; padding: 16vh 24px 32px; display: flex; flex-direction: column; align-items: center;
  color: var(--deep); background: rgba(36,22,73,.88); text-align: center; backdrop-filter: blur(4px);
}
.result-character { margin-bottom: -18px; z-index: 3; filter: drop-shadow(0 4px 0 #fff); transform: scale(1.25) rotate(-3deg); }
.result-sign {
  z-index: 2; min-width: 250px; padding: 13px 24px; border: 5px solid var(--deep); border-radius: 20px;
  color: var(--deep); background: var(--accent); box-shadow: 0 7px 0 var(--deep); font-size: 29px; font-weight: 900;
}
.result-panel {
  width: min(100%, 400px); margin-top: 16px; padding: 24px 26px; border: 5px solid var(--deep); border-radius: 28px;
  color: var(--deep); background: #fff; box-shadow: 0 9px 0 rgba(0,0,0,.23);
}
.result-panel p { margin: 0 0 10px; font-size: 17px; font-weight: 900; }
.star-row { margin: 4px 0 17px; color: #ffd258; -webkit-text-stroke: 2px var(--deep); paint-order: stroke; font-size: 36px; letter-spacing: 7px; }
.result-primary,
.result-secondary { width: 100%; height: 52px; border: 4px solid var(--deep); border-radius: 18px; color: var(--deep); font-size: 18px; font-weight: 900; cursor: pointer; }
.result-primary { background: var(--good); box-shadow: 0 5px 0 var(--deep); }
.result-secondary { margin-top: 12px; background: var(--accent-soft); }
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 30; transform: translateX(-50%);
  max-width: min(86vw, 410px); padding: 11px 18px; border: 3px solid white; border-radius: 21px;
  color: #fff; background: rgba(43,27,81,.94); box-shadow: 0 5px 18px rgba(0,0,0,.28); white-space: nowrap; font-size: 13px;
}

@keyframes found-pop { 0% { transform: translate(-50%,-50%) scale(.65); } 65% { transform: translate(-50%,-50%) scale(1.18); } 100% { transform: translate(-50%,-50%) scale(1); } }
@keyframes slot-pop { 50% { transform: scale(1.2) rotate(-5deg); } }
@keyframes hint-ring { from { transform: scale(.84); } to { transform: scale(1.08); } }
@keyframes timer-pulse { to { transform: scale(1.06); } }
@keyframes miss { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.4); } 55% { opacity: 1; transform: translate(-50%,-50%) scale(1.25); } 100% { opacity: 0; transform: translate(-50%,-50%) scale(1); } }
@keyframes score-fly { from { opacity: 0; transform: translate(-50%,-20%) scale(.7); } 35% { opacity: 1; } to { opacity: 0; transform: translate(-50%,-130%) scale(1.15); } }
@keyframes combo-bounce { 50% { transform: translateX(-50%) rotate(3deg) scale(1.18); } }

@media (max-width: 430px) {
  .menu-screen { padding-left: 18px; padding-right: 18px; }
  .stage-stack { height: 260px; }
  .stage-stack article { height: 245px; }
  .stage-stack img { height: 192px; }
  .play-header { min-height: 174px; padding-left: 10px; padding-right: 10px; }
  .timer { width: 128px; height: 44px; font-size: 19px; }
  .back-button { left: 9px; width: 42px; height: 42px; }
  .score-box { right: 9px; min-width: 67px; height: 42px; }
  .target-row { gap: 10px; }
  .mission-label { min-width: 68px; }
  .mission-label strong { font-size: 20px; }
  .target-slot { width: 42px; height: 42px; border-radius: 13px; font-size: 22px; }
  .power-bar { min-height: 112px; }
  .category-splash { inset: 174px 0 112px; }
  .combo-pop { top: 207px; }
}

@media (max-height: 760px) and (max-width: 430px) {
  .menu-screen { padding-top: 17px; }
  .menu-badge { margin-bottom: 7px; }
  .brand-mark { transform: scale(.8) rotate(-3deg); margin-bottom: -3px; }
  .menu-screen h1 { font-size: 42px; }
  .menu-screen > p { margin-bottom: 10px; }
  .stage-stack { height: 225px; margin-bottom: 10px; }
  .stage-stack article { height: 215px; }
  .stage-stack img { height: 166px; }
  .menu-meta { margin-top: 13px; }
}

@media (min-width: 700px) {
  body { padding: 24px 0; }
  #game-app { min-height: 0; border: 7px solid rgba(255,255,255,.72); border-radius: 30px; }
  .screen { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
