/* ============================================================
   嘌呤分拣大挑战 - 主样式表
   设计风格：明亮、卡通、亲切的健康科普风
   ============================================================ */

/* ===== 基础重置 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: #f5f9f5;
  color: #2e7d32;
  font-size: 16px;
}

/* ===== 游戏容器 ===== */
#game-container {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: 500px;
  margin: 0 auto;
  background: linear-gradient(180deg, #e8f5e9 0%, #f5f9f5 30%, #f5f9f5 100%);
  overflow: hidden;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.05);
}

/* ===== 屏幕切换 ===== */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* ================================================================
   开始页
   ================================================================ */
#start-screen {
  align-items: center;
  justify-content: flex-start;
  padding-top: 40px;
  overflow-y: auto;
}

.start-content {
  width: 100%;
  padding: 0 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.game-logo {
  display: flex;
  gap: 8px;
  font-size: 48px;
  animation: bounce-slow 2s ease-in-out infinite;
}

.logo-emoji {
  display: inline-block;
}

.logo-emoji:nth-child(2) {
  animation-delay: 0.2s;
}

.logo-emoji:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce-slow {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.game-title {
  font-size: 32px;
  font-weight: 800;
  color: #2e7d32;
  text-align: center;
  letter-spacing: 2px;
  text-shadow: 0 2px 4px rgba(76, 175, 80, 0.2);
}

.game-subtitle {
  font-size: 14px;
  color: #666;
  margin-top: -12px;
}

.start-desc-card {
  background: #fff;
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  width: 100%;
  text-align: center;
}

.start-desc {
  font-size: 16px;
  color: #333;
  font-weight: 500;
  line-height: 1.6;
}

.rules-box {
  background: #fff;
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  width: 100%;
}

.rules-title {
  font-size: 16px;
  color: #2e7d32;
  margin-bottom: 12px;
  font-weight: 700;
}

.rules-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rules-list li {
  font-size: 14px;
  color: #555;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rule-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.basket-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  width: 100%;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #555;
  font-weight: 500;
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.legend-dot.high {
  background: #f44336;
}

.legend-dot.mid {
  background: #ff9800;
}

.legend-dot.low {
  background: #4caf50;
}

/* ===== 主按钮 ===== */
.btn-primary {
  background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
  color: #fff;
  border: none;
  border-radius: 28px;
  padding: 14px 48px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 3px 10px rgba(76, 175, 80, 0.3);
}

.start-btn {
  margin-top: 8px;
  width: 100%;
  padding: 16px;
  font-size: 20px;
}

/* ================================================================
   游戏页
   ================================================================ */
#game-screen {
  display: none;
  flex-direction: column;
}

#game-screen.active {
  display: flex;
}

/* ---- HUD 顶部栏 ---- */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(76, 175, 80, 0.1);
  z-index: 10;
  flex-shrink: 0;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 60px;
}

.hud-label {
  font-size: 11px;
  color: #888;
  font-weight: 500;
}

.hud-value {
  font-size: 18px;
  font-weight: 800;
  color: #2e7d32;
}

.hud-lives .hud-value {
  font-size: 16px;
  letter-spacing: 1px;
}

.hud-combo .hud-value {
  color: #ff9800;
}

.hud-combo .hud-value.combo-fire {
  color: #f44336;
  animation: pulse-glow 0.5s ease;
}

@keyframes pulse-glow {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

/* ---- 游戏区域 ---- */
#play-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ---- 食材卡片 ---- */
.food-card {
  position: absolute;
  width: 80px;
  height: 90px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: grab;
  touch-action: none;
  z-index: 5;
  transition: box-shadow 0.15s ease;
  will-change: transform;
}

.food-card.dragging {
  cursor: grabbing;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transform: scale(1.1);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.food-emoji {
  font-size: 36px;
  line-height: 1;
}

.food-name {
  font-size: 12px;
  color: #333;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

/* 正确动画 */
.food-card.correct {
  animation: correct-pop 0.4s ease forwards;
  pointer-events: none;
}

@keyframes correct-pop {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(0) translateY(20px);
    opacity: 0;
  }
}

/* 错误动画 */
.food-card.wrong {
  animation: wrong-shake 0.5s ease;
  pointer-events: none;
}

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

/* ---- 错误提示条 ---- */
.error-tip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(244, 67, 54, 0.95);
  color: #fff;
  padding: 14px 24px;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 700;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(244, 67, 54, 0.4);
}

.error-tip.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ---- 飘字（+10、连击等） ---- */
#floating-scores {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150;
}

