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

:root {
  --bg: #0c0e11;
  --panel: #171b20;
  --text: #f3f0e8;
  --muted: #a9adad;
  --soft: #747c7a;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --mint: #7ee0b2;
  --mint-ink: #0b1b14;
  --amber: #f1c56b;
  --red: #ff817a;
  --cyan: #78c7e8;
  --violet: #c7a8ff;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  --radius: 8px;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #101316 0%, #0c0e11 55%, #0b0d0f 100%);
  color: var(--text);
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 1;
  color: var(--soft) !important;
  border-color: var(--line) !important;
  background: #12161a !important;
  transform: none !important;
}

a {
  color: inherit;
}

svg {
  display: block;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.sim-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.sim-topbar,
.brand-block,
.top-actions,
.sim-head,
.chart-toolbar,
.control-title,
.direction-grid,
.timer-row,
.section-title,
.price-pill,
.phase-pill,
.chat-tools {
  display: flex;
  gap: 10px;
}

.sim-topbar {
  position: sticky;
  top: 10px;
  z-index: 30;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 19, 22, 0.92);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.brand-block,
.top-actions,
.sim-head,
.chart-toolbar,
.control-title,
.section-title,
.price-pill,
.phase-pill {
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  color: var(--mint);
  background: #101a15;
  border: 1px solid rgba(126, 224, 178, 0.26);
}

.brand-mark .icon {
  width: 24px;
  height: 24px;
}

.eyebrow,
.stat-pill span,
.map-card span,
.range-grid label > span,
.price-pill span,
.section-title,
.asset-btn small,
.timer-pill {
  margin: 0;
  color: var(--soft);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  letter-spacing: 0;
}

h1 {
  font-size: 1.1rem;
}

h2 {
  font-size: clamp(1.4rem, 2vw, 2.1rem);
}

p {
  margin: 0;
}

.soft-btn,
.primary-btn,
.direction-btn,
.scenario-btn,
.asset-btn,
.icon-button,
.chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #15191e;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.soft-btn,
.primary-btn {
  min-height: 40px;
  padding: 9px 12px;
  font-size: 0.88rem;
}

.soft-btn:hover,
.primary-btn:hover,
.direction-btn:hover,
.scenario-btn:hover,
.asset-btn:hover,
.icon-button:hover,
.chat-send:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.primary-btn {
  border-color: rgba(126, 224, 178, 0.46);
  background: var(--mint);
  color: var(--mint-ink);
}

.primary-btn:hover {
  background: #91ecc2;
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
}

.stat-pill {
  min-width: 128px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #13171b;
}

.stat-pill strong {
  display: block;
  margin-top: 2px;
  font-family: "Space Grotesk", sans-serif;
  white-space: nowrap;
}

.sim-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 27, 32, 0.92);
  box-shadow: var(--shadow);
}

.sim-head {
  justify-content: space-between;
  align-items: end;
}

.sim-head p {
  max-width: 62ch;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.55;
}

.asset-panel,
.scenario-panel {
  margin-top: 16px;
}

.section-title {
  margin-bottom: 8px;
  color: var(--muted);
}

.section-title .icon {
  color: var(--mint);
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.asset-btn {
  min-height: 78px;
  padding: 10px;
  justify-content: flex-start;
  text-align: left;
  border-width: 2px;
  background: linear-gradient(180deg, #151a1f, #11161a);
}

.asset-btn.is-active {
  border-color: rgba(126, 224, 178, 0.48);
  background: #102019;
}

.asset-btn .asset-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  color: var(--cyan);
  background: rgba(120, 199, 232, 0.12);
}

.asset-btn strong,
.asset-btn small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.asset-btn small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.25;
}

.tiny-note {
  margin-top: 8px;
  color: var(--soft);
  font-size: 0.82rem;
  line-height: 1.45;
}

