*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-elevated: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --green: #3fb950;
  --green-dim: rgba(63, 185, 80, 0.15);
  --red: #f85149;
  --red-dim: rgba(248, 81, 73, 0.15);
  --blue: #58a6ff;
  --blue-dim: rgba(88, 166, 255, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 56px;
  --nav-h: 64px;
  --disclaimer-h: 28px;
  --sticky-order-h: 64px;
  --scrollbar-size: 5px;
  --scrollbar-track: var(--bg-elevated);
  --scrollbar-thumb: #3d444d;
  --scrollbar-thumb-hover: var(--blue);
  --scrollbar-thumb-active: #79b8ff;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-width: 375px;
}

/* Custom scrollbar — dark arena theme */
.app-content,
.coin-preview-page,
.logo-preview-page,
.scroll-area {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.app-content::-webkit-scrollbar,
.coin-preview-page::-webkit-scrollbar,
.logo-preview-page::-webkit-scrollbar,
.scroll-area::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

.app-content::-webkit-scrollbar-track,
.coin-preview-page::-webkit-scrollbar-track,
.logo-preview-page::-webkit-scrollbar-track,
.scroll-area::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}

.app-content::-webkit-scrollbar-thumb,
.coin-preview-page::-webkit-scrollbar-thumb,
.logo-preview-page::-webkit-scrollbar-thumb,
.scroll-area::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4a5568 0%, var(--scrollbar-thumb) 100%);
  border-radius: 999px;
  border: 1px solid rgba(13, 17, 23, 0.6);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.app-content::-webkit-scrollbar-thumb:hover,
.coin-preview-page::-webkit-scrollbar-thumb:hover,
.logo-preview-page::-webkit-scrollbar-thumb:hover,
.scroll-area::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--scrollbar-thumb-hover) 0%, #3b82f6 100%);
  box-shadow: 0 0 8px rgba(88, 166, 255, 0.35);
}

.app-content::-webkit-scrollbar-thumb:active,
.coin-preview-page::-webkit-scrollbar-thumb:active,
.logo-preview-page::-webkit-scrollbar-thumb:active,
.scroll-area::-webkit-scrollbar-thumb:active {
  background: var(--scrollbar-thumb-active);
}

.app-content::-webkit-scrollbar-corner,
.coin-preview-page::-webkit-scrollbar-corner,
.logo-preview-page::-webkit-scrollbar-corner,
.scroll-area::-webkit-scrollbar-corner {
  background: transparent;
}

/* Game-style display font for headings, brand and actions */
h1, h2, h3,
.brand-name,
.loader-logo,
.btn,
.side-btn,
.nav-label,
.interval-btn,
.leverage-btn,
.size-preset-btn,
.size-power-badge,
.size-qty-value,
.tpsl-preset-btn,
.tpsl-preset-label,
.tpsl-step-btn,
.side-chip,
.tpsl-expand-btn,
.rank-badge,
.market-badge,
.chart-legend-pill,
.chart-hud-label,
.chart-pin-badge,
.position-side,
.risk-title {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
}

.hidden { display: none !important; }

.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral { color: var(--text-muted); }

/* Loader */
.loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loader.loader-exit {
  opacity: 0;
  pointer-events: none;
}

.loader-arena {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(92vw, 360px);
  padding: 28px 22px 32px;
  gap: 18px;
}

.loader-arena-grid {
  position: absolute;
  inset: -40px;
  background-image:
    linear-gradient(rgba(59, 130, 246, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black 20%, transparent 75%);
  pointer-events: none;
}

.loader-arena-glow {
  position: absolute;
  top: -20%;
  left: 50%;
  width: 280px;
  height: 280px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(59, 130, 246, 0.18) 0%, transparent 70%);
  animation: loaderGlow 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes loaderGlow {
  0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.08); }
}

.loader-brand {
  position: relative;
  text-align: center;
  z-index: 1;
  width: 100%;
}

.loader-fms-logo {
  display: flex;
  justify-content: center;
  margin: 0 auto 16px;
  width: min(94%, 280px);
  animation: loaderIconBounce 2.4s ease-in-out infinite;
  filter: drop-shadow(0 4px 16px rgba(88, 166, 255, 0.2));
}

.fms-brand-logo svg,
.fms-brand-svg,
.fms-brand-img {
  width: 100%;
  height: auto;
  display: block;
  max-width: 280px;
  margin: 0 auto;
}

.streak-dot-coin .fms-coin {
  --fms-coin-size: 10px;
}

.streak-dot-coin .coin-amount {
  flex-direction: column;
  gap: 1px;
  font-size: 8px;
  line-height: 1;
}

.streak-dot-coin .coin-amount-num {
  font-size: 8px;
}

.lb-score .coin-amount {
  justify-content: flex-end;
}

.loader-brand-icon {
  display: block;
  font-size: 42px;
  margin-bottom: 6px;
  animation: loaderIconBounce 2s ease-in-out infinite;
}

@keyframes loaderIconBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.loader-game-logo {
  display: flex;
  justify-content: center;
  width: min(96%, 260px);
  margin: 4px auto 6px;
  animation: loaderIconBounce 2.4s ease-in-out infinite;
  filter: drop-shadow(0 4px 16px rgba(88, 166, 255, 0.25));
}

.loader-game-logo svg {
  width: 100%;
  height: auto;
  display: block;
}

.loader-logo {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0;
  background: linear-gradient(135deg, #fff 30%, var(--blue) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.loader-tagline {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.loader-disclaimer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px 14px;
  border-radius: 12px;
  border: 1px solid rgba(234, 179, 8, 0.35);
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.08) 0%, rgba(59, 130, 246, 0.06) 100%);
  box-shadow: 0 0 20px rgba(234, 179, 8, 0.08);
}

.loader-disclaimer-badge {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.3);
  overflow: visible;
}

.loader-disclaimer-badge .fms-coin {
  --fms-coin-size: 38px;
}

.fms-coin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--fms-coin-size, 64px);
  height: var(--fms-coin-size, 64px);
  flex-shrink: 0;
  line-height: 0;
}

