:root {
  --primary-color: #ff9f1c;
  --primary-dark: #f77f00;
  --accent-color: #2ec4b6;
  --bg-gradient: linear-gradient(150deg, #dcfce7 0%, #fef3c7 50%, #e0f2fe 100%);
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --bowl-grad: linear-gradient(180deg, #ea580c 0%, #c2410c 100%);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-gradient);
  min-height: var(--game-content-height);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 10px;
  color: var(--text-main);
}

/* 移动端卡片式容器 (高度契合 H5 体验，基于屏幕高度居中) */
.app-card {
  width: 100%;
  max-width: 440px;
  background: var(--card-bg);
  border-radius: 24px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.08);
  padding: 16px 14px 16px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto 0;
}

/* 顶部标题 (紧凑精致，上方留白缩减一半以上) */
.header {
  text-align: center;
  margin-bottom: 4px;
}

.header h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #ea580c;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.header p {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* 战绩栏 (紧凑适中) */
.stats-row {
  display: flex;
  justify-content: space-around;
  width: 100%;
  background: #f8fafc;
  border-radius: 10px;
  padding: 4px 8px;
  margin-bottom: 6px;
  border: 1px solid #e2e8f0;
}

.stat-box {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.stat-box strong {
  display: block;
  font-size: 1.08rem;
  color: var(--text-main);
  font-weight: 700;
  margin-top: 1px;
}

.stat-box strong.streak {
  color: #ea580c;
}

/* 游戏桌面舞台 (高度优化，预留充足揭碗空间并大幅缩减上方留白) */
.stage-box {
  width: 100%;
  height: 200px;
  background: linear-gradient(180deg, #f0fdf4 0%, #bbf7d0 70%, #86efac 100%);
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.06), 0 8px 20px rgba(34, 197, 94, 0.15);
  margin-bottom: 8px;
  perspective: 700px; /* 提供真实 3D 交换透视效果 */
}

/* 木质桌边底座 */
.table-wood {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(180deg, #b45309 0%, #78350f 100%);
  border-top: 3.5px solid #d97706;
  box-shadow: 0 -3px 8px rgba(0,0,0,0.12);
  z-index: 1;
}

/* 碗移动轨道 */
.tracks {
  position: absolute;
  bottom: 26px;
  left: 0;
  right: 0;
  height: 155px;
  z-index: 2;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
}

/* 单个碗的主实体容器 */
.bowl-entity {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100px;
  height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
  touch-action: manipulation;
  will-change: transform, z-index, filter;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /* 核心位移过渡 */
  transition: transform 0.45s cubic-bezier(0.35, 0, 0.2, 1);
}

/* 碗的外观模型 (经典三仙归洞·朱红描金倒扣御瓷碗) */
.bowl-cap {
  width: 96px;
  height: 68px;
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: center;
  align-items: center;
  transform-origin: bottom center;
  /* 经典倒扣瓷碗轮廓：顶部平滑收拢为碗底，两侧微鼓饱满，底部敞口 */
  border-radius: 46px 46px 8px 8px;
  /* 景德镇红釉高光瓷感：圆柱反射高光 + 深邃朱红釉渐变 */
  background:
    linear-gradient(90deg,
      rgba(0, 0, 0, 0.28) 0%,
      rgba(255, 255, 255, 0) 14%,
      rgba(255, 255, 255, 0.75) 26%,
      rgba(255, 255, 255, 0.95) 30%,
      rgba(255, 255, 255, 0.3) 42%,
      rgba(0, 0, 0, 0.05) 70%,
      rgba(0, 0, 0, 0.35) 100%),
    linear-gradient(180deg, #c2410c 0%, #ea580c 35%, #9a3412 100%);
  border: 2px solid #7c2d12;
  border-bottom: 4px solid #d97706; /* 碗口金色瓷沿 */
  box-shadow:
    0 12px 22px rgba(0, 0, 0, 0.35),
    inset 0 3px 5px rgba(255, 255, 255, 0.65),
    inset 0 -3px 6px rgba(0, 0, 0, 0.45);
  /* 升起/盖上平滑过渡 (更轻快敏捷) */
  transition: transform 0.26s cubic-bezier(0.34, 1.35, 0.64, 1), box-shadow 0.2s;
  will-change: transform;
}

/* 倒扣圈足 (顶部碗底足) */
.bowl-cap::before {
  content: '';
  position: absolute;
  top: -8px;
  width: 44px;
  height: 9px;
  background: linear-gradient(180deg, #fef08a 0%, #f97316 45%, #9a3412 100%);
  border: 2px solid #7c2d12;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  box-shadow:
    0 -1px 3px rgba(0, 0, 0, 0.2),
    inset 0 2px 2px rgba(0, 0, 0, 0.3),
    inset 0 -1px 2px rgba(255, 255, 255, 0.7);
  z-index: 6;
}

/* 碗身精细描金腰线 */
.bowl-cap::after {
  content: '';
  position: absolute;
  top: 30px;
  left: 8px;
  right: 8px;
  height: 4px;
  background: linear-gradient(90deg, #b45309 0%, #fef08a 25%, #f59e0b 50%, #fef08a 75%, #b45309 100%);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  opacity: 0.95;
}

/* 碗的桌面阴影 */
.bowl-shadow {
  position: absolute;
  bottom: -4px;
  width: 88px;
  height: 14px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.38) 0%, rgba(0, 0, 0, 0) 75%);
  border-radius: 50%;
  z-index: 2;
  transition: all 0.45s ease;
}

/* 碗掀开升起的过渡效果 */
.bowl-entity.lifted .bowl-cap {
  transform: translateY(-72px) rotate(-8deg);
  box-shadow: 0 26px 30px rgba(0, 0, 0, 0.2);
}

.bowl-entity.lifted .bowl-shadow {
  transform: scale(0.6);
  opacity: 0.3;
  filter: blur(8px);
}

/* 选中的高亮光环过渡 (整体倒扣碗外廓发光) */
.bowl-entity.chosen {
  filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.95)) drop-shadow(0 0 3px rgba(254, 240, 138, 0.8));
}

.bowl-entity.chosen .bowl-cap {
  border-color: #fbbf24;
}

/* 鸭子形象 */
.duck-sprite {
  position: absolute;
  bottom: 2px;
  font-size: 2.8rem;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.6) translateY(10px);
  transition: all 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.duck-sprite.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.duck-sprite.jumping {
  animation: duckHop 0.5s infinite alternate ease-in-out;
}

@keyframes duckHop {
  0% { transform: scale(1, 0.92) translateY(0) rotate(-5deg); }
  100% { transform: scale(0.95, 1.05) translateY(-18px) rotate(5deg); }
}

/* 手机端可触控掀碗时的轻微悬浮呼吸提示 */
.bowl-entity.can-tap .bowl-cap {
  border-color: #f59e0b;
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.45), inset 0 4px 8px rgba(255, 255, 255, 0.4);
  animation: bowlHoverPulse 1.1s infinite ease-in-out;
  cursor: pointer;
}

.bowl-entity.can-tap:active .bowl-cap {
  transform: scale(0.92);
}

@keyframes bowlHoverPulse {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.04); }
}