.float-text {
  position: absolute;
  font-size: 22px;
  font-weight: 800;
  color: #4caf50;
  text-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
  animation: float-up 0.8s ease-out forwards;
  pointer-events: none;
}

.float-text.combo-text {
  color: #ff9800;
  font-size: 18px;
}

@keyframes float-up {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.5);
  }
  30% {
    opacity: 1;
    transform: translateY(-20px) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translateY(-60px) scale(1);
  }
}

/* ---- 底部三个筐 ---- */
.baskets {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 8px 12px 16px;
  background: rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
  gap: 8px;
}

.basket {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform 0.2s ease;
}

.basket.hovered {
  transform: scale(1.08);
}

.basket-label {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  padding: 4px 12px;
  border-radius: 12px;
  z-index: 2;
  order: 2;
}

.basket-high .basket-label {
  background: #f44336;
}

.basket-mid .basket-label {
  background: #ff9800;
}

.basket-low .basket-label {
  background: #4caf50;
}

.basket-key {
  display: none;
  font-size: 11px;
  color: #999;
}

.basket-body {
  width: 100%;
  height: 70px;
  border-radius: 0 0 12px 12px;
  border-top: none;
  position: relative;
  order: 3;
}

.basket-high .basket-body {
  background: linear-gradient(180deg, #ffcdd2 0%, #ef9a9a 100%);
  border: 3px solid #f44336;
  border-top: none;
}

.basket-mid .basket-body {
  background: linear-gradient(180deg, #ffe0b2 0%, #ffcc80 100%);
  border: 3px solid #ff9800;
  border-top: none;
}

.basket-low .basket-body {
  background: linear-gradient(180deg, #c8e6c9 0%, #a5d6a7 100%);
  border: 3px solid #4caf50;
  border-top: none;
}

/* 筐的开口线 */
.basket-body::before {
  content: "";
  position: absolute;
  top: 0;
  left: -3px;
  right: -3px;
  height: 6px;
  border-radius: 3px;
}

.basket-high .basket-body::before {
  background: #f44336;
}

.basket-mid .basket-body::before {
  background: #ff9800;
}

.basket-low .basket-body::before {
  background: #4caf50;
}

/* ================================================================
   结算页
   ================================================================ */
#result-screen {
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: 30px;
}

.result-content {
  width: 100%;
  padding: 0 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.result-emoji {
  font-size: 72px;
  animation: bounce-in 0.6s ease;
}

@keyframes bounce-in {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.result-title {
  font-size: 28px;
  font-weight: 800;
  color: #2e7d32;
}

.result-rank {
  font-size: 22px;
  font-weight: 800;
  color: #ff9800;
  background: #fff;
  padding: 8px 24px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-top: -8px;
}

.result-stats {
  display: flex;
  justify-content: space-around;
  width: 100%;
  background: #fff;
  border-radius: 16px;
  padding: 20px 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: #4caf50;
}

.stat-label {
  font-size: 12px;
  color: #888;
  font-weight: 500;
}

/* ---- 答错列表 ---- */
.wrong-list {
  width: 100%;
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.wrong-title {
  font-size: 16px;
  font-weight: 700;
  color: #2e7d32;
  margin-bottom: 12px;
}

.wrong-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wrong-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #fafafa;
  border-radius: 10px;
  font-size: 14px;
}

.wrong-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wrong-item-emoji {
  font-size: 22px;
}

.wrong-item-name {
  color: #333;
  font-weight: 500;
}

.wrong-item-level {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  color: #fff;
}

.wrong-item-level.high {
  background: #f44336;
}

.wrong-item-level.mid {
  background: #ff9800;
}

.wrong-item-level.low {
  background: #4caf50;
}

.wrong-empty {
  text-align: center;
  color: #999;
  font-size: 13px;
  padding: 12px 0;
}

/* ---- 冷知识 ---- */
.fun-fact-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: linear-gradient(135deg, #fff8e1 0%, #fffde7 100%);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.15);
  width: 100%;
  border: 1px solid #ffe082;
}

.fun-fact-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.fun-fact-text {
  font-size: 14px;
  color: #795548;
  line-height: 1.6;
}

.restart-btn {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  margin-top: 4px;
}

/* ================================================================
   桌面端适配（非触屏）
   ================================================================ */
@media (hover: hover) and (pointer: fine) {
  .basket-key {
    display: block;
  }
}

/* ================================================================
   小屏适配（iPhone SE 等）
   ================================================================ */
@media (max-width: 375px) {
  .game-title {
    font-size: 28px;
  }

  .food-card {
    width: 70px;
    height: 80px;
  }

  .food-emoji {
    font-size: 30px;
  }

  .food-name {
    font-size: 11px;
  }

  .basket-body {
    height: 60px;
  }
}

/* ================================================================
   大屏桌面端：限制最大宽度 + 居中
   ================================================================ */
@media (min-width: 501px) {
  body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #e8f5e9;
  }

  #game-container {
    border-radius: 24px;
    overflow: hidden;
    height: 90vh;
    max-height: 800px;
  }
}

/* ===== 分享功能 0909 ===== */
.share-row{display:flex;gap:10px;margin-top:14px}
.btn-share,.btn-poster{flex:1;border:none;border-radius:12px;padding:13px 8px;font-size:15px;font-weight:700;cursor:pointer;transition:transform .12s,box-shadow .12s}
.btn-share{background:#fff;color:#ff6a3d;border:2px solid #ff6a3d}
.btn-poster{background:linear-gradient(135deg,#ff9a3c,#ff6a3d);color:#fff;box-shadow:0 3px 10px rgba(255,106,61,.3)}
.btn-share:active,.btn-poster:active{transform:scale(.96)}
.share-tip{text-align:center;color:#2da063;font-size:13px;margin:10px 0 0;font-weight:600}
.poster-wrap{margin-top:14px;text-align:center;animation:posterIn .35s ease}
@keyframes posterIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
.poster-img{width:100%;max-width:340px;border-radius:14px;box-shadow:0 6px 20px rgba(0,0,0,.18)}

/* wx guide + bigger buttons 0909 */
.wx-guide-mask{position:fixed;inset:0;background:rgba(0,0,0,.72);z-index:9999;opacity:0;visibility:hidden;transition:opacity .25s ease;-webkit-transition:opacity .25s ease;}
.wx-guide-mask.show{opacity:1;visibility:visible;}
.wx-guide-arrow{position:absolute;top:10px;right:14px;font-size:56px;animation:wxGuideBounce 1s infinite;-webkit-animation:wxGuideBounce 1s infinite;}
@keyframes wxGuideBounce{0%,100%{transform:translateY(0);}50%{transform:translateY(-12px);}}
@-webkit-keyframes wxGuideBounce{0%,100%{-webkit-transform:translateY(0);}50%{-webkit-transform:translateY(-12px);}}
.wx-guide-card{position:absolute;top:96px;right:16px;left:16px;background:#fff;border-radius:16px;padding:26px 22px;text-align:center;box-shadow:0 10px 40px rgba(0,0,0,.3);}
.wx-guide-title{font-size:22px;font-weight:700;color:#ff6a3d;margin-bottom:12px;}
.wx-guide-desc{font-size:16px;color:#333;line-height:1.7;margin-bottom:18px;}
.wx-guide-close{display:inline-block;font-size:15px;color:#fff;background:#ff6a3d;border-radius:20px;padding:9px 26px;}
.share-row{gap:12px;margin-top:18px}
.btn-share,.btn-poster{padding:17px 10px;font-size:17px;border-radius:14px;font-weight:800}
.share-tip{font-size:14px}

/* 开始页底部品牌条 0909 */
.game-brand{position:absolute;left:0;right:0;bottom:88px;text-align:center;z-index:6;pointer-events:none;}
.game-brand img{height:24px;width:auto;opacity:.75;}
.game-brand .game-ver{display:block;font-size:10px;line-height:1.4;color:#9bb89e;margin-top:3px;letter-spacing:.5px;}
