:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --ink: #563b2d;
  --cream: #fffaf0;
  --yellow: #ffd765;
  --cyan: #54d7dc;
  --pink: #ff7e9e;
  --green: #66b76e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, rgba(255,255,255,.9), transparent 25%),
    linear-gradient(150deg, #bcecff 0%, #e9f9d4 48%, #fff0b8 100%);
  color: var(--ink);
  overflow-x: hidden;
}

button { font: inherit; }

.game-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.game-card {
  width: min(100%, 520px);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 26px;
  background: rgba(255,250,240,.9);
  box-shadow: 0 24px 65px rgba(59,108,119,.25), inset 0 1px 0 #fff;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 13px;
  background: linear-gradient(90deg, rgba(255,255,255,.98), rgba(255,248,218,.95));
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-badge {
  padding: 5px 8px;
  border-radius: 999px;
  background: #fff0b5;
  color: #9a623d;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 2px;
  color: #c57545;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
}

h1 {
  margin: 0;
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.15;
}

.counter {
  flex: 0 0 auto;
  min-width: 76px;
  padding: 8px 12px;
  border: 2px solid rgba(93,190,184,.45);
  border-radius: 999px;
  background: white;
  color: #288f94;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 5px 0 rgba(84,175,172,.17);
}

.counter-divider { margin: 0 5px; color: #a7c6bc; }

.scene {
  position: relative;
  width: 100%;
  isolation: isolate;
  background: #a8e9ff;
  overflow: hidden;
  touch-action: manipulation;
}

.scene > img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-select: none;
}

.sun-glow {
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255,255,255,.13), transparent 35%);
  mix-blend-mode: screen;
}

.hotspots { position: absolute; z-index: 3; inset: 0; }

.hotspot {
  position: absolute;
  translate: -50% -50%;
  width: var(--w);
  aspect-ratio: var(--ratio, 1);
  padding: 0;
  border: 0;
  border-radius: 48%;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hotspot::before,
.hotspot::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
}

.hotspot::before {
  border: 3px solid #fff;
  filter: drop-shadow(0 2px 2px rgba(84,58,33,.7));
}

.hotspot::after {
  inset: -10px;
  border: 3px dashed var(--yellow);
}

.hotspot.found { cursor: default; }
.hotspot.found::before { opacity: 1; animation: ring-pop .5s cubic-bezier(.2,1.7,.5,1); }
.hotspot.found::after { opacity: 1; animation: orbit 9s linear infinite; }

.hotspot.hint-pulse {
  animation: hint-pulse 2s ease-in-out;
}

.found-spark {
  position: absolute;
  z-index: 4;
  translate: -50% -50%;
  color: #fff6a5;
  font-size: 28px;
  text-shadow: 0 2px 5px #c26b35;
  pointer-events: none;
  animation: sparkle-up 1s ease-out forwards;
}

.tap-ripple {
  position: absolute;
  z-index: 2;
  width: 20px;
  height: 20px;
  translate: -50% -50%;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 50%;
  pointer-events: none;
  animation: tap-ripple .55s ease-out forwards;
}

.tip {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 2.2%;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 999px;
  background: rgba(76,54,38,.74);
  color: white;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(7px);
  transition: .35s ease;
}

.tip.hidden { opacity: 0; translate: -50% 10px; pointer-events: none; }
.tip-icon { color: #ffe983; animation: twinkle 1.5s ease-in-out infinite; }

.switch-toast {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 4%;
  translate: -50% -12px;
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 999px;
  background: rgba(40,74,81,.83);
  color: white;
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(8px);
  transition: .25s ease;
}

.switch-toast.visible { opacity: 1; translate: -50% 0; }

.progress-wrap {
  position: relative;
  padding: 14px 18px 16px;
  text-align: center;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9dec7;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan), #7c9cf7);
  transition: width .4s cubic-bezier(.2,.8,.2,1);
}

#status-text { margin: 8px 0 0; font-size: 13px; font-weight: 700; }

.keyboard-hint {
  margin: 5px 0 0;
  color: #9b7d67;
  font-size: 10px;
}

kbd {
  display: inline-block;
  min-width: 25px;
  padding: 1px 5px;
  border: 1px solid #d4c2a7;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: white;
  color: #725541;
  font-family: inherit;
  font-size: 9px;
  font-weight: 900;
}

