:root {
  --navy-950: #071025;
  --blue-accent: #719CE3;
  --blue-mid: #2C4F7F;
  --lavender: #AEA6CC;
  --blue-deep: #4A75BB;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--navy-950);
  color: #e4e7f1;
}
.hidden { display: none !important; }

/* ============================ INTRO SCREEN ============================ */
.intro-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, var(--blue-mid) 0%, var(--navy-950) 65%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.flying-text-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.flying-text {
  position: absolute;
  left: -30%;
  white-space: nowrap;
  font-weight: 800;
  color: rgba(113, 156, 227, 0.14);
  animation-name: fly-diagonal;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes fly-diagonal {
  from { transform: translate(0, 0) rotate(-6deg); }
  to { transform: translate(160vw, 30vh) rotate(-6deg); }
}
.auth-bar { text-align: center; margin-bottom: 20px; font-size: 12px; color: var(--lavender); position: relative; z-index: 1; }
.auth-bar b { color: var(--blue-accent); }
.link-btn {
  background: none; border: none; color: var(--blue-accent);
  text-decoration: underline; cursor: pointer; padding: 0; font-size: inherit;
}
.auth-forms { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.auth-forms input { width: 140px; }
.auth-error { color: #ef5350; font-size: 11px; width: 100%; text-align: center; }

.intro-content { text-align: center; max-width: 520px; width: 100%; position: relative; z-index: 1; }
.intro-logo {
  margin: 0;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--blue-accent);
  text-shadow: 0 0 24px rgba(113, 156, 227, 0.35);
}
.intro-tagline {
  margin: 6px 0 32px;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lavender);
}
.intro-card {
  background: rgba(44, 79, 127, 0.25);
  border: 1px solid var(--blue-mid);
  border-radius: 12px;
  padding: 28px;
  backdrop-filter: blur(6px);
}
.intro-field { margin-bottom: 24px; text-align: left; }
.intro-field label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--lavender);
  margin-bottom: 10px;
}
.date-selects { display: flex; gap: 8px; }
.date-selects select { flex: 1; }

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.account-card {
  background: rgba(7, 16, 37, 0.6);
  border: 1px solid var(--blue-mid);
  border-radius: 8px;
  padding: 14px 10px;
  color: #e4e7f1;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.account-card:hover { border-color: var(--blue-accent); }
.account-card.selected {
  border-color: var(--blue-accent);
  background: rgba(113, 156, 227, 0.15);
  box-shadow: 0 0 0 1px var(--blue-accent);
}
.account-card-label { font-size: 16px; font-weight: 700; color: var(--blue-accent); }
.account-card-detail { font-size: 11px; color: var(--lavender); }

.sessions-list { display: flex; flex-direction: column; gap: 8px; max-height: 160px; overflow-y: auto; }

.payout-island {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
  background: rgba(76, 175, 130, 0.15);
  border: 1px solid #4caf82;
  color: #4caf82;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 999px;
}

.leaderboard-panel {
  position: absolute;
  top: 50%;
  right: 40px;
  transform: translateY(-50%);
  z-index: 1;
  width: 240px;
  background: rgba(44, 79, 127, 0.2);
  border: 1px solid var(--blue-mid);
  border-radius: 12px;
  padding: 20px;
  backdrop-filter: blur(6px);
}
.leaderboard-panel h3 {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--blue-accent);
  text-align: center;
}
.leaderboard-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.lb-tab {
  flex: 1;
  background: transparent;
  border: 1px solid var(--blue-mid);
  color: var(--lavender);
  padding: 6px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.lb-tab.active { background: var(--blue-deep); border-color: var(--blue-deep); color: #fff; }
.leaderboard-list { list-style: decimal; margin: 0; padding-left: 20px; font-size: 13px; color: #e4e7f1; }
.leaderboard-list li { margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
.leaderboard-list .lb-value { color: var(--blue-accent); font-weight: 700; }

.payout-ready-notice {
  position: fixed;
  left: 12px;
  bottom: 90px;
  z-index: 20;
  border-radius: 12px;
  padding: 3px;
  overflow: hidden;
}
.payout-ready-notice::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  animation: spin-rgb 3s linear infinite;
}
@keyframes spin-rgb { to { transform: rotate(360deg); } }
.payout-ready-inner {
  position: relative;
  z-index: 1;
  background: #0b1730;
  border-radius: 9px;
  padding: 14px 18px;
  text-align: center;
  min-width: 200px;
}
.payout-ready-inner p { margin: 0 0 10px; color: #e4e7f1; font-weight: 600; font-size: 13px; }
.payout-ready-inner .notice-close { position: absolute; top: 2px; right: 6px; background: transparent; border: none; color: var(--lavender); font-size: 15px; }
.money-particle {
  position: absolute;
  font-size: 16px;
  color: #4caf82;
  pointer-events: none;
  animation: money-burst 1s ease-out forwards;
  z-index: 30;
}
@keyframes money-burst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0.5); opacity: 0; }
}

.payout-box { max-width: 380px; }
#payoutSlider { width: 100%; margin: 16px 0; }
.payout-amount-display { font-size: 28px; font-weight: 700; color: #4caf82; text-align: center; margin-bottom: 12px; }
.payout-error { color: #ef5350; font-size: 12px; min-height: 16px; margin: 0 0 12px !important; }

.shop-panel {
  position: absolute;
  top: 50%;
  left: 40px;
  transform: translateY(-50%);
  z-index: 1;
  width: 220px;
  background: rgba(44, 79, 127, 0.2);
  border: 1px solid var(--blue-mid);
  border-radius: 12px;
  padding: 20px;
  backdrop-filter: blur(6px);
}
.shop-panel h3 { margin: 0 0 14px; font-size: 14px; color: var(--blue-accent); text-align: center; }
.shop-theme-grid { display: flex; flex-direction: column; gap: 8px; }
.shop-theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--blue-mid);
  border-radius: 8px;
  background: rgba(7, 16, 37, 0.6);
  color: #e4e7f1;
  cursor: pointer;
  font-family: inherit;
}
.shop-theme-btn:hover { border-color: var(--blue-accent); }
.shop-theme-btn.owned { border-color: #4caf82; }
.shop-theme-btn.active-theme { border-color: #f2c94c; background: rgba(242, 201, 76, 0.1); }
.shop-theme-btn .theme-name { font-size: 13px; font-weight: 700; }
.shop-theme-btn .theme-price { font-size: 11px; color: var(--lavender); margin-top: 2px; }

.theme-preview-box { max-width: 420px; }
.theme-preview-chart {
  height: 140px;
  border-radius: 8px;
  overflow: hidden;
  margin: 16px 0;
  display: flex;
}
.theme-preview-chart .tp-price { flex: 1 1 60%; }
.theme-preview-chart .tp-stoch { flex: 1 1 10%; border-left: 1px solid rgba(255,255,255,0.1); }

.brokie-toast {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  color: #ef5350;
  font-size: 22px;
  font-weight: 800;
  text-shadow: 0 0 10px rgba(239, 83, 80, 0.6);
  animation: brokie-fade 4s ease-out forwards;
  pointer-events: none;
}
@keyframes brokie-fade {
  0% { opacity: 0; transform: translate(-50%, -40%); }
  15% { opacity: 1; transform: translate(-50%, -50%); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

.title-preview-box { max-width: 380px; }
.title-preview-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 20px 0 8px;
  font-size: 16px;
  color: #e4e7f1;
}
.title-preview-caption { font-size: 12px; color: var(--lavender); text-align: center; margin-bottom: 16px !important; }

/* ============================ DRAWING TOOLS ============================ */
.tools-control-group { position: relative; }
.tools-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #0b1730;
  border: 1px solid var(--blue-mid);
  border-radius: 6px;
  padding: 6px;
  z-index: 50;
  min-width: 130px;
}
.tool-option {
  text-align: left;
  background: transparent;
  border: none;
  color: #e4e7f1;
  padding: 7px 10px;
  border-radius: 4px;
  font-size: 13px;
}
.tool-option:hover { background: rgba(113, 156, 227, 0.15); }
.tool-option.active { background: var(--blue-deep); color: #fff; }

.drawings-layer { position: absolute; inset: 0; pointer-events: none; z-index: 7; overflow: hidden; }
.lines-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.lines-svg line { pointer-events: stroke; cursor: move; stroke-width: 2; }
.lines-svg line.selected { stroke-width: 3; }
.lines-svg circle.line-handle { pointer-events: all; cursor: nwse-resize; fill: var(--blue-accent); }

.drawing-textbox {
  position: absolute;
  pointer-events: all;
  background: rgba(11, 23, 48, 0.85);
  border: 1px solid var(--blue-accent);
  border-radius: 4px;
  padding: 4px 6px;
  color: #e4e7f1;
  font-size: 13px;
  cursor: move;
  overflow: auto;
  min-width: 40px;
  min-height: 20px;
}
.drawing-textbox:focus { outline: none; cursor: text; }
.drawing-textbox .resize-handle {
  position: absolute;
  right: -4px; bottom: -4px;
  width: 10px; height: 10px;
  background: var(--blue-accent);
  border-radius: 2px;
  cursor: nwse-resize;
  pointer-events: all;
}
.drawing-textbox .drawing-delete {
  position: absolute;
  top: -10px; right: -10px;
  width: 16px; height: 16px;
  background: #ef5350;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  pointer-events: all;
  display: none;
}
.drawing-textbox.selected .drawing-delete { display: block; }

.position-box {
  position: absolute;
  pointer-events: none;
}
.position-box .zone {
  position: absolute;
  left: 0; right: 0;
  pointer-events: all;
}
.position-box .zone.profit { background: rgba(76, 175, 130, 0.25); border-top: 1px solid #4caf82; }
.position-box .zone.loss { background: rgba(239, 83, 80, 0.25); border-bottom: 1px solid #ef5350; }
.position-box .edge-handle {
  position: absolute;
  left: 0; right: 0;
  height: 6px;
  cursor: ns-resize;
  pointer-events: all;
}
.position-box .entry-line { position: absolute; left: 0; right: 0; border-top: 1px dashed #e4e7f1; }
.position-box .position-label {
  position: absolute;
  right: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  color: #071025;
  white-space: nowrap;
  pointer-events: none;
  display: none;
}
.position-box .position-label.profit-label { background: #4caf82; }
.position-box .position-label.loss-label { background: #ef5350; }
.position-box:hover .position-label { display: block; }
.position-box .drawing-delete {
  position: absolute;
  top: -10px; right: -10px;
  width: 16px; height: 16px;
  background: #ef5350;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  pointer-events: all;
  display: none;
  z-index: 2;
}
.position-box.selected .drawing-delete { display: block; }
.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--blue-mid);
  border-radius: 6px;
  background: rgba(7, 16, 37, 0.6);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.session-item:hover { border-color: var(--blue-accent); }
.session-main { display: flex; flex-direction: column; gap: 2px; }
.session-title { font-size: 13px; font-weight: 600; color: #e4e7f1; }
.session-sub { font-size: 11px; color: var(--lavender); }
.session-badge { font-size: 10px; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; flex-shrink: 0; }
.session-badge.active { background: rgba(113, 156, 227, 0.2); color: var(--blue-accent); }
.session-badge.passed { background: rgba(76, 175, 130, 0.2); color: #4caf82; }
.session-badge.failed { background: rgba(239, 83, 80, 0.2); color: #ef5350; }
.session-badge.payout-ready { background: rgba(242, 201, 76, 0.2); color: #f2c94c; font-weight: 700; }
.session-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.session-delete {
  background: transparent; border: none; color: var(--lavender);
  font-size: 16px; line-height: 1; padding: 2px 6px; cursor: pointer;
}
.session-delete:hover { color: #ef5350; }

.start-btn {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, var(--blue-deep), var(--blue-accent));
  color: #071025;
  cursor: pointer;
}
.start-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.start-btn:not(:disabled):hover { filter: brightness(1.08); }

select, input, button {
  background: #101b34;
  color: #e4e7f1;
  border: 1px solid var(--blue-mid);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
}

/* ============================ CHALLENGE MODAL ============================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 16, 37, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--navy-950);
  border: 1px solid var(--blue-accent);
  border-radius: 12px;
  padding: 32px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 0 40px rgba(113, 156, 227, 0.25);
}
.modal-box h2 { margin: 0 0 12px; color: var(--blue-accent); }
.modal-box p { margin: 0 0 24px; color: var(--lavender); line-height: 1.5; }
.modal-box.passed h2 { color: #4caf82; }
.modal-box.failed h2 { color: #ef5350; }

.modal-btn-row { display: flex; gap: 10px; }
.modal-btn-row button { flex: 1; padding: 14px; border-radius: 8px; font-weight: 700; font-size: 14px; }
.stay-btn {
  background: transparent;
  border: 1px solid var(--blue-mid);
  color: var(--lavender);
  cursor: pointer;
}
.stay-btn:hover { border-color: var(--blue-accent); color: #e4e7f1; }

.funded-box { max-width: 460px; text-align: left; }
.funded-title { text-align: center; font-size: 26px; color: var(--blue-accent); margin: 0 0 4px; }
.funded-subtitle { text-align: center; font-size: 12px; color: var(--lavender); margin: 0 0 20px; }
.funded-info-heading { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--lavender); margin: 0 0 10px; }
.funded-info-list { margin: 0 0 16px; padding-left: 20px; color: #e4e7f1; font-size: 13px; line-height: 1.6; }
.funded-info-list li { margin-bottom: 6px; }
.funded-small-print { text-align: center; font-size: 11px; color: var(--lavender); margin: 0 0 20px; }

/* ============================ APP SCREEN ============================ */
.app-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: #0b1730;
  border-bottom: 1px solid var(--blue-mid);
  flex-shrink: 0;
}
.brand { font-weight: 700; font-size: 15px; color: #ffffff; margin-right: 8px; }
.control-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.control-group.push-right { margin-left: auto; }
.inline-label { font-size: 12px; color: var(--lavender); }
button { cursor: pointer; }
button:hover { border-color: var(--blue-accent); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.tf-btn.active { background: var(--blue-deep); border-color: var(--blue-deep); color: #fff; }
button.danger { color: #ef5350; }
#fullscreenBtn { display: inline-flex; align-items: center; gap: 6px; }
.fullscreen-icon { flex-shrink: 0; }

.layout { display: flex; flex: 1 1 auto; min-height: 0; }
.chart-main { flex: 1 1 65%; min-width: 0; position: relative; }
#priceChart { width: 100%; height: 100%; }

.bar-countdown {
  position: absolute;
  right: 4px;
  padding: 3px 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: #071025;
  background: var(--blue-accent);
  border-radius: 3px;
  pointer-events: none;
  display: none;
  z-index: 5;
}

.trade-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px dashed;
  cursor: ns-resize;
  z-index: 4;
}
.trade-line.sl-line { border-color: #ef5350; cursor: ns-resize; }
.trade-line.tp-line { border-color: #4caf82; cursor: ns-resize; }
.trade-line.entry-line { border-color: #ffffff; cursor: default; }
.trade-line.current-price-line { border-color: #719CE3; cursor: default; z-index: 3; }
.trade-line.dragging { border-style: solid; }
.trade-line-label {
  position: absolute;
  right: 4px;
  top: -18px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  color: #071025;
  pointer-events: none;
}
.sl-line .trade-line-label { background: #ef5350; }
.tp-line .trade-line-label { background: #4caf82; }
.entry-line .trade-line-label { background: #ffffff; }

.trade-blocked-notice {
  position: absolute;
  left: 12px;
  bottom: 78px;
  z-index: 6;
  max-width: 280px;
  padding: 10px 28px 10px 12px;
  background: rgba(239, 83, 80, 0.15);
  border: 1px solid #ef5350;
  border-radius: 8px;
  color: #ffdad8;
  font-size: 12px;
  line-height: 1.4;
}
.trade-blocked-notice .notice-close {
  position: absolute;
  top: 4px;
  right: 6px;
  background: transparent;
  border: none;
  color: #ffdad8;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
}
.trade-blocked-notice .notice-close:hover { color: #fff; }

.funded-tag {
  color: #f2c94c;
  font-weight: 700;
  margin: 0 4px;
}

.trade-hud {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(7, 16, 37, 0.82);
  border: 1px solid var(--blue-mid);
  border-radius: 8px;
  backdrop-filter: blur(4px);
  max-width: calc(100% - 24px);
}
.hud-inputs { display: flex; gap: 8px; }
.hud-inputs label {
  display: flex;
  flex-direction: column;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--lavender);
  gap: 3px;
}
.hud-inputs input { width: 64px; }
.hud-actions { display: flex; gap: 6px; }
.hud-actions button { padding: 8px 12px; font-weight: 600; }
.analytics-btn { background: transparent; border: 1px solid var(--blue-accent); color: var(--blue-accent); }
.analytics-btn:hover { background: rgba(113, 156, 227, 0.12); }
.open-trade-info { font-size: 12px; white-space: nowrap; }

.stoch-column {
  flex: 1 1 35%;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--blue-mid);
}
.stoch-panel {
  flex: 1 1 25%;
  min-height: 0;
  border-bottom: 1px solid var(--blue-mid);
  position: relative;
}
.stoch-panel:last-child { border-bottom: none; }
.stoch-value-label {
  position: absolute;
  top: 4px;
  left: 8px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 5;
}
.stoch-panel > div { width: 100%; height: 100%; }

.panel-block { margin-bottom: 24px; }
.panel-block h3 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--lavender);
  letter-spacing: 0.06em;
}

.account-block .stat, .stats-block .stat, .trade-row {
  display: flex; justify-content: space-between; font-size: 13px;
  padding: 5px 0; border-bottom: 1px solid #14213f;
}

button.buy { background: #2e9c76; border-color: #2e9c76; color: #fff; }
button.sell { background: #ef5350; border-color: #ef5350; color: #fff; }

.open-trade { padding: 6px 8px; border-radius: 4px; background: #101b34; display: inline-block; }

.pos { color: #4caf82; }
.neg { color: #ef5350; }

.trade-history { max-height: 240px; overflow-y: auto; }
.muted { color: #6b7280; font-size: 13px; }

.hover-footer {
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--lavender);
  background: #0b1730;
  border-top: 1px solid var(--blue-mid);
}

.analytics-box {
  position: relative;
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  text-align: left;
}
.analytics-box h2 { color: var(--blue-accent); margin: 0 0 20px; text-align: center; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--lavender);
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--blue-accent); }