.scenario-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.scenario-btn {
  min-height: 54px;
  padding: 10px;
  border-width: 2px;
  background: #15191e;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.scenario-btn.is-active,
.direction-btn.is-active {
  color: var(--mint);
  border-color: rgba(126, 224, 178, 0.48);
  background: #102019;
}

.chart-shell {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f1216;
}

.chart-toolbar {
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.chart-toolbar strong {
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

.timer-row {
  align-items: stretch;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.timer-pill,
.price-pill,
.phase-pill {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.timer-pill {
  color: var(--amber);
}

.timer-pill .icon {
  width: 16px;
  height: 16px;
}

.price-pill strong,
.phase-pill {
  font-family: "Space Grotesk", sans-serif;
}

.phase-pill {
  color: var(--mint);
}

.phase-pill.is-running {
  color: var(--amber);
  border-color: rgba(241, 197, 107, 0.34);
}

.phase-pill.is-finished {
  color: var(--mint);
  border-color: rgba(126, 224, 178, 0.55);
  background: rgba(126, 224, 178, 0.12);
  animation: finish-blink 900ms ease-in-out 4;
}

.sim-chart {
  min-height: 450px;
  padding: 12px;
}

.sim-chart svg {
  width: 100%;
  height: 430px;
}

.trade-runner {
  transform-box: fill-box;
  transform-origin: center;
  will-change: transform;
}

.trade-dot,
.trade-dot-core,
.trade-trail,
.trade-halo {
  pointer-events: none;
}

.trade-dot {
  animation: dot-glow 900ms ease-in-out infinite;
}

.trade-halo {
  animation: halo-glow 900ms ease-in-out infinite;
}

.trade-trail {
  animation: trail-fade 900ms ease-in-out infinite;
}

@keyframes dot-glow {
  50% {
    opacity: 0.8;
    filter: drop-shadow(0 0 18px rgba(126, 224, 178, 0.9));
  }
}

@keyframes halo-glow {
  50% {
    opacity: 0.35;
    stroke-width: 5;
  }
}

@keyframes trail-fade {
  50% {
    opacity: 0.35;
    transform: translateX(-5px) scale(1.25);
  }
}

.control-title {
  margin-bottom: 16px;
}

.control-title .icon {
  color: var(--mint);
}

.direction-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.direction-btn {
  min-height: 70px;
  padding: 12px;
  font-weight: 900;
}

.range-grid {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.range-grid label > span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.range-grid strong {
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--mint);
}

.money-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.map-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.map-card strong {
  display: block;
  margin-top: 4px;
  font-family: "Space Grotesk", sans-serif;
}

.map-card.win strong {
  color: var(--mint);
}

.map-card.loss strong {
  color: var(--red);
}

.checklist {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.check-row:last-child {
  border-bottom: 0;
}

.check-row .icon {
  color: var(--amber);
}

.check-row.good .icon {
  color: var(--mint);
}

.check-row.bad .icon {
  color: var(--red);
}

.result-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #11161a;
}

.result-box.is-win {
  border-color: rgba(126, 224, 178, 0.36);
}

.result-box.is-loss {
  border-color: rgba(255, 129, 122, 0.36);
}

.result-box.is-running {
  border-color: rgba(241, 197, 107, 0.36);
}

.result-box.is-finished {
  animation: result-finish 950ms ease-in-out 3;
}

.finish-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-bottom: 9px;
  padding: 5px 8px;
  border: 1px solid rgba(126, 224, 178, 0.36);
  border-radius: var(--radius);
  background: rgba(126, 224, 178, 0.12);
  color: var(--mint);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.result-money {
  display: grid;
  gap: 3px;
  margin: 8px 0 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.result-money span {
  color: var(--soft);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.result-money strong {
  font-size: 1.45rem;
}

.result-money.win {
  border-color: rgba(126, 224, 178, 0.34);
  background: rgba(126, 224, 178, 0.08);
}

.result-money.win strong {
  color: var(--mint);
}

.result-money.loss {
  border-color: rgba(255, 129, 122, 0.34);
  background: rgba(255, 129, 122, 0.08);
}

.result-money.loss strong {
  color: var(--red);
}

.result-box strong {
  display: block;
  font-family: "Space Grotesk", sans-serif;
}

.result-box p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.55;
}

.trade-log {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

@keyframes result-finish {
  50% {
    border-color: rgba(126, 224, 178, 0.8);
    box-shadow: 0 0 0 3px rgba(126, 224, 178, 0.16);
  }
}

@keyframes finish-blink {
  50% {
    background: rgba(126, 224, 178, 0.24);
    box-shadow: 0 0 0 3px rgba(126, 224, 178, 0.12);
  }
}

.has-tip {
  position: relative;
}

.has-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 90;
  width: min(260px, 72vw);
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(14, 17, 20, 0.98);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.4;
  text-transform: none;
  transform: translate(-50%, 5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

.has-tip:hover::after,
.has-tip:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 7, 9, 0.76);
  backdrop-filter: blur(12px);
}

.intro-card {
  position: relative;
  width: min(620px, 100%);
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #151a1f;
  box-shadow: var(--shadow);
}

.intro-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.intro-card h2 {
  margin-top: 4px;
}

.intro-steps {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.intro-steps div {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.intro-steps strong {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: rgba(126, 224, 178, 0.13);
  color: var(--mint);
  font-family: "Space Grotesk", sans-serif;
}

.intro-steps span,
.intro-warning {
  color: var(--muted);
  line-height: 1.5;
}

.intro-warning {
  margin-top: 14px;
}

.intro-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.study-chat {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 65;
  display: grid;
  justify-items: end;
  gap: 10px;
  width: min(390px, calc(100vw - 28px));
  pointer-events: none;
}

.chat-toggle,
.chat-panel {
  pointer-events: auto;
}

.chat-toggle {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid rgba(126, 224, 178, 0.46);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.22), transparent 32%),
    linear-gradient(135deg, #123121, #163b4d);
  color: var(--mint);
  box-shadow: var(--shadow);
}

.chat-toggle .icon {
  width: 24px;
  height: 24px;
}

.study-chat:not(.is-closed) .chat-toggle {
  background: #161b20;
  color: var(--text);
}

.chat-panel {
  width: 100%;
  height: min(530px, calc(100vh - 104px));
  min-height: 360px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(24, 29, 34, 0.98), rgba(14, 17, 20, 0.98)),
    #11161a;
  box-shadow: var(--shadow);
}

.chat-tools {
  justify-content: flex-end;
  min-height: 34px;
}

.chat-messages {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding: 2px 2px 4px;
  scrollbar-width: thin;
}

.chat-message {
  width: fit-content;
  max-width: 86%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.chat-message.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.045);
}

.chat-message.user {
  align-self: flex-end;
  border-color: rgba(120, 199, 232, 0.35);
  background: rgba(120, 199, 232, 0.13);
}

.chat-message.is-typing::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 1em;
  margin-left: 3px;
  border-radius: 2px;
  background: currentColor;
  vertical-align: -0.15em;
  animation: typing-cursor 0.8s steps(2, start) infinite;
}

.chat-message mark {
  padding: 0 4px;
  border-radius: 5px;
  background: rgba(126, 224, 178, 0.18);
  color: var(--mint);
  font-weight: 900;
}

@keyframes typing-cursor {
  50% {
    opacity: 0;
  }
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.chat-form input {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f1317;
  color: var(--text);
  outline: none;
}

.chat-form input:focus {
  border-color: rgba(126, 224, 178, 0.45);
}

.chat-send {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--mint);
  color: var(--mint-ink);
}

@media (max-width: 1080px) {
  .sim-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .sim-shell {
    padding: 8px;
  }

  .sim-topbar,
  .top-actions,
  .sim-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .sim-topbar {
    top: 6px;
    gap: 8px;
    padding: 8px;
  }

  .brand-block {
    min-width: 0;
  }

  .brand-block > div:last-child {
    min-width: 0;
  }

  .brand-block h1,
  .brand-block .eyebrow {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-actions .soft-btn,
  .top-actions .stat-pill,
  .primary-btn {
    width: 100%;
  }

  .stat-pill {
    min-width: 0;
  }

  .panel {
    padding: 12px;
  }

  .asset-grid,
  .scenario-tabs,
  .direction-grid,
  .money-map {
    grid-template-columns: 1fr;
  }

  .timer-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .timer-pill,
  .price-pill,
  .phase-pill {
    justify-content: space-between;
  }

  .sim-chart {
    min-height: 310px;
    padding: 8px;
  }

  .sim-chart svg {
    height: 290px;
  }

  .study-chat {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }

  .chat-panel {
    height: min(560px, calc(100vh - 96px));
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 1rem;
  }

  h2 {
    font-size: 1.35rem;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .soft-btn,
  .primary-btn,
  .direction-btn,
  .scenario-btn,
  .asset-btn {
    min-height: 44px;
  }

  .asset-btn {
    min-height: 70px;
  }

  .direction-btn {
    min-height: 62px;
  }

  .sim-chart {
    min-height: 270px;
  }

  .sim-chart svg {
    height: 250px;
  }

  .result-box,
  .map-card,
  .check-row {
    overflow-wrap: anywhere;
  }
}
