/* ============================================================
   快乐鸡场 · 游戏前端样式
   风格：奶油纸感 + 粗描边贴纸 + 硬阴影，玩具感
   ============================================================ */
:root {
  --cream: #FFF3DA;
  --cream-2: #FFE7B8;
  --paper: #FFFDF6;
  --ink: #3A2418;
  --ink-soft: #7A5C48;
  --amber: #FFC53D;
  --amber-deep: #F2A93B;
  --orange: #FF8A3D;
  --green: #59B368;
  --green-deep: #3E8F4C;
  --sky: #8FD3E8;
  --red: #E5533D;
  --line: 3px solid var(--ink);
  --shadow: 4px 4px 0 rgba(58, 36, 24, .85);
  --shadow-sm: 3px 3px 0 rgba(58, 36, 24, .8);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: #E9D3AE;
  color: var(--ink);
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  overscroll-behavior: none;
}

body::before {
  /* 桌面底纹：木纹 + 颗粒 */
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.5), transparent 45%),
    repeating-linear-gradient(92deg, #E4CBA1 0 18px, #E9D3AE 18px 36px);
  opacity: .9;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: 99; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  opacity: .28; mix-blend-mode: multiply;
}

#app {
  position: relative; z-index: 1;
  max-width: 468px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  background: var(--cream);
  display: flex; flex-direction: column;
  box-shadow: 0 0 0 3px var(--ink), 0 20px 60px rgba(58,36,24,.35);
}

