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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #eaf3ff;
  color: #33405a;
  user-select: none;
  -webkit-user-select: none;
}

#app { position: relative; width: 100%; height: 100%; }

[hidden] { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ============ 通用视图 ============ */
.view { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; }

/* ============ 首页 ============ */
.home-view { justify-content: center; align-items: center; padding: 24px; gap: 12px; max-width: 520px; margin: 0 auto; }
.home-icon { font-size: 70px; line-height: 1; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.12)); }
.home-title { font-size: 34px; font-weight: 800; letter-spacing: 4px; text-align: center; }
.home-sub { font-size: 14px; color: #8b98b0; margin-bottom: 4px; text-align: center; }

.home-stats, .home-stats2 { display: flex; gap: 10px; width: 100%; max-width: 440px; }
.hstat { flex: 1; background: #fff; border-radius: 14px; padding: 10px 8px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.05); min-width: 0; }
.hstat-label { display: block; font-size: 12px; color: #8b98b0; }
.hstat-val { display: block; font-size: 16px; font-weight: 700; margin-top: 2px; white-space: nowrap; }

.home-btns { display: flex; flex-direction: column; gap: 11px; width: 100%; max-width: 300px; margin-top: 6px; }
.home-foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.home-tip { font-size: 12px; color: #aab4c8; }

/* ============ 按钮 ============ */
.btn {
  display: block; width: 100%; padding: 13px 16px; font-size: 16px; font-weight: 600;
  border-radius: 12px; background: #fff; color: #33405a;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08); transition: transform .05s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #4a8cff; color: #fff; }
.btn-big { font-size: 19px; padding: 15px 16px; }
.btn.ghost { background: transparent; box-shadow: none; border: 1px solid #d6deea; color: #7a869c; }

.btn-mini { padding: 7px 11px; font-size: 13px; border-radius: 9px; background: #fff; box-shadow: 0 1px 5px rgba(0,0,0,0.08); border: 1px solid #e2e9f4; }

/* ============ 游戏页 ============ */
.game-view { max-width: 1200px; margin: 0 auto; }

.hud {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 8px; gap: 6px;
}
.hud-cell { display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0; justify-content: center; }
.hud-cell.hud-r { flex: 0 0 auto; justify-content: flex-end; gap: 8px; }
.hud-label { font-size: 11px; color: #8b98b0; white-space: nowrap; }
.hud-num { font-size: 17px; font-weight: 800; white-space: nowrap; }
.hud2 { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 0 14px 6px; min-height: 20px; }
.hud-row2 { display: flex; width: 100%; justify-content: center; gap: 28px; }
.hud-row2 .hud-cell { flex: 0 0 auto; }
.hud-buff { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.buff-chip {
  font-size: 12px; font-weight: 700; color: #b8860b; background: #fff8e6;
  border: 1px solid #f0d9a8; border-radius: 10px; padding: 3px 9px; white-space: nowrap;
}

/* 金币图标（CSS 绘制） */
.coin {
  display: inline-block; width: 15px; height: 15px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a3, #f6b73c 55%, #d99a1e);
  border: 2px solid #b97e10; box-shadow: inset 0 -2px 3px rgba(0,0,0,0.22);
  vertical-align: -2px; flex-shrink: 0;
}
/* 红心（CSS 绘制，不依赖 emoji 字体） */
.heart { display: inline-block; color: #ff5b6a; font-size: 15px; transform: scale(1.15); }

.game-mid { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: center; padding: 0 10px; }
#game-wrap {
  position: relative; width: 100%; max-width: 900px; aspect-ratio: 2.11 / 1;
  margin: 0 auto; background: #e8f4ff; border-radius: 14px;
  box-shadow: inset 0 0 0 2px #d6e6f7, 0 6px 18px rgba(0,0,0,0.06);
  overflow: hidden; flex-shrink: 0;
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.touch-hint {
  position: absolute; left: 0; right: 0; bottom: 14px; text-align: center;
  font-size: 13px; color: #9db1cc; pointer-events: none; animation: hintFade 3s ease forwards;
}
@keyframes hintFade { 0%{opacity:1} 70%{opacity:1} 100%{opacity:0} }

/* ============ 覆盖层 ============ */
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(20,35,60,0.45); z-index: 20; padding: 20px;
}
.confirm-mask { z-index: 60; }
.overlay-card {
  background: #fff; border-radius: 18px; padding: 24px 26px; width: 100%; max-width: 340px;
  text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.ov-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.ov-big { font-size: 20px; margin-bottom: 4px; }
.ov-big b { font-size: 30px; color: #4a8cff; }
.ov-new { color: #e09a1c; font-weight: 800; margin: 6px 0; animation: glow 0.8s ease infinite alternate; }
@keyframes glow { from { opacity: .6; } to { opacity: 1; } }
.ov-score { color: #8b98b0; margin-bottom: 12px; }
.ov-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed #e2e9f4; font-size: 15px; }
.ov-row:last-child { border-bottom: none; }
.ov-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

.count-num { font-size: 90px; font-weight: 900; color: #fff; text-shadow: 0 4px 20px rgba(0,0,0,0.4); }

/* ============ 列表页 ============ */
.page-view { max-width: 480px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; gap: 10px; flex-shrink: 0; }
.page-title { font-size: 18px; font-weight: 800; }
.page-coins { font-size: 15px; font-weight: 700; color: #b8860b; }

/* ============ 商店 ============ */
.shop-list { flex: 1; overflow-y: auto; min-height: 0; padding: 4px 14px 24px; display: flex; flex-direction: column; gap: 10px; }
.shop-row { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 14px; padding: 12px 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.shop-icon { font-size: 30px; flex-shrink: 0; }
.shop-info { flex: 1; min-width: 0; }
.shop-name { font-weight: 700; font-size: 15px; }
.shop-desc { font-size: 12px; color: #8b98b0; margin-top: 2px; line-height: 1.4; }
.shop-buy { flex-shrink: 0; padding: 9px 12px; border-radius: 10px; font-size: 13px; font-weight: 700; background: #4a8cff; color: #fff; min-width: 82px; }
.shop-buy:disabled { background: #e3e9f2; color: #a0aabe; cursor: default; }
.shop-buy.owned { background: #f3f0ff; color: #7b5fe0; border: 1px solid #dcd3f5; }

/* ============ 排行榜 ============ */
.tabs { display: flex; gap: 8px; padding: 6px 14px; flex-shrink: 0; }
.tab, .ptab { flex: 1; padding: 9px 6px; border-radius: 10px; font-size: 14px; font-weight: 600; background: #fff; color: #8b98b0; border: 1px solid #e2e9f4; }
.tab.active { background: #4a8cff; color: #fff; border-color: #4a8cff; }
.ptab { flex: 0 0 auto; padding: 7px 14px; font-size: 13px; }
.ptab.active { background: #33405a; color: #fff; border-color: #33405a; }

.lb-note { padding: 4px 16px 2px; font-size: 12px; color: #8b98b0; flex-shrink: 0; }
.lb-body { flex: 1; overflow-y: auto; min-height: 0; padding: 4px 14px 24px; }
.lb-tip { text-align: center; color: #aab4c8; padding: 30px 0; font-size: 14px; }
.lb-row { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 9px 12px; margin-bottom: 8px; box-shadow: 0 1px 5px rgba(0,0,0,0.04); }
.lb-rank { width: 30px; font-weight: 800; color: #a0aabe; text-align: center; flex-shrink: 0; }
.lb-rank.top { color: #e09a1c; }
.lb-user { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.lb-avatar { width: 26px; height: 26px; border-radius: 50%; background: #e2e9f4; flex-shrink: 0; }
.lb-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.lb-score { font-weight: 700; font-size: 14px; flex-shrink: 0; }

/* ============ 设置 ============ */
.set-body { flex: 1; overflow-y: auto; min-height: 0; padding: 4px 18px 30px; }
.set-sec { background: #fff; border-radius: 14px; padding: 16px; box-shadow: 0 1px 5px rgba(0,0,0,0.04); margin-bottom: 12px; }
.set-sec h3 { font-size: 16px; margin-bottom: 10px; }
.set-desc { font-size: 13px; color: #8b98b0; line-height: 1.7; margin-bottom: 12px; }
.sync-tip { font-size: 12px; color: #7b5fe0; margin-top: 10px; min-height: 16px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; }
.switch-label { font-size: 15px; }
.switch { position: relative; width: 50px; height: 28px; appearance: none; -webkit-appearance: none; background: #d6deea; border-radius: 14px; outline: none; cursor: pointer; transition: background .2s; flex-shrink: 0; }
.switch::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.2); transition: transform .2s;
}
.switch:checked { background: #4a8cff; }
.switch:checked::after { transform: translateX(22px); }

/* ============ 角色颜色 ============ */
.color-preview-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.color-preview {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid #e6e1d4; box-shadow: inset 0 -5px 10px rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.color-hex { font-weight: 700; font-size: 15px; color: #5a564c; }
.color-presets { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.color-swatch {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid #e0dac8; cursor: pointer; transition: transform .06s;
}
.color-swatch:active { transform: scale(0.92); }
.color-swatch.active { border: 3px solid #33405a; transform: scale(1.12); }
.color-custom-row { display: flex; align-items: center; gap: 10px; }
.color-custom-label { font-size: 14px; color: #8b98b0; white-space: nowrap; }
#color-input {
  width: 46px; height: 34px; border: 1px solid #e0dac8; border-radius: 8px;
  padding: 2px; background: #fff; cursor: pointer;
}

/* ============ 说明 ============ */
.help-body { flex: 1; overflow-y: auto; min-height: 0; padding: 4px 18px 30px; }
.help-sec { background: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; box-shadow: 0 1px 5px rgba(0,0,0,0.04); }
.help-sec h3 { font-size: 16px; margin-bottom: 8px; }
.help-sec p { font-size: 13.5px; color: #5a6678; line-height: 1.7; margin-bottom: 4px; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; top: 14%; transform: translateX(-50%); max-width: 82%;
  background: rgba(0,0,0,0.82); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; line-height: 1.5; text-align: center; z-index: 80; transition: opacity .4s; pointer-events: none;
}

/* ============ 桌面端 ============ */
@media (min-width: 900px) and (pointer: fine) {
  .home-view { max-width: 560px; }
  .hud { padding: 12px 20px; }
  .hud-num { font-size: 22px; }
  .hud-label { font-size: 12px; }
  #game-wrap { border-radius: 18px; }
}
