:root {
  color-scheme: dark;
  --page: #07111e;
  --page-deep: #030912;
  --panel: #0c1b2a;
  --panel-raised: #112437;
  --paper: #f4efe3;
  --paper-ink: #162236;
  --ink: #eef5fb;
  --muted: #a8b9c8;
  --line: #395065;
  --line-soft: #22394d;
  --player-one: #49a8ff;
  --player-two: #ff7858;
  --gold: #ffd166;
  --selected-surface: #2f270a;
  --green: #61d59a;
  --red: #ff7a88;
  --shadow: 0 26px 80px rgb(0 0 0 / 35%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page-deep);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  background:
    radial-gradient(circle at 12% -8%, rgb(25 105 165 / 30%), transparent 34rem),
    radial-gradient(circle at 91% 8%, rgb(255 120 88 / 12%), transparent 28rem),
    linear-gradient(160deg, var(--page) 0%, var(--page-deep) 76%);
}

button {
  font: inherit;
}

button:focus-visible,
.tree-viewport:focus-visible,
.table-wrap:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1500px, calc(100% - 36px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 25px;
}

.eyebrow,
.section-number {
  margin: 0 0 5px;
  color: var(--player-one);
  font-size: 0.8125rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.45rem, 5vw, 4.8rem);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.045em;
}

h1 i {
  color: var(--gold);
}

h2 {
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.018em;
}

h3 {
  margin-bottom: 5px;
  font-size: 1rem;
  line-height: 1.3;
}

.new-game-button,
.tree-control-button,
.explain-button,
.answer-choice {
  cursor: pointer;
  transition:
    transform 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.new-game-button {
  min-height: 48px;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  color: #06111d;
  background: var(--player-one);
  box-shadow: 0 8px 24px rgb(73 168 255 / 22%);
  font-weight: 850;
}

.new-game-button:hover {
  background: #79c0ff;
  transform: translateY(-1px);
}

.instruction-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 28px;
  align-items: center;
  margin-bottom: 18px;
  padding: 24px clamp(20px, 4vw, 42px);
  border-radius: 20px;
  color: var(--paper-ink);
  background:
    linear-gradient(115deg, rgb(255 255 255 / 40%), transparent 38%),
    var(--paper);
  box-shadow: var(--shadow);
}

.instructions-copy {
  max-width: 820px;
}

.instructions-copy .section-number {
  color: #176eaa;
}

.instructions-copy p:last-child {
  margin-bottom: 0;
  color: #435064;
  font-size: 1.0525rem;
}

.method-card {
  display: grid;
  gap: 3px;
  padding: 17px 20px;
  border: 1px solid #c7c0b2;
  border-radius: 14px;
  background: rgb(255 255 255 / 58%);
}

.method-label {
  color: #657085;
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.method-card strong {
  color: #162236;
  font-size: 1.075rem;
}

.method-card span:last-child {
  color: #596579;
  font-size: 0.92rem;
}

.tree-card,
.question-card,
.explanation {
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tree-card {
  overflow: hidden;
}

.tree-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 20px clamp(18px, 3vw, 32px) 17px;
  border-bottom: 1px solid var(--line-soft);
  background: rgb(255 255 255 / 2%);
}

.tree-toolbar h2 {
  margin-bottom: 0;
}

.tree-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}

.player-key {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 20px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 750;
}

.player-key span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.player-mark {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgb(255 255 255 / 4%);
}

.player-one-mark {
  background: var(--player-one);
}

.player-two-mark {
  background: var(--player-two);
}

.tree-button-group {
  display: flex;
  gap: 8px;
}

.tree-control-button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #d9e6ef;
  background: #142a3d;
  font-size: 0.875rem;
  font-weight: 800;
}

.tree-control-button:hover {
  border-color: #7690a5;
  background: #1b354a;
}

