* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

:root {
  --bg1: #fff6e9;
  --bg2: #ffe8d6;
  --ink: #4a3b32;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Comic Sans MS", sans-serif;
  color: var(--ink);
}

body {
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
}

#app {
  height: 100%;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ===== 顶部栏 ===== */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  flex: 0 0 auto;
}

#page-title {
  font-size: 22px;
  font-weight: 800;
}

.icon-btn {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
  font-size: 26px;
  cursor: pointer;
  transition: transform 0.1s;
}
.icon-btn:active { transform: scale(0.9); }

/* ===== 通用视图 ===== */
.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px 20px;
  overflow: hidden;
  animation: viewIn 0.3s ease;
}

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

/* ===== 首页 ===== */
.home-hero {
  text-align: center;
  margin-top: 2vh;
}

.home-cat {
  width: min(42vw, 220px);
  margin: 0 auto;
  animation: bob 2.4s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.app-title {
  font-size: clamp(34px, 8vw, 48px);
  font-weight: 900;
  color: #e2725b;
  text-shadow: 2px 3px 0 #ffd9c9;
  letter-spacing: 4px;
}

.app-subtitle {
  font-size: clamp(16px, 4vw, 20px);
  color: #a0785a;
  margin-top: 4px;
}

.menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  max-width: 440px;
  margin-top: 3vh;
}

.menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 8px;
  border: none;
  border-radius: 24px;
  background: linear-gradient(160deg, var(--c1), var(--c2));
  box-shadow: 0 6px 0 rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.12s;
}
.menu-btn:active { transform: scale(0.94); }

.menu-emoji { font-size: 44px; }
.menu-label {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 2px rgba(0,0,0,0.18);
}

.home-stars {
  margin-top: 3vh;
  font-size: 26px;
  font-weight: 800;
  color: #f0a500;
}

/* ===== 认识猫咪 ===== */
.gallery-stage {
  width: min(64vw, 320px);
  flex: 0 0 auto;
  margin-top: 1vh;
  cursor: pointer;
  animation: bob 3s ease-in-out infinite;
}

.gallery-name {
  font-size: clamp(30px, 7vw, 40px);
  font-weight: 900;
  color: #e2725b;
  margin-top: 8px;
}

.gallery-fact {
  font-size: clamp(18px, 4.4vw, 22px);
  color: #8a6d55;
  margin-top: 6px;
  min-height: 30px;
  text-align: center;
}

.gallery-controls {
  display: flex;
  gap: 22px;
  margin-top: 2vh;
  align-items: center;
}

.round-btn {
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 5px 0 rgba(0,0,0,0.12);
  font-size: 28px;
  cursor: pointer;
  transition: transform 0.1s;
}
.round-btn.big {
  width: 84px;
  height: 84px;
  font-size: 40px;
  background: #ffd93d;
}
.round-btn:active { transform: scale(0.9); }

.gallery-dots {
  margin-top: 2vh;
  font-size: 18px;
  font-weight: 800;
  color: #b79a7d;
  background: rgba(255,255,255,0.7);
  border-radius: 999px;
  padding: 4px 18px;
}

/* ===== 游戏通用 ===== */
.prompt-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 480px;
  margin-top: 4px;
}

.prompt-text {
  flex: 1;
  font-size: clamp(20px, 5vw, 26px);
  font-weight: 800;
  color: #5b4636;
  background: #fff;
  border-radius: 18px;
  padding: 10px 16px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.08);
  text-align: center;
}

.game-footer {
  margin-top: auto;
  padding-top: 10px;
}

.stars-label {
  font-size: 24px;
  font-weight: 800;
  color: #f0a500;
}

/* ===== 找一找 ===== */
.find-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  max-width: 460px;
  margin-top: 2vh;
}

.find-card {
  background: #fff;
  border: 4px solid transparent;
  border-radius: 22px;
  padding: 10px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,0.1);
  transition: transform 0.12s;
  animation: viewIn 0.3s ease;
}
.find-card:active { transform: scale(0.95); }
.find-card.correct {
  border-color: #6bcb77;
  animation: happyJump 0.6s ease;
}
.find-card.wrong {
  animation: shake 0.45s ease;
  border-color: #ffb3b3;
}