/* 交互面板 */
.panel-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 文本输入框行 */
.input-wrapper {
  display: flex;
  gap: 8px;
  width: 100%;
}

.input-text {
  flex: 1;
  height: 48px;
  border: 2px solid #cbd5e1;
  border-radius: 14px;
  font-size: 1.05rem;
  text-align: center;
  font-weight: 700;
  color: #1e293b;
  outline: none;
  transition: all 0.25s;
}

.input-text:focus {
  border-color: #ea580c;
  box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.18);
}

.input-text:disabled {
  background: #f8fafc;
  color: #94a3b8;
}

/* 按钮通用 */
.btn {
  border: none;
  outline: none;
  font-weight: 700;
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:active:not(:disabled) {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-submit {
  width: 105px;
  height: 48px;
  background: #2ec4b6;
  color: white;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(46, 196, 182, 0.35);
}

.btn-submit:hover:not(:disabled) {
  background: #25a195;
}

/* 主行动按钮：直接放置在原数字键黄金触控位置 */
.btn-action-main {
  width: 100%;
  height: 50px;
  background: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
  color: white;
  font-size: 1.18rem;
  font-weight: 800;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(234, 88, 12, 0.35);
  margin-top: 2px;
  touch-action: manipulation;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 1px;
}

.btn-action-main:hover:not(:disabled) {
  box-shadow: 0 8px 24px rgba(234, 88, 12, 0.5);
}

@keyframes startPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 6px 18px rgba(234, 88, 12, 0.38);
  }
  50% {
    transform: scale(1.025);
    box-shadow: 0 8px 26px rgba(234, 88, 12, 0.65);
  }
}

