:root {
  --bg: #f1f5f9;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --rest: #0284c7;
  --graphql: #db2777;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { color: var(--ink); background: var(--bg); }
code, pre { font-family: "SF Mono", Menlo, Consolas, monospace; }

#app { height: 100vh; display: flex; flex-direction: column; }

/* --- header (same shape as every other demo) ----------------------------- */
.page-head {
  flex: none;
  background: #fff;
  border-bottom: 3px solid var(--ink);
  padding: 14px 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.page-explain { margin: 0; max-width: 900px; font-size: 15px; line-height: 1.5; }
.page-explain em { font-style: normal; font-weight: 600; }
.page-explain code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.page-controls {
  flex: none;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.back {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.back:hover { background: var(--bg); }
.play {
  background: transparent;
  color: #0284c7;
  border: 1px solid #0284c7;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.play.active { background: #0284c7; color: #fff; }

/* --- the situations ------------------------------------------------------ */
.scenarios {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.scenario {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 4px solid var(--c);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 14px;
  cursor: pointer;
}
.scenario.win-rest { --c: var(--rest); }
.scenario.win-graphql { --c: var(--graphql); }
.scenario.current { background: var(--ink); color: #fff; border-color: var(--ink); border-left-color: var(--c); }
.scenario:disabled { cursor: default; }

/* --- the two sides ------------------------------------------------------- */
.split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 18px 22px;
  align-items: start;
  overflow: auto;
}
@media (max-width: 720px) {
  .split { grid-template-columns: 1fr; }
}
.side {
  --c: var(--rest);
  background: #fff;
  border: 1px solid var(--line);
  border-top: 5px solid var(--c);
  border-radius: 14px;
  padding: 16px 18px;
  transition: box-shadow 0.2s, opacity 0.2s;
}
.side-graphql { --c: var(--graphql); }
.side { animation: side-in 0.35s ease-out; }
@keyframes side-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .side { animation: none; } }
.side.wins { box-shadow: 0 0 0 3px var(--c), 0 10px 30px rgba(15, 23, 42, 0.1); }
.side-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.side-head h2 { margin: 0; font-size: 24px; color: var(--c); }
.verdict { font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.wins .verdict { background: #dcfce7; color: #166534; }
.loses .verdict { background: #fee2e2; color: #991b1b; }

.wire {
  margin: 0 0 8px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 5.2em;
}
.note { margin: 0 0 16px; font-size: 14px; color: var(--muted); line-height: 1.5; min-height: 3em; }
.cost { margin: -8px 0 16px; font-size: 13px; font-weight: 700; color: var(--c); }

.lists { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.list-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.points { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.point {
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px 6px 26px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.point::before { position: absolute; left: 9px; font-weight: 700; }
.pro::before { content: "+"; color: #16a34a; }
.con::before { content: "−"; color: #dc2626; }
.point.current.pro { background: #dcfce7; border-color: #16a34a; }
.point.current.con { background: #fee2e2; border-color: #dc2626; }
.scenario.all { --c: var(--ink); font-weight: 600; }
.tally { font-size: 13px; color: var(--muted); font-weight: 600; }
.none { color: var(--muted); padding: 6px 10px; font-size: 13px; }

/* --- phone: one column, and the whole page scrolls ------------------------
   Locked to the screen height, the stacked halves would each shrink into a
   small scroll box with the interesting part hidden inside it. */
@media (max-width: 720px) {
  #app { height: auto; min-height: 100vh; }
  .page-head { flex-direction: column; }
  .page-controls { order: -1; flex-direction: row; justify-content: space-between; align-items: center; width: 100%; margin-left: 0; }
  .split { overflow: visible; padding: 8px; gap: 8px; grid-template-columns: minmax(0, 1fr); }
  /* Room for the tour to keep the situations at the top even when one situation is shorter than the full list. */
  .split.playing { min-height: 100vh; align-content: start; }
  /* The winner jumps to the top of the stack; don't let the browser shift the page to follow the old first card. */
  html { overflow-anchor: none; }
  /* The situations ride along in one swipeable row, so the one being shown
     stays in sight while the two sides scroll past under it. */
  .scenarios {
    position: sticky; top: 0; z-index: 1;
    flex-wrap: nowrap; overflow-x: auto;
    scroll-snap-type: x proximity; scroll-padding-left: 16px;
    border-bottom: 1px solid var(--line);
  }
  /* Plain chips here: half-scrolled-off winner stripes at both edges read as
     stray colour, and the sides below already say who wins. */
  .scenario { flex: none; white-space: nowrap; scroll-snap-align: start; border-left: 1px solid var(--line); }
  .scenario.current { border-left-color: var(--ink); }
  /* Stacked, the side that wins the picked situation comes first — right under
     the situations — instead of sometimes falling below the fold. */
  .side { padding: 10px 12px; scroll-margin-top: 76px; }
  .side-head { margin-bottom: 8px; }
  .side-head h2 { font-size: 20px; }
  .side.wins { order: -1; }
  .wire { font-size: 11px; line-height: 1.5; padding: 8px 10px; min-height: 0; white-space: pre; overflow-x: auto; }
  .note { margin-bottom: 8px; min-height: 0; }
  .cost { margin: 0 0 8px; }
  .list-title { margin-bottom: 4px; }
  .point { font-size: 15px; }
  .lists { grid-template-columns: 1fr; gap: 8px; }
  .lists > div:has(.none) { display: none; }
}
