/* BUY THE DIP — Gilded Observatory skin.
   Token values mirror public/styles/app.css (:root Gilded Observatory block):
   gold-on-void luxury instrument chrome, candle-colored tape, press physics
   ("presses are POSITION, not motion" — they survive prefers-reduced-motion).
   The game is a standalone page, so tokens are re-declared here by the same
   convention learn/ and for-teachers/ use. */
:root {
  --void: #0B0E16;
  --panel: #0d121e;
  --panel2: #10141F;
  --hair: rgba(140, 160, 190, 0.14);
  --ink: #eef2f7;
  --ink2: #aeb8c7;
  --ink3: #6f7c8f;
  --gold: #E6BD5C;
  --gold-lt: #f0cd75;
  --gold-sh: #8a6f31;
  --up: #26A69A;
  --up-lt: #2fbfb1;
  --up-sh: #135e57;
  --down: #EF5350;
  --down-lt: #f4736b;
  --down-sh: #8f2b26;
  --pearl: #AEBFE8;
  --info: #7fb4ff;
  --mono: 'Spline Sans Mono', ui-monospace, 'SF Mono', Menlo, Consolas, 'Roboto Mono', monospace;
  --sans: 'Spline Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --disp: 'Fraunces', Georgia, 'Times New Roman', serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button { font-family: var(--sans); }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  position: relative;
}

/* ---------- HUD ---------- */
#hud {
  padding: 8px 12px 6px;
  background: linear-gradient(180deg, rgba(13, 18, 30, 0.92), rgba(13, 18, 30, 0.4));
  border-bottom: 1px solid var(--hair);
}

.hud-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink3);
}

.badge {
  background: linear-gradient(180deg, var(--gold-lt), var(--gold));
  color: var(--void);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: 0.08em;
  box-shadow: 0 2px 0 var(--gold-sh);
}

#tickerName {
  flex: 1;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#muteBtn {
  background: none;
  border: none;
  font-size: 16px;
  opacity: 0.8;
  padding: 2px 4px;
}

.hud-mid {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 4px;
  gap: 12px;
}

#bank {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  transition: color 0.15s;
}
#bank.up { color: var(--up); }
#bank.down { color: var(--down); }

.target-wrap { flex: 1; max-width: 46%; text-align: right; }

/* mono-gold eyebrow — the .pn-eyebrow pattern from the planner instruments */
#targetLabel {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--ink3);
  margin-bottom: 4px;
}
#targetLabel.hit { color: var(--gold); font-weight: 600; }

#timebar {
  height: 6px;
  border-radius: 3px;
  background: rgba(140, 160, 190, 0.12);
  overflow: hidden;
}
#timefill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--pearl), var(--gold));
}
#timefill.late { background: linear-gradient(90deg, var(--gold), var(--down)); }
#timefill.critical { animation: barpulse 0.5s ease-in-out infinite alternate; }
@keyframes barpulse { from { opacity: 1; } to { opacity: 0.35; } }

#news {
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  background: var(--panel);
  border: 1px solid var(--hair);
  color: var(--ink2);
  min-height: 28px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#news.tease {
  color: var(--gold);
  border-color: rgba(230, 189, 92, 0.45);
  animation: pulse 0.5s ease-in-out infinite alternate;
}
#news.good { color: var(--up); border-color: rgba(38, 166, 154, 0.45); }
#news.bad { color: var(--down); border-color: rgba(239, 83, 80, 0.45); }

@keyframes pulse { from { opacity: 0.75; } to { opacity: 1; } }

.hud-sub {
  display: flex;
  justify-content: space-between;
  min-height: 18px;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}
#comboText { color: var(--gold); }
#hotText { color: var(--up); animation: pulse 0.4s ease-in-out infinite alternate; }

/* ---------- Chart ---------- */
#chartWrap { flex: 1; position: relative; min-height: 0; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Big centered win/loss pop over the chart */
.big-pop {
  position: absolute;
  top: 34%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 46px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: -1px;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.big-pop.win { color: var(--up); text-shadow: 0 0 24px rgba(38, 166, 154, 0.6); }
.big-pop.loss { color: var(--down); text-shadow: 0 0 24px rgba(239, 83, 80, 0.5); }
.big-pop.go { animation: bigpop 0.95s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
@keyframes bigpop {
  0% { opacity: 0; transform: scale(0.4); }
  18% { opacity: 1; transform: scale(1.12); }
  55% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1) translateY(-34px); }
}

@media (prefers-reduced-motion: reduce) {
  .big-pop.go { animation: none; opacity: 1; }
  #timefill.critical, #news.tease, #hotText, #posInfo.coach { animation: none; }
  #openCard { animation: none; }
}