.tree-viewport {
  width: 100%;
  min-height: 640px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  background:
    radial-gradient(circle, rgb(157 189 214 / 16%) 1.1px, transparent 1.2px),
    linear-gradient(180deg, #0b1927, #081522);
  background-size: 24px 24px, auto;
  scrollbar-color: var(--line) var(--page-deep);
}

.game-tree {
  display: block;
  min-width: 1000px;
  margin: 0 auto;
  overflow: visible;
}

.branch {
  fill: none;
  stroke: #5d7386;
  stroke-linecap: round;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.decision-node circle {
  stroke-width: 3;
  filter: drop-shadow(0 5px 10px rgb(0 0 0 / 30%));
}

.player-1-node circle {
  fill: #0f4f7c;
  stroke: var(--player-one);
}

.player-2-node circle {
  fill: #713625;
  stroke: var(--player-two);
}

.node-abbreviation {
  fill: #fff;
  font-size: 1rem;
  font-weight: 900;
  pointer-events: none;
}

.node-name {
  font-size: 0.875rem;
  font-weight: 850;
  pointer-events: none;
}

.player-1-node .node-name {
  fill: var(--player-one);
}

.player-2-node .node-name {
  fill: var(--player-two);
}

.action-badge rect,
.terminal-box {
  fill: #12283a;
  stroke: #6d8294;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  transition:
    fill 130ms ease,
    stroke 130ms ease,
    stroke-width 130ms ease;
}

.action-badge text {
  fill: #f5f8fb;
  font-size: 1rem;
  font-weight: 900;
  pointer-events: none;
}

.scratch-control {
  cursor: pointer;
  outline: none;
}

.scratch-control:hover rect {
  fill: #19364d;
  stroke: #d4e1ec;
}

.scratch-control:focus-visible rect {
  stroke: var(--gold);
  stroke-width: 3;
}

.scratch-control.is-selected rect,
.scratch-control.is-selected:hover rect {
  fill: var(--selected-surface);
  stroke: var(--gold);
  stroke-width: 3;
}

.payoff-text {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  font-weight: 800;
}

.player-one-payoff,
.p1-inline {
  color: var(--player-one);
  fill: var(--player-one);
}

.player-two-payoff,
.p2-inline {
  color: var(--player-two);
  fill: var(--player-two);
}

.payoff-comma {
  fill: #d7e0e8;
}

.p1-inline,
.p2-inline {
  font-weight: 800;
}

.tree-description {
  margin: 0;
  padding: 15px 24px 12px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.9375rem;
  text-align: center;
}

.question-card {
  margin-top: 18px;
  padding: clamp(22px, 3vw, 34px);
  background:
    radial-gradient(circle at 92% 0, rgb(255 209 102 / 8%), transparent 22rem),
    var(--panel-raised);
}

.question-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
}

.question-heading h2 {
  max-width: 960px;
  margin-bottom: 6px;
  font-size: clamp(1.5rem, 2.8vw, 2.3rem);
}

.question-kind {
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid #536a7f;
  border-radius: 999px;
  color: #c9d7e3;
  background: #0e2031;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.choice-instruction {
  margin-bottom: 18px;
  color: var(--muted);
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.answer-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 13px 16px;
  border: 2px solid #4c6378;
  border-radius: 14px;
  color: #f1f6fa;
  background: #0c1c2c;
  text-align: left;
  font-weight: 850;
}

.answer-choice:hover:not(:disabled) {
  border-color: #87a0b6;
  background: #142c40;
  transform: translateY(-1px);
}

.answer-choice:disabled {
  cursor: default;
}

.answer-choice.is-wrong {
  border-color: var(--red);
  color: #ffdce0;
  background: #441a26;
}

.answer-choice.is-correct {
  border-color: var(--green);
  color: #ddffed;
  background: #123d2b;
  box-shadow: 0 0 0 4px rgb(97 213 154 / 10%);
}

.answer-label {
  overflow-wrap: anywhere;
}

.answer-marker {
  flex: 0 0 auto;
  font-size: 1.35rem;
  font-weight: 950;
}

.answer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #2a4257;
}

.answer-feedback {
  margin: 0;
  color: #c2d0dc;
  font-weight: 750;
}

.answer-feedback.is-wrong {
  color: #ffb4bd;
}

.answer-feedback.is-correct {
  color: #9eebc2;
}

.explain-button {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 11px 19px;
  border: 0;
  border-radius: 999px;
  color: #241d0d;
  background: var(--gold);
  box-shadow: 0 8px 24px rgb(255 209 102 / 18%);
  font-weight: 850;
}

.explain-button:hover {
  background: #ffe092;
  transform: translateY(-1px);
}

.explanation {
  margin-top: 18px;
  padding: clamp(24px, 4vw, 42px);
}

.explanation-heading {
  max-width: 900px;
}

.explanation-heading > p:last-child {
  color: var(--muted);
  font-size: 1.025rem;
}

.explanation-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0;
  padding: 0;
  list-style: none;
  counter-reset: rollback-step;
}

.explanation-steps li {
  position: relative;
  min-height: 150px;
  padding: 19px 20px 18px 58px;
  border: 1px solid #2f485e;
  border-radius: 15px;
  background: #0a1927;
  counter-increment: rollback-step;
}

.explanation-steps li::before {
  position: absolute;
  top: 18px;
  left: 18px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: #0a1520;
  background: var(--player-one);
  content: counter(rollback-step);
  font-size: 0.82rem;
  font-weight: 900;
}

.explanation-steps p {
  margin-bottom: 0;
  color: #bdcbd6;
  font-size: 0.95rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #30485d;
  border-radius: 14px;
}

.table-wrap + .table-wrap {
  margin-top: 16px;
}

table {
  width: 100%;
  min-width: 580px;
  border-collapse: collapse;
  background: #091826;
}

caption {
  padding: 13px 16px;
  color: #dbe5ec;
  background: #13283a;
  font-weight: 850;
  text-align: left;
}

th,
td {
  padding: 12px 16px;
  border-top: 1px solid #293f53;
  text-align: left;
}

th {
  color: #9fb2c2;
  font-size: 0.78rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

td {
  color: #dce5ec;
}

.range-cell,
.payoff-cell {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
  white-space: nowrap;
}

.path-cell {
  color: #bed4e5;
  font-weight: 750;
  white-space: nowrap;
}

.yes-cell {
  color: var(--green);
  font-weight: 900;
}

.no-cell {
  color: #c5d0d9;
}

.conclusion {
  margin: 22px 0 0;
  padding: 17px 20px;
  border: 1px solid rgb(97 213 154 / 42%);
  border-radius: 14px;
  color: #dffff0;
  background: rgb(31 156 102 / 15%);
  font-size: 1.045rem;
  font-weight: 850;
}

@media (max-width: 980px) {
  .explanation-steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 1500px);
    padding-top: 23px;
  }

  .site-header,
  .tree-toolbar,
  .question-heading,
  .answer-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .new-game-button,
  .explain-button {
    width: 100%;
  }

  .instruction-panel {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .tree-tools {
    align-items: stretch;
    justify-content: space-between;
  }

  .player-key {
    justify-content: flex-start;
  }

  .question-kind {
    align-self: flex-start;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 2.55rem;
  }

  .tree-tools {
    flex-direction: column;
  }

  .tree-button-group {
    width: 100%;
  }

  .tree-control-button {
    flex: 1;
  }

  .answer-grid {
    grid-template-columns: 1fr;
  }

  .answer-choice {
    min-height: 58px;
  }

  .explanation-steps li {
    padding-left: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