.btn-action-main:not(:disabled) {
  animation: startPulse 1.5s infinite ease-in-out;
}

/* 速度调节分段胶囊控制栏 */
.speed-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  background: #fff7ed;
  border: 1.5px solid #fed7aa;
  border-radius: 14px;
  padding: 3px 4px 3px 10px;
  margin-top: 4px;
  box-shadow: 0 2px 5px rgba(234, 88, 12, 0.08);
  transition: opacity 0.2s ease;
}

.speed-control-bar.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.speed-label {
  font-size: 0.95rem;
  font-weight: 800;
  color: #9a3412;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.speed-segmented {
  display: flex;
  gap: 4px;
  background: rgba(254, 215, 170, 0.45);
  padding: 3px;
  border-radius: 12px;
  flex: 1;
}

.speed-btn {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  padding: 6px 0;
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 800;
  color: #78350f;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: manipulation;
}

.speed-btn:active {
  transform: scale(0.95);
}

.speed-btn.active {
  background: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(234, 88, 12, 0.35);
}

/* 手机端特定自适应 */
/* 手机端特定自适应 (确保不用滑动即可完整看到“再玩一局”大按钮) */
@media (max-width: 480px) {
  body {
    min-height: 100vh;
    min-height: 100dvh;
    align-items: center;
    padding: 10px 8px;
  }
  .app-card {
    border-radius: 22px;
    padding: 16px 12px 14px;
  }
  .header {
    margin-bottom: 6px;
  }
  .header h1 {
    font-size: 1.35rem;
    gap: 6px;
  }
  .header p {
    font-size: 0.72rem;
    margin-top: 1px;
  }
  .stats-row {
    margin-bottom: 6px;
    padding: 4px 8px;
    border-radius: 10px;
  }
  .stat-box {
    font-size: 0.72rem;
  }
  .stat-box strong {
    font-size: 1.05rem;
    margin-top: 0px;
  }
  .stage-box {
    height: 195px;
    margin-bottom: 8px;
    border-radius: 18px;
  }
  .table-wood {
    height: 38px;
  }
  .tracks {
    bottom: 25px;
    height: 155px;
  }
  .btn-action-main {
    height: 48px;
    font-size: 1.15rem;
    border-radius: 14px;
    margin-top: 2px;
  }
  .speed-control-bar {
    padding: 3px 4px 3px 10px;
    margin-top: 5px;
    border-radius: 13px;
  }
  .speed-label {
    font-size: 0.92rem;
    font-weight: 800;
  }
  .speed-segmented {
    padding: 2.5px;
    border-radius: 10px;
  }
  .speed-btn {
    font-size: 0.88rem;
    font-weight: 800;
    padding: 5px 0;
    border-radius: 8px;
  }
}

@media (max-width: 380px) {
  .bowl-entity {
    width: 82px;
    height: 135px;
  }
  .bowl-cap {
    width: 78px;
    height: 56px;
    border-radius: 38px 38px 7px 7px;
  }
  .bowl-cap::before {
    width: 36px;
    height: 8px;
    top: -7px;
  }
  .bowl-cap::after {
    top: 25px;
    left: 6px;
    right: 6px;
    height: 3.5px;
  }
  .bowl-shadow {
    width: 72px;
    height: 11px;
  }
  .duck-sprite {
    font-size: 2.1rem;
  }
  .stage-box {
    height: 185px;
    margin-bottom: 6px;
  }
  .speed-control-bar {
    padding: 3px 3px 3px 8px;
  }
  .speed-label {
    font-size: 0.88rem;
    font-weight: 800;
  }
  .speed-segmented {
    padding: 2px;
  }
  .speed-btn {
    font-size: 0.84rem;
    font-weight: 800;
    padding: 5px 0;
  }
}

/* 全屏彩花 Canvas */
#confetti-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
}
