:root {
  --ink: #2b2350;
  --cream: #fff9ee;
}

* {
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Baloo 2', 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  background: #fff7e6;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(253, 186, 116, 0.35) 0, transparent 42%),
    radial-gradient(circle at 88% 12%, rgba(147, 197, 253, 0.4) 0, transparent 40%),
    radial-gradient(circle at 70% 92%, rgba(196, 181, 253, 0.35) 0, transparent 45%),
    radial-gradient(circle at 25% 88%, rgba(134, 239, 172, 0.3) 0, transparent 40%);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

/* 云朵装饰 */
.cloud {
  position: fixed;
  background: #fff;
  border-radius: 999px;
  opacity: 0.65;
  filter: blur(0.5px);
  pointer-events: none;
  z-index: 0;
}

.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: #fff;
  border-radius: 999px;
}

.cloud::before {
  width: 55%;
  height: 130%;
  top: -55%;
  left: 12%;
}

.cloud::after {
  width: 45%;
  height: 110%;
  top: -40%;
  right: 12%;
}

@keyframes floatCloud {
  0% { transform: translateX(-8vw); }
  100% { transform: translateX(108vw); }
}

.cloud-a { width: 140px; height: 46px; top: 8%; animation: floatCloud 68s linear infinite; }
.cloud-b { width: 100px; height: 34px; top: 26%; animation: floatCloud 92s linear infinite 12s; }
.cloud-c { width: 170px; height: 54px; top: 62%; animation: floatCloud 110s linear infinite 25s; opacity: 0.45; }

/* 卡片 */
.toon-card {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 26px;
  box-shadow: 6px 6px 0 rgba(43, 35, 80, 0.85);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.toon-card-hover:hover {
  transform: translate(-3px, -3px);
  box-shadow: 9px 9px 0 rgba(43, 35, 80, 0.85);
}

.toon-btn {
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 4px 4px 0 rgba(43, 35, 80, 0.9);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.15s;
  font-weight: 800;
  cursor: pointer;
}

.toon-btn:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 rgba(43, 35, 80, 0.9);
  filter: brightness(1.05);
}

.toon-btn:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 rgba(43, 35, 80, 0.9);
}

.toon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: 2px 2px 0 rgba(43, 35, 80, 0.5);
}

.nav-pill {
  position: relative;
  border: 3px solid transparent;
  transition: all 0.18s ease;
}

.nav-pill.active {
  border-color: var(--ink);
  background: #ffd93d;
  box-shadow: 4px 4px 0 rgba(43, 35, 80, 0.9);
  transform: translateY(-2px);
}

/* 开始页插画 */
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-12px) rotate(3deg); }
}

.bob { animation: bob 3.2s ease-in-out infinite; }

@keyframes wiggle {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}

.wiggle { animation: wiggle 1.6s ease-in-out infinite; }

