/* ============================================================
   CkattoTV Idle Empire — Stylesheet
   Dark, neon, modern. Self-contained (no external fonts/assets).
   ============================================================ */

:root {
  --bg-0: #0a0a12;
  --bg-1: #0f0f1a;
  --bg-2: #15152a;
  --bg-3: #1c1c36;
  --card: #14142380;
  --card-solid: #16162a;
  --border: #2a2a4a;
  --text-0: #f4f4ff;
  --text-1: #b8b8d4;
  --text-2: #7c7c9c;

  --neon-purple: #b26bff;
  --neon-cyan: #35f0e0;
  --neon-gold: #ffd166;
  --neon-pink: #ff5fa2;
  --neon-green: #4dff9e;
  --neon-red: #ff5c6a;

  --grad-purple: linear-gradient(135deg, #b26bff, #7c3aed);
  --grad-cyan: linear-gradient(135deg, #35f0e0, #0ea5b8);
  --grad-gold: linear-gradient(135deg, #ffd166, #f59e0b);
  --grad-pink: linear-gradient(135deg, #ff5fa2, #c026d3);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-glow: 0 0 24px rgba(178, 107, 255, 0.15);
  --transition: 180ms cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Segoe UI', ui-sans-serif, system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(178,107,255,0.10), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(53,240,224,0.08), transparent 55%),
    var(--bg-0);
  color: var(--text-0);
  overflow-x: hidden;
}

#app { display: flex; flex-direction: column; min-height: 100vh; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--neon-purple); }

/* ===================== HEADER ===================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: linear-gradient(180deg, rgba(21,21,42,0.9), rgba(15,15,26,0.6));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 40;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-emoji {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 10px rgba(178,107,255,0.6));
  animation: float 3.2s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0) rotate(0deg);} 50% { transform: translateY(-3px) rotate(-4deg);} }

.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-title { font-weight: 800; font-size: 1.15rem; letter-spacing: .3px; }
.brand-accent { color: var(--neon-cyan); }
.brand-sub { font-size: .68rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 1px; }

.header-stats { display: flex; gap: 8px; flex-wrap: wrap; }

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .82rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}
.stat-pill .stat-icon { font-size: .95rem; }
.stat-pill .stat-value { font-weight: 700; color: var(--neon-gold); font-variant-numeric: tabular-nums; }
.stat-pill .stat-label { color: var(--text-2); font-size: .72rem; }
.stat-pill--ghost .stat-value { color: var(--neon-cyan); }
.stat-pill--lives .stat-value { color: var(--neon-pink); }
.stat-pill.bump { animation: bump 260ms ease; }
@keyframes bump { 0% { transform: scale(1);} 40% { transform: scale(1.12);} 100% { transform: scale(1);} }

.header-actions { display: flex; gap: 6px; }
.icon-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: 10px;
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}
.icon-btn:hover { border-color: var(--neon-purple); color: var(--text-0); transform: translateY(-1px); }

/* ===================== TAB NAV ===================== */
.tab-nav {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: rgba(10,10,18,0.5);
  position: sticky;
  top: 58px;
  z-index: 39;
  scrollbar-width: thin;
}
.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: var(--transition);
}
.tab-btn:hover { color: var(--text-0); background: var(--bg-2); }
.tab-btn.active {
  color: #0a0a12;
  background: var(--grad-cyan);
  box-shadow: 0 0 18px rgba(53,240,224,0.35);
}

/* ===================== LAYOUT ===================== */
.app-body { display: flex; flex: 1; min-height: 0; }
.app-main { flex: 1; padding: 16px; overflow-y: auto; min-width: 0; }

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.tab-panel { display: none; animation: fadein 220ms ease; }
.tab-panel.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }

/* ===================== CARDS ===================== */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)) , var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.card:hover { border-color: rgba(178,107,255,0.4); box-shadow: var(--shadow-glow); transform: translateY(-2px); }
.card--wide { grid-column: 1 / -1; }
.card-title { font-weight: 700; font-size: .95rem; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.card-desc { color: var(--text-2); font-size: .8rem; margin: -4px 0 10px; }

.card--hero { display: flex; align-items: center; gap: 16px; background: linear-gradient(120deg, rgba(178,107,255,0.12), rgba(53,240,224,0.06)); }
.hero-avatar { font-size: 3rem; filter: drop-shadow(0 0 16px rgba(178,107,255,0.5)); }
.hero-info { flex: 1; min-width: 0; }
.hero-title { font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.live-badge {
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.live-badge--offline { background: var(--bg-3); color: var(--text-2); border-color: var(--border); }
.live-badge--live {
  background: rgba(255,92,106,0.12);
  color: var(--neon-red);
  border-color: rgba(255,92,106,0.4);
  animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse { 0%,100% { box-shadow: 0 0 0 rgba(255,92,106,0.5); } 50% { box-shadow: 0 0 12px rgba(255,92,106,0.6); } }

.btn-live-active { background: linear-gradient(135deg,#ff5c6a,#c0243a); color: #fff; }
.hero-sub { color: var(--text-1); font-size: .82rem; margin: 3px 0 8px; }
.hero-next { color: var(--text-2); font-size: .72rem; margin-top: 4px; }

.big-number { font-size: 1.6rem; font-weight: 800; color: var(--neon-gold); font-variant-numeric: tabular-nums; }

/* progress + bars */
.progress-bar { height: 10px; background: var(--bg-1); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; width: 0%; background: var(--grad-purple); transition: width 260ms ease; box-shadow: 0 0 10px rgba(178,107,255,0.6); }

.stat-row { display: flex; align-items: center; gap: 10px; font-size: .8rem; color: var(--text-1); margin-bottom: 8px; }
.stat-row span:first-child { width: 70px; flex-shrink: 0; }
.mini-bar { flex: 1; height: 8px; background: var(--bg-1); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.mini-fill { height: 100%; width: 50%; transition: width 400ms ease; }
.mini-fill--energy { background: var(--grad-gold); }
.mini-fill--happy { background: linear-gradient(135deg, #ff5fa2, #ff9ec7); }

.breakdown-row { display: flex; justify-content: space-between; font-size: .82rem; color: var(--text-1); padding: 6px 0; border-bottom: 1px dashed var(--border); }
.breakdown-row:last-child { border-bottom: none; }
.breakdown-total { font-weight: 700; color: var(--text-0); }

/* ===================== BUTTONS ===================== */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  transition: var(--transition);
  color: #0a0a12;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(0.3); }
.btn-block { width: 100%; }
.btn-primary { background: var(--grad-purple); color: #fff; box-shadow: 0 4px 16px rgba(178,107,255,0.3); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-secondary { background: var(--bg-3); color: var(--text-0); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--neon-cyan); }
.btn-danger { background: linear-gradient(135deg,#ff5c6a,#c0243a); color: #fff; }
.btn-buy, .btn-long { background: var(--grad-cyan); }
.btn-sell, .btn-short { background: linear-gradient(135deg,#ff5c6a,#ff8a8a); color: #fff; }
.trade-buttons { display: flex; gap: 8px; margin-top: 8px; }
.trade-buttons .btn { flex: 1; }

.input {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-0);
  font-size: .85rem;
  margin-top: 4px;
  outline: none;
  transition: var(--transition);
}
.input:focus { border-color: var(--neon-cyan); box-shadow: 0 0 0 3px rgba(53,240,224,0.12); }

.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ===================== BUSINESS / UPGRADE CARD ===================== */
.biz-card { display: flex; flex-direction: column; gap: 8px; }
.biz-head { display: flex; align-items: center; gap: 10px; }
.biz-icon { font-size: 1.7rem; }
.biz-name { font-weight: 700; font-size: .9rem; }
.biz-owned { font-size: .72rem; color: var(--text-2); }
.biz-income { font-size: .78rem; color: var(--neon-green); }
.biz-actions { display: flex; gap: 6px; margin-top: 4px; }
.biz-actions .btn { flex: 1; font-size: .75rem; padding: 8px 6px; }
.biz-manager { background: var(--bg-3); border: 1px solid var(--border); color: var(--text-1); }
.biz-manager.active { background: var(--grad-gold); color: #0a0a12; border-color: transparent; }

/* ===================== REAL ESTATE / FLEX ASSETS ===================== */
.section-heading {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 22px 4px 10px;
  letter-spacing: .3px;
}
.asset-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.asset-card.owned {
  border-color: rgba(77,255,158,0.4);
  background: linear-gradient(180deg, rgba(77,255,158,0.06), rgba(255,255,255,0)), var(--card-solid);
}
.asset-icon { font-size: 2rem; flex-shrink: 0; filter: drop-shadow(0 0 10px rgba(178,107,255,0.35)); }
.asset-body { flex: 1; min-width: 0; }
.asset-name { font-weight: 700; font-size: .88rem; }
.asset-meta { font-size: .72rem; color: var(--text-2); margin-top: 2px; }
.asset-card .btn { flex-shrink: 0; font-size: .76rem; padding: 8px 12px; white-space: nowrap; }
.asset-owned-badge {
  flex-shrink: 0;
  color: var(--neon-green);
  font-weight: 700;
  font-size: .78rem;
  background: rgba(77,255,158,0.1);
  border: 1px solid rgba(77,255,158,0.3);
  border-radius: 999px;
  padding: 6px 12px;
}

/* ===================== CRYPTO ===================== */
.crypto-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.coin-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.coin-tab {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text-1);
  padding: 7px 12px; border-radius: 10px; cursor: pointer; font-size: .8rem; font-weight: 700;
  transition: var(--transition);
}
.coin-tab.active { background: var(--grad-purple); color: #fff; border-color: transparent; }
.leverage-control { display: flex; flex-direction: column; gap: 4px; font-size: .75rem; color: var(--text-2); min-width: 160px; }
.leverage-control input { accent-color: var(--neon-pink); }
#leverage-value { color: var(--neon-pink); font-weight: 700; }

.crypto-grid .card--chart { min-height: 300px; }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; flex-wrap: wrap; gap: 6px; }
.chart-symbol { font-weight: 800; font-size: 1rem; margin-right: 8px; }
.chart-price { font-weight: 700; color: var(--text-0); margin-right: 8px; font-variant-numeric: tabular-nums; }
.chart-change { font-size: .82rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.chart-change.up { color: var(--neon-green); background: rgba(77,255,158,0.1); }
.chart-change.down { color: var(--neon-red); background: rgba(255,92,106,0.1); }
.chart-event { font-size: .75rem; color: var(--neon-gold); font-weight: 700; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1;} 50% { opacity: .4;} }
.chart-svg { width: 100%; height: 220px; }

.trade-balance { font-size: .78rem; color: var(--text-2); margin-bottom: 4px; }

.positions-list, #bots-list, #staking-list { display: flex; flex-direction: column; gap: 8px; }
.position-row, .bot-row, .stake-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: .8rem;
}
.position-row .pnl.up { color: var(--neon-green); font-weight: 700; }
.position-row .pnl.down { color: var(--neon-red); font-weight: 700; }
.empty-hint { color: var(--text-2); font-size: .8rem; font-style: italic; }
.bot-row .btn, .stake-row .btn { font-size: .72rem; padding: 6px 10px; }

/* ===================== TICKER ===================== */
.ticker { overflow: hidden; white-space: nowrap; border-top: 1px solid var(--border); padding-top: 8px; }
.ticker-track { display: inline-block; padding-left: 100%; animation: ticker-scroll 26s linear infinite; font-size: .82rem; color: var(--text-1); }
.ticker-track span { margin-right: 40px; }
@keyframes ticker-scroll { from { transform: translateX(0);} to { transform: translateX(-100%);} }

/* ===================== DOT MINIGAME ===================== */
.dot-arena {
  position: relative;
  height: 180px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  overflow: hidden;
}
.dot-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-2); font-size: .85rem; }
.red-dot {
  position: absolute;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a8a, #ff5c6a 60%, #c0243a);
  box-shadow: 0 0 14px rgba(255,92,106,0.7);
  cursor: pointer;
  animation: dot-pop 180ms ease;
  border: none;
}
@keyframes dot-pop { from { transform: scale(0);} to { transform: scale(1);} }

/* ===================== RANK LADDER ===================== */
.rank-ladder { display: flex; flex-direction: column; gap: 6px; }
.rank-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); font-size: .82rem; color: var(--text-2); }
.rank-item.reached { color: var(--text-0); background: var(--bg-2); }
.rank-item.current { color: #0a0a12; background: var(--grad-gold); font-weight: 700; }

/* ===================== CHAT SIDEBAR ===================== */
.chat-sidebar {
  width: 260px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: rgba(10,10,18,0.5);
  display: flex;
  flex-direction: column;
  transition: width var(--transition), min-width var(--transition);
}
.chat-sidebar.collapsed { width: 0; min-width: 0; overflow: hidden; border-left: none; }
.chat-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; font-weight: 700; font-size: .85rem; border-bottom: 1px solid var(--border);
}
.chat-messages { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { font-size: .78rem; line-height: 1.35; animation: fadein 200ms ease; }
.chat-user { font-weight: 700; margin-right: 4px; }
.chat-embedded { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.chat-embedded--offline { align-items: center; justify-content: center; min-height: 80px; }

.energy-live-hint { font-size: .72rem; margin: -4px 0 10px; color: var(--neon-red); }

/* ===================== TOASTS ===================== */
.toast-stack { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 90vw; }
.toast {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--neon-cyan);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .82rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  animation: toast-in 220ms ease, toast-out 260ms ease 3.2s forwards;
  max-width: 320px;
}
.toast.event { border-left-color: var(--neon-gold); }
.toast.danger { border-left-color: var(--neon-red); }
.toast.good { border-left-color: var(--neon-green); }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px);} to { opacity: 1; transform: translateX(0);} }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); height: 0; padding: 0; margin: 0;} }

/* floating cash gain text */
.float-gain {
  position: fixed;
  color: var(--neon-green);
  font-weight: 800;
  font-size: .9rem;
  pointer-events: none;
  z-index: 90;
  animation: float-up 900ms ease-out forwards;
}
@keyframes float-up { from { opacity: 1; transform: translateY(0);} to { opacity: 0; transform: translateY(-46px);} }

/* ===================== ACCOUNT / AUTH ===================== */
.auth-buttons { display: flex; gap: 8px; margin-top: 8px; }
.auth-buttons .btn { flex: 1; }
.auth-status { font-size: .78rem; margin-top: 8px; min-height: 1.1em; }
.auth-status.error { color: var(--neon-red); }
.auth-status.good { color: var(--neon-green); }

/* ===================== LEADERBOARD ===================== */
.leaderboard-table-wrap { overflow-x: auto; }
.leaderboard-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.leaderboard-table th {
  text-align: left;
  color: var(--text-2);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.leaderboard-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.leaderboard-table tbody tr:last-child td { border-bottom: none; }
.leaderboard-table tbody tr:hover { background: var(--bg-2); }
.leaderboard-table tr.you { background: rgba(53,240,224,0.06); }
.leaderboard-rank { font-weight: 800; color: var(--text-2); width: 2.5em; }
.leaderboard-rank.top1 { color: var(--neon-gold); }
.leaderboard-rank.top2 { color: #c9c9e0; }
.leaderboard-rank.top3 { color: #cd8a5c; }
.leaderboard-name { font-weight: 700; }

/* ===================== MODAL ===================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,5,10,0.7); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 200;
}
.modal-backdrop.open { display: flex; }
.modal { width: min(360px, 90vw); background: var(--card-solid); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }

/* ===================== FOOTER ===================== */
.app-footer {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 10px 18px; border-top: 1px solid var(--border); font-size: .72rem; color: var(--text-2);
  background: rgba(10,10,18,0.6);
}
.footer-links { display: flex; gap: 14px; }
.footer-links a { color: var(--text-1); text-decoration: none; font-weight: 600; transition: var(--transition); }
.footer-links a:hover { color: var(--neon-cyan); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) {
  .chat-sidebar { position: fixed; right: 0; top: 0; bottom: 0; z-index: 60; box-shadow: -10px 0 30px rgba(0,0,0,0.5); }
  .chat-sidebar.collapsed { width: 0; }
}
@media (max-width: 640px) {
  .app-header { padding: 10px; }
  .brand-sub { display: none; }
  .header-stats { gap: 6px; }
  .stat-pill { padding: 5px 10px; font-size: .74rem; }
  .app-main { padding: 10px; }
  .panel-grid { grid-template-columns: 1fr; }
  .footer-links { gap: 10px; }
}

/* small helper utility */
.text-muted { color: var(--text-2); }
.text-good { color: var(--neon-green); }
.text-bad { color: var(--neon-red); }
