:root {
  --green: #4caf50;
  --green-d: #388e3c;
  --wood: #c79a6b;
  --egg: #ffd23f;
  --bg: #eaf7e6;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: #333;
  max-width: 480px;
  margin: 0 auto;
}
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* 顶栏 */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--green); color: #fff;
  position: sticky; top: 0; z-index: 5;
}
.topbar .logo { font-weight: 700; font-size: 17px; }
.topbar .wallet { background: rgba(255,255,255,.2); padding: 4px 12px; border-radius: 20px; font-size: 14px; }
.topbar .wallet span { font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 10px; }
/* 右上角登录按钮 */
.auth-btn {
  max-width: 120px; padding: 5px 12px; border-radius: 20px; cursor: pointer;
  background: rgba(255,255,255,.2); color: #fff; font-size: 13px; font-weight: 600;
  border: 1px solid rgba(255,255,255,.45); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; -webkit-tap-highlight-color: transparent;
}
.auth-btn:active { transform: scale(.94); }
.sound-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.2); color: #fff; font-size: 18px; line-height: 1;
}

/* 农场（使用背景图 assets/bj1.jpg） */
.farm {
  position: relative; flex: 1; min-height: 340px; overflow: hidden;
  background: #bfe9ff url('bj1.jpg') center 55% / cover no-repeat;
}
.chicken {
  position: absolute; left: calc(50% + 30px); top: calc(50% + 50px);
  transform: translate(-50%, -50%);
  width: min(74%, 390px); aspect-ratio: 1 / 1;
  transition: transform .2s; pointer-events: none;
}
.chicken img {
  width: 100%; height: 100%; display: block; object-fit: contain;
}
/* 小鸡阶段：体型约为母鸡的 2/5（长大后由 JS 去掉 is-chick 变大） */
.chicken.is-chick {
  width: min(30%, 156px);
}
.chicken.is-chick .chicken-say {
  font-size: 13px; padding: 7px 11px; max-width: 210px;
}

/* 蝴蝶：从右上角慢慢飞出，斜向穿过农场，从左下角飞出去 */
.butterfly {
  position: absolute; right: -24px; top: 6%;
  width: 70px; height: 70px; opacity: 0; pointer-events: none; z-index: 2;
}
.butterfly img { width: 100%; height: 100%; display: block; object-fit: contain; }
/* --fx / --fy 由 JS 按农场实际宽高设置，保证真的从对角飞出画面 */
.butterfly.fly { animation: flyDiag 10s linear forwards; }
@keyframes flyDiag {
  0%   { transform: translate(0, 0) scale(.55);                                             opacity: 0; }
  10%  { opacity: 1; }
  25%  { transform: translate(calc(var(--fx) * -0.25), calc(var(--fy) * 0.20)) scale(.85);  opacity: 1; }
  50%  { transform: translate(calc(var(--fx) * -0.50), calc(var(--fy) * 0.48)) scale(1);    opacity: 1; }
  75%  { transform: translate(calc(var(--fx) * -0.75), calc(var(--fy) * 0.76)) scale(.9);   opacity: 1; }
  92%  { opacity: 1; }
  100% { transform: translate(calc(var(--fx) * -1), var(--fy)) scale(.55);                  opacity: 0; }
}

/* 小鸡说话气泡（每 3~5 秒随机冒一句） */
.chicken-say {
  position: absolute; bottom: 86%; left: 50%;
  transform: translateX(-50%) translateY(8px) scale(.9);
  background: #fff; color: #6d4c41; border: 2px solid var(--egg);
  border-radius: 14px; padding: 9px 13px;
  font-size: 15px; line-height: 1.45; text-align: center;
  max-width: 240px; width: max-content;
  opacity: 0; pointer-events: none; z-index: 3;
  box-shadow: 0 4px 10px rgba(0,0,0,.15);
  transition: opacity .25s ease, transform .25s ease;
}
.chicken-say.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.chicken-say::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: var(--egg);
}

