/* Number Go Up.
 *
 * Four acts on one page, one visible at a time. The chart is the hero in
 * every act, so it gets a fixed aspect box that never reflows between them -
 * the player's guess line and the real curve must land on the same grid or
 * the comparison means nothing.
 */

body { overflow-x: hidden; }

.screen {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(64px, calc(env(safe-area-inset-top) + 56px)) 20px max(20px, env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}

.screen[hidden] { display: none; }

/* ---------- intro ---------- */

#intro { justify-content: center; }

.kicker {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: var(--dim);
}

.title {
  margin: 0;
  font-size: clamp(50px, 15vw, 84px);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.045em;
}

.title .up {
  display: block;
  color: var(--gold);
}

.pitch {
  margin: 28px 0 0;
  font-size: 17px;
  line-height: 1.55;
  color: var(--dim);
  max-width: 34ch;
}

.pitch b { color: var(--paper); font-weight: 700; }

/* What an index fund is, without ever using the words. It sits below the
   button and is folded away, so it never delays the first tap — the same
   .illustrative fold the reveal screen uses for its honesty note. */
#intro .illustrative { margin-top: 16px; max-width: 36ch; }

.ask {
  margin: 20px 0 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--paper);
}

.big-btn {
  margin-top: 30px;
  padding: 18px 26px;
  border-radius: 16px;
  background: var(--paper);
  color: var(--void);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: transform 0.14s var(--ease-snap), opacity 0.15s;
}

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

.big-btn[disabled] {
  opacity: 0.32;
  cursor: default;
  transform: none;
}

.ghost-btn {
  padding: 14px 22px;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-lift);
  color: var(--paper);
  font-size: 15px;
  font-weight: 600;
}

/* ---------- act headers ---------- */

.act { flex: none; }

.act-title {
  margin: 0;
  font-size: clamp(24px, 6.4vw, 33px);
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -0.032em;
}

.act-sub {
  margin: 12px 0 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--dim);
}

.act-sub b { color: var(--paper); }

.act-note {
  margin: 18px 0 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--paper);
}

/* ---------- chart ----------
 * Fixed ratio so the same grid carries across guess, reveal and idle. */

.chart-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  /* Capped so the act's main button still lands above the fold on a phone -
     a "Lock it in" she has to scroll to find is a button that does not exist. */
  max-height: 38vh;
  margin: 16px 0 0;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
  touch-action: none;
}

.chart-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* The idle act carries a hero stat, a ledger and two controls as well as the
   chart, so the chart gives up height to keep the buttons on screen. */
.chart-live { margin-top: 12px; max-height: 28vh; }

/* ---------- act 1: drawing ---------- */

#guess { justify-content: flex-start; }

/* The draw nudge. Sits on the chart's start point and pulses until she
   touches it - the entire instruction, with no tutorial wall. */
.draw-nudge {
  position: absolute;
  left: 38px;
  bottom: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  transition: opacity 0.25s;
}

.draw-nudge.gone { opacity: 0; }

.nudge-dot {
  width: 16px;
  height: 16px;
  border-radius: 99px;
  background: var(--gold);
  animation: nudge-pulse 1.5s ease-out infinite;
}

.nudge-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  white-space: nowrap;
}

@keyframes nudge-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 197, 49, 0.55); }
  100% { box-shadow: 0 0 0 16px rgba(255, 197, 49, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .nudge-dot { animation: none; }
}

/* Collapsed fallback. Present for keyboard and screen readers, but never
   competing with the chart for attention. */
.a11y-draw {
  margin: 14px 0 0;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.a11y-draw[open] { padding-bottom: 14px; display: grid; gap: 10px; }

.a11y-draw summary {
  padding: 14px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--dim);
  cursor: pointer;
  list-style: none;
  min-height: 24px;
}

.a11y-draw summary::-webkit-details-marker { display: none; }
.a11y-draw summary::after { content: ' \25BE'; }
.a11y-draw[open] summary::after { content: ' \25B4'; }

.a11y-draw label {
  font-size: 13px;
  line-height: 1.45;
  color: var(--dim);
}

.a11y-draw input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
  height: 28px;
}

#guess-slider-out {
  font-size: 19px;
  font-weight: 700;
  color: var(--gold);
}

.a11y-draw .ghost-btn { justify-self: start; }

.draw-foot { margin-top: auto; padding-top: 18px; }

.progress {
  height: 5px;
  border-radius: 99px;
  background: var(--panel-lift);
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--gold);
  transition: width 0.1s linear;
}

.hint {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--dim);
  min-height: 1.3em;
}

.draw-foot .big-btn { width: 100%; margin-top: 12px; }

/* ---------- act 1b: reveal ---------- */

.figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0 0;
}

