/* === 花钱模拟器 v7.0 — 金色奢华主题 === */
* { margin:0; padding:0; box-sizing:border-box; }
:root {
  --bg-dark: #0f1923;
  --bg-card: rgba(255,255,255,0.06);
  --bg-card-hover: rgba(255,255,255,0.10);
  --gold: #f5c518;
  --gold-dim: #c9a000;
  --gold-glow: rgba(245,197,24,0.3);
  --green: #00d26a;
  --red: #ff4757;
  --blue: #4facfe;
  --text: #e8e8e8;
  --text-dim: #8899aa;
  --text-muted: #556677;
  --border: rgba(255,255,255,0.08);
  --radius: 14px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-dark);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(15,52,96,0.6) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(100,60,180,0.15) 0%, transparent 50%);
  min-height: 100vh;
  color: var(--text);
  padding-bottom: 80px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow-x: hidden;
}
#app { max-width: 520px; margin: 0 auto; position: relative; }

/* ===== 背景粒子 ===== */
#particles {
  position: fixed; top:0; left:0; right:0; bottom:0;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.particle {
  position: absolute; width: 3px; height: 3px;
  background: var(--gold); border-radius: 50%;
  opacity: 0; animation: floatUp linear infinite;
}
@keyframes floatUp {
  0% { opacity:0; transform:translateY(100vh) scale(0.5); }
  10% { opacity:0.6; }
  90% { opacity:0.3; }
  100% { opacity:0; transform:translateY(-10vh) scale(1.2); }
}

/* ===== Header ===== */
#header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(180deg, rgba(15,25,35,0.98) 0%, rgba(15,25,35,0.92) 100%);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
}

/* Level Bar */
.level-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px; padding: 6px 12px;
  background: rgba(245,197,24,0.08);
  border: 1px solid rgba(245,197,24,0.15);
  border-radius: 10px;
}
#levelDisplay { font-size: 13px; font-weight: 600; white-space: nowrap; }
.lv-icon { font-size: 18px; }
.lv-name { font-weight: 700; }
.rep-bar-wrap {
  flex: 1; height: 6px; background: rgba(255,255,255,0.08);
  border-radius: 3px; overflow: hidden; min-width: 50px;
}
.rep-bar {
  height: 100%; width: 0; border-radius: 3px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width 0.5s ease;
  box-shadow: 0 0 8px var(--gold-glow);
}
.rep-text { font-size: 10px; color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Budget Display */
.budget-display { text-align: center; margin: 8px 0; }
.budget-label { font-size: 11px; color: var(--text-dim); letter-spacing: 2px; text-transform: uppercase; }
.budget-amount {
  font-size: 36px; font-weight: 800; color: var(--gold);
  text-shadow: 0 0 30px var(--gold-glow), 0 2px 4px rgba(0,0,0,0.3);
  transition: color 0.3s, transform 0.15s;
  font-variant-numeric: tabular-nums;
}
.budget-amount.flash-earn { animation: flashEarn 0.5s ease; }
.budget-amount.flash-burn { animation: flashBurn 0.5s ease; }
@keyframes flashEarn {
  0% { transform:scale(1); filter:brightness(1); }
  50% { transform:scale(1.06); filter:brightness(1.5); color:var(--green); }
  100% { transform:scale(1); filter:brightness(1); }
}
@keyframes flashBurn {
  0% { transform:scale(1); filter:brightness(1); }
  50% { transform:scale(1.06); filter:brightness(1.3); color:var(--red); }
  100% { transform:scale(1); filter:brightness(1); }
}

/* Interest floating number */
.interest-float {
  position: absolute; left: 50%; transform: translateX(-50%);
  color: var(--gold); font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none;
  animation: floatNumber 2s ease-out forwards;
}
@keyframes floatNumber {
  0% { opacity:1; transform:translateX(-50%) translateY(0); }
  100% { opacity:0; transform:translateX(-50%) translateY(-40px); }
}

/* Stats */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 4px; margin-bottom: 8px;
}
.stat {
  text-align: center; padding: 4px 2px;
  background: var(--bg-card); border-radius: 8px;
}
.stat-label { display: block; font-size: 9px; color: var(--text-muted); margin-bottom: 1px; }
.stat-value { font-size: 12px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* Progress Bar */
.progress-bar {
  position: relative; height: 20px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%; border-radius: 10px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width 0.3s;
  box-shadow: 0 0 12px var(--gold-glow);
  position: relative;
}
.progress-fill::after {
  content: ''; position: absolute; top:0; left:0; right:0; bottom:0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  animation: shimmer 2s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.progress-text {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-size: 10px; font-weight: 700; color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* ===== Categories ===== */
#categories {
  display: flex; gap: 6px; padding: 10px 12px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; margin: 0;
}
#categories::-webkit-scrollbar { display: none; }
.cat-btn {
  padding: 6px 14px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-dim);
  border-radius: 20px; font-size: 12px; cursor: pointer;
  white-space: nowrap; transition: all 0.2s; flex-shrink: 0;
}
.cat-btn.active {
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  color: #1a1a2e; border-color: var(--gold); font-weight: 700;
  box-shadow: 0 0 12px var(--gold-glow);
}
.cat-count {
  display: inline-block; background: var(--red); color: white;
  font-size: 9px; min-width: 14px; height: 14px; line-height: 14px;
  border-radius: 7px; text-align: center; margin-left: 3px; padding: 0 3px;
}

.tip {
  text-align: center; padding: 6px 12px;
  font-size: 10px; color: var(--text-muted);
}

/* ===== Item Grid ===== */
.item-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px; padding: 0 10px 10px;
}
.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 8px 10px;
  transition: all 0.2s; user-select: none; -webkit-user-select: none;
  position: relative; overflow: hidden;
}
.item-card::before {
  content: ''; position: absolute; top:0; left:0; right:0; height: 2px;
  background: transparent; transition: background 0.3s;
}
.item-card.bought {
  border-color: var(--gold);
  background: rgba(245,197,24,0.05);
  box-shadow: 0 0 15px rgba(245,197,24,0.08);
}
.item-card.bought::before { background: var(--gold); }
.item-card.cant-afford { opacity: 0.35; }
.item-card.has-income-pos::before { background: var(--green); }
.item-card.has-income-neg::before { background: var(--red); }
.item-card.bought.has-income-pos { border-color: var(--green); box-shadow: 0 0 12px rgba(0,210,106,0.1); }
.item-card.bought.has-income-neg { border-color: var(--red); box-shadow: 0 0 12px rgba(255,71,87,0.1); }