@keyframes happyJump {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.12) rotate(-3deg); }
  70% { transform: scale(1.06) rotate(3deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* ===== 数猫咪 ===== */
.count-field {
  position: relative;
  width: 100%;
  max-width: 480px;
  flex: 1;
  min-height: 180px;
  background: rgba(255,255,255,0.55);
  border-radius: 24px;
  margin-top: 2vh;
  overflow: hidden;
}

.count-cat {
  position: absolute;
  animation: popIn 0.4s ease backwards;
  cursor: pointer;
}

@keyframes popIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.count-options {
  display: flex;
  gap: 12px;
  margin-top: 2vh;
  flex-wrap: wrap;
  justify-content: center;
}

.num-btn {
  width: 68px;
  height: 68px;
  border: none;
  border-radius: 20px;
  background: linear-gradient(160deg, #4d96ff, #3a76d1);
  box-shadow: 0 5px 0 rgba(0,0,0,0.18);
  color: #fff;
  font-size: 34px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.1s;
}
.num-btn:active { transform: scale(0.9); }
.num-btn.wrong { animation: shake 0.45s ease; }
.num-btn.correct { background: linear-gradient(160deg, #6bcb77, #4dae5c); }

/* ===== 翻翻乐 ===== */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 440px;
  margin-top: 2vh;
}

.mem-card {
  aspect-ratio: 3 / 4;
  perspective: 600px;
  cursor: pointer;
}

.mem-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.4s;
}

.mem-card.flipped .mem-inner,
.mem-card.matched .mem-inner {
  transform: rotateY(180deg);
}

.mem-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
}

.mem-back {
  background: linear-gradient(160deg, #ff9a8b, #ff6b9d);
  font-size: 38px;
}

.mem-front {
  background: #fff;
  transform: rotateY(180deg);
  padding: 8px;
}

.mem-card.matched {
  animation: happyJump 0.6s ease;
  pointer-events: none;
}
.mem-card.matched .mem-front {
  box-shadow: 0 0 0 4px #6bcb77, 0 4px 0 rgba(0,0,0,0.12);
}

/* ===== 奖励 ===== */
.celebration {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 50;
}

.celebration-emoji {
  font-size: 110px;
  animation: celebratePop 0.9s ease;
}

.celebration-text {
  font-size: 44px;
  font-weight: 900;
  color: #e2725b;
  text-shadow: 2px 3px 0 #fff;
  animation: celebratePop 0.9s ease;
}

@keyframes celebratePop {
  0% { transform: scale(0); opacity: 0; }
  40% { transform: scale(1.25); opacity: 1; }
  70% { transform: scale(1); }
  100% { transform: scale(1); opacity: 1; }
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 49;
}

/* 猫咪 svg 通用 */
.cat-svg { width: 100%; height: auto; display: block; }

/* 猫咪真实照片通用 */
.cat-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  display: block;
  border-radius: inherit;
  user-select: none;
  -webkit-user-drag: none;
}

/* 首页：圆形头像 */
.home-cat .cat-photo {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  box-shadow: 0 8px 0 rgba(0,0,0,0.1);
}

/* 认识猫咪：大照片 */
.gallery-stage .cat-photo {
  aspect-ratio: 4 / 3.4;
  border-radius: 28px;
  box-shadow: 0 8px 0 rgba(0,0,0,0.12);
  background: #fff;
  object-fit: contain;
  object-position: center;
  padding: 10px;
}

/* 找一找卡片 */
.find-card .cat-photo {
  aspect-ratio: 1 / 1;
  border-radius: 14px;
}

/* 数猫咪：场地里的小猫 */
.count-cat .cat-photo {
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  box-shadow: 0 5px 0 rgba(0,0,0,0.12);
}

/* 翻翻乐卡片 */
.mem-front .cat-photo {
  border-radius: 10px;
}

@media (max-height: 620px) {
  .home-cat { width: min(30vw, 150px); }
  .gallery-stage { width: min(46vw, 220px); }
  .menu { gap: 10px; }
  .menu-btn { padding: 10px 6px; }
  .menu-emoji { font-size: 34px; }
  .menu-label { font-size: 18px; }
}