.fms-coin-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.fms-coin-mount {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.coin-amount {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.coin-amount .fms-coin {
  flex-shrink: 0;
}

.coin-amount-num {
  font-variant-numeric: tabular-nums;
}

.coin-amount--plus .coin-amount-num {
  font-weight: 700;
}

.coin-margin-pct {
  color: var(--text-muted);
  font-weight: 600;
}

.balance-value.coin-amount,
.balance-value .coin-amount {
  font-size: 14px;
  font-weight: 700;
}

.balance-value.equity .coin-amount-num {
  color: var(--blue);
}

.loader-disclaimer-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #fbbf24;
}

.loader-disclaimer-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
}

.loader-disclaimer-sub {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

.loader-boot {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-size: 11px;
  color: rgba(59, 130, 246, 0.75);
  min-height: 16px;
}

.loader-boot::after {
  content: '▋';
  margin-left: 3px;
  color: rgba(96, 165, 250, 0.95);
  animation: loaderCursorBlink 1s steps(1) infinite;
}

@keyframes loaderCursorBlink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

.loader-progress-block {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.loader-status-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
}

.loader-percent {
  flex-shrink: 0;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 800;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(88, 166, 255, 0.4);
}

.loader-bar {
  position: relative;
  width: 100%;
  height: 7px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.loader-bar-fill {
  position: relative;
  height: 100%;
  width: 0%;
  overflow: hidden;
  background: linear-gradient(90deg, var(--blue), #60a5fa, #34d399);
  border-radius: 4px;
  transition: width 0.35s ease;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}

.loader-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: loaderBarShine 1.5s ease-in-out infinite;
}

@keyframes loaderBarShine {
  0% { transform: translateX(-100%); }
  60%, 100% { transform: translateX(220%); }
}

.loader-text {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.loader-tip {
  margin: 0;
  min-height: 18px;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  line-height: 1.4;
  animation: loaderTipFade 0.4s ease;
}

@keyframes loaderTipFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.loader-teaser {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.25);
  border-radius: 20px;
  animation: loaderTeaserPop 0.5s ease;
}

@keyframes loaderTeaserPop {
  0% { opacity: 0; transform: scale(0.9); }
  70% { transform: scale(1.03); }
  100% { opacity: 1; transform: scale(1); }
}

.loader-enter-btn {
  position: relative;
  z-index: 1;
  margin-top: 4px;
  padding: 14px 32px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, var(--blue) 0%, #2563eb 100%);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
  animation: loaderEnterPulse 2s ease-in-out infinite;
}

.loader-enter-btn:active {
  transform: scale(0.97);
}

@keyframes loaderEnterPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4); }
  50% { box-shadow: 0 4px 28px rgba(59, 130, 246, 0.65); }
}

@media (prefers-reduced-motion: reduce) {
  .loader-arena-glow,
  .loader-fms-logo,
  .loader-game-logo,
  .loader-brand-icon,
  .loader-bar-fill::after,
  .loader-boot::after,
  .loader-enter-btn,
  .ticker-track,
  .chart-wrap::after {
    animation: none !important;
  }
}

.app.app-enter {
  animation: appEnter 0.45s ease;
}

@keyframes appEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* App shell */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  overflow-x: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: var(--header-h);
}

.ticker-bar {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  height: 22px;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(234, 179, 8, 0.18), rgba(234, 179, 8, 0.08));
  border-bottom: 1px solid rgba(234, 179, 8, 0.32);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);
}

.ticker-track {
  display: flex;
  flex-shrink: 0;
  white-space: nowrap;
  will-change: transform;
  animation: tickerScroll 32s linear infinite;
}

.ticker-group {
  display: flex;
  flex-shrink: 0;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  padding: 0 22px;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fbbf24;
  white-space: nowrap;
}

.ticker-item::after {
  content: '•';
  margin-left: 22px;
  opacity: 0.5;
}

@keyframes tickerScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-game-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 4px rgba(88, 166, 255, 0.3));
}

.header-game-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
}

.mode-badge {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fbbf24;
  background: rgba(234, 179, 8, 0.14);
  border: 1px solid rgba(234, 179, 8, 0.4);
  padding: 2px 6px;
  border-radius: 5px;
  line-height: 1;
  white-space: nowrap;
  cursor: default;
}

.header-balance {
  display: flex;
  gap: 16px;
}

.balance-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.balance-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0;
}

.balance-value {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.app-header .balance-value .coin-amount {
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
}

.app-header .balance-value .fms-coin {
  --fms-coin-size: 32px;
  filter: drop-shadow(0 1px 4px rgba(251, 191, 36, 0.32));
}

.balance-value.equity {
  color: var(--blue);
}

.balance-value.balance-flash-up,
.balance-value.balance-flash-down {
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

.balance-value.balance-flash-up {
  color: var(--green);
  text-shadow: 0 0 12px rgba(63, 185, 80, 0.45);
}

.balance-value.balance-flash-down {
  color: var(--red);
  text-shadow: 0 0 12px rgba(248, 81, 73, 0.45);
}

.balance-value.equity.balance-flash-up {
  color: var(--green);
}

.balance-value.equity.balance-flash-down {
  color: var(--red);
}

.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.bottom-nav {
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  min-height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  transition: color 0.15s;
  position: relative;
}

.nav-btn.active {
  color: var(--blue);
}

.nav-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--blue);
  box-shadow: 0 0 10px rgba(88, 166, 255, 0.55);
}

.nav-icon { font-size: 18px; line-height: 1; }

.nav-icon.nav-icon-svg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}

.nav-icon.nav-icon-svg svg {
  width: 100%;
  height: 100%;
  display: block;
}

.nav-label { font-size: 10px; font-weight: 500; }

.sound-toggle {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  margin-left: 6px;
  flex-shrink: 0;
}

.sound-toggle.muted {
  opacity: 0.55;
}

.disclaimer {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  padding: 6px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Screens */
.screen {
  padding: 16px;
  padding-bottom: 24px;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

.screen-header {
  margin-bottom: 20px;
}

.screen-header h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* Instrument list */
.instrument-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text);
  text-align: left;
}

.instrument-card:active {
  background: var(--bg-elevated);
  border-color: var(--blue);
}

.instrument-card {
  gap: 12px;
}

.instrument-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

/* Gamified instrument badges — chunky rims, glow, category frames */
.coin-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: block;
  position: relative;
  border-radius: 50%;
  overflow: visible;
  background: transparent;
  border: none;
  box-shadow: none;
}