/* ---------- Dock ---------- */
#dock {
  padding: 8px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(13, 18, 30, 0.95), rgba(13, 18, 30, 0.5));
  border-top: 1px solid var(--hair);
}

#posInfo {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink2);
  text-align: center;
  margin-bottom: 7px;
  min-height: 15px;
}
#posInfo.coach {
  color: var(--gold);
  font-weight: 600;
  animation: pulse 0.6s ease-in-out infinite alternate;
}

/* The trade button is an instrument: candle-colored face, a dark machine lip
   that collapses on press (the .press physics from the Observatory system). */
#tradeBtn {
  width: 100%;
  height: 84px;
  border: none;
  border-radius: 20px;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--void);
  transition: transform 0.08s var(--ease), box-shadow 0.08s var(--ease);
}
#tradeBtn.buy {
  background: linear-gradient(180deg, var(--up-lt), var(--up));
  box-shadow: 0 5px 0 var(--up-sh), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
#tradeBtn.sell {
  background: linear-gradient(180deg, var(--down-lt), var(--down));
  box-shadow: 0 5px 0 var(--down-sh), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
#tradeBtn:active {
  transform: translateY(4px);
}
#tradeBtn.buy:active { box-shadow: 0 1px 0 var(--up-sh), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
#tradeBtn.sell:active { box-shadow: 0 1px 0 var(--down-sh), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
#tradeBtn:disabled { opacity: 0.35; }
#tradeBtn .sub {
  display: block;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  opacity: 0.8;
}

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: rgba(7, 9, 14, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  text-align: center;
  z-index: 10;
}
.screen.hidden { display: none; }

.logo { display: flex; flex-direction: column; line-height: 0.98; }
.logo-buy {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  color: var(--ink2);
}
.logo-dip {
  font-family: var(--disp);
  font-size: 96px;
  font-weight: 600;
  background: linear-gradient(180deg, var(--gold-lt), var(--gold) 55%, var(--gold-sh));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 18px rgba(230, 189, 92, 0.3));
}
.tagline { color: var(--ink2); font-size: 15px; margin-top: -4px; }

.howto {
  list-style: none;
  text-align: left;
  font-size: 14px;
  color: var(--ink2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
  margin: 8px 0;
}
.howto b { color: var(--ink); }

.best-line { font-family: var(--mono); font-size: 13px; color: var(--gold); min-height: 16px; }

/* .press-gold — the gilded primary, straight from the Observatory system */
.cta {
  border: none;
  border-radius: 16px;
  padding: 18px 34px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--void);
  background: linear-gradient(180deg, var(--gold-lt), var(--gold));
  box-shadow: 0 5px 0 var(--gold-sh), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.08s var(--ease), box-shadow 0.08s var(--ease);
}
.cta:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--gold-sh), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.cta.ghost {
  background: var(--panel);
  border: 1px solid var(--hair);
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.5);
}
.cta.ghost:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5); }

.clear-big { font-family: var(--disp); font-size: 34px; font-weight: 600; color: var(--up); }
.clear-gain {
  font-family: var(--mono);
  font-size: 52px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.clear-next { font-family: var(--mono); font-size: 14px; color: var(--gold); }

.site-line {
  position: absolute;
  bottom: calc(18px + env(safe-area-inset-bottom));
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
}
.site-line a { color: var(--ink3); text-decoration: none; }
.site-line a:hover, .site-line a:focus-visible { color: var(--gold); }

.open-day {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  color: var(--gold);
}
.open-ticker {
  font-family: var(--mono);
  font-size: 62px;
  font-weight: 600;
  letter-spacing: -1px;
  background: linear-gradient(180deg, var(--gold-lt), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.open-name { font-family: var(--disp); font-size: 19px; color: var(--ink); margin-top: -8px; }
.open-target {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-top: 10px;
}
#openCard { animation: cardin 0.25s ease-out; }
@keyframes cardin { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: none; } }

.over-reason { font-family: var(--disp); font-size: 30px; font-weight: 600; color: var(--down); }
.over-bank {
  font-family: var(--mono);
  font-size: 56px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.new-best { color: var(--gold); font-weight: 700; font-size: 18px; }
.new-best.hidden { display: none; }

#overSpark {
  width: 280px;
  height: 64px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--hair);
}

.over-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 26px;
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink3);
  margin: 6px 0 10px;
}
.over-stats b { color: var(--ink); font-weight: 600; }

.over-row { display: flex; gap: 12px; }