.fig {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.fig-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.fig b {
  display: block;
  margin-top: 6px;
  font-size: clamp(21px, 6vw, 27px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.fig-real { border-color: rgba(255, 197, 49, 0.45); }
.fig-real b { color: var(--gold); }

.foot { margin-top: auto; padding-top: 18px; }

/* The honesty note. It must stay on the page, but she will never read a
   four-line disclaimer - so it folds away under one short line. */
.illustrative {
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--dim);
}

.illustrative summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  /* 44px: the documented minimum tap target. It was 24px, which is under the
     size a thumb can reliably hit. */
  min-height: 44px;
}

.illustrative summary::-webkit-details-marker { display: none; }
.illustrative summary::after { content: ' \25BE'; }
.illustrative[open] summary::after { content: ' \25B4'; }

.illustrative p { margin: 6px 0 0; }
.illustrative b { color: var(--paper); }

.foot .big-btn { width: 100%; margin-top: 0; }

/* ---------- act 2: the idle run ---------- */

#idle { justify-content: flex-start; }

.idle-top { flex: none; }

.clock {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.clock-year { font-size: 15px; color: var(--dim); }
.clock-year b { font-size: 26px; font-weight: 700; color: var(--paper); letter-spacing: -0.02em; }
.clock-age { font-size: 13px; color: var(--dim); }
.clock-age b { color: var(--paper); font-weight: 700; }

.timeline {
  height: 5px;
  border-radius: 99px;
  background: var(--panel-lift);
  overflow: hidden;
}

.timeline i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--gold);
}

/* The hero stat: the gap between what went in and what it is worth. That
   gap is the whole lesson, so it is the biggest thing on the screen. */
.hero-stat {
  margin: 14px 0 0;
  text-align: center;
}

.hero-label {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}

.hero-value {
  margin: 6px 0 0;
  font-size: clamp(38px, 11vw, 56px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.045em;
  color: var(--volt);
}

.hero-sub {
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--dim);
  min-height: 1.45em;
}

.ledger {
  margin: 16px 0 0;
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.ledger-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
}

.ledger-row dt {
  font-size: 13.5px;
  color: var(--dim);
}

.ledger-row dd {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ledger-quiet dd { font-size: 15px; font-weight: 600; color: var(--dim); }

/* Appears mid-run, so it has to earn its height: any taller and it shoves
   the two controls off the bottom of a phone screen. */
.crossover {
  margin: 12px 0 0;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid rgba(255, 197, 49, 0.45);
  background: rgba(255, 197, 49, 0.09);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--paper);
}

.crossover[hidden] { display: none; }

.controls {
  margin-top: auto;
  padding-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ctrl {
  min-height: var(--thumb);
  padding: 10px 14px;
  border-radius: 16px;
  border: 1.5px solid;
  display: grid;
  gap: 2px;
  align-content: center;
  transition: transform 0.12s var(--ease-snap);
}

.ctrl:active { transform: scale(0.96); }

.ctrl-main { font-size: 16px; font-weight: 700; letter-spacing: -0.015em; }
.ctrl-note { font-size: 11.5px; color: var(--dim); }

.ctrl-bump { color: var(--volt); border-color: rgba(0, 229, 192, 0.4); background: rgba(0, 229, 192, 0.09); }
.ctrl-skip { color: var(--gold); border-color: rgba(255, 197, 49, 0.4); background: rgba(255, 197, 49, 0.09); }

.ctrl[disabled] { opacity: 0.35; cursor: default; transform: none; }

/* ---------- act 3: the ghost ---------- */

#ghost { justify-content: flex-start; padding-bottom: 40px; }

.versus {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 16px 0 0;
}

.vs-col {
  padding: 14px 12px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: center;
  display: grid;
  gap: 4px;
}

.vs-who {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.vs-col b {
  font-size: clamp(19px, 5.4vw, 25px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.vs-in { font-size: 11.5px; color: var(--dim); }

.vs-you { border-color: rgba(0, 229, 192, 0.42); }
.vs-you b { color: var(--volt); }

.vs-them b { color: var(--dim); }

.vs-mid {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.points {
  margin: 26px 0 0;
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.point { padding: 16px 18px; background: var(--panel); }

.point h3 {
  margin: 0 0 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.point p {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: #ded0f2;
}

/* A folded point. The summary is styled as the h3 it stands in for, so the
   three rows still read as one list whether they are open or shut — the only
   difference is the caret and that it is tappable. */
.point-fold { padding: 0; }

.point-fold summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--thumb);
  padding: 14px 18px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  cursor: pointer;
  list-style: none;
}

.point-fold summary::-webkit-details-marker { display: none; }

.point-fold summary::after {
  content: "\25BE";
  flex: none;
  letter-spacing: 0;
  color: var(--dim);
}

.point-fold[open] summary::after { content: "\25B4"; }

.point-fold p { padding: 0 18px 16px; }

.end-actions {
  margin: 26px 0 0;
  display: grid;
  justify-items: center;
  gap: 4px;
}

.end-actions .big-btn { width: 100%; margin-top: 0; }

.text-link {
  margin-top: 14px;
  font-size: 14px;
  color: var(--dim);
  text-decoration: none;
}

.text-link:hover { color: var(--paper); }

/* The crossover beat. game.js adds .pulse to the hero number for one
   animation and animates the callout in as it appears. Both are single,
   earned events rather than idle decoration. */
.hero-value.pulse { animation: ngu-pop 0.45s var(--ease-snap); }

@keyframes ngu-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.crossover { animation: ngu-land 0.5s var(--ease-snap) both; }

@keyframes ngu-land {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

@keyframes ss-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