.coin-icon-game {
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}

.coin-icon-game.coin-icon-svg svg {
  width: 100%;
  height: 100%;
  display: block;
  color: var(--coin-color, #58a6ff);
}

.coin-icon-game::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 12px 2px var(--coin-glow, transparent);
  opacity: 0.55;
}

.coin-frame-crypto::after {
  opacity: 0.7;
}

.coin-frame-stock::after {
  box-shadow: 0 0 10px 1px var(--coin-glow, transparent), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.coin-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.6);
}

.coin-icon-svg svg {
  width: 100%;
  height: 100%;
  display: block;
}

.coin-icon-fallback {
  display: flex;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow:
    inset 0 2px 6px rgba(255, 255, 255, 0.2),
    0 2px 8px rgba(0, 0, 0, 0.4);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.trading-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.trading-title .coin-icon {
  width: 32px;
  height: 32px;
}

.instrument-symbol {
  font-weight: 600;
  font-size: 16px;
}

.instrument-name {
  font-size: 13px;
  color: var(--text-muted);
}

.instrument-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.price-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: color 0.15s ease, text-shadow 0.15s ease;
}

.price-value.price-flash-up {
  color: var(--green);
  text-shadow: 0 0 10px rgba(63, 185, 80, 0.4);
}

.price-value.price-flash-down {
  color: var(--red);
  text-shadow: 0 0 10px rgba(248, 81, 73, 0.4);
}

.price-change {
  font-size: 13px;
  font-weight: 500;
}

/* Trading screen */
.trading-screen {
  padding: 12px;
  padding-bottom: calc(12px + var(--sticky-order-h));
}

.trading-screen .screen-header {
  margin-bottom: 10px;
}

.trading-screen .subtitle {
  display: none;
}

.trading-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.trading-header h1 {
  font-size: 16px;
  line-height: 1.2;
}

.trade-price-block {
  text-align: right;
}

.trade-price-block .price-value {
  display: block;
  font-size: 18px;
}

.btn-icon {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trade-price-block .price-value {
  display: block;
  font-size: 16px;
}

.chart-block {
  position: relative;
  margin-bottom: 10px;
}

.chart-hud-label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: rgba(88, 166, 255, 0.55);
  text-transform: uppercase;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(88, 166, 255, 0.35);
}

.chart-trade-legend {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px;
  max-width: 112px;
  pointer-events: none;
}

.chart-legend-pill {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 6.5px;
  font-weight: 800;
  letter-spacing: 0.25px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-transform: uppercase;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.chart-legend-pill .pill-icon {
  font-size: 5.5px;
  line-height: 1;
}

.chart-legend-pill.buy {
  color: #5dff8a;
  background: rgba(93, 255, 138, 0.1);
  border-color: rgba(93, 255, 138, 0.35);
  box-shadow: none;
}

.chart-legend-pill.sell {
  color: #ff6b7a;
  background: rgba(255, 107, 122, 0.1);
  border-color: rgba(255, 107, 122, 0.35);
  box-shadow: none;
}

.chart-legend-pill.tp {
  color: #58ffa8;
  background: rgba(88, 255, 168, 0.1);
  border-color: rgba(88, 255, 168, 0.4);
}

.chart-legend-pill.sl {
  color: #ff4757;
  background: rgba(255, 71, 87, 0.1);
  border-color: rgba(255, 71, 87, 0.4);
}

.interval-tabs {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: flex;
  gap: 3px;
  margin: 0;
  padding: 3px;
  background: rgba(13, 17, 23, 0.88);
  border: 1px solid rgba(48, 54, 61, 0.9);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.interval-btn {
  flex: 0 0 auto;
  min-width: 30px;
  padding: 4px 7px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.interval-btn:hover:not(:disabled) {
  background: rgba(88, 166, 255, 0.1);
  color: var(--text);
}

.interval-btn.active {
  background: var(--blue-dim);
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: 0 0 8px rgba(88, 166, 255, 0.25);
}

.interval-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.chart-surface {
  position: relative;
  height: 168px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(88, 166, 255, 0.32);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(88, 166, 255, 0.1) 0%, transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(93, 255, 138, 0.04) 0%, transparent 40%),
    linear-gradient(180deg, rgba(22, 27, 34, 0.98) 0%, rgba(13, 17, 23, 1) 100%);
  box-shadow:
    inset 0 0 28px rgba(88, 166, 255, 0.06),
    0 4px 16px rgba(0, 0, 0, 0.35);
  transition: border-color 0.25s, box-shadow 0.25s;
}

.chart-loading {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(13, 17, 23, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
}

.chart-loading[hidden] {
  display: none;
}

.chart-loading-shimmer {
  width: min(72%, 220px);
  height: 56px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(48, 54, 61, 0.5) 0%,
    rgba(88, 166, 255, 0.22) 50%,
    rgba(48, 54, 61, 0.5) 100%
  );
  background-size: 200% 100%;
  animation: chartShimmer 1.2s ease-in-out infinite;
}

.chart-loading-text {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blue);
}

@keyframes chartShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.chart-block.is-loading .chart-wrap {
  opacity: 0.45;
}

.chart-block.is-loading .chart-wrap::after {
  animation-play-state: paused;
  opacity: 0;
}

.chart-wrap {
  position: relative;
  height: 100%;
  margin-bottom: 0;
  overflow: hidden;
  background: transparent;
}

.chart-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(88, 166, 255, 0.14);
  opacity: 0.85;
}

.chart-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(88, 166, 255, 0.025) 2px,
    rgba(88, 166, 255, 0.025) 4px
  );
  animation: chartScan 6s linear infinite;
}

