:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-card: #1a1a28;
  --bg-hover: #22223a;
  --border: #2a2a3a;
  --border-focus: #00d4ff;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #555570;
  --accent: #00d4ff;
  --accent-dim: #0099cc;
  --danger: #ff6b6b;
  --success: #36d399;
  --warning: #ffd700;
  --gold: #ffd700;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.003em; }
h2 { font-size: 20px; font-weight: 600; margin-bottom: 12px; }
h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
p { font-size: 14px; color: var(--text-secondary); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: all var(--transition);
  margin-bottom: 12px;
}
.card:hover { border-color: var(--accent-dim); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent-dim); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #000; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-gold { background: var(--gold); color: #000; border-color: var(--gold); }
.btn-gold:hover { filter: brightness(1.1); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.input {
  width: 100%; padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  transition: border var(--transition);
}
.input:focus { outline: none; border-color: var(--accent); }
.input-sm { padding: 6px 10px; font-size: 13px; }

.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  background: rgba(10,10,15,0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  height: 48px;
}
.nav-left, .nav-center, .nav-right { display: flex; align-items: center; gap: 8px; }
.nav-logo { font-size: 16px; font-weight: 700; color: var(--accent); letter-spacing: 1px; }
.nav-version { font-size: 10px; color: var(--text-muted); padding: 1px 5px; border: 1px solid var(--border); border-radius: 4px; }
.nav-income { font-size: 13px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.nav-cash { font-size: 15px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; }

.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex;
  background: rgba(10,10,15,0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  height: 56px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  padding: 6px 4px;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  transition: color var(--transition);
  text-decoration: none;
  border: none;
  background: none;
  font-family: var(--font);
}
.tab-item.active { color: var(--accent); }
.tab-item:hover { color: var(--text-secondary); }
.tab-icon { font-size: 20px; line-height: 1; }

.view {
  padding: 56px 12px 64px 12px;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

.row { display: flex; gap: 8px; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.col { display: flex; flex-direction: column; gap: 8px; }
.gap-sm { gap: 4px; }
.gap-md { gap: 8px; }
.gap-lg { gap: 16px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 12px; color: var(--text-muted); }
.text-number { font-variant-numeric: tabular-nums; }
.text-nowrap { white-space: nowrap; }
.flex-1 { flex: 1; }

.energy-bar {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-secondary);
}
.energy-fill {
  flex: 1; height: 6px; background: var(--bg-secondary);
  border-radius: 3px; overflow: hidden;
}
.energy-fill-inner {
  height: 100%; background: var(--accent); border-radius: 3px;
  transition: width 0.3s;
}

.asset-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.asset-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  transition: all var(--transition);
  cursor: pointer;
}
.asset-card:hover { border-color: var(--accent-dim); }
.asset-card.locked { opacity: 0.5; }
.asset-icon { font-size: 28px; margin-bottom: 4px; }
.asset-name { font-size: 13px; font-weight: 600; }
.asset-level { font-size: 11px; color: var(--text-muted); }
.asset-income { font-size: 12px; color: var(--gold); margin-top: 4px; }

.gamble-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.gamble-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.gamble-card:hover { border-color: var(--accent-dim); }
.gamble-icon { font-size: 32px; margin-bottom: 6px; }
.gamble-name { font-size: 14px; font-weight: 600; }
.gamble-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.leaderboard-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.leaderboard-item:last-child { border-bottom: none; }
.lb-rank { width: 28px; font-size: 14px; font-weight: 700; text-align: center; color: var(--text-muted); }
.lb-rank.top1 { color: var(--gold); }
.lb-rank.top2 { color: #c0c0c0; }
.lb-rank.top3 { color: #cd7f32; }
.lb-name { flex: 1; font-size: 14px; }
.lb-value { font-size: 14px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; }

.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.stat-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}
.stat-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 400px;
  width: 100%;
}

.abyss-board {
  display: grid; gap: 4px; margin: 16px 0;
  justify-content: center;
}
.abyss-cell {
  width: 48px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.abyss-cell:hover { border-color: var(--accent); transform: translateY(-2px); }
.abyss-cell.hidden { opacity: 0.3; cursor: not-allowed; }
.abyss-cell.hidden:hover { transform: none; border-color: var(--border); }
.abyss-cell.cleared { visibility: hidden; }
.abyss-slot {
  display: flex; gap: 4px; justify-content: center; margin: 12px 0;
  min-height: 56px;
}
.abyss-slot-cell {
  width: 48px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

.coinflip-result {
  font-size: 48px; text-align: center; margin: 16px 0;
}
.coinflip-choices {
  display: flex; gap: 12px; justify-content: center; margin: 16px 0;
}
.coinflip-choice {
  padding: 16px 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 24px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-secondary);
}
.coinflip-choice:hover { border-color: var(--accent); }
.coinflip-choice.selected { border-color: var(--gold); background: rgba(255,215,0,0.1); }

.more-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.view > * { animation: fadeIn 0.2s ease; }

.toast {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 200;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 768px) {
  .view { max-width: 560px; }
}