/* ------------------------------ 顶部 HUD ------------------------------ */
.hud {
  position: sticky; top: 0; z-index: 20;
  padding: 14px 14px 12px;
  background: linear-gradient(180deg, var(--amber) 0%, var(--amber-deep) 100%);
  border-bottom: var(--line);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 42px; height: 42px; border-radius: 14px; flex: 0 0 auto;
  background: var(--paper); border: var(--line);
  display: grid; place-items: center; font-size: 22px;
  box-shadow: var(--shadow-sm);
}
.who { flex: 1; min-width: 0; }
.who .nick {
  font-weight: 900; font-size: 15px; letter-spacing: .5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.who .uid { font-size: 11px; font-weight: 700; color: rgba(58,36,24,.62); margin-top: 2px; }

.wallet { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 3px 10px 3px 6px; font-weight: 900; font-size: 13px;
  box-shadow: 2px 2px 0 rgba(58,36,24,.75);
  font-variant-numeric: tabular-nums;
}
.chip .i { font-size: 13px; }
.chip.cash { background: #E7F7E9; }
.chip.pulse { animation: chipPulse .45s ease; }
@keyframes chipPulse { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ------------------------------ 主内容 ------------------------------ */
main { flex: 1; padding: 14px 14px 96px; display: flex; flex-direction: column; gap: 14px; }
.screen { display: none; flex-direction: column; gap: 14px; }
.screen.active { display: flex; }

.card {
  background: var(--paper);
  border: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.card.tight { padding: 10px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; gap: 8px;
}
.card-title { font-weight: 900; font-size: 15px; letter-spacing: .5px; display: flex; align-items: center; gap: 6px; }
.card-sub { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); }

/* 标签 */
.tag {
  font-size: 10.5px; font-weight: 900; padding: 2px 7px; border-radius: 999px;
  border: 2px solid var(--ink); background: var(--cream-2); letter-spacing: .3px;
}
.tag.ok { background: #D8F5DD; }
.tag.warn { background: #FFE0A8; }
.tag.bad { background: #FFD3CB; }

/* ------------------------------ 鸡舍 ------------------------------ */
/* 蛋仓卡片 */
.eggcard { background: linear-gradient(180deg, #FFF9E6 0%, #FFF3DA 100%); }
.egg-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.egg-num { display: flex; align-items: baseline; gap: 6px; }
.egg-num b { font-size: 34px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.egg-num span { font-size: 12px; font-weight: 800; color: var(--ink-soft); }
.egg-worth { text-align: right; font-size: 12.5px; font-weight: 800; color: var(--ink-soft); line-height: 1.5; }
.egg-worth b { font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.egg-cash b { color: var(--green-deep); }

.coop-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 800; color: var(--ink-soft); margin-bottom: 8px;
}
.coop {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.slot {
  position: relative; aspect-ratio: 1 / 1;
  border: 3px dashed rgba(58,36,24,.35); border-radius: 16px;
  background:
    radial-gradient(circle at 50% 85%, rgba(255,197,61,.28), transparent 60%),
    var(--cream);
  display: grid; place-items: center;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
  cursor: pointer; overflow: hidden;
}
.slot.empty { color: rgba(58,36,24,.3); font-weight: 900; font-size: 22px; }
/* 长按交互：禁用文字选中与系统长按菜单 */
.slot { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.slot.empty:active { transform: scale(.96); }
.slot.has { border-style: solid; border-color: var(--ink); background: #FFF9E9; }

.chicken { line-height: 0; animation: bob 2.6s ease-in-out infinite; display: flex; align-items: center; justify-content: center; }
.chicken svg { width: 46px; height: 46px; }

/* SVG 图标内联对齐 */
.ico-inline { display: inline-flex; align-items: center; vertical-align: -3px; margin-right: 4px; }
.ico-inline svg { display: block; }
.egg-ico { display: inline-flex; align-items: center; margin-right: 4px; }
.chip .i { display: inline-flex; align-items: center; }
.pending { display: inline-flex; align-items: center; gap: 1px; }
.pending b { font-size: 9.5px; font-weight: 900; }
.pending svg { width: 8px; height: 10px; }
.sheet-h3 { display: flex; align-items: center; gap: 6px; }
.slot:nth-child(2n) .chicken { animation-delay: -.7s; }
.slot:nth-child(3n) .chicken { animation-delay: -1.4s; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-4px) rotate(1.5deg); } }

.lv {
  position: absolute; top: 4px; left: 4px;
  background: var(--ink); color: var(--amber);
  font-size: 9.5px; font-weight: 900; padding: 1.5px 6px; border-radius: 999px;
  letter-spacing: .4px;
}
.pending {
  position: absolute; top: 4px; right: 4px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 999px;
  font-size: 9.5px; font-weight: 900; padding: 1px 5px;
  font-variant-numeric: tabular-nums;
}
.pending.hot { background: var(--amber); animation: hot 1.4s ease-in-out infinite; }
@keyframes hot { 50% { transform: scale(1.1); } }
.slot .bar {
  position: absolute; bottom: 6px; left: 8px; right: 8px; height: 5px;
  background: rgba(58,36,24,.12); border-radius: 999px; overflow: hidden;
}
.slot .bar > i { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .3s; }

.slot.picked {
  border-color: var(--orange); background: #FFF0DC;
  box-shadow: inset 0 0 0 3px rgba(255,138,61,.35), 0 0 0 3px var(--orange);
  transform: translateY(-2px);
}
.slot.pop { animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.85); } 55% { transform: scale(1.08); } 100% { transform: scale(1); } }

/* ------------------------------ 按钮 ------------------------------ */
.btn-row { display: flex; gap: 9px; }
.btn {
  flex: 1; border: var(--line); border-radius: 14px; padding: 12px 10px;
  font-family: inherit; font-size: 14px; font-weight: 900; letter-spacing: .6px;
  color: var(--ink); background: var(--paper); box-shadow: var(--shadow-sm);
  cursor: pointer; transition: transform .08s ease, box-shadow .08s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 rgba(0,0,0,0); }
.btn.primary { background: var(--amber); }
.btn.green { background: var(--green); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.btn.orange { background: var(--orange); color: #fff; }
.btn.ghost { background: var(--cream); }
.btn.sm { padding: 8px 10px; font-size: 12px; border-width: 2.5px; border-radius: 11px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.wide { width: 100%; }

/* ------------------------------ 邀请 ------------------------------ */
.code-box {
  display: flex; align-items: center; gap: 10px;
  background: repeating-linear-gradient(135deg, #FFF6DD 0 10px, #FFEFC9 10px 20px);
  border: 3px dashed var(--ink); border-radius: 14px; padding: 12px;
}
.code {
  font-size: 26px; font-weight: 900; letter-spacing: 5px;
  font-family: "Cascadia Code", Consolas, monospace;
}
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  border: 2.5px solid var(--ink); border-radius: 12px; background: var(--cream);
  padding: 9px 6px; text-align: center;
}
.stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 10.5px; font-weight: 800; color: var(--ink-soft); }

.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 2.5px solid rgba(58,36,24,.22); border-radius: 12px;
  padding: 9px 11px; background: #FFFCF1; font-size: 12.5px;
}
.row .l { min-width: 0; }
.row .l b { font-size: 13px; }
.row .r { text-align: right; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-soft); font-weight: 700; font-size: 11px; }
.empty-tip { text-align: center; color: var(--ink-soft); font-weight: 700; font-size: 12px; padding: 16px 0; }

/* ------------------------------ 表单 ------------------------------ */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.field label { font-size: 11.5px; font-weight: 900; color: var(--ink-soft); letter-spacing: .4px; }
.input, select.input, textarea.input {
  width: 100%; border: 2.5px solid var(--ink); border-radius: 12px;
  background: var(--paper); padding: 11px 12px; font-family: inherit; font-size: 14px; font-weight: 700;
  color: var(--ink); outline: none;
}
.input:focus { box-shadow: 0 0 0 3px rgba(255,197,61,.55); }
textarea.input { resize: vertical; min-height: 76px; }

/* ------------------------------ 底部导航 ---------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 468px; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--paper); border-top: var(--line);
  padding: 7px 7px calc(7px + env(safe-area-inset-bottom));
}
.tabbar button {
  border: none; background: none; font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; border-radius: 12px; color: var(--ink-soft); font-weight: 900; font-size: 10.5px;
}
.tabbar button .ic { font-size: 19px; filter: grayscale(1) opacity(.55); transition: .15s; }
.tabbar button.on { color: var(--ink); }
.tabbar button.on .ic { filter: none; transform: translateY(-2px) scale(1.1); }
.tabbar button .dot {
  position: absolute; margin: -2px 0 0 18px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); border: 1.5px solid var(--paper); display: none;
}
.tabbar button.has-dot .dot { display: block; }

/* ------------------------------ 浮层 ------------------------------ */
.mask {
  position: fixed; inset: 0; z-index: 60; background: rgba(58,36,24,.55);
  display: none; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(2px);
}
.mask.show { display: flex; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 468px; background: var(--cream);
  border: var(--line); border-radius: 22px 22px 0 0; border-bottom: none;
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .24s cubic-bezier(.22,1.2,.36,1); max-height: 88vh; overflow: auto;
}
@keyframes up { from { transform: translateY(100%); } }
.sheet h3 { margin: 0 0 4px; font-size: 17px; font-weight: 900; letter-spacing: .4px; }
.sheet .sub { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); margin-bottom: 12px; }
.sheet-close {
  position: absolute; right: 16px; border: 2.5px solid var(--ink); background: var(--paper);
  width: 30px; height: 30px; border-radius: 50%; font-weight: 900; cursor: pointer;
  font-family: inherit; line-height: 1;
}

/* 登录 */
.login-wrap { padding: 26px 18px 40px; display: flex; flex-direction: column; gap: 14px; }
.logo {
  text-align: center; font-size: 30px; font-weight: 900; letter-spacing: 2px;
  color: var(--ink); text-shadow: 3px 3px 0 var(--amber);
}
.logo small { display: block; font-size: 11px; letter-spacing: 3px; color: var(--ink-soft); text-shadow: none; margin-top: 6px; }
.tabs2 { display: flex; border: var(--line); border-radius: 12px; overflow: hidden; background: var(--paper); }
.tabs2 button {
  flex: 1; padding: 10px; border: none; background: none; font-family: inherit;
  font-weight: 900; font-size: 13px; cursor: pointer; color: var(--ink-soft);
}
.tabs2 button.on { background: var(--amber); color: var(--ink); }

/* 悬浮动画元素 */
.floaty {
  position: fixed; z-index: 80; pointer-events: none; font-weight: 900; font-size: 18px;
  color: var(--green-deep); text-shadow: 0 2px 0 #fff; animation: floatUp .9s ease-out forwards;
}
@keyframes floatUp { 0% { opacity: 1; transform: translateY(0) scale(.9); } 100% { opacity: 0; transform: translateY(-64px) scale(1.25); } }

/* Toast */
#toast {
  position: fixed; left: 50%; top: 76px; transform: translate(-50%, -8px); z-index: 90;
  background: var(--ink); color: var(--paper); font-weight: 800; font-size: 13px;
  padding: 9px 16px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: .22s; max-width: 86%; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 封禁/冻结遮罩 */
.blocked {
  position: fixed; inset: 0; z-index: 95; background: rgba(58,36,24,.92);
  display: none; place-items: center; padding: 24px;
}
.blocked.show { display: grid; }
.blocked .box {
  background: var(--paper); border: var(--line); border-radius: 20px; padding: 22px;
  max-width: 340px; text-align: center; box-shadow: var(--shadow);
}
.blocked h2 { margin: 8px 0 6px; font-size: 19px; }
.blocked p { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); line-height: 1.6; }

/* 工单聊天 */
.chat { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 8px; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 13px; font-weight: 600; line-height: 1.55; border: 2.5px solid var(--ink); }
.msg.user { align-self: flex-end; background: var(--amber); border-bottom-right-radius: 3px; }
.msg.cs { align-self: flex-start; background: var(--paper); border-bottom-left-radius: 3px; }
.msg.system { align-self: center; background: var(--cream-2); font-size: 11.5px; border-style: dashed; max-width: 90%; text-align: center; }
.msg .t { display: block; font-size: 9.5px; font-weight: 800; color: var(--ink-soft); margin-top: 4px; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }

.scroll-y { overflow-y: auto; }

/* 收款方式 tab + 二维码上传 */
.pay-tabs { display: flex; gap: 8px; }
.pay-tabs button {
  flex: 1; border: 2.5px solid var(--ink); background: var(--paper); border-radius: 12px;
  padding: 10px; font-weight: 900; font-family: inherit; font-size: 13px; cursor: pointer;
  color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: .12s;
}
.pay-tabs button.on { background: var(--amber); }
.qr-pick {
  border: 2.5px dashed var(--ink); border-radius: 14px; background: var(--cream);
  min-height: 118px; display: grid; place-items: center; cursor: pointer; overflow: hidden;
}
.qr-empty { text-align: center; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ink-soft); }
.qr-empty b { font-size: 13.5px; color: var(--ink); }
.qr-empty small { font-size: 11px; font-weight: 700; }
.qr-prev { width: 100%; max-height: 190px; object-fit: contain; background: #fff; }

/* 兑换滑块 */
.range { width: 100%; accent-color: var(--orange); }

@media (max-width: 380px) {
  .chicken { font-size: 29px; }
  .code { font-size: 22px; letter-spacing: 3px; }
}

/* ============================ 进游戏公告 ============================ */
.announce {
  position: fixed; inset: 0; z-index: 96; display: none;
  align-items: center; justify-content: center; padding: 22px;
  background: rgba(58,36,24,.62); backdrop-filter: blur(3px);
}
.announce.show { display: flex; animation: fadeIn .2s ease; }
.announce-card {
  width: 100%; max-width: 360px; background: var(--paper);
  border: 3px solid var(--ink); border-radius: 20px; overflow: hidden;
  box-shadow: 6px 6px 0 rgba(58,36,24,.85);
  animation: annPop .28s cubic-bezier(.22,1.3,.4,1);
}
@keyframes annPop { from { transform: scale(.92) translateY(10px); opacity: 0; } }
.announce-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; font-size: 16px; font-weight: 900; letter-spacing: .5px;
  background: linear-gradient(180deg, var(--amber), var(--amber-deep));
  border-bottom: 3px solid var(--ink);
}
.announce-ico { display: inline-flex; }
.announce-body {
  padding: 16px; max-height: 46vh; overflow: auto;
  font-size: 13.5px; font-weight: 700; line-height: 1.85; color: var(--ink);
  white-space: pre-wrap; word-break: break-word;
  background: repeating-linear-gradient(180deg, #FFFCF1 0 34px, #FFF9E6 34px 68px);
}
.announce-foot {
  display: flex; gap: 8px; padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  border-top: 2.5px dashed rgba(58,36,24,.35);
}
.announce-foot .btn { flex: 1; }
/* ============================ 悬浮客服按钮 ============================ */
.fab-cs {
  position: fixed;
  right: max(16px, calc(50vw - 236px + 16px));
  bottom: calc(80px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  border: 3px solid var(--ink);
  background: linear-gradient(180deg, #FFD166 0%, #F2A93B 100%);
  box-shadow: 4px 4px 0 rgba(58, 36, 24, .85);
  display: grid; place-items: center; padding: 0; cursor: pointer;
  z-index: 26; transition: transform .1s ease, box-shadow .1s ease;
  animation: fabBob 3.2s ease-in-out infinite;
}
.fab-cs:active { transform: translate(3px, 3px); box-shadow: 0 0 0 rgba(0,0,0,0); }
.fab-cs { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.fab-cs.dragging {
  animation: none; transform: scale(1.08); cursor: grabbing;
  box-shadow: 7px 7px 0 rgba(58,36,24,.9);
  transition: none;
}
.fab-cs svg { display: block; }
@keyframes fabBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.fab-cs .fab-dot {
  position: absolute; top: -6px; right: -6px;
  min-width: 21px; height: 21px; padding: 0 5px;
  border-radius: 999px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 900; line-height: 17px;
  border: 2px solid var(--paper); display: none; font-family: inherit;
}
.fab-cs .fab-dot.show { display: block; }
/* ============================ 头像选择 ============================ */
.avatar { cursor: pointer; transition: transform .1s ease; overflow: hidden; }
.avatar:active { transform: scale(.94); }
.avatar .av-img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 11px; }
.avatar svg { display: block; }

.av-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
}
.av-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px 6px; border: 2.5px solid rgba(58,36,24,.25); border-radius: 14px;
  background: var(--paper); cursor: pointer; font-family: inherit;
  transition: .12s;
}
.av-item small { font-size: 9.5px; font-weight: 900; color: var(--ink-soft); letter-spacing: .2px; }
.av-item.on {
  border-color: var(--ink); background: #FFF3D0;
  box-shadow: 3px 3px 0 rgba(58,36,24,.75); transform: translateY(-2px);
}
.av-item.on small { color: var(--ink); }