/* 左右两侧装饰 GIF */
.decor {
  position: absolute; bottom: 94px; pointer-events: none;
}
.decor img { display: block; width: 100%; height: 100%; object-fit: contain; }
.decor-left {
  left: 9%; width: 120px; height: 120px;
}
.decor-right {
  right: 9%; width: 90px; height: 95px;
}
.chicken.shake { animation: shake .5s; }
@keyframes shake {
  0%,100% { transform: translate(-50%,-50%) rotate(0); }
  25% { transform: translate(-54%,-50%) rotate(-6deg); }
  75% { transform: translate(-46%,-50%) rotate(6deg); }
}
.egg-pop, .feed-pop {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 34px; opacity: 0; pointer-events: none; z-index: 2;
}
.feed-pop { top: 18%; }
.egg-pop { top: 62%; }
.egg-pop.show { animation: eggFall 1s ease forwards; }
.feed-pop.show { animation: feedDrop .6s ease forwards; }
@keyframes eggFall {
  0% { opacity: 0; top: 62%; }
  30% { opacity: 1; top: 70%; }
  100% { opacity: 0; top: 82%; }
}
@keyframes feedDrop {
  0% { opacity: 0; top: 8%; }
  60% { opacity: 1; top: 26%; }
  100% { opacity: 0; top: 28%; }
}