.footer-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.hint-button {
  padding: 8px 14px;
  border: 1px solid rgba(66,163,164,.35);
  border-radius: 999px;
  background: linear-gradient(135deg, #eafff7, #e4f7ff);
  color: #368c8f;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(77,153,155,.12);
  cursor: pointer;
}

.hint-button:disabled { opacity: .45; cursor: default; }

.reset-button {
  border: 0;
  background: none;
  color: #a26f54;
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.celebration[hidden] { display: none; }

.celebration {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: rgba(24,52,72,.45);
  backdrop-filter: blur(10px);
  animation: veil-in .5s ease-out;
}

.celebration-card {
  position: relative;
  width: min(100%, 430px);
  padding: 48px 28px 30px;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,.92);
  border-radius: 35px;
  background:
    radial-gradient(circle at 50% -10%, #fff 0 18%, transparent 38%),
    linear-gradient(155deg, #fffce9 0%, #fff1a9 34%, #ffcaac 64%, #f5b9e4 100%);
  text-align: center;
  box-shadow: 0 30px 100px rgba(48,43,87,.4), inset 0 0 30px rgba(255,255,255,.7);
  animation: card-in .7s cubic-bezier(.15,1.35,.35,1);
}

.celebration-card::before,
.celebration-card::after {
  content: "✦  ·  ✧  ·  ✦";
  position: absolute;
  color: rgba(255,255,255,.75);
  font-size: 22px;
  letter-spacing: .35em;
}
.celebration-card::before { top: 13px; left: 24px; }
.celebration-card::after { right: 15px; bottom: 12px; rotate: 180deg; }

.celebration-kicker {
  margin: 0 0 8px;
  color: #b06663;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .18em;
}

.celebration h2 {
  position: relative;
  z-index: 2;
  margin: 0;
  color: #7b455b;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(38px, 11vw, 58px);
  line-height: 1.05;
  text-shadow: 0 3px 0 rgba(255,255,255,.8);
}

.celebration h2 em { color: #ee647b; font-style: normal; font-size: 1.12em; }
.celebration-copy { position: relative; z-index: 2; margin: 18px 0 14px; font-size: 14px; line-height: 1.8; }
.bottle-row { display: flex; justify-content: center; gap: 18px; margin: 8px 0 20px; color: #4b9aa3; font-size: 26px; }

#play-again {
  position: relative;
  z-index: 3;
  padding: 12px 28px;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 999px;
  background: linear-gradient(135deg, #ff718e, #ed7dbb);
  color: white;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(180,76,113,.25);
  cursor: pointer;
}

.magic-orbit {
  position: absolute;
  left: 50%;
  top: 48%;
  translate: -50% -50%;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 50%;
  pointer-events: none;
}
.orbit-one { width: 360px; height: 120px; rotate: 14deg; animation: orbit-wide 13s linear infinite; }
.orbit-two { width: 330px; height: 110px; rotate: -18deg; animation: orbit-wide 9s linear infinite reverse; }
.celebration-star { position: absolute; top: 28px; right: 35px; color: white; font-size: 42px; animation: twinkle 1.2s ease-in-out infinite; }

.confetti-piece {
  position: absolute;
  top: -12vh;
  width: 9px;
  height: 18px;
  border-radius: 3px;
  animation: confetti-fall var(--duration) linear var(--delay) infinite;
}

@keyframes ring-pop { from { scale: .4; opacity: 0; } 70% { scale: 1.15; } to { scale: 1; opacity: 1; } }
@keyframes orbit { to { rotate: 360deg; } }
@keyframes sparkle-up { 0% { scale: .3; opacity: 0; } 35% { scale: 1.25; opacity: 1; } 100% { translate: -50% -130%; opacity: 0; } }
@keyframes tap-ripple { to { scale: 4; opacity: 0; } }
@keyframes hint-pulse {
  0%, 38%, 100% { background: transparent; box-shadow: 0 0 0 0 rgba(255,241,126,0); }
  18%, 58% { background: rgba(255,248,168,.24); box-shadow: 0 0 20px 10px rgba(255,235,92,.82); }
  28%, 72% { background: rgba(255,255,215,.1); box-shadow: 0 0 8px 4px rgba(255,248,175,.34); }
}
@keyframes twinkle { 50% { scale: .72; opacity: .55; } }
@keyframes veil-in { from { opacity: 0; } }
@keyframes card-in { from { opacity: 0; scale: .72; translate: 0 50px; } }
@keyframes orbit-wide { to { rotate: 360deg; } }
@keyframes confetti-fall { to { translate: var(--drift) 120vh; rotate: 720deg; } }

@media (max-width: 540px) {
  .game-shell { padding: 0; display: block; }
  .game-card { width: 100%; border: 0; border-radius: 0; box-shadow: none; }
  .hud { padding-top: max(11px, env(safe-area-inset-top)); }
  .progress-wrap { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .level-badge { display: none; }
}

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