/* Locked */
.item-card.locked {
  opacity: 0.3; background: rgba(255,255,255,0.02);
  border-color: transparent;
}
.lock-req {
  font-size: 9px; text-align: center; color: var(--gold);
  font-weight: 600; margin-top: 4px; padding: 2px 6px;
  background: rgba(245,197,24,0.1); border-radius: 6px;
}

.item-emoji { font-size: 32px; text-align: center; line-height: 1.1; }
.item-name {
  font-size: 11px; font-weight: 600; text-align: center;
  margin: 3px 0 2px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-price {
  font-size: 14px; font-weight: 700; text-align: center;
  color: var(--gold); margin-bottom: 3px;
}

/* Tags */
.item-tags { text-align: center; margin-bottom: 2px; min-height: 14px; }
.tag {
  display: inline-block; font-size: 9px; padding: 1px 6px;
  border-radius: 8px; font-weight: 500;
}
.tag-earn { background: rgba(0,210,106,0.15); color: var(--green); }
.tag-burn { background: rgba(255,71,87,0.15); color: var(--red); }
.craft-time { font-size: 9px; text-align: center; color: var(--text-muted); margin-bottom: 3px; }
.item-flavor {
  font-size: 9px; text-align: center; color: var(--text-muted);
  margin-bottom: 4px; display: none;
}
.item-card:hover .item-flavor, .item-card.bought .item-flavor { display: block; }

/* Controls */
.item-controls { display: flex; align-items: center; justify-content: center; gap: 6px; }
.item-btn {
  width: 30px; height: 30px; border: none;
  border-radius: 50%; font-size: 16px; line-height: 30px;
  text-align: center; cursor: pointer; transition: all 0.15s;
  -webkit-appearance: none;
}
.item-btn.buy-btn {
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  color: #1a1a2e; font-weight: 700;
}
.item-btn.sell-btn {
  background: rgba(255,255,255,0.1); color: var(--text-dim);
  border: 1px solid var(--border);
}
.item-btn:active:not(:disabled) { transform: scale(0.88); }
.item-btn:disabled { background: rgba(255,255,255,0.04); color: var(--text-muted); cursor: not-allowed; opacity: 0.4; border: none; }
.item-count {
  min-width: 28px; text-align: center; font-weight: 700;
  font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums;
}
.item-count small { display: block; font-size: 9px; color: var(--gold); }

/* Batch */
.batch-btns { display: flex; gap: 3px; justify-content: center; margin-top: 4px; }
.batch-btn {
  padding: 2px 8px; border: 1px solid rgba(245,197,24,0.3);
  background: transparent; color: var(--gold);
  border-radius: 6px; font-size: 10px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.batch-btn:active:not(:disabled) { background: var(--gold); color: #1a1a2e; }
.batch-btn:disabled { border-color: var(--border); color: var(--text-muted); cursor: not-allowed; }

/* ===== Footer ===== */
#footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(15,25,35,0.98);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 8px 12px; display: flex; justify-content: space-around;
  border-top: 1px solid var(--border); z-index: 100;
}
.footer-btn {
  flex: 1; margin: 0 2px; padding: 8px 4px; border: none;
  background: var(--bg-card); color: var(--text-dim);
  border-radius: 10px; font-size: 11px; font-weight: 600;
  cursor: pointer; position: relative; transition: all 0.2s;
  border: 1px solid var(--border);
}
.footer-btn:active { background: var(--bg-card-hover); color: var(--gold); }
.badge {
  position: absolute; top: -4px; right: -2px;
  background: var(--red); color: white;
  font-size: 9px; min-width: 16px; height: 16px; line-height: 16px;
  border-radius: 8px; text-align: center;
  animation: badgePulse 2s infinite;
}
@keyframes badgePulse {
  0%,100% { transform:scale(1); }
  50% { transform:scale(1.15); }
}
.version-tag { text-align: center; font-size: 9px; color: var(--text-muted); padding: 4px 0 8px; opacity: 0.5; }

/* ===== Toast ===== */
.toast-container {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  z-index: 2000; width: 92%; max-width: 420px; pointer-events: none;
}
.toast {
  padding: 10px 16px; margin: 6px 0; border-radius: 12px;
  font-size: 13px; font-weight: 500; opacity: 0;
  transform: translateY(-20px); transition: all 0.3s;
  pointer-events: auto; backdrop-filter: blur(10px);
  border: 1px solid var(--border);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-info { background: rgba(79,172,254,0.9); color: white; }
.toast-success { background: rgba(0,210,106,0.9); color: white; }
.toast-earn { background: rgba(0,210,106,0.9); color: white; }
.toast-burn { background: rgba(255,71,87,0.9); color: white; }
.toast-milestone {
  background: linear-gradient(135deg, rgba(245,197,24,0.95), rgba(201,160,0,0.95));
  color: #1a1a2e; font-weight: 700; font-size: 14px;
  text-align: center; padding: 14px;
  box-shadow: 0 4px 20px var(--gold-glow);
  border-color: var(--gold);
}

/* ===== Modals ===== */
.modal {
  position: fixed; top:0; left:0; right:0; bottom:0;
  background: rgba(0,0,0,0.7); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fadeIn 0.2s;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.modal-content {
  background: #1a2332; border: 1px solid var(--border);
  border-radius: 20px; max-width: 480px; width: 100%;
  max-height: 80vh; overflow: hidden;
  display: flex; flex-direction: column;
  animation: slideUp 0.25s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
@keyframes slideUp { from{transform:translateY(30px);opacity:0} to{transform:translateY(0);opacity:1} }
.modal-header {
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { font-size: 16px; margin: 0; color: var(--gold); }
.modal-header small { color: var(--text-muted); margin-left: 8px; }
.modal-close { border: none; background: none; font-size: 26px; cursor: pointer; color: var(--text-dim); }
.modal-body {
  padding: 14px 18px; overflow-y: auto; flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* Queue */
.queue-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.queue-info { font-size: 13px; min-width: 100px; color: var(--text); }
.queue-bar { flex: 1; height: 6px; background: rgba(255,255,255,0.06); border-radius: 3px; overflow: hidden; }
.queue-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width 0.5s linear;
}
.queue-time { font-size: 12px; color: var(--text-dim); min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.queue-cancel {
  border: none; background: var(--red); color: white;
  width: 28px; height: 28px; border-radius: 14px;
  font-size: 13px; cursor: pointer; flex-shrink: 0;
}
.empty { text-align: center; color: var(--text-muted); padding: 30px 20px; }

/* Events */
.event-item {
  display: flex; gap: 8px; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.ev-time { color: var(--text-muted); min-width: 40px; font-variant-numeric: tabular-nums; }
.ev-text { flex: 1; color: var(--text-dim); }
.ev-amount { font-weight: 600; min-width: 80px; text-align: right; }
.ev-earn .ev-amount { color: var(--green); }
.ev-burn .ev-amount { color: var(--red); }

/* Receipt */
.receipt-item {
  display: flex; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px;
  color: var(--text);
}
.receipt-item.crafting { color: var(--gold); font-style: italic; }
.receipt-section { font-size: 13px; font-weight: 600; color: var(--gold); padding: 12px 0 4px; }
.receipt-returns { font-size: 14px; color: var(--green); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.receipt-total {
  font-size: 16px; font-weight: 700; color: var(--gold);
  margin-top: 8px; padding-top: 8px;
  border-top: 2px solid var(--gold-dim); text-align: right;
}

/* Leaderboard */
.leaderboard-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.leaderboard-rank { font-weight: 700; color: var(--gold); min-width: 50px; }
.leaderboard-name { flex: 1; color: var(--text); }
.leaderboard-name .lb-level { display: block; font-size: 10px; color: var(--text-muted); }
.leaderboard-time { color: var(--green); font-weight: 600; }

/* Complete */
.complete-content { text-align: center; padding: 36px 20px; }
.complete-content h2 { font-size: 22px; margin-bottom: 14px; color: var(--gold); }
.complete-content p { margin: 6px 0; color: var(--text-dim); font-size: 14px; }

/* Tutorial */
.tutorial-content { text-align: center; padding: 30px 24px; }
.tutorial-content h2 { font-size: 22px; margin-bottom: 16px; color: var(--gold); }
.tutorial-body { text-align: left; margin-bottom: 20px; }
.tutorial-body p { margin: 10px 0; font-size: 14px; line-height: 1.6; color: var(--text-dim); }
.tutorial-body b { color: var(--gold); }
.tutorial-start { width: 100%; padding: 14px; font-size: 16px; }

/* Buttons */
.complete-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-primary, .btn-secondary {
  flex: 1; padding: 12px; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  color: #1a1a2e;
}
.btn-secondary { background: rgba(255,255,255,0.1); color: var(--text); border: 1px solid var(--border); }

/* ===== Responsive ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #footer { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  body { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (max-width: 768px) {
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; padding: 0 8px 8px; }
  .budget-amount { font-size: 30px; }
}
@media (max-width: 360px) {
  .item-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 难度选择 ===== */
.diff-btn {
  padding: 10px 8px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-dim);
  border-radius: 10px; font-size: 14px; cursor: pointer;
  transition: all 0.2s; line-height: 1.3;
}
.diff-btn small { font-size: 10px; color: var(--text-muted); }
.diff-btn.active {
  border-color: var(--gold); background: rgba(245,197,24,0.1);
  color: var(--gold); box-shadow: 0 0 12px var(--gold-glow);
}

/* ===== 购买金币粒子 ===== */
.coin-particle {
  position: fixed; z-index: 3000; pointer-events: none;
  font-size: 18px; transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  opacity: 1;
}

/* ===== 升级全屏动画 ===== */
.levelup-overlay {
  position: fixed; top:0; left:0; right:0; bottom:0;
  z-index: 5000; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(245,197,24,0.15) 0%, transparent 70%);
  opacity: 0; transition: opacity 0.4s;
}
.levelup-overlay.show { opacity: 1; }
.levelup-content { text-align: center; }
.levelup-icon {
  font-size: 64px; animation: levelBounce 0.6s ease;
  filter: drop-shadow(0 0 20px rgba(245,197,24,0.6));
}
@keyframes levelBounce {
  0% { transform: scale(0) rotate(-20deg); }
  50% { transform: scale(1.3) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}
.levelup-text {
  font-size: 14px; color: var(--gold); letter-spacing: 4px;
  text-transform: uppercase; margin-top: 8px;
  text-shadow: 0 0 20px var(--gold-glow);
}
.levelup-name {
  font-size: 28px; font-weight: 800; color: white;
  margin-top: 4px; text-shadow: 0 0 30px var(--gold-glow), 0 2px 4px rgba(0,0,0,0.5);
  animation: nameGlow 1.5s ease infinite alternate;
}
@keyframes nameGlow {
  from { text-shadow: 0 0 20px var(--gold-glow); }
  to { text-shadow: 0 0 40px var(--gold-glow), 0 0 60px rgba(245,197,24,0.2); }
}

/* ===== 烟花画布 ===== */
.fireworks-canvas {
  position: fixed; top:0; left:0; z-index: 4000;
  pointer-events: none; width: 100vw; height: 100vh;
}

/* ===== 购买卡片弹跳 ===== */
.item-card.bounce { animation: cardBounce 0.3s ease; }
@keyframes cardBounce {
  0% { transform: scale(1); }
  40% { transform: scale(0.92); }
  70% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
