*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ========== 动画关键帧 ========== */
@keyframes sway {
  0%, 100% { transform: translateX(-50%) rotate(-3deg); }
  50% { transform: translateX(-50%) rotate(3deg); }
}

@keyframes monkey-bounce {
  0% { transform: scale(1) translateY(0); }
  30% { transform: scale(1.25) translateY(-8px); }
  60% { transform: scale(1.15) translateY(-4px); }
  100% { transform: scale(1) translateY(0); }
}

@keyframes monkey-idle {
  0%, 100% { transform: rotate(-5deg) scale(1); }
  25% { transform: rotate(2deg) scale(1.02); }
  50% { transform: rotate(5deg) scale(1); }
  75% { transform: rotate(-2deg) scale(1.02); }
}

@keyframes score-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.2); }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.5); }
  50% { box-shadow: 0 0 24px 10px rgba(249, 115, 22, 0.35); }
}

@keyframes timer-urgent {
  0%, 100% { transform: scale(1); color: #dc2626; filter: drop-shadow(0 0 0 transparent); }
  50% { transform: scale(1.12); color: #f87171; filter: drop-shadow(0 0 12px rgba(248, 113, 113, 0.8)); }
}

@keyframes leaf-float {
  0%, 100% { transform: translateY(0) rotate(-3deg); opacity: 0.75; }
  50% { transform: translateY(-8px) rotate(8deg); opacity: 1; }
}

@keyframes cloud-drift {
  0% { transform: translateX(-16px) scale(1); opacity: 0.55; }
  50% { transform: translateX(12px) scale(1.05); opacity: 0.9; }
  100% { transform: translateX(-16px) scale(1); opacity: 0.55; }
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes rank-slide {
  from { opacity: 0; transform: translateX(24px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes bg-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes score-float {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-32px) scale(1.15); }
}

@keyframes progress-shine-sweep {
  0% { left: -100%; }
  100% { left: 100%; }
}

@keyframes other-monkey-wiggle {
  0%, 100% { transform: translate(-50%, 0) rotate(-6deg); }
  50% { transform: translate(-50%, 0) rotate(6deg); }
}

@keyframes card-float {
  0%, 100% { box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08); }
  50% { box-shadow: 0 14px 36px rgba(15, 23, 42, 0.12); }
}

@keyframes tree-bg {
  0%, 100% { background-position: 0% 50%; filter: brightness(1); }
  50% { background-position: 100% 50%; filter: brightness(1.03); }
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, 'Noto Sans', sans-serif;
  background: radial-gradient(ellipse at 30% 20%, #ffe4e6 0%, #fed7e2 35%, #f4f6ff 100%);
  color: #222;
}

.mobile-body {
  background: radial-gradient(ellipse at 50% 0%, #ffe4e6 0%, #fed7e2 40%, #fee2e2 75%, #fdf2f8 100%);
  background-size: 120% 120%;
  animation: bg-shift 12s ease-in-out infinite;
}

.app-container,
.screen-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.app-header {
  text-align: center;
  margin-bottom: 12px;
}

.app-header h1 {
  margin: 0 0 4px;
  animation: header-glow 2.5s ease-in-out infinite;
}

.app-header p {
  animation: header-sub 3s ease-in-out infinite;
}

@keyframes header-glow {
  0%, 100% { text-shadow: 0 0 12px rgba(249, 115, 22, 0.45), 0 2px 6px rgba(0,0,0,0.06); }
  50% { text-shadow: 0 0 22px rgba(249, 115, 22, 0.65), 0 4px 10px rgba(0,0,0,0.08); }
}

@keyframes header-sub {
  0%, 100% { opacity: 0.88; }
  50% { opacity: 1; }
}

.mobile-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(12px);
  animation: card-enter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.card.card-float {
  animation: card-float 4s ease-in-out infinite;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }

.card-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

.field-label {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.text-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  outline: none;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus {
  border-color: #fb923c;
  box-shadow: 0 0 0 2px rgba(251, 146, 60, 0.3);
}

.primary-btn,
.secondary-btn,
.tap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 10px 18px;
  margin-top: 8px;
  transition: transform 0.08s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.primary-btn {
  background: linear-gradient(135deg, #fb923c, #f97316);
  color: #fff;
  box-shadow: 0 10px 20px rgba(249, 115, 22, 0.4);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(249, 115, 22, 0.5);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.5);
}

.secondary-btn {
  background: #eef2ff;
  color: #4f46e5;
  box-shadow: none;
}

.secondary-btn:hover {
  background: #e0e7ff;
}

.secondary-btn:active {
  background: #c7d2fe;
}

.tap-btn {
  width: 100%;
  margin-top: 10px;
  padding: 18px;
  font-size: 18px;
  background: radial-gradient(circle at top left, #4ade80, #22c55e);
  color: white;
  box-shadow: 0 14px 30px rgba(34, 197, 94, 0.5);
}

.tap-btn:active {
  transform: translateY(2px) scale(0.97);
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.6);
}

.tap-btn.tap-flash {
  animation: tap-flash 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tap-flash {
  0% { transform: scale(1); box-shadow: 0 14px 30px rgba(34, 197, 94, 0.5); }
  45% { transform: scale(1.08); box-shadow: 0 18px 40px rgba(34, 197, 94, 0.7); }
  100% { transform: scale(1); box-shadow: 0 14px 30px rgba(34, 197, 94, 0.5); }
}

.status-text {
  margin-top: 6px;
  font-size: 12px;
  color: #64748b;
}

.status-text.error {
  color: #b91c1c;
}

.status-text.small {
  font-size: 11px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.status-label {
  font-size: 12px;
  color: #64748b;
}

.status-value {
  font-size: 16px;
  font-weight: 600;
}

.status-timer {
  color: #ef4444;
}

.score-display {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 4px;
  transition: transform 0.15s ease;
}

.score-display.score-pop {
  animation: score-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card-score-wrap .score-row {
  position: relative;
  display: inline-block;
}

.score-float-container {
  position: absolute;
  left: 50%;
  top: -4px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 5;
}

.score-float {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  font-size: 18px;
  font-weight: 700;
  color: #16a34a;
  pointer-events: none;
  animation: score-float 0.6s ease-out forwards;
  z-index: 10;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}

.tree-area {
  position: relative;
  width: 100%;
  height: 200px;
  margin-bottom: 10px;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(160deg, #a7f3d0 0%, #d9f99d 35%, #fde68a 70%, #fef3c7 100%);
  background-size: 200% 200%;
  animation: tree-bg 10s ease-in-out infinite;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.25),
    0 12px 28px rgba(15, 23, 42, 0.12);
}

.tree-area::before,
.tree-area::after {
  content: '☁️';
  position: absolute;
  font-size: 20px;
  top: 12%;
  opacity: 0.6;
  animation: cloud-drift 4s ease-in-out infinite;
  pointer-events: none;
}

.tree-area::before { left: 8%; animation-delay: 0s; }
.tree-area::after { right: 12%; top: 20%; animation-delay: -2s; }

.tree-leaf {
  position: absolute;
  font-size: 18px;
  opacity: 0.7;
  animation: leaf-float 2.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

.tree-leaf-1 { left: 18%; bottom: 35%; animation-delay: 0s; }
.tree-leaf-2 { right: 22%; bottom: 55%; animation-delay: -1.2s; }

.tree-trunk {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 28px;
  height: 100%;
  background: linear-gradient(180deg, #b45309 0%, #92400e 30%, #78350f 100%);
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(120, 53, 15, 0.5),
    inset 2px 0 8px rgba(255,255,255,0.1);
  animation: sway 2.8s ease-in-out infinite;
}

.monkey-wrap {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 0%);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 2;
}

.monkey-sprite {
  display: inline-block;
  font-size: 40px;
  filter: drop-shadow(0 6px 10px rgba(15, 23, 42, 0.4))
    drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.monkey-sprite.monkey-climb {
  animation: monkey-bounce 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.monkey-sprite.monkey-idle {
  animation: monkey-idle 2s ease-in-out infinite;
}

.others-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.other-monkey {
  position: absolute;
  transform: translate(-50%, 0);
  font-size: 22px;
  text-align: center;
  color: #1f2937;
  transition: bottom 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    left 0.25s ease-out;
  animation: other-monkey-wiggle 2.5s ease-in-out infinite;
}

.other-monkey:nth-child(1) { animation-delay: 0s; }
.other-monkey:nth-child(2) { animation-delay: -0.6s; }
.other-monkey:nth-child(3) { animation-delay: -1.2s; }
.other-monkey:nth-child(4) { animation-delay: -1.8s; }

.other-monkey span {
  display: block;
  text-shadow: 0 2px 4px rgba(15, 23, 42, 0.35);
}

.other-monkey-name {
  font-size: 10px;
  margin-top: -2px;
  max-width: 52px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-wrap {
  position: relative;
  width: 100%;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #e2e8f0, #cbd5e1);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

.progress-bar {
  width: 100%;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #e2e8f0, #cbd5e1);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

.progress-inner {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #16a34a, #22c55e, #a3e635);
  background-size: 200% 100%;
  transition: width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.progress-inner.progress-shine {
  animation: progress-pulse 0.5s ease-out;
}

.progress-inner.progress-shine::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: progress-shine-sweep 0.6s ease-out;
}

@keyframes progress-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
}

.hint-text {
  font-size: 13px;
  color: #6b7280;
  margin-top: 0;
}

.screen-body {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 30%, #fef3c7 60%, #fdf2f8 100%);
  background-size: 200% 200%;
  animation: bg-shift 8s ease-in-out infinite;
}

.screen-header h1 {
  animation: header-glow 2.5s ease-in-out infinite;
}

.screen-wrapper {
  padding: 24px 32px;
}

.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 16px;
}

.screen-header-text {
  text-align: left;
}

.screen-main {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(340px, 1.2fr);
  gap: 20px;
  align-items: flex-start;
}

.screen-left,
.screen-right {
  width: 100%;
}

.qr-card {
  min-width: 220px;
  max-width: 260px;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  text-align: center;
}

.qr-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.qr-box {
  width: 150px;
  height: 150px;
  margin: 4px auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9fafb;
  border-radius: 12px;
}

.qr-url-tip {
  font-size: 12px;
  color: #6b7280;
}

.qr-url {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
  color: #111827;
  word-break: break-all;
}

.control-panel .big {
  width: 100%;
  padding: 14px 18px;
  font-size: 18px;
}

.control-panel .big.ready-pulse {
  animation: pulse-glow 2s ease-in-out infinite;
}

.timer-display {
  margin-top: 10px;
}

.timer-value {
  font-size: 32px;
  font-weight: 700;
  color: #dc2626;
  transition: transform 0.2s ease, color 0.2s ease;
}

.timer-value.timer-urgent {
  animation: timer-urgent 1s ease-in-out infinite;
}

.ranking-panel {
  max-height: calc(100vh - 160px);
  overflow: hidden;
}

.ranking-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  max-height: calc(100vh - 210px);
  overflow-y: auto;
  overflow-x: hidden;
}

.ranking-item {
  display: grid;
  grid-template-columns: 48px 1fr 80px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.9);
  animation: rank-slide 0.35s ease-out backwards;
}


.ranking-item:nth-child(1) {
  background: linear-gradient(90deg, #fef3c7, #f97316);
  color: #1f2937;
}

.ranking-item:nth-child(2) {
  background: linear-gradient(90deg, #e5e7eb, #9ca3af);
}

.ranking-item:nth-child(3) {
  background: linear-gradient(90deg, #fef9c3, #fde047);
}

.ranking-item .rank-no {
  transition: transform 0.2s ease;
}

.ranking-item:nth-child(1) .rank-no {
  animation: rank-pop 0.5s ease-out;
}

@keyframes rank-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.rank-no {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.rank-name {
  font-size: 16px;
  font-weight: 500;
  padding: 0 4px;
}

.rank-score {
  font-size: 16px;
  font-weight: 600;
  text-align: right;
}

@media (max-width: 768px) {
  .screen-main {
    grid-template-columns: 1fr;
  }

  .screen-wrapper {
    padding: 16px;
  }
}