@keyframes chartScan {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

.chart-effects-paused .chart-wrap::after {
  animation-play-state: paused;
}

.chart-block.has-position .chart-surface {
  border-color: rgba(93, 255, 138, 0.55);
  box-shadow:
    inset 0 0 36px rgba(93, 255, 138, 0.08),
    0 0 20px rgba(93, 255, 138, 0.14),
    0 4px 16px rgba(0, 0, 0, 0.35);
  animation: chartPulse 2.4s ease-in-out infinite;
}

.chart-block.has-position .chart-wrap::before {
  box-shadow: inset 0 0 0 1px rgba(93, 255, 138, 0.22);
}

@keyframes chartPulse {
  0%, 100% {
    box-shadow:
      inset 0 0 36px rgba(93, 255, 138, 0.08),
      0 0 16px rgba(93, 255, 138, 0.12),
      0 4px 16px rgba(0, 0, 0, 0.35);
  }
  50% {
    box-shadow:
      inset 0 0 42px rgba(93, 255, 138, 0.12),
      0 0 26px rgba(93, 255, 138, 0.22),
      0 4px 16px rgba(0, 0, 0, 0.35);
  }
}

.chart-container {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
  border-radius: inherit;
  isolation: isolate;
}

.chart-wrap > .chart-trade-links,
.chart-container > .chart-trade-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  overflow: visible;
}

.chart-wrap > .chart-pins-layer,
.chart-container > .chart-pins-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  overflow: visible;
}

.chart-trade-links {
  overflow: visible;
}

.chart-trade-link {
  fill: none;
  stroke-width: 1.25;
  stroke-dasharray: 4 3;
  opacity: 0.75;
  animation: tradeLinkDash 1.2s linear infinite;
}

.chart-trade-link.win {
  stroke: rgba(93, 255, 138, 0.5);
  filter: none;
}

.chart-trade-link.loss {
  stroke: rgba(255, 107, 122, 0.5);
  filter: none;
}

@keyframes tradeLinkDash {
  to { stroke-dashoffset: -18; }
}

.chart-trade-node {
  fill: #0d1117;
  stroke-width: 1.25;
}

.chart-trade-node.entry {
  stroke: #58a6ff;
}

.chart-trade-node.exit.win {
  stroke: #5dff8a;
}

.chart-trade-node.exit.loss {
  stroke: #ff6b7a;
}

.chart-pin-wrap {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  --callout-shift: 0px;
}

.chart-pin-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 5px;
  height: 5px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid #0d1117;
  box-shadow: 0 0 5px currentColor;
  z-index: 2;
}

