:root {
  --bg: #f4f1e6;
  --card: #fffdf7;
  --ink: #24211c;
  --muted: #6f685c;
  --border: #2c2822;
  --shadow: #2c2822;
  --primary: #e86a33;
  --primary-dark: #c94e1b;
  --green: #3c9d5c;
  --blue: #2f7ed8;
  --gold: #d99b1a;
  --purple: #7d56c2;
  --danger: #d64545;
  --soft: #ece6d5;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: radial-gradient(circle at top, #fbf8ef 0%, var(--bg) 70%);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  line-height: 1.45;
}
.hidden { display: none !important; }

.app-shell {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

/* Pixel Card & Buttons */
.pixel-card {
  background: var(--card);
  border: 2.5px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 0 var(--shadow);
  padding: 12px;
}

.pix-btn {
  appearance: none;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 12px;
  box-shadow: 0 3px 0 var(--shadow);
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.pix-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--shadow);
}
.pix-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.pix-btn.primary { background: var(--primary); color: #fff; }
.pix-btn.green { background: var(--green); color: #fff; }
.pix-btn.blue { background: var(--blue); color: #fff; }
.pix-btn.purple { background: var(--purple); color: #fff; }
.pix-btn.danger { background: var(--danger); color: #fff; }
.pix-btn.small { padding: 4px 9px; font-size: 12px; box-shadow: 0 2px 0 var(--shadow); }
.pix-btn.full { width: 100%; }
.pix-btn.active { background: var(--ink); color: #fff; }

/* Auth */
.auth-view {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card { width: 100%; }
.auth-hero { text-align: center; margin-bottom: 14px; }
.auth-hero h1 { margin: 8px 0 4px; font-size: 22px; }
.hero-sprite {
  width: 96px;
  height: 96px;
  object-fit: contain;
  image-rendering: pixelated;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 6px;
}
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.field input {
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
  background: #fff;
}
.error-box {
  background: #fdeaea;
  border: 2px solid var(--danger);
  color: #a82222;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
}

/* Header & Bottom Nav */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--card);
  border-bottom: 2.5px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.top-user { display: flex; align-items: center; justify-content: space-between; }
.currency-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.coin-pill, .dia-pill, .pts-pill {
  font-size: 12px;
  background: var(--soft);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
}

.content {
  padding: 12px 12px 84px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-top: 2.5px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px;
  z-index: 25;
}
.nav-btn {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}
.nav-btn span { font-size: 18px; }
.nav-btn small { font-size: 11px; }
.nav-btn.active { color: var(--primary-dark); }

/* Common layout helpers */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 12px; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--soft);
}
.badge.el-火 { background: #ffe4d6; color: #b53312; }
.badge.el-水 { background: #dcefff; color: #165aa8; }
.badge.el-草 { background: #dcf5e3; color: #1d753b; }
.badge.el-雷 { background: #fff4cc; color: #9c6b00; }
.badge.el-岩 { background: #ece3d5; color: #6e4e2a; }
.badge.el-风 { background: #dcf7f2; color: #15756b; }
.badge.el-冰 { background: #e3f5ff; color: #1b6d96; }
.badge.el-光 { background: #f4e8ff; color: #6d3aa8; }

.rarity-普通 { background: #eef0f2; color: #4a5568; }
.rarity-稀有 { background: #dff1ff; color: #1b63b0; }
.rarity-史诗 { background: #efe3ff; color: #6f35b8; }
.rarity-传说 { background: #fff0c2; color: #a86400; }

/* Sprites */
.sprite-box {
  width: 76px;
  height: 76px;
  flex-shrink: 0;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
.sprite-box.lg { width: 104px; height: 104px; }
.sprite-box.sm { width: 52px; height: 52px; }
.sprite-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.sprite-img.locked { filter: brightness(0.15) opacity(0.35); }

.evo-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.evo-node {
  background: var(--soft);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 4px;
  text-align: center;
}
.evo-node.current {
  background: #fff3d6;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.evo-node .sprite-box {
  width: 58px;
  height: 58px;
  margin: 0 auto 4px;
}
.evo-node .evo-tag {
  font-size: 10px;
  color: var(--muted);
}
.evo-node .evo-name {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Grids */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 6px; }
.stat-cell {
  background: var(--soft);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  text-align: center;
  padding: 4px 2px;
  font-size: 11px;
}
.stat-cell b { display: block; font-size: 14px; }

.sub-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.sub-tabs .pix-btn { white-space: nowrap; }

.progress-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.prog-item {
  background: var(--soft);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
}

.pre-text {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.55;
  background: var(--soft);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin: 0;
}

/* Modal & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, 0.55);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  width: 100%;
  max-width: 440px;
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }

.toast {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--ink);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