/* 底部居中按钮组（喂食 / 收鸡蛋） */
.corner-bar {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 16px; display: flex; gap: 20px; z-index: 4;
}
.corner-btn {
  position: relative; width: 78px;
  background: none; border: none; padding: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: transform .1s;
}
.corner-btn img { width: 100%; display: block; }
.corner-btn:active { transform: scale(.94); }
.corner-btn.disabled { filter: grayscale(1); opacity: .55; }
.corner-btn .badge {
  position: absolute; top: -6px; right: -6px; min-width: 24px; height: 24px;
  background: #ff5b5b; color: #fff; border-radius: 12px; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

/* 收鸡蛋弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: none; align-items: center; justify-content: center;
  z-index: 30; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 16px; padding: 18px; width: 100%;
  max-width: 340px; max-height: 82vh; overflow-y: auto; text-align: center;
}
.modal-box h3 { margin: 0 0 10px; color: var(--green-d); font-size: 17px; }
.m-stores { text-align: left; margin-top: 12px; }
.m-stores .store-item { padding: 10px 12px; }
.m-close {
  margin-top: 14px; padding: 9px 30px; border: none; border-radius: 20px;
  background: var(--green); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}

/* 长成母鸡提示弹窗 */
.hen-card h3 { color: #ef6c00; }
.hen-tip { margin: 6px 0 18px; font-size: 15px; line-height: 1.8; color: #555; }
.hen-tip b { color: var(--green-d); font-size: 17px; }
.hen-warn { display: inline-block; margin-top: 6px; color: #e53935; font-weight: 700; }

/* 登录弹窗（手机号 + 密码） */
.login-card {
  background: #fff; border-radius: 16px; padding: 22px 18px 18px;
  width: 100%; max-width: 320px; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.login-card h3 { margin: 0 0 8px; color: var(--green-d); font-size: 18px; }
.login-card .login-tip { margin: 0 0 16px; font-size: 12px; color: #888; line-height: 1.6; }
.login-input {
  width: 100%; padding: 11px 12px; margin-bottom: 10px;
  border: 1px solid #ddd; border-radius: 9px; font-size: 15px;
  outline: none; -webkit-appearance: none;
}
.login-input:focus { border-color: var(--green); }
.login-err { min-height: 18px; margin: 0 0 6px; font-size: 12px; color: #e53935; }

/* 首次进入：玩法规则弹窗 */
.rule-card {
  background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 320px;
  text-align: left; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.rule-card h3 { margin: 0 0 14px; text-align: center; color: var(--green-d); font-size: 19px; }
.rule-card .rule-body p { margin: 9px 0; font-size: 14px; color: #444; line-height: 1.5; }

/* 农场右上角附近门店按钮（在规则按钮下方；双类名提高优先级，避免被 .rule-btn 的 top 覆盖） */
.rule-btn.stores-btn { top: 94px; }

/* 附近可领取鸡蛋门店弹窗 */
.stores-card .stores-scroll {
  max-height: 46vh; overflow-y: auto; text-align: left; margin-top: 4px;
}
.stores-card .store-item {
  background: #f7f7f7; box-shadow: none; padding: 10px 12px; margin-bottom: 8px;
}
.stores-card .store-item .name { font-size: 14px; }
.stores-card .store-item .meta { font-size: 12px; }

/* 农场内喂食提示 */
.feed-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.45); color: #fff; font-size: 13px;
  padding: 6px 14px; border-radius: 16px; white-space: nowrap; z-index: 3;
}

/* 农场右上角规则按钮（位于喂食提示下方，避免遮挡） */
.rule-btn {
  position: absolute; top: 52px; right: 12px; z-index: 3;
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.88); color: #6d4c41;
  border: 1px solid rgba(0,0,0,.08); border-radius: 16px;
  padding: 5px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
  -webkit-tap-highlight-color: transparent; transition: transform .1s;
}
.rule-btn:active { transform: scale(.94); }

/* 飘屏提示（从右往左飘过） */
.float-tip {
  position: absolute; top: 26%; left: 100%;
  background: rgba(0,0,0,.5); color: #fff; font-size: 13px;
  padding: 7px 16px; border-radius: 18px; white-space: nowrap;
  z-index: 3; pointer-events: none; opacity: 0;
}
/* 飘屏滚动放慢：12 秒走完一屏，便于看清文字 */
.float-tip.run { animation: floatAcross 12s linear forwards; }
@keyframes floatAcross {
  0%   { transform: translateX(0); opacity: 0; }
  6%   { opacity: 1; }
  94%  { opacity: 1; }
  100% { transform: translateX(calc(-100vw - 100%)); opacity: 0; }
}

/* 鸡蛋盒卡片 */
.box-card {
  margin: 14px 16px; background: #fff; border-radius: 16px; padding: 16px;
  text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,.08);
  border: 2px dashed var(--egg);
}
.box-card h3 { margin: 0 0 10px; color: var(--green-d); }
.qrcode { display: flex; justify-content: center; margin: 8px 0; }
.qrcode img, .qrcode canvas { width: 140px !important; height: 140px !important; }
.box-card .code { font-size: 18px; font-weight: 800; letter-spacing: 2px; color: #ff8f00; }
.box-tip { font-size: 12px; color: #999; margin: 6px 0 0; }
.box-tip.next-month {
  margin-top: 12px; color: var(--green-d); font-size: 13px; font-weight: 600;
}
.stores-link {
  display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 600;
  color: var(--green-d); text-decoration: none;
}

/* 门店页 */
.topbar .back { color: #fff; font-size: 13px; text-decoration: none; }
.page-stores { padding-top: 14px; }

/* 门店 */
.stores { padding: 8px 16px 20px; }
.stores h3 { font-size: 16px; margin: 8px 0 12px; }
.store-list .loading { color: #999; font-size: 13px; }
.store-item {
  background: #fff; border-radius: 14px; padding: 12px 14px; margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.store-item .name { font-weight: 700; font-size: 15px; }
.store-item .meta { font-size: 13px; color: #777; margin-top: 4px; line-height: 1.5; }

.foot { text-align: center; font-size: 12px; color: #aaa; padding: 16px 0 24px; margin-top: auto; }

/* Toast */
.toast {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%,-50%);
  background: rgba(0,0,0,.8); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 99;
  max-width: 80%; text-align: center;
}
.toast.show { opacity: 1; }