.chart-pin-dot.pin-buy { background: #5dff8a; color: #5dff8a; }
.chart-pin-dot.pin-sell { background: #ff6b7a; color: #ff6b7a; }
.chart-pin-dot.pin-win { background: #5dff8a; color: #5dff8a; }
.chart-pin-dot.pin-loss { background: #ff6b7a; color: #ff6b7a; }
.chart-pin-dot.pin-tp { background: #58ffa8; color: #58ffa8; }
.chart-pin-dot.pin-sl { background: #ff4757; color: #ff4757; }
.chart-pin-dot.pin-liq { background: #fb923c; color: #fb923c; }

.chart-pin-callout {
  position: absolute;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateX(calc(-50% + var(--callout-shift)));
  color: #5dff8a;
}

.chart-pin-callout.pin-buy { color: #5dff8a; }
.chart-pin-callout.pin-sell { color: #ff6b7a; }
.chart-pin-callout.pin-win { color: #5dff8a; }
.chart-pin-callout.pin-loss { color: #ff6b7a; }
.chart-pin-callout.pin-tp { color: #58ffa8; }
.chart-pin-callout.pin-sl { color: #ff4757; }
.chart-pin-callout.pin-liq { color: #fb923c; }

.chart-pin-wrap.anchor-below .chart-pin-callout {
  top: calc(50% + 3px);
}

.chart-pin-wrap.anchor-above .chart-pin-callout {
  bottom: calc(50% + 3px);
  flex-direction: column-reverse;
}

.chart-pin-stem {
  display: block;
  width: 1px;
  height: 18px;
  background: currentColor;
  opacity: 0.75;
  box-shadow: 0 0 4px currentColor;
}

.chart-pin-badge {
  position: relative;
  left: auto;
  top: auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 4px;
  border-radius: 999px;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 6.5px;
  font-weight: 800;
  letter-spacing: 0.25px;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  text-transform: uppercase;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transform: none;
}

.chart-pin-icon {
  font-size: 5px;
  line-height: 1;
}

.chart-pin-badge.pin-buy {
  color: #062a14;
  background: linear-gradient(180deg, #7dffb0 0%, #5dff8a 100%);
  border-color: rgba(125, 255, 176, 0.65);
  box-shadow: none;
}

.chart-pin-badge.pin-sell {
  color: #2a0608;
  background: linear-gradient(180deg, #ff8a96 0%, #ff6b7a 100%);
  border-color: rgba(255, 138, 150, 0.65);
  box-shadow: none;
}

.chart-pin-badge.pin-win {
  color: #062a14;
  background: linear-gradient(180deg, #7dffb0 0%, #5dff8a 100%);
  border-color: rgba(125, 255, 176, 0.8);
}

.chart-pin-badge.pin-loss {
  color: #2a0608;
  background: linear-gradient(180deg, #ff8a96 0%, #ff6b7a 100%);
  border-color: rgba(255, 138, 150, 0.8);
}

.chart-pin-badge.pin-tp {
  color: #042818;
  background: linear-gradient(180deg, #8bffd0 0%, #58ffa8 100%);
  border-color: rgba(88, 255, 168, 0.65);
  box-shadow: none;
}

.chart-pin-badge.pin-sl {
  color: #2a0406;
  background: linear-gradient(180deg, #ff7080 0%, #ff4757 100%);
  border-color: rgba(255, 71, 87, 0.65);
  box-shadow: none;
}

.chart-pin-badge.pin-liq {
  color: #2a1200;
  background: linear-gradient(180deg, #fdba74 0%, #fb923c 100%);
  border-color: rgba(251, 146, 60, 0.65);
  box-shadow: none;
}

.chart-pin-wrap.pin-live .chart-pin-badge {
  animation: pinBadgePulse 1.6s ease-in-out infinite;
}

.chart-pin-wrap.pin-live .chart-pin-dot {
  animation: dotPulse 1.6s ease-in-out infinite;
}

@keyframes pinBadgePulse {
  0%, 100% { filter: brightness(1); transform: scale(1); }
  50% { filter: brightness(1.08); transform: scale(1.03); }
}

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 4px currentColor; }
  50% { box-shadow: 0 0 8px currentColor; }
}

/* Order panel */
.order-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  max-width: 100%;
  overflow: hidden;
}

.quick-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.quick-rows .size-presets {
  margin-bottom: 0;
}

.quick-rows .leverage-btns {
  display: flex;
  gap: 6px;
}

.size-max-loss-hint {
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
  background: rgba(248, 81, 73, 0.06);
  border: 1px solid rgba(248, 81, 73, 0.18);
}

.size-max-loss-hint .coin-amount {
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  vertical-align: middle;
}

.size-max-loss-hint .fms-coin {
  --fms-coin-size: 12px;
}

.max-loss-note {
  opacity: 0.8;
}

.sticky-order-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 100vw;
  bottom: calc(var(--nav-h) + var(--disclaimer-h));
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(13, 17, 23, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(88, 166, 255, 0.28);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.4);
}

.sticky-order-meta {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 88px;
}

.sticky-order-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sticky-order-margin {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sticky-order-margin .coin-amount {
  gap: 4px;
  font-size: 14px;
}

.sticky-order-margin .fms-coin {
  --fms-coin-size: 16px;
}

.sticky-order-btns {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
}

.sticky-order-btns .btn {
  padding: 12px 8px;
  font-size: 15px;
  font-weight: 800;
}

.trading-screen .toast {
  bottom: calc(var(--nav-h) + var(--disclaimer-h) + var(--sticky-order-h) + 12px);
}

.trading-screen .btn {
  padding: 12px 10px;
  font-size: 15px;
}

.side-chips {
  display: inline-flex;
  gap: 4px;
}

.tpsl-side-chips {
  margin-right: 2px;
}

.side-chip {
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
}

.side-chip.long.active {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.side-chip.short.active {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}

.size-panel-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.size-panel-top .label {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.size-panel-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.size-panel-left .label {
  font-size: 13px;
  color: var(--text-muted);
}

.size-qty-inline {
  flex: 1;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.size-qty-inline .size-qty-value {
  font-family: 'Baloo 2', sans-serif;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.size-qty-inline .size-qty-unit {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 4px;
}

.side-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.side-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.side-btn.long.active {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.side-btn.short.active {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}

.order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.order-row label {
  font-size: 14px;
  color: var(--text-muted);
}

.order-row input {
  width: 140px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  text-align: right;
}

/* Gamified position size slider */
.size-panel {
  --size-accent: var(--blue);
  --size-glow: rgba(88, 166, 255, 0.45);
  margin-bottom: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(88, 166, 255, 0.08) 0%, var(--bg) 100%);
  border: 1px solid rgba(88, 166, 255, 0.2);
  transition: border-color 0.2s, background 0.2s;
}

.size-panel[data-side="long"] {
  --size-accent: var(--green);
  --size-glow: rgba(63, 185, 80, 0.45);
  background: linear-gradient(180deg, rgba(63, 185, 80, 0.08) 0%, var(--bg) 100%);
  border-color: rgba(63, 185, 80, 0.22);
}

.size-panel[data-side="short"] {
  --size-accent: var(--red);
  --size-glow: rgba(248, 81, 73, 0.45);
  background: linear-gradient(180deg, rgba(248, 81, 73, 0.08) 0%, var(--bg) 100%);
  border-color: rgba(248, 81, 73, 0.22);
}

.size-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.size-panel-header .label {
  font-size: 14px;
  color: var(--text-muted);
}

.size-power-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--size-accent);
  background: color-mix(in srgb, var(--size-accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--size-accent) 35%, transparent);
  transition: transform 0.15s ease;
}

.size-power-badge[data-tier="all-in"] {
  animation: size-pulse 1.2s ease-in-out infinite;
}

@keyframes size-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.size-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.size-qty-value {
  font-family: 'Baloo 2', sans-serif;
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  text-shadow: 0 0 18px color-mix(in srgb, var(--size-accent) 35%, transparent);
}

.size-qty-unit {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}

.size-slider-wrap {
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.size-slider-fill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 8px;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--size-accent) 70%, #fff), var(--size-accent));
  box-shadow: 0 0 12px var(--size-glow);
  pointer-events: none;
  transition: width 0.08s linear;
}

.size-slider {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
}

.size-slider:focus {
  outline: none;
}

.size-slider:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.size-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.size-slider::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: radial-gradient(circle at 35% 35%, #fff 0%, var(--size-accent) 45%, color-mix(in srgb, var(--size-accent) 70%, #000) 100%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--size-accent) 25%, transparent), 0 0 14px var(--size-glow);
}

.size-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: radial-gradient(circle at 35% 35%, #fff 0%, var(--size-accent) 45%, color-mix(in srgb, var(--size-accent) 70%, #000) 100%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--size-accent) 25%, transparent), 0 0 14px var(--size-glow);
}

.size-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

#size-pct-label {
  font-weight: 700;
  color: var(--size-accent);
}

.trading-screen .size-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.trading-screen .size-preset-btn {
  padding: 6px 4px;
  font-size: 11px;
}

.trading-screen .leverage-btn {
  flex: 1;
  padding: 6px 4px;
  font-size: 12px;
}

.size-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.size-preset-btn {
  padding: 8px 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.size-preset-btn.active {
  background: color-mix(in srgb, var(--size-accent) 18%, transparent);
  border-color: var(--size-accent);
  color: var(--size-accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--size-accent) 25%, transparent);
}

.size-preset-btn[data-pct="100"].active {
  animation: size-pulse 1.2s ease-in-out infinite;
}

.leverage-row {
  margin-bottom: 12px;
}

.leverage-row .label {
  display: block;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.leverage-btns {
  display: flex;
  gap: 8px;
}

.leverage-btn {
  flex: 1;
  padding: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.leverage-btn.active {
  background: var(--blue-dim);
  border-color: var(--blue);
  color: var(--blue);
}

/* Exit plan (TP/SL) */
.tpsl-panel {
  margin-bottom: 0;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(136, 87, 255, 0.1) 0%, var(--bg) 100%);
  border: 1px solid rgba(136, 87, 255, 0.25);
  transition: opacity 0.2s;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.tpsl-panel.disabled {
  opacity: 0.72;
}

.tpsl-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tpsl-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tpsl-expand-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(136, 87, 255, 0.35);
  background: rgba(136, 87, 255, 0.12);
  color: #d2a8ff;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
}

.tpsl-expand-btn:hover {
  background: rgba(136, 87, 255, 0.22);
}

.tpsl-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tpsl-icon {
  font-size: 16px;
}

.tpsl-toggle-wrap {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.tpsl-toggle-wrap input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.tpsl-toggle-ui {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}

.tpsl-toggle-ui::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s, background 0.2s;
}

.tpsl-toggle-wrap input:checked + .tpsl-toggle-ui {
  background: rgba(136, 87, 255, 0.35);
  border-color: #a371f7;
}

.tpsl-toggle-wrap input:checked + .tpsl-toggle-ui::after {
  transform: translateX(20px);
  background: #d2a8ff;
}

.tpsl-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 0;
}

.tpsl-preset-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.tpsl-preset-emoji {
  font-size: 14px;
  line-height: 1;
}

.tpsl-preset-label {
  font-size: 11px;
  font-weight: 700;
}

.tpsl-preset-meta {
  display: none;
}

.tpsl-details {
  margin-top: 8px;
}

.tpsl-preset-btn.active {
  background: rgba(136, 87, 255, 0.18);
  border-color: #a371f7;
  color: #d2a8ff;
  box-shadow: 0 0 10px rgba(136, 87, 255, 0.25);
}

.tpsl-targets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.tpsl-target {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.tpsl-target.tp {
  border-color: rgba(63, 185, 80, 0.35);
  background: rgba(63, 185, 80, 0.08);
}

.tpsl-target.sl {
  border-color: rgba(248, 81, 73, 0.35);
  background: rgba(248, 81, 73, 0.08);
}

.tpsl-target-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.tpsl-target-price {
  font-family: 'Baloo 2', sans-serif;
  font-size: 15px;
  font-weight: 700;
}

.tpsl-target.tp .tpsl-target-price { color: var(--green); }
.tpsl-target.sl .tpsl-target-price { color: var(--red); }

.tpsl-custom {
  margin-bottom: 8px;
  max-width: 100%;
}

.tpsl-custom-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.tpsl-custom-inputs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
}

.tpsl-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.tpsl-input-row.tp {
  border-color: rgba(63, 185, 80, 0.25);
}

.tpsl-input-row.sl {
  border-color: rgba(248, 81, 73, 0.25);
}

.tpsl-input-row.has-value.tp {
  border-color: rgba(63, 185, 80, 0.55);
  box-shadow: 0 0 10px rgba(63, 185, 80, 0.12);
}

.tpsl-input-row.has-value.sl {
  border-color: rgba(248, 81, 73, 0.55);
  box-shadow: 0 0 10px rgba(248, 81, 73, 0.12);
}

.tpsl-input-label {
  flex-shrink: 0;
  width: 36px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.tpsl-stepper {
  display: flex;
  align-items: stretch;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.tpsl-step-btn {
  flex-shrink: 0;
  width: 28px;
  min-height: 36px;
  padding: 0;
  border-radius: 8px;
  border: none;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.tpsl-input-row.tp .tpsl-step-btn {
  color: #b7f5c4;
  background: linear-gradient(180deg, rgba(63, 185, 80, 0.55) 0%, rgba(34, 120, 50, 0.85) 100%);
  border: 1px solid rgba(126, 231, 145, 0.55);
  box-shadow:
    0 3px 0 rgba(15, 50, 22, 0.9),
    0 0 12px rgba(63, 185, 80, 0.2);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.tpsl-input-row.sl .tpsl-step-btn {
  color: #ffd0cc;
  background: linear-gradient(180deg, rgba(248, 81, 73, 0.55) 0%, rgba(150, 35, 30, 0.9) 100%);
  border: 1px solid rgba(255, 140, 130, 0.5);
  box-shadow:
    0 3px 0 rgba(60, 15, 12, 0.9),
    0 0 12px rgba(248, 81, 73, 0.2);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.tpsl-step-btn:hover {
  filter: brightness(1.08);
}

.tpsl-step-btn:active {
  transform: translateY(2px) scale(0.96);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.tpsl-price-input {
  flex: 1;
  min-width: 0;
  width: 0;
  padding: 6px 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-variant-numeric: tabular-nums;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.tpsl-price-input::-webkit-outer-spin-button,
.tpsl-price-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.tpsl-input-row.tp .tpsl-price-input:focus {
  outline: none;
  border-color: var(--green);
}

.tpsl-input-row.sl .tpsl-price-input:focus {
  outline: none;
  border-color: var(--red);
}

.tpsl-input-row.tp .tpsl-price-input { color: var(--green); }
.tpsl-input-row.sl .tpsl-price-input { color: var(--red); }

.tpsl-hint {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.tpsl-hint-error {
  color: var(--red);
  font-weight: 600;
}

.exit-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.exit-tag.tp {
  color: var(--green);
  background: var(--green-dim);
  border: 1px solid rgba(63, 185, 80, 0.35);
}

.exit-tag.sl {
  color: var(--red);
  background: var(--red-dim);
  border: 1px solid rgba(248, 81, 73, 0.35);
}

.exit-tag.liq {
  color: #fb923c;
  background: rgba(251, 146, 60, 0.15);
  border: 1px solid rgba(251, 146, 60, 0.4);
}

.exit-tag.none {
  color: var(--text-muted);
  background: transparent;
  border: none;
  padding: 0;
  font-weight: 500;
}

.position-exits,
.position-exits-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.position-row-tpsl {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.position-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.position-row-tpsl.is-editing-tpsl {
  border-color: rgba(88, 166, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(88, 166, 255, 0.15);
}

.position-tpsl-editor {
  width: 100%;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.position-tpsl-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.position-tpsl-presets {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.position-tpsl-preset-btn {
  flex: 1;
  padding: 6px 4px;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 10px;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
}

.position-tpsl-preset-btn:active {
  opacity: 0.85;
}

.position-tpsl-inputs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.position-tpsl-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.position-tpsl-hint.error {
  color: var(--red);
}

.position-tpsl-hint.ok {
  color: var(--green);
}

.position-tpsl-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.btn-tpsl-edit.active {
  background: var(--blue-dim);
  border-color: var(--blue);
  color: var(--blue);
}

.btn-tpsl-save {
  background: var(--green-dim);
  border: 1px solid var(--green);
  color: var(--green);
}

.btn-tpsl-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.position-row-tpsl .position-info {
  flex: 1 1 140px;
  min-width: 0;
}

.position-row-tpsl .position-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.btn-tpsl-set {
  padding: 6px 8px;
  min-width: 36px;
}

.btn-tpsl-edit {
  padding: 6px 8px;
  min-width: 36px;
}

.detail-full {
  grid-column: 1 / -1;
}

.margin-row {
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.margin-value {
  font-weight: 600;
}

.trade-btns {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:active { opacity: 0.8; }

.btn-long {
  background: var(--green);
  color: #fff;
}

.btn-short {
  background: var(--red);
  color: #fff;
}

.btn-sm {
  flex: none;
  padding: 6px 12px;
  font-size: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-close {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}

/* Open positions */
.open-positions h3 {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.trading-screen .open-positions {
  margin: 12px 0 14px;
}

.trading-screen .open-positions h3 {
  margin-bottom: 8px;
}

.position-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.position-row.position-row-tpsl {
  flex-direction: column;
  align-items: stretch;
}

.position-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.position-side {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.position-side.long { color: var(--green); }
.position-side.short { color: var(--red); }

.position-qty, .position-entry {
  font-size: 12px;
  color: var(--text-muted);
}

.position-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.position-pnl {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Portfolio */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.portfolio-section {
  margin-bottom: 24px;
}

.portfolio-section h2 {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.position-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.position-card-tpsl .position-tpsl-editor {
  margin-top: 4px;
  padding-top: 12px;
}

.position-card-tpsl .btn-close-portfolio {
  width: 100%;
  margin-top: 10px;
}

.position-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.position-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.detail {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 11px;
  color: var(--text-muted);
}

.history-row {
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.history-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.history-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.history-detail {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.btn-reset {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  margin-top: 8px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px;
}

/* Market sections & badges */
.market-section {
  margin-bottom: 20px;
}

.market-section-title {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.instrument-symbol-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.market-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  vertical-align: middle;
  white-space: nowrap;
}

.market-badge.live {
  color: var(--green);
  background: var(--green-dim);
}

.market-badge.delayed {
  color: #f0b72f;
  background: rgba(240, 183, 47, 0.15);
}

.market-badge.closed {
  color: var(--text-muted);
  background: var(--bg-elevated);
}

.market-badge.nokey {
  color: var(--red);
  background: var(--red-dim);
}

.api-banner {
  background: rgba(240, 183, 47, 0.08);
  border: 1px solid rgba(240, 183, 47, 0.35);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.api-banner a {
  color: #f0b72f;
}

.api-banner code {
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

.api-banner-dev .api-banner-label {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f0b72f;
  background: rgba(240, 183, 47, 0.15);
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 6px;
  vertical-align: middle;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.market-closed-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Stats screen */
.perf-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, #1a2230 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  margin-bottom: 16px;
}

.perf-main {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.perf-pnl {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.perf-return {
  font-size: 16px;
  font-weight: 600;
}

.perf-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.perf-equity {
  font-size: 13px;
  color: var(--text-muted);
}

.rank-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.rank-scout { color: var(--blue); border-color: var(--blue); background: var(--blue-dim); }
.rank-challenger { color: var(--green); border-color: var(--green); background: var(--green-dim); }
.rank-pro { color: #d2a8ff; border-color: #8957e5; background: rgba(137, 87, 229, 0.15); }
.rank-legend { color: #f0b72f; border-color: #f0b72f; background: rgba(240, 183, 47, 0.15); }

.equity-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.equity-svg {
  display: block;
  width: 100%;
  height: 90px;
}

.risk-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.risk-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.risk-cautious .risk-title { color: var(--green); }
.risk-balanced .risk-title { color: var(--blue); }
.risk-aggressive .risk-title { color: #f0b72f; }
.risk-degen .risk-title { color: var(--red); }

.risk-blurb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.risk-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.breakdown-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.ls-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--red-dim);
  overflow: hidden;
  margin-bottom: 8px;
}

.ls-long {
  height: 100%;
  background: var(--green);
  border-radius: 4px 0 0 4px;
}

.ls-legend {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.breakdown-label {
  color: var(--text-muted);
}

.breakdown-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.achievement {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.achievement.locked {
  opacity: 0.55;
}

.achievement.unlocked {
  border-color: rgba(240, 183, 47, 0.4);
}

.achievement-icon {
  font-size: 20px;
}

.achievement-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.achievement-label {
  font-size: 14px;
  font-weight: 600;
}

.achievement-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* Daily streak */
.streak-section {
  margin-bottom: 16px;
}

.streak-card {
  background: linear-gradient(135deg, rgba(248, 81, 73, 0.12) 0%, var(--bg-card) 55%);
  border: 1px solid rgba(248, 81, 73, 0.35);
  border-radius: var(--radius);
  padding: 16px;
}

.streak-card.streak-legend {
  background: linear-gradient(135deg, rgba(240, 183, 47, 0.15) 0%, var(--bg-card) 55%);
  border-color: rgba(240, 183, 47, 0.45);
  box-shadow: 0 0 20px rgba(240, 183, 47, 0.12);
}

.streak-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.streak-count-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.streak-flame-big {
  font-size: 36px;
  line-height: 1;
}

.streak-count-num {
  font-family: 'Baloo 2', sans-serif;
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  color: #ff6b4a;
}

.streak-legend .streak-count-num {
  color: #f0b72f;
}

.streak-count-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.streak-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.streak-meta-item.claimed strong {
  color: var(--green);
}

.streak-meta strong {
  color: var(--text);
}

.streak-dots {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.streak-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  min-height: 52px;
  justify-content: center;
}

.streak-dot.filled {
  background: rgba(248, 81, 73, 0.12);
  border-color: rgba(248, 81, 73, 0.4);
}

.streak-dot.active {
  border-color: #ff6b4a;
  box-shadow: 0 0 12px rgba(248, 81, 73, 0.25);
}

.streak-legend .streak-dot.filled {
  background: rgba(240, 183, 47, 0.12);
  border-color: rgba(240, 183, 47, 0.4);
}

.streak-dot-day {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.streak-dot-flame {
  font-size: 14px;
  line-height: 1;
}

.streak-dot-coin {
  font-size: 8px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
}

.streak-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

.streak-legend-badge {
  margin-top: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #f0b72f;
}

/* Leaderboard */
.leaderboard-hero {
  text-align: center;
  padding: 16px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(240, 183, 47, 0.12) 0%, var(--bg-card) 100%);
  border: 1px solid rgba(240, 183, 47, 0.3);
}

.leaderboard-trophy {
  font-size: 36px;
  display: block;
  margin-bottom: 8px;
}

.leaderboard-hero-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.leaderboard-status {
  font-size: 14px;
  font-weight: 700;
  color: #f0b72f;
}

.leaderboard-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.btn-refresh {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.leaderboard-row.player-row {
  border-color: rgba(88, 166, 255, 0.5);
  background: rgba(88, 166, 255, 0.08);
  box-shadow: 0 0 12px rgba(88, 166, 255, 0.12);
}

.lb-rank {
  font-family: 'Baloo 2', sans-serif;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.lb-player {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lb-avatar,
.lb-avatar-fallback {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

.lb-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  color: var(--blue);
}

.lb-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-you {
  color: var(--blue);
  font-weight: 700;
}

.lb-score {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--disclaimer-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 100;
  animation: toastIn 0.2s ease;
  white-space: nowrap;
}

.toast-success {
  background: var(--green);
  color: #fff;
}

.toast-error {
  background: var(--red);
  color: #fff;
}

.toast-global {
  z-index: 200;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 700;
  max-width: calc(100vw - 32px);
  white-space: normal;
  text-align: center;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (min-width: 768px) {
  .app {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .sticky-order-bar {
    max-width: 480px;
  }

  .chart-surface {
    height: 280px;
  }
}

/* Nav "new" dot — Learn tab with unfinished courses */
.nav-btn {
  position: relative;
}

.nav-btn.has-new .nav-icon::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 50%;
  transform: translateX(14px);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.8);
}

/* Learn — contextual hint on trading screen */
.learn-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(88, 166, 255, 0.08);
  border: 1px solid rgba(88, 166, 255, 0.28);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.learn-hint:hover {
  background: rgba(88, 166, 255, 0.14);
  border-color: var(--blue);
}

.learn-hint-icon {
  font-size: 15px;
  flex-shrink: 0;
}

.learn-hint-text {
  flex: 1;
}

.learn-hint-arrow {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  color: var(--blue);
  font-weight: 800;
  flex-shrink: 0;
}

/* Learn — hub & player typography */
.learn-screen {
  padding: 16px;
  padding-bottom: 24px;
  font-family: 'Nunito', sans-serif;
}

.learn-screen .screen-header h1 {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.learn-screen .subtitle {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.4;
}

.course-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.course-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.1s, background 0.15s;
}

.course-card:hover {
  border-color: var(--blue);
  background: var(--bg-elevated);
}

.course-card:active {
  transform: scale(0.99);
}

.course-card.done {
  border-color: rgba(63, 185, 80, 0.4);
}

.course-card-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.course-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.course-card-title {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.course-card-sub {
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-muted);
}

.course-card-meta {
  font-family: 'Nunito', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 3px;
}

.course-card-status {
  flex-shrink: 0;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--text-muted);
}

.course-card.done .course-card-status {
  color: var(--green);
}

.learn-foot-note {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(88, 166, 255, 0.08), rgba(234, 179, 8, 0.06));
  border: 1px solid rgba(88, 166, 255, 0.22);
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--text-muted);
  text-align: center;
}

.learn-foot-note strong {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 700;
  color: var(--blue);
}

/* Learn — course player */
.course-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.course-top-title {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.course-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
}

.course-dot {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-elevated);
  transition: background 0.2s;
}

.course-dot.filled {
  background: var(--blue);
}

.course-dot.active {
  background: #93c5fd;
}

.course-step {
  min-height: 0;
  padding-bottom: 8px;
}

.course-step-num {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
  opacity: 0.85;
}

.course-step-title {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  margin: 10px 0 14px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.course-step-body {
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.65;
  color: rgba(230, 237, 243, 0.94);
  letter-spacing: 0.01em;
}

.course-nav {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.course-nav-btn {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius);
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: 1px solid var(--border);
}

.course-nav-btn.ghost {
  background: var(--bg-card);
  color: var(--text);
}

.course-nav-btn.ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.course-nav-btn.primary {
  background: linear-gradient(135deg, var(--blue) 0%, #2563eb 100%);
  border-color: transparent;
  color: #fff;
}

.course-nav-btn.primary:active {
  transform: scale(0.98);
}

/* Learn — finish */
.course-finish {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 12px;
  gap: 8px;
}

.course-finish-badge {
  font-size: 48px;
}

.course-finish h2 {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.course-finish-sub {
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.course-cta {
  width: 100%;
  margin-top: 6px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(88, 166, 255, 0.4);
  background: linear-gradient(135deg, rgba(88, 166, 255, 0.16), rgba(234, 179, 8, 0.08));
  color: var(--text);
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.35;
  cursor: pointer;
}

.course-cta:hover {
  border-color: var(--blue);
}

.course-finish-done {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
}

/* Learn — quiz */
.course-quiz {
  padding: 8px 0 16px;
}

.course-quiz-label {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
  opacity: 0.9;
}

.course-quiz-question {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  margin: 10px 0 12px;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.course-quiz-prize {
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #fbbf24;
  margin-bottom: 16px;
}

.course-quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.course-quiz-opt {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.course-quiz-opt:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--bg-elevated);
}

.course-quiz-opt:active:not(:disabled) {
  transform: scale(0.99);
}

.course-quiz-opt.correct {
  border-color: var(--green);
  background: var(--green-dim);
}

.course-quiz-opt.wrong {
  border-color: var(--red);
  background: var(--red-dim);
  animation: quizShake 0.35s ease;
}

@keyframes quizShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.course-quiz-feedback {
  margin-top: 14px;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.course-quiz-feedback.hidden {
  display: none;
}

.course-quiz-feedback.error {
  color: var(--red);
}

.course-quiz-feedback.success {
  color: var(--green);
}

.course-quiz-reward {
  margin: 8px 0 4px;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: #fbbf24;
}

.course-finish-reward-note {
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}
