:root {
  --bg: #12141C;
  --panel: #1B1E29;
  --panel-raised: #21242F;
  --border: #2A2D3A;
  --text: #F2F1EC;
  --muted: #8B8D98;
  --profit: #3ECF8E;
  --profit-glow: rgba(62, 207, 142, 0.35);
  --commission: #F2A65A;
  --accent: #6E8FF0;
  --danger: #E5484D;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* FIX: hidden attribute must always win over display:flex */
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.brand-mark {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 8px;
}
.brand-mark.small { font-size: 18px; margin-bottom: 0; }
.login-card h1 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 4px 0;
}
.login-card input {
  width: 100%;
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}
.error-text {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-top: 8px;
}
.warning-text {
  color: var(--commission);
  font-size: 13px;
  margin-top: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 14px 18px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  width: 100%;
  margin-top: 14px;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #0A0E17; }
.btn-accent { background: var(--profit); color: #0A0E17; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-start { background: var(--profit); color: #0A0E17; margin-top: 0; }
.btn-stop { background: transparent; border: 1px solid var(--danger); color: var(--danger); margin-top: 0; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- App shell / swipe pages ---------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.disabled-banner {
  background: var(--danger);
  color: white;
  text-align: center;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
}
.pages-track {
  display: flex;
  flex: 1;
  width: 300%; /* 3 pages now: overview, trading controls, win rates */
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.page {
  width: 33.3333%;
  padding: 20px 18px 40px;
  flex-shrink: 0;
}
.swipe-hint { cursor: pointer; }
.page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.page-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 14px;
}
.label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

/* ---------- Balance ---------- */
.balance-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
}

/* ---------- Profit (signature element) ---------- */
.profit-card { text-align: left; position: relative; }
.profit-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 40px;
  color: var(--profit);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.profit-underline {
  height: 3px;
  width: 64px;
  background: var(--profit);
  border-radius: 2px;
  margin: 8px 0 16px;
  box-shadow: 0 0 12px 2px var(--profit-glow);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.timeframe-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tf-tab {
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
}
.tf-tab.active {
  background: var(--accent);
  color: #0A0E17;
  border-color: var(--accent);
  font-weight: 600;
}

/* ---------- Commission ---------- */
.commission-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.commission-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--commission);
  font-variant-numeric: tabular-nums;
}
.countdown-block { text-align: right; }
.countdown-value {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text);
}

/* ---------- Payment / wallets ---------- */
.wallet-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.wallet-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}
.wallet-item.selected { border-color: var(--accent); }
.wallet-item .addr { color: var(--muted); font-size: 12px; font-family: var(--font-mono); }
.new-wallet-form, .confirm-wallet-form { margin-top: 12px; }
.new-wallet-form input {
  width: 100%;
  margin-bottom: 10px;
  padding: 12px 14px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
}
.address-display {
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin: 10px 0;
}

/* ---------- Trading controls page ---------- */
/* CHANGED: friend picks a COUNT, not a specific asset -- the leaderboard
   decides which symbols fill those slots. Replaces the old asset-chip grid. */
.count-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 10px;
}
.stepper-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-raised);
  color: var(--text);
  font-size: 22px;
  font-family: var(--font-body);
  cursor: pointer;
}
.stepper-btn:active { transform: scale(0.95); }
.count-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  min-width: 40px;
  text-align: center;
}

.currently-trading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.currently-trading-row:last-child { border-bottom: none; }

#levelsInput {
  width: 100%;
  padding: 14px 16px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  margin-top: 6px;
}

#baseStakeInput {
  width: 100%;
  padding: 14px 16px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
}
.min-capital-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}
.mono-value {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text);
}

.controls-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.running-time-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.swipe-hint {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 20px;
}

.page-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 14px 0;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
}
.dot.active { background: var(--accent); }

/* ---------- Win rates page (page 3) ---------- */
#winRateLevelsInput {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
}
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.leaderboard-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}
.leaderboard-table td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
}
.leaderboard-table tr:last-child td { border-bottom: none; }
.not-ready-row td { color: var(--muted); font-style: italic; }
.score-cell { font-weight: 700; }
.score-high { color: var(--profit); }
.score-mid { color: var(--commission); }
.score-low { color: var(--danger); }
