* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0b0e14;
  --surface: #12161f;
  --surface2: #1a2029;
  --line: #1f2631;
  --text: #e9ecf1;
  --muted: #7a8494;
  --accent: #f7931a;
  --accent-ink: #161005;
  --green: #2ebd6b;
  --red: #e5484d;
  --green-bg: rgba(46, 189, 107, 0.12);
  --red-bg: rgba(229, 72, 77, 0.12);
}

html, body { height: 100%; }
/* reserve the scrollbar so content doesn't shift sideways between tabs */
html { scrollbar-gutter: stable; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
  user-select: none;
  font-feature-settings: 'tnum';
}

.hidden { display: none !important; }

/* ---------- shared primitives ---------- */
.list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  transition: background 0.12s;
}
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--surface2); }
.row.static { cursor: default; }
.row.static:active { background: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.row-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { text-align: right; flex-shrink: 0; }
.row-num { display: block; font-weight: 600; font-size: 15px; }
.row-end .pill { margin-top: 3px; }

.ticker-badge {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px; letter-spacing: 0.02em;
}
.ticker-badge.lg { width: 44px; height: 44px; font-size: 12px; }

.pill {
  display: inline-block;
  padding: 2px 7px; border-radius: 6px;
  font-size: 12px; font-weight: 600;
}
.pill.up { color: var(--green); background: var(--green-bg); }
.pill.down { color: var(--red); background: var(--red-bg); }

.up { color: var(--green); }
.down { color: var(--red); }

.section-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted);
  margin: 22px 4px 8px;
}
.empty-note { color: var(--muted); font-size: 13.5px; text-align: center; padding: 24px 16px; }

.logo-mark {
  width: 64px; height: 64px; border-radius: 18px;
  background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 800;
}
.logo-mark.small { width: 26px; height: 26px; border-radius: 8px; font-size: 15px; }

/* ---------- header ---------- */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-brand { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; }
.header-worth { text-align: right; }
.worth-value { font-size: 17px; font-weight: 700; }
.worth-change { font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 1px; }
.worth-change.up { color: var(--green); }
.worth-change.down { color: var(--red); }

/* ---------- screens ---------- */
.screen {
  display: none;
  padding: calc(env(safe-area-inset-top) + 72px) 14px calc(env(safe-area-inset-bottom) + 82px);
  max-width: 560px; margin: 0 auto;
}
.screen.active { display: block; }

/* ---------- market ---------- */
.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 16px 14px;
}
.hero-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.hero-title { flex: 1; min-width: 0; }
.hero-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.hero-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-right { text-align: right; flex-shrink: 0; }
.hero-price { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.hero-right .pill { margin-top: 3px; }
#hero-chart { width: 100%; margin: 2px 0 12px; }
.hero-actions { display: flex; gap: 10px; }
.btn-trade {
  flex: 1; border: none; border-radius: 12px; padding: 14px;
  font-size: 15px; font-weight: 700; letter-spacing: -0.01em; cursor: pointer;
  font-family: inherit; color: #fff;
  transition: transform 0.08s, filter 0.15s;
}
.btn-trade:active { transform: scale(0.98); filter: brightness(1.1); }
.btn-trade.buy { background: var(--green); }
.btn-trade.sell { background: var(--red); }
.row.selected { background: var(--surface2); }
.btn-trade svg { width: 16px; height: 16px; vertical-align: -2px; margin-right: 6px; }

/* labeled market-change pill — distinguishes coin movement from trade P/L */
.mini-cap {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.market-pill { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.sheet-head .market-pill { margin-left: auto; }

/* "Your trades" section under the hero chart */
.hero-trades { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 11px; }
.ht-head { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 9px; }
#ht-total { font-weight: 700; font-size: 13.5px; }
#hero-positions { display: flex; flex-direction: column; gap: 8px; }
.pos-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 10px 9px 12px;
  font-size: 13px; font-weight: 600;
}
.pos-chip .pos-pnl { margin-left: auto; white-space: nowrap; }
.pos-pnl small { font-size: 11px; font-weight: 600; opacity: 0.85; }

.dir {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.05em;
  padding: 2.5px 7px; border-radius: 6px;
}
.dir svg { width: 10px; height: 10px; }
.dir.up { color: var(--green); background: var(--green-bg); }
.dir.down { color: var(--red); background: var(--red-bg); }
.dir.neutral { color: var(--muted); background: var(--surface2); }

.btn-close {
  border: 1px solid var(--line); background: var(--surface2); color: var(--text);
  font-family: inherit; font-size: 12px; font-weight: 700;
  padding: 7px 14px; border-radius: 9px; cursor: pointer; flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.btn-close:active { background: var(--line); }
.btn-close:disabled { opacity: 0.5; }

/* closed trade history */
.closed-item + .closed-item { border-top: 1px solid var(--line); }
.closed-detail {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  padding: 4px 16px 14px 68px;
}
.closed-item.expanded .closed-detail { display: grid; }
.closed-item.expanded > .row { background: var(--surface2); }
.cd-cell .summary-label { margin-bottom: 2px; }
.cd-cell div:last-child { font-size: 13.5px; font-weight: 600; }
.cd-share { grid-column: 1 / -1; margin-top: 2px; }

.spark { width: 64px; height: 30px; flex-shrink: 0; }
/* fixed price column so the sparklines align on a common left axis */
#coin-list .row-end { width: 112px; flex-shrink: 0; }

/* ---------- portfolio ---------- */
.summary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 16px 14px;
}
.summary-label {
  font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted);
}
.summary-value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 2px; }
.summary-sub { font-size: 13.5px; font-weight: 600; }
.summary-split {
  display: flex; gap: 24px;
  border-top: 1px solid var(--line);
  margin-top: 14px; padding-top: 12px;
}
.summary-split > div { flex: 1; }
.summary-num { font-size: 15px; font-weight: 600; margin-top: 3px; }

