/* Forward.
 *
 * Two surfaces. The chat is deliberately mundane — it should feel like the app
 * you already have open, so the forward tag reads as furniture rather than as
 * a warning. The cascade is the opposite: it takes the whole screen and is the
 * only thing in the game allowed to be spectacular, because seeing your own
 * node light up a branch is the entire lesson.
 */

body { overflow: 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));
}

.screen[hidden] { display: none; }

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

#intro { justify-content: center; max-width: 520px; margin: 0 auto; }

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

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

/* Three dots that keep going, like the message that never stops being passed
   on. Also used inside the checking state. */
.dots::after {
  content: "...";
  color: var(--gold);
  animation: ellipsis 1.4s steps(4, end) infinite;
}

@keyframes ellipsis {
  0%   { content: "."; }
  33%  { content: ".."; }
  66%  { content: "..."; }
}

.pitch {
  margin: 26px 0 0;
  font-size: 17px;
  line-height: 1.5;
  color: var(--dim);
  max-width: 32ch;
}

.rules {
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 9px;
  font-size: 15px;
}

.rules b { font-weight: 700; }
.gold { color: var(--gold); }
.volt { color: var(--volt); }
.hot { color: var(--hot); }

.big-btn {
  margin-top: 32px;
  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);
}

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

.foot-note { margin: 16px 0 0; font-size: 13px; color: var(--dim); }

/* ---------- chat frame ---------- */

/* Fixed to the viewport, not just at least as tall as it: the chat scrolls
   inside, the controls stay under the thumb. */
#play { padding: 0; min-height: 100dvh; height: 100dvh; overflow: hidden; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(58px, calc(env(safe-area-inset-top) + 52px)) 16px 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 9, 31, 0.86);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 3;
}

.ch-avatar {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--panel-lift);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  color: var(--dim);
  letter-spacing: 0.04em;
}

.ch-meta { flex: 1; min-width: 0; }

.ch-name {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.ch-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ch-count { text-align: right; flex: none; }

#queue-n {
  display: block;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
}

.ch-count-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--dim);
}

/* ---------- thread ---------- */

.thread {
  flex: 1;
  /* Without this a flex child refuses to shrink below its content, so a long
     thread pushes the decision buttons off the bottom of the screen instead
     of scrolling inside its own box. */
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
}

.msg {
  max-width: min(94%, 480px);
  align-self: flex-start;
  animation: pop-in 0.34s var(--ease-out) both;
}

/* Messages stack up from the bottom like every chat app, so a thread with one
   message in it does not float in a sea of empty panel. Done with auto margin
   on the first child rather than justify-content: flex-end, which overflows
   unreachably above the scroll box once the thread gets long. */
.thread > :first-child { margin-top: auto; }

/* The player's own sends sit on the right, like they do everywhere else. */
.msg.mine { align-self: flex-end; }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.msg-who {
  margin: 0 0 4px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gold);
}

.bubble {
  position: relative;
  padding: 10px 13px 8px;
  border-radius: 14px 14px 14px 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px -18px rgba(0, 0, 0, 0.9);
}

.msg.mine .bubble {
  border-radius: 14px 14px 4px 14px;
  background: linear-gradient(160deg, #2b1a4a, #241543);
}

/* The forward tag, as close to the real thing as CSS gets: small, grey,
   an arrow, and utterly unremarkable. That is why it works. */
.fwd {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 5px;
  font-size: 11.5px;
  font-style: italic;
  color: var(--dim);
  opacity: 0.95;
}

.fwd svg { flex: none; }
.fwd.many { font-weight: 500; }

.body {
  margin: 0;
  font-size: 15px;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Attached photo, rendered as a described placeholder rather than a stock
   image: the caption is the honest version and it stays readable to a screen
   reader. */
.photo {
  margin: 9px 0 0;
  border-radius: 9px;
  border: 1px solid var(--line);
  background:
    repeating-linear-gradient(115deg, rgba(155, 134, 196, 0.1) 0 9px, transparent 9px 18px),
    linear-gradient(160deg, #2c1b4d, #1a0f2f);
  padding: 26px 14px;
  font-size: 12px;
  color: var(--dim);
  text-align: center;
  font-style: italic;
}

.stamp-time {
  display: block;
  margin: 5px 0 0;
  text-align: right;
  font-size: 10.5px;
  color: var(--dim);
  opacity: 0.8;
}

/* Outcome chip under a resolved message, so the thread keeps a record. */
.chip {
  margin: 7px 0 0 4px;
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.chip.shared-false { background: rgba(255, 45, 120, 0.14); color: var(--hot); }
.chip.shared-true  { background: rgba(0, 229, 192, 0.13); color: var(--volt); }
.chip.checked      { background: rgba(255, 197, 49, 0.14); color: var(--gold); }
.chip.dropped      { background: rgba(155, 134, 196, 0.14); color: var(--dim); }

/* What a check turns up, printed into the thread as a system note. */
.result {
  align-self: center;
  max-width: min(94%, 480px);
  width: 100%;
  padding: 13px 15px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: rgba(0, 0, 0, 0.26);
  animation: pop-in 0.34s var(--ease-out) both;
}

/* The nudge after a check. Quiet, but it is the only thing on screen that
   says a decision is still owed. */
.ask {
  align-self: center;
  margin: 10px 0 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--paper);
  text-align: center;
  animation: pop-in 0.34s var(--ease-out) both;
}

/* After 3s of no input the action bar breathes once a second. No tutorial,
   no arrow, just enough motion to say "your turn". */
@keyframes nudge {
  0%, 100% { transform: none; }
  50%      { transform: translateY(-3px); }
}

.actions.waiting .act { animation: nudge 1.6s var(--ease-out) infinite; }
.actions.waiting .act.verify { animation-delay: 0.12s; }
.actions.waiting .act.ignore { animation-delay: 0.24s; }

@media (prefers-reduced-motion: reduce) {
  .actions.waiting .act { animation: none; }
}

.result h3 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--gold);
  text-transform: uppercase;
}

.result ul { margin: 0; padding: 0 0 0 16px; }

.result li {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--paper);
  margin-bottom: 5px;
}

