/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #0d1117;
  color: #c9d1d9;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 13px;
}

/* Subtle scanline texture */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.08) 3px,
    rgba(0,0,0,0.08) 4px
  );
  z-index: 999;
}

/* ── Game layout ─────────────────────────────────────────────────────────── */
#game {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── HUD ─────────────────────────────────────────────────────────────────── */
#hud {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.55rem 1rem;
  background: #010409;
  border-bottom: 1px solid #21262d;
  flex-shrink: 0;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow-x: auto;
}

#hud-level   { color: #58a6ff; font-weight: 600; }
#hud-candle  { color: #6e7681; }
#hud-cash    { color: #c9d1d9; }
#hud-position{ color: #e3b341; }
#hud-pnl     { color: #c9d1d9; min-width: 12ch; }

/* P&L color pulse */
@keyframes pnl-flash-up   { 0%,100% { color: #c9d1d9; } 40% { color: #3fb950; } }
@keyframes pnl-flash-down { 0%,100% { color: #c9d1d9; } 40% { color: #f85149; } }
#hud-pnl.pnl-up   { animation: pnl-flash-up   0.7s ease; }
#hud-pnl.pnl-down { animation: pnl-flash-down 0.7s ease; }

/* ── Chart container ─────────────────────────────────────────────────────── */
#chart-container {
  flex: 1;
  min-height: 0;
  background: #0d1117;
}

/* Candle-reveal pulse: brief glow on the chart border */
@keyframes cpulse {
  0%   { box-shadow: none; }
  30%  { box-shadow: inset 0 0 0 1px rgba(88,166,255,0.25); }
  100% { box-shadow: none; }
}
#chart-container.candle-pulse { animation: cpulse 0.35s ease; }

/* ── Action bar ──────────────────────────────────────────────────────────── */
#action-bar {
  display: flex;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  background: #010409;
  border-top: 1px solid #21262d;
  flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  background: #0d1117;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 0.5rem 1.4rem;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:hover:not(:disabled)  { transform: translateY(-2px); border-color: #58a6ff; background: #161b22; }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.32; cursor: not-allowed; transform: none; }

.btn-buy  { border-left: 3px solid #3fb950; }
.btn-sell { border-left: 3px solid #f85149; }
.btn-hold { border-left: 3px solid #6e7681; }

.btn-primary {
  background: #21262d;
  border-color: #58a6ff;
  color: #58a6ff;
  padding: 0.6rem 2rem;
}
.btn-primary:hover:not(:disabled) { background: #1a2030; }

.btn-secondary {
  border-color: #30363d;
  color: #8b949e;
}

/* ── Overlay screens ─────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(1,4,9,0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}
.screen.hidden { display: none; }

.overlay-content {
  width: min(680px, 94vw);
  padding: 2rem;
}

/* ── Title screen ────────────────────────────────────────────────────────── */
.title-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}
.title-label {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #58a6ff;
}
.title-sub {
  color: #6e7681;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
}
.title-disclaimer {
  font-size: 0.75rem;
  color: #484f58;
  margin-top: 1.5rem;
}

/* ── How-to-play ─────────────────────────────────────────────────────────── */
.htp-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.htp-block {
  border: 1px solid #21262d;
  padding: 1rem 1.25rem;
  background: #010409;
}
.htp-objective {
  color: #8b949e;
  font-size: 1rem;
  letter-spacing: 0.04em;
}
.htp-rules-title,
.htp-patterns-title {
  color: #58a6ff;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  margin-bottom: 0.75rem;
}
.htp-rules-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1.5rem;
  color: #8b949e;
}
.htp-rules-grid span:nth-child(odd)  { color: #6e7681; }
.htp-rules-grid span:nth-child(even) { color: #c9d1d9; }

/* Pattern cards */
.pattern-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}
.pattern-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 0.5rem;
  border: 1px solid #21262d;
  background: #0d1117;
}
.psvg       { width: 40px; height: 70px; }
.psvg-wide  { width: 80px; height: 70px; }
.pcard-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #c9d1d9;
  letter-spacing: 0.04em;
  text-align: center;
}
.pcard-desc {
  font-size: 0.72rem;
  color: #6e7681;
  text-align: center;
  line-height: 1.45;
}

.htp-content .btn { align-self: center; margin-top: 0.5rem; }

/* ── Signal callout ──────────────────────────────────────────────────────── */
.signal-callout {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  background: #010409;
  border: 1px solid #58a6ff;
  padding: 0.65rem 0.9rem;
  min-width: 180px;
  animation: callout-in 0.22s ease forwards;
}
.signal-callout.hidden { display: none; }

@keyframes callout-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.callout-title { font-size: 0.65rem; color: #58a6ff; letter-spacing: 0.12em; margin-bottom: 0.25rem; }
.callout-name  { font-size: 0.9rem;  color: #c9d1d9; font-weight: 600; }
.callout-desc  { font-size: 0.72rem; color: #6e7681; margin-top: 0.2rem; }

/* ── Stop-loss toast ─────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: 200;
  background: #1a0000;
  border: 1px solid #f85149;
  padding: 0.75rem 1.25rem;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}
#toast.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.hidden { display: none; }

.toast-title { color: #f85149; font-size: 0.72rem; letter-spacing: 0.1em; margin-bottom: 0.2rem; }
.toast-body  { color: #c9d1d9; font-size: 0.85rem; }

/* ── Recap screen ────────────────────────────────────────────────────────── */
.recap-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.recap-title   { font-size: 1.3rem; font-weight: 700; color: #58a6ff; letter-spacing: 0.08em; }
.recap-verdict { color: #8b949e; font-size: 0.9rem; }

.recap-stats { border: 1px solid #21262d; background: #010409; }
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #161b22;
}
.stat-row:last-child { border-bottom: none; }
.stat-label { color: #6e7681; }
.stat-value { color: #c9d1d9; font-weight: 600; min-width: 8ch; text-align: right; }

.recap-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-start;
}

/* ── Game-over screen ────────────────────────────────────────────────────── */
.gameover-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}
.gameover-title    { font-size: 2rem; font-weight: 700; letter-spacing: 0.14em; color: #f85149; }
.gameover-pnl-label{ color: #6e7681; font-size: 0.8rem; letter-spacing: 0.1em; }
.gameover-pnl      { font-size: 2.2rem; font-weight: 700; color: #c9d1d9; margin-bottom: 1rem; }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Pattern card action hint ────────────────────────────────────────────── */
.pcard-action {
  font-size: 0.68rem;
  color: #6e7681;
  letter-spacing: 0.06em;
  margin-top: 0.1rem;
}
.pcard-action-buy  { color: #3fb950; }
.pcard-action-sell { color: #f85149; }

/* ── Signal callout -- headline ──────────────────────────────────────────── */
.callout-headline {
  font-size: 0.68rem;
  color: #58a6ff;
  font-style: italic;
  border-top: 1px solid #21262d;
  margin-top: 0.45rem;
  padding-top: 0.4rem;
  line-height: 1.4;
}

/* ── HUD -- streak chip ──────────────────────────────────────────────────── */
.hud-streak-chip {
  color: #e3b341;
  font-weight: 700;
  letter-spacing: 0.05em;
  animation: streak-pop 0.3s ease;
}
@keyframes streak-pop {
  0%   { transform: scale(0.85); opacity: 0; }
  60%  { transform: scale(1.12); }
  100% { transform: scale(1);    opacity: 1; }
}

/* ── Action bar -- hints toggle ──────────────────────────────────────────── */
#btn-hints {
  margin-left: auto;
  font-size: 0.72rem;
  padding: 0.4rem 0.85rem;
  border-color: #3fb950;
  color: #3fb950;
  letter-spacing: 0.08em;
}
#btn-hints.hints-off {
  border-color: #30363d;
  color: #484f58;
}

/* ── Achievement chips ───────────────────────────────────────────────────── */
#achievement-queue {
  position: fixed;
  top: 56px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  z-index: 300;
  pointer-events: none;
}
.achievement-chip {
  background: #0d1117;
  border: 1px solid #e3b341;
  color: #e3b341;
  padding: 0.35rem 0.85rem;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  font-weight: 600;
  opacity: 0;
  transform: translateX(18px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.achievement-chip.chip-show {
  opacity: 1;
  transform: translateX(0);
}

}
.achievement-chip.chip-show {
  opacity: 1;
  transform: translateX(0);
}