.trade-tag {
  display: inline-block; min-width: 38px; text-align: center;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 7px; border-radius: 6px;
}
.trade-tag.buy { color: var(--green); background: var(--green-bg); }
.trade-tag.sell { color: var(--red); background: var(--red-bg); }

/* ---------- leaderboard ---------- */
.seg {
  display: flex; background: var(--surface); border: 1px solid var(--line);
  border-radius: 11px; padding: 3px; margin-bottom: 4px;
}
.seg button {
  flex: 1; border: none; background: none; color: var(--muted);
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  padding: 8px; border-radius: 8px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg button.active { background: var(--surface2); color: var(--text); }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 20px; padding: 18px 0 22px; }
.pod { display: flex; flex-direction: column; align-items: center; width: 92px; }
.pod .avatar { width: 56px; height: 56px; font-size: 20px; border: 2.5px solid transparent; }
.pod-1 .avatar { width: 76px; height: 76px; font-size: 27px; }
.pod-1 { padding-bottom: 16px; }
.pod-1 .avatar { border-color: #ecc94b; box-shadow: 0 0 26px rgba(236, 201, 75, 0.28); }
.pod-2 .avatar { border-color: #a7b3c4; }
.pod-3 .avatar { border-color: #d08a54; }
.pod-rank {
  width: 21px; height: 21px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #14100a;
  margin-top: -12px; border: 2.5px solid var(--bg); z-index: 1;
}
.pod-1 .pod-rank { background: #ecc94b; }
.pod-2 .pod-rank { background: #a7b3c4; }
.pod-3 .pod-rank { background: #d08a54; }
.pod-name {
  font-size: 12.5px; font-weight: 700; margin-top: 7px; max-width: 92px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pod-name .you-tag { margin-left: 4px; }
.pod-val { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 2px; }

.lb-rank { width: 24px; text-align: center; font-weight: 700; font-size: 14px; color: var(--muted); flex-shrink: 0; }
.lb-rank.r1 { color: #ecc94b; }
.lb-rank.r2 { color: #a7b3c4; }
.lb-rank.r3 { color: #d08a54; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.row.me { box-shadow: inset 3px 0 0 var(--accent); }
.you-tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 5px; padding: 1px 5px; margin-left: 7px;
  vertical-align: 1px;
}

/* ---------- achievements ---------- */
.awards-progress { margin: 2px 4px 14px; }
.awards-progress .ap-text { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.awards-progress .ap-bar { height: 4px; border-radius: 2px; background: var(--surface2); overflow: hidden; }
.awards-progress .ap-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s; }

.ach-icon {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface2); color: var(--muted);
}
.ach-icon svg { width: 21px; height: 21px; }
.row.unlocked .ach-icon { background: rgba(247, 147, 26, 0.13); color: var(--accent); }
.row.locked .row-title { color: var(--muted); }
.ach-check { color: var(--green); flex-shrink: 0; }
.ach-check svg { width: 18px; height: 18px; display: block; }

/* ---------- profile ---------- */
.profile-head { display: flex; align-items: center; gap: 14px; padding: 6px 4px 16px; }
.avatar.xl { width: 56px; height: 56px; font-size: 22px; border-radius: 50%; }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-btn {
  position: relative; border: none; background: none; padding: 0; cursor: pointer;
  font-family: inherit;
}
.avatar-badge {
  position: absolute; right: -2px; bottom: -2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface2); border: 2px solid var(--bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.avatar-badge svg { width: 12px; height: 12px; }
.prof-name { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 14px;
}
.stat-value { font-size: 17px; font-weight: 700; margin-top: 4px; }
.row-title.danger { color: var(--red); }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.01em;
  padding: 9px 0 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-family: inherit;
  transition: color 0.15s;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--text); }
.tab.active svg { color: var(--accent); }

/* ---------- trade sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(4, 6, 10, 0.65); }
.trade-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface);
  border: 1px solid var(--line); border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 8px 18px calc(env(safe-area-inset-bottom) + 18px);
  max-width: 560px; margin: 0 auto;
  animation: slideUp 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--surface2); margin: 6px auto 16px; }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.sheet-price { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.sheet-head .pill { margin-left: auto; }
#sheet-chart { width: 100%; margin-bottom: 6px; }
.sheet-owned { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; min-height: 15px; }

.side-toggle { display: flex; background: var(--surface2); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.side-btn {
  flex: 1; border: none; background: none; color: var(--muted);
  font-weight: 700; font-size: 14px; padding: 9px; border-radius: 8px; cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.side-btn.active { background: var(--green); color: #fff; }
.side-btn.sell.active { background: var(--red); }
.side-btn svg { width: 13px; height: 13px; vertical-align: -1.5px; margin-right: 5px; }

.amount-row {
  display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 14px; margin-bottom: 10px;
  transition: border-color 0.15s;
}
.amount-row:focus-within { border-color: var(--accent); }
.dollar { color: var(--muted); font-weight: 600; font-size: 17px; }
#amount-input {
  flex: 1; background: none; border: none; outline: none; color: var(--text);
  font-size: 19px; font-weight: 600; padding: 13px 8px; font-family: inherit;
}
#amount-input::-webkit-outer-spin-button, #amount-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.quick-amounts { display: flex; gap: 8px; margin-bottom: 14px; }
.quick-amounts button {
  flex: 1; background: var(--surface2); border: 1px solid transparent; color: var(--muted);
  font-weight: 600; font-size: 13px; padding: 9px 0; border-radius: 9px; cursor: pointer;
  font-family: inherit;
  transition: color 0.12s, border-color 0.12s;
}
.quick-amounts button:active { background: var(--line); }
.quick-amounts button.active { border-color: var(--accent); color: var(--text); }


/* risk summary — makes the capped downside explicit */
.risk-line {
  font-size: 12.5px; color: var(--muted); font-weight: 600;
  margin: -4px 2px 12px; min-height: 16px;
}
.risk-line b { color: var(--text); font-weight: 700; }

/* PWA install banner */
.install-banner {
  position: fixed; z-index: 210;
  left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 74px);
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.25s ease;
  max-width: 460px; margin: 0 auto;
}
.ib-text { flex: 1; font-size: 13px; font-weight: 600; line-height: 1.35; }
.ib-x {
  background: none; border: none; color: var(--muted);
  font-size: 20px; line-height: 1; padding: 2px 4px; cursor: pointer; font-family: inherit;
}

/* take-profit / stop-loss selectors */
.tpsl-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.tpsl-row .mini-cap { width: 74px; flex-shrink: 0; }
.tpsl-opts { display: flex; gap: 6px; flex: 1; }
.tpsl-opts button {
  flex: 1; background: var(--surface2); border: 1px solid transparent; color: var(--muted);
  font-family: inherit; font-size: 12px; font-weight: 700;
  padding: 7px 0; border-radius: 8px; cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.tpsl-opts button.active { color: var(--text); border-color: var(--accent); }

/* first-session hint */
.hint-card {
  display: flex; align-items: center; gap: 12px;
  background: rgba(247, 147, 26, 0.08);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 12px;
}
.hint-text { font-size: 13px; color: var(--text); line-height: 1.5; }
.hint-text b { color: var(--accent); }

/* centered modal (daily bonus) */
.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 60; width: min(320px, calc(100vw - 48px));
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 26px 22px 22px; text-align: center;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -47%) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.modal h2 { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.modal-sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 6px; }
.modal-icon {
  width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 14px;
  background: rgba(247, 147, 26, 0.13); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.modal-icon svg { width: 26px; height: 26px; }
.bonus-amount { font-size: 34px; font-weight: 800; color: var(--green); margin-bottom: 18px; letter-spacing: -0.02em; }
.modal-input {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 14px; color: var(--text);
  font-size: 16px; font-weight: 600; outline: none; margin: 8px 0 14px;
  font-family: inherit; text-align: center;
}
.modal-input:focus { border-color: var(--accent); }
#refcode-input { text-transform: uppercase; margin-top: 10px; }
#refcode-input::placeholder { text-transform: none; }
.link-btn {
  background: none; border: none; color: var(--muted); font-family: inherit;
  font-size: 13px; font-weight: 600; margin-top: 14px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

/* nudge brand-new players toward their first trade — one pulse per button */
.hero-actions.pulse .btn-trade { animation: pulseBtn 0.9s ease-in-out 1; }
.hero-actions.pulse .btn-trade.sell { animation-delay: 0.9s; }
@keyframes pulseBtn {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.04); }
}

/* loading skeleton */
.skel-box { background: var(--surface2); border-radius: 10px; animation: skel 1.2s ease-in-out infinite; }
@keyframes skel { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
.skel-badge { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; }
.skel-line { height: 13px; width: 90px; }
.skel-line.short { width: 50px; margin-top: 6px; }

.btn-primary {
  width: 100%; border: none; border-radius: 12px; padding: 15px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 15px; font-weight: 700; letter-spacing: -0.01em; cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s, opacity 0.15s;
}
.btn-primary:active { transform: scale(0.985); }
.btn-primary:disabled { opacity: 0.55; }
.btn-primary.buy-mode { background: var(--green); color: #fff; }
.btn-primary.sell-mode { background: var(--red); color: #fff; }
.error-msg { color: var(--red); font-size: 13px; font-weight: 500; text-align: center; margin-top: 10px; min-height: 16px; }

/* ---------- onboarding ---------- */
.onboarding {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.onboarding-card { text-align: center; max-width: 320px; width: 100%; }
.onboarding-card h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 18px 0 4px; }
.onboarding-card .tagline { color: var(--muted); font-size: 14.5px; margin-bottom: 24px; }
.onb-points { text-align: left; margin: 0 auto 26px; display: inline-flex; flex-direction: column; gap: 12px; }
.onb-point { display: flex; align-items: center; gap: 11px; font-size: 14px; font-weight: 500; color: var(--text); }
.onb-point svg { width: 19px; height: 19px; color: var(--accent); flex-shrink: 0; }
#username-input {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; color: var(--text);
  font-size: 16px; font-weight: 500; outline: none; margin-bottom: 10px;
  font-family: inherit; text-align: center;
  transition: border-color 0.15s;
}
#username-input:focus { border-color: var(--accent); }
#username-input::placeholder { color: var(--muted); }

/* ---------- toasts ---------- */
.toast-container {
  position: fixed; bottom: calc(env(safe-area-inset-bottom) + 78px);
  left: 0; right: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  background: #242d3d; border: 1px solid #35415a;
  border-radius: 11px; padding: 12px 18px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65);
  animation: toastIn 0.22s ease;
  max-width: 100%;
}
.toast.achievement { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.toast.achievement b { color: var(--accent); font-weight: 700; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.toast.out { opacity: 0; transition: opacity 0.3s; }

/* ---------- desktop (≥900px): sidebar nav + centered wide content ---------- */
.side-brand { display: none; }

@media (hover: hover) {
  .row:not(.static):hover { background: var(--surface2); }
  .coin-row:hover { background: var(--surface2); }
  .tab:hover { color: var(--text); }
  .btn-primary:hover, .btn-trade:hover, .btn-visit:hover { filter: brightness(1.09); }
  .btn-close:hover { border-color: var(--muted); }
}

@media (min-width: 900px) {
  /* Nav lives in the top bar — no sidebar, so content gets the full width. */
  .tabbar {
    top: 0; bottom: auto; left: 50%; right: auto;
    transform: translateX(-50%);
    width: auto; height: 62px;
    flex-direction: row; align-items: center; gap: 2px;
    background: none; padding: 0;
    /* the nav overlays the header, so it carries the same hairline —
       otherwise the header's border-bottom is interrupted behind it */
    border: none; border-bottom: 1px solid var(--line);
    z-index: 25;
  }
  .side-brand { display: none; }
  .tab {
    flex: 0 0 auto; flex-direction: row; align-items: center;
    gap: 8px; padding: 8px 14px; font-size: 13.5px;
    border-radius: 10px;
  }
  .tab.active { background: var(--surface2); }
  .tab svg { width: 18px; height: 18px; }

  /* align header content with the content column instead of the window edges */
  .header {
    padding-top: 14px; padding-bottom: 12px;
    padding-left: max(28px, calc((100% - 1120px) / 2 + 28px));
    padding-right: max(28px, calc((100% - 1120px) / 2 + 28px));
  }

  .screen {
    max-width: 1120px;
    padding: 86px 28px 56px;
  }
  .screen > * { max-width: 720px; margin-left: auto; margin-right: auto; }
  /* buttons are inline-block — force block so the auto margins actually centre them */
  .screen > button { display: block; width: 100%; }
  .section-title { max-width: 712px; }

  /* trade sheet becomes a centered dialog */
  .trade-sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: 460px; max-width: 460px;
    transform: translate(-50%, -50%);
    border-radius: 20px; border-bottom: 1px solid var(--line);
    animation: dialogIn 0.18s ease;
    padding-bottom: 20px;
  }
  .sheet-handle { display: none; }
  .toast-container { bottom: 24px; }

  .onboarding-card { max-width: 420px; }
  .onboarding-card h1 { font-size: 32px; }
  .onboarding-card .tagline { font-size: 16px; line-height: 1.55; }
  .onb-visual { margin-bottom: 32px; }
  .onb-big-btn, .onb-chart-icon { width: 96px; height: 96px; border-radius: 26px; }
  .onb-big-btn svg, .onb-chart-icon svg { width: 44px; height: 44px; }
  .onb-point { font-size: 15px; }
}
@keyframes dialogIn {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ---------- wide desktop (≥1200px): leaderboard beside the market ---------- */
.market-aside { display: none; }

@media (min-width: 1200px) {
  #screen-market.active {
    display: grid;
    grid-template-columns: minmax(0, 720px) 320px;
    gap: 24px;
    justify-content: center;
    align-items: start;
    max-width: 1120px;
  }
  #screen-market > :not(.market-aside) {
    grid-column: 1;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    width: 100%;
  }
  .market-aside {
    display: block;
    grid-column: 2;
    grid-row: 1 / span 30;
    position: sticky;
    top: 86px;
    max-width: none;
    margin: 0;
    width: 100%;
  }
  .aside-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin: 2px 4px 8px; cursor: pointer;
  }
  .aside-title {
    font-size: 12px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--muted);
  }
  .aside-head:hover .aside-title { color: var(--text); }
  .aside-sub { font-size: 11.5px; color: var(--muted); opacity: 0.8; }
  .market-aside .avatar { width: 28px; height: 28px; font-size: 12px; }
  .market-aside .row { padding: 9px 12px; gap: 9px; }
  .market-aside .row-title { font-size: 13.5px; }
  .market-aside .row-num { font-size: 13px; }
  .market-aside .lb-rank { width: 18px; font-size: 12px; }
  /* drop the hero by the height of the rail's section label so both cards line up */
  #screen-market.active > .hero { margin-top: 24px; }
  #aside-activity .row { padding: 8px 12px; gap: 9px; }
  .act-sym { font-size: 12px; font-weight: 700; }
  .act-name {
    font-size: 12.5px; color: var(--muted); font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .act-pnl { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
}

/* ---------- broker affiliates ---------- */
.sponsored-tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.07em;
  color: var(--muted); border: 1px solid var(--line);
  border-radius: 5px; padding: 1.5px 5px; margin-left: 7px;
  vertical-align: 1.5px; text-transform: uppercase;
}
.broker-rating {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12.5px; font-weight: 700; color: #ecc94b;
}
.broker-rating svg { width: 12px; height: 12px; }
.btn-visit {
  border: none; border-radius: 10px; padding: 9px 16px;
  background: var(--accent); color: var(--accent-ink);
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  flex-shrink: 0;
}
.btn-visit:active { transform: scale(0.97); }
.broker-disclaimer {
  font-size: 11px; color: var(--muted); line-height: 1.5;
  margin: 10px 4px 0; opacity: 0.8;
}
.cd-real {
  grid-column: 1 / -1; text-align: left;
  background: none; border: none; padding: 2px 0 0; cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--accent);
}

/* ---------- onboarding slides ---------- */
.onb-visual { display: flex; justify-content: center; gap: 16px; margin-bottom: 26px; }
.onb-big-btn {
  width: 84px; height: 84px; border-radius: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
}
.onb-big-btn.buy { background: var(--green); }
.onb-big-btn.sell { background: var(--red); }
.onb-big-btn svg { width: 38px; height: 38px; }
.onb-chart-icon {
  width: 84px; height: 84px; border-radius: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(247, 147, 26, 0.13); color: var(--accent);
}
.onb-chart-icon svg { width: 40px; height: 40px; }
.onb-dots { display: flex; justify-content: center; gap: 7px; margin-top: 22px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--surface2); }
.dot.active { background: var(--accent); }
.onb-next { margin-top: 4px; }

/* ---------- trade result modal ---------- */
.rm-pnl { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; margin: 8px 0 6px; white-space: nowrap; }
#rm-pct { font-size: 13px; padding: 3px 9px; margin-bottom: 4px; }
#rm-chart { width: 100%; margin: 12px 0 4px; }
.modal-actions { display: flex; gap: 10px; }
.btn-modal {
  flex: 1 1 0; min-width: 0;
  border: none; border-radius: 12px; padding: 14px 8px;
  background: var(--accent); color: var(--accent-ink);
  font-family: inherit; font-size: 14.5px; font-weight: 700;
  cursor: pointer; transition: transform 0.08s, filter 0.15s;
}
.btn-modal:active { transform: scale(0.98); }
.btn-modal.secondary { background: var(--surface2); color: var(--text); }

.rm-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px 16px; text-align: left; margin: 12px 2px 16px;
}
.rm-val { font-size: 14px; font-weight: 600; margin-top: 2px; }

/* ---------- open-trade panel (replaces Up/Down while a trade is open) ---------- */
.hero-trade-panel {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 12px 12px 14px;
}
.htp-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.htp-detail { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.htp-close {
  flex: 0 0 auto; padding: 13px 22px; font-size: 14.5px;
  background: var(--surface2); color: var(--text);
}
.htp-close.profit { background: var(--green); color: #fff; }
.htp-close.loss { background: var(--red); color: #fff; }

/* accessibility: visible keyboard focus */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* achievement progress bars on locked rows */
.ach-progress {
  height: 3px; border-radius: 2px; background: var(--surface2);
  margin-top: 7px; overflow: hidden; max-width: 190px;
}
.ach-progress > span { display: block; height: 100%; background: var(--muted); border-radius: 2px; }
.row.locked .row-sub { opacity: 0.9; }
.ach-pct { font-size: 11.5px; color: var(--muted); font-weight: 600; flex-shrink: 0; }

/* accessibility: respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* store-screenshot mode: hide transient chrome */
body.shot .toast-container, body.shot .hint-card, body.shot .modal,
body.shot .sheet-backdrop, body.shot .onboarding { display: none !important; }