@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.pop-in { animation: popIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

@keyframes floatUpFade {
  0% { transform: translateY(0) scale(0.9); opacity: 0; }
  20% { transform: translateY(-14px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-90px) scale(1); opacity: 0; }
}

.score-float {
  position: absolute;
  animation: floatUpFade 1s ease-out forwards;
  pointer-events: none;
  font-weight: 900;
  z-index: 40;
}

@keyframes shakeIt {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.shake-fail { animation: shakeIt 0.3s ease-in-out 2; }

/* 游戏区 */
.game-stage {
  position: relative;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: linear-gradient(180deg, #a5d8ff 0%, #d0ebff 42%, #e7f5ff 70%, #d3f9d8 100%);
  user-select: none;
}

.star-bg {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 12% 22%, #fff 50%, transparent 50%),
    radial-gradient(2px 2px at 46% 12%, #fff 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 78% 30%, #fff 50%, transparent 50%),
    radial-gradient(2px 2px at 32% 48%, #fff 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 88% 8%, #fff 50%, transparent 50%),
    radial-gradient(2px 2px at 62% 40%, #fff 50%, transparent 50%);
  opacity: 0.75;
  pointer-events: none;
}

.grass-bg {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 20% 88%, rgba(74, 222, 128, 0.55) 0 14px, transparent 15px),
    radial-gradient(circle at 48% 94%, rgba(74, 222, 128, 0.5) 0 18px, transparent 19px),
    radial-gradient(circle at 76% 86%, rgba(74, 222, 128, 0.55) 0 12px, transparent 13px),
    radial-gradient(circle at 92% 96%, rgba(74, 222, 128, 0.45) 0 16px, transparent 17px);
  pointer-events: none;
}

/* 目标（飞船/小动物） */
.target {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  will-change: transform;
  transition: filter 0.12s;
}

.target.locked {
  filter: drop-shadow(0 0 10px #ffd93d) drop-shadow(0 0 22px #f59e0b);
}

.target .key-bubble {
  border: 3px solid var(--ink);
  background: #fff;
  border-radius: 14px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 3px 3px 0 rgba(43, 35, 80, 0.9);
}

@keyframes explode {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.1); opacity: 0; }
}

.explode {
  animation: explode 0.42s ease-out forwards;
  pointer-events: none;
}

@keyframes escapeLeft {
  0% { transform: translateX(0) scale(1); opacity: 1; }
  100% { transform: translateX(-42px) scale(0.7); opacity: 0; }
}

.escape {
  animation: escapeLeft 0.55s ease-in forwards;
  pointer-events: none;
}

@keyframes lockRing {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.lock-ring {
  animation: lockRing 0.26s ease-out both;
}

/* 顶部飘落字母 rain */
@keyframes rainFall {
  0% { transform: translateY(-30px); }
  100% { transform: translateY(60vh); }
}

/* 进度条 */
.progress-shell {
  background: #ede9fe;
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 键盘提示 */
.kbd-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}

.kbd-key {
  min-width: 26px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 2px 0 rgba(43, 35, 80, 0.75);
  transition: all 0.1s;
}

.kbd-key.hit {
  background: #86efac;
  transform: translateY(2px);
  box-shadow: none;
}

.kbd-key.expected {
  background: #ffd93d;
  transform: translateY(-2px);
}

.pinyin-kbd .kbd-key.expected {
  background: #ffd93d;
  box-shadow: 0 6px 0 rgba(43, 35, 80, 0.75);
  animation: py-next 0.8s ease-in-out infinite;
}

.kbd-key.miss {
  background: #fda4af;
  transform: translateY(2px);
  box-shadow: none;
}

button.kbd-key {
  padding: 0;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

.pinyin-stage {
  background: linear-gradient(180deg, #ffe8c2 0%, #fff7ed 46%, #ffedd5 100%);
}

.canteen-bg {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 16% 84%, rgba(251, 146, 60, 0.35) 0 28px, transparent 29px),
    radial-gradient(circle at 84% 16%, rgba(253, 224, 71, 0.45) 0 22px, transparent 23px);
  pointer-events: none;
}

.py-slot {
  width: 42px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 3px 3px 0 rgba(43, 35, 80, 0.85);
}

.py-slot.current {
  background: #ffd93d;
  animation: py-next 0.8s ease-in-out infinite;
}

@keyframes py-next {
  0%, 100% { transform: translateY(-2px); }
  50% { transform: translateY(-6px); }
}

.py-slot.filled {
  background: #86efac;
}

.py-slot.shown {
  background: #fecdd3;
  color: #be123c;
}

/* 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(43, 35, 80, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 16px;
  animation: fadeIn 0.2s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalPop {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-box { animation: modalPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both; max-height: 92vh; overflow-y: auto; }

/* 彩带 */
.confetti-piece {
  position: fixed;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  z-index: 120;
  pointer-events: none;
  animation: confettiFall 1.5s linear forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(80vh) rotate(720deg); opacity: 0; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #f1f3f5; border-radius: 10px; }
::-webkit-scrollbar-thumb { background: #c4b5fd; border-radius: 10px; border: 2px solid #f1f3f5; }
::-webkit-scrollbar-thumb:hover { background: #a78bfa; }

/* 表格 */
.record-row:nth-child(even) { background: #faf5ff; }

/* 星星锁 */
.badge-locked { filter: grayscale(1) opacity(0.55); }

/* 手型提示 */
.tap-tip {
  animation: tapPulse 1.4s ease-in-out infinite;
}

@keyframes tapPulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.12); opacity: 1; }
}

/* 页面切换淡入 */
.view-enter { animation: viewIn 0.3s ease both; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 数字跳动 */
@keyframes numBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); color: #f59e0b; }
  100% { transform: scale(1); }
}

.num-bump { animation: numBump 0.4s ease; }

@media (max-width: 640px) {
  .toon-card { border-radius: 20px; box-shadow: 4px 4px 0 rgba(43, 35, 80, 0.85); }
  .kbd-key { min-width: 20px; height: 24px; font-size: 9px; border-radius: 5px; }
}