.result .src {
  margin: 9px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--dim);
  font-style: italic;
}

/* ---------- decision deck ---------- */

.deck {
  flex: none;
  padding: 10px 14px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(18, 9, 31, 0.9);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 3;
}

.actions {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 0.9fr;
  gap: 9px;
}

/* display:grid beats the hidden attribute, so say it explicitly — otherwise
   the buttons stay on screen through the whole check. */
.actions[hidden] { display: none; }

.act {
  min-height: var(--thumb);
  border-radius: 15px;
  border: 1.5px solid;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 6px 4px;
  transition: transform 0.12s var(--ease-snap), opacity 0.15s;
}

.act:active { transform: scale(0.96); }
.act[disabled] { opacity: 0.4; pointer-events: none; }

.act-top { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.act-sub { font-size: 10.5px; opacity: 0.8; font-weight: 500; }

.act.share  { color: var(--gold); border-color: rgba(255, 197, 49, 0.42); background: rgba(255, 197, 49, 0.1); }
.act.verify { color: var(--volt); border-color: rgba(0, 229, 192, 0.4);  background: rgba(0, 229, 192, 0.09); }
.act.ignore { color: var(--dim);  border-color: var(--line);              background: rgba(155, 134, 196, 0.07); }

/* The cost of checking, made visible: a bar that fills while the queue grows
   behind it. */
.verifying { padding: 6px 2px 10px; }

.vf-bar {
  height: 6px;
  border-radius: 99px;
  background: var(--panel-lift);
  overflow: hidden;
}

.vf-bar i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: var(--volt);
  transform: scaleX(0);
  transform-origin: left;
}

.vf-label {
  margin: 9px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--volt);
}

.vf-warn { margin: 3px 0 0; font-size: 12px; color: var(--dim); }
.vf-warn.loud { color: var(--hot); }

/* ---------- cascade ---------- */

.cascade {
  position: fixed;
  inset: 0;
  z-index: 20;
  /* Fully opaque. At 0.93 the chat text underneath ghosted through the
     verdict for the first seconds, which is exactly when it is being read. */
  background: #0a0512;
  display: grid;
  place-items: center;
  padding: max(56px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  /* The backdrop must NOT be part of the fade. Animating opacity on this
     element makes the whole panel — background included — translucent for the
     length of the animation, and the chat underneath reads straight through
     the verdict. Fade the contents instead; the cover is opaque from frame 1. */
  overflow-y: auto;
}

.cascade > .cas-inner {
  animation: fade-in 0.28s var(--ease-out) both;
}

.cascade[hidden] { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.cas-inner {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
}

#graph {
  width: 100%;
  height: auto;
  aspect-ratio: 640 / 440;
  display: block;
}

.cas-copy { margin-top: 4px; }

.cas-verdict {
  margin: 0;
  font-size: clamp(24px, 7vw, 32px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.cas-verdict.bad  { color: var(--hot); }
.cas-verdict.good { color: var(--volt); }
.cas-verdict.flat { color: var(--paper); }

.cas-reach {
  margin: 10px 0 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.cas-harm {
  margin: 12px 0 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--paper);
}

.cas-tell {
  margin: 12px 0 0;
  padding-left: 12px;
  border-left: 2px solid var(--line);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--dim);
}

.cas-next { margin-top: 22px; align-self: stretch; }

/* ---------- receipt ---------- */

#over { justify-content: center; max-width: 520px; margin: 0 auto; overflow-y: auto; }

.over-title {
  margin: 0 0 24px;
  font-size: clamp(30px, 8.5vw, 42px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

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

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

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

.ta-row dd {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.ta-row:nth-child(1) dd { color: var(--hot); }
.ta-row:nth-child(2) dd { color: var(--hot); }
.ta-row:nth-child(3) dd { color: var(--volt); }
.ta-row:nth-child(4) dd { color: var(--gold); }

.stat-lede {
  margin: 28px 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--gold);
  text-transform: uppercase;
}

.stat {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--paper);
}

.stat b { color: var(--hot); font-weight: 700; }

.closer {
  margin: 22px 0 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--dim);
  border-left: 2px solid var(--gold);
  padding-left: 14px;
}

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

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

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

/* Taller screens can afford a bigger graph; short ones need the copy. */
@media (max-height: 680px) {
  #graph { aspect-ratio: 640 / 340; }
  .cas-harm { font-size: 14px; }
}
