:root {
  color-scheme: light dark;
  --page: #087f83;
  --ink: #17313b;
  --muted: #50636a;
  --card: #fffaf0;
  --soft: #e7f3ef;
  --accent: #f4bd4a;
  --accent-ink: #17313b;
  --second: #ef6d57;
  --second-soft: #ffe2da;
  --success: #176847;
  --success-soft: #d9f0e3;
  --wrong: #9d352f;
  --wrong-soft: #f7dfda;
  --shadow: rgba(7, 42, 55, 0.4);
  --radius: 16px;
  --font: "Arial Narrow", "Aptos Narrow", "Roboto Condensed", Arial, sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #102d35;
    --ink: #eaf6f3;
    --muted: #bed0cd;
    --card: #173d43;
    --soft: #1d4a4e;
    --accent: #ffd169;
    --accent-ink: #17313b;
    --second: #ff8b75;
    --second-soft: #5a302c;
    --success: #8ad4ad;
    --success-soft: #1a4734;
    --wrong: #ff9a89;
    --wrong-soft: #552e2c;
    --shadow: rgba(2, 13, 17, 0.55);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 700;
}

h1, h2, p { margin: 0; }
button, a { font: inherit; }

button:focus-visible,
a:focus-visible,
.scenario-card:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 4px;
}

.background-shapes {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.shape { position: absolute; display: block; }

.shape-ring {
  top: -78px;
  right: -52px;
  width: 210px;
  height: 210px;
  border: 32px solid var(--accent);
  border-radius: 50%;
  opacity: 0.92;
}

.shape-stripe {
  bottom: 48px;
  left: -54px;
  width: 190px;
  height: 34px;
  border: 3px solid var(--ink);
  background: var(--second);
  transform: rotate(-18deg);
}

.shape-corner {
  right: clamp(20px, 5vw, 74px);
  bottom: -58px;
  width: 112px;
  height: 112px;
  border: 3px solid var(--ink);
  border-radius: 26px;
  background: var(--accent);
  transform: rotate(15deg);
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 920px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(14px, 2.4vw, 26px) 16px clamp(22px, 4vw, 40px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: clamp(12px, 2.2vh, 22px);
}

.game-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.title-lockup { display: flex; align-items: flex-start; gap: 10px; }

.family-mark {
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--second);
  color: var(--card);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 900;
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-5deg);
}

h1 {
  color: var(--ink);
  font-size: clamp(21px, 5vw, 35px);
  font-weight: 950;
  letter-spacing: -0.058em;
  line-height: 0.88;
}

h1 span { color: var(--accent); }

.game-meta {
  min-width: 200px;
  padding: 10px 12px 11px;
  display: grid;
  gap: 8px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 4px 4px 0 var(--ink);
  color: var(--ink);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.meta-copy { display: flex; justify-content: space-between; gap: 14px; white-space: nowrap; }
#progress { font-size: 13px; }
#score { color: var(--muted); font-size: 12px; }

.progress-marks { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.progress-mark { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--ink) 18%, transparent); }
.progress-mark.is-complete { background: var(--ink); }
.progress-mark.is-current { background: var(--second); transform: scaleY(1.8); }

.intro-screen, .play-screen, .end-screen { width: 100%; align-self: center; }

.intro-card, .scenario-card, .end-screen {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 10px 10px 0 var(--shadow);
}

.intro-card::before, .scenario-card::before, .end-screen::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  width: 42%;
  height: 11px;
  background: var(--accent);
}

.intro-card::after, .end-screen::after {
  content: "";
  position: absolute;
  z-index: -1;
  right: -62px;
  bottom: -78px;
  width: 210px;
  height: 210px;
  border: 32px solid color-mix(in srgb, var(--second) 35%, transparent);
  border-radius: 50%;
}

.intro-card {
  padding: clamp(27px, 4.5vw, 42px);
  display: grid;
  gap: 13px;
}

.card-label {
  width: fit-content;
  color: var(--second);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.intro-card h2 {
  max-width: 22ch;
  color: var(--ink);
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 950;
  letter-spacing: -0.045em;
  line-height: 1;
}

.intro-copy { max-width: 67ch; display: grid; gap: 8px; color: var(--muted); font-size: clamp(16px, 2.3vw, 17px); line-height: 1.35; }
.intro-copy strong { color: var(--ink); }

.examples {
  padding: 10px 14px;
  display: grid;
  gap: 6px;
  border-left: 7px solid var(--second);
  border-radius: 0 10px 10px 0;
  background: var(--soft);
}

.primary-button, .secondary-button, .next-button {
  min-height: 58px;
  padding: 13px 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 950;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.secondary-button { background: var(--second); color: #17313b; }

.primary-button:hover, .secondary-button:hover, .next-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--ink);
}

.primary-button:active, .secondary-button:active, .next-button:active {
  transform: translateY(3px) scale(0.99);
  box-shadow: 0 1px 0 var(--ink);
}

.play-screen { display: grid; gap: 13px; }

.scenario-card {
  min-height: clamp(290px, 43dvh, 390px);
  padding: clamp(28px, 6vw, 52px);
  display: grid;
  align-content: center;
  gap: 22px;
}

.scenario-card::after {
  content: "?";
  position: absolute;
  z-index: -1;
  right: 18px;
  bottom: -32px;
  color: color-mix(in srgb, var(--second) 20%, transparent);
  font-size: 150px;
  font-weight: 950;
  transform: rotate(8deg);
}

.statements { position: relative; z-index: 1; display: grid; gap: 18px; }
.statement span { color: var(--second); font-family: var(--mono); font-size: 12px; font-weight: 900; }
.statement p { max-width: 34ch; margin-top: 4px; font-size: clamp(22px, 4.6vw, 34px); font-weight: 900; letter-spacing: -0.025em; line-height: 1.12; text-wrap: balance; }
.defendant-statement { padding-top: 17px; border-top: 2px solid color-mix(in srgb, var(--ink) 18%, transparent); }

.answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }

.answer-button {
  position: relative;
  min-height: 78px;
  padding: 12px 28px 12px 45px;
  display: grid;
  align-content: center;
  gap: 3px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.deny-button { background: var(--accent); }
.defend-button { background: var(--second); color: #17313b; }
.answer-title { font-size: clamp(19px, 3vw, 23px); font-weight: 950; }
.answer-help { font-size: 14px; font-weight: 750; }

.answer-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }
.answer-button:active:not(:disabled) { transform: translateY(3px) scale(0.99); box-shadow: 0 1px 0 var(--ink); }
.answer-button:disabled { cursor: default; opacity: 0.58; }
.answer-button.is-correct { background: var(--success-soft); color: var(--ink); box-shadow: 0 5px 0 var(--success); opacity: 1; }
.answer-button.is-wrong { background: var(--wrong-soft); color: var(--ink); box-shadow: 0 5px 0 var(--wrong); opacity: 1; }

kbd {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: color-mix(in srgb, var(--card) 40%, transparent);
  font-family: var(--mono);
  font-size: 12px;
  transform: translateY(-50%);
}

.feedback {
  min-height: 102px;
  padding: 15px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 2px solid var(--ink);
  border-left-width: 8px;
  border-radius: 12px;
  background: var(--card);
  box-shadow: 5px 5px 0 var(--shadow);
}

.feedback:not([hidden]) { display: flex; }
.feedback strong { display: block; margin-bottom: 4px; font-size: 19px; }
.feedback p { max-width: 52ch; color: var(--muted); font-size: clamp(16px, 2.7vw, 18px); line-height: 1.35; }
.feedback.is-correct { border-left-color: var(--success); }
.feedback.is-correct strong { color: var(--success); }
.feedback.is-wrong { border-left-color: var(--wrong); }
.feedback.is-wrong strong { color: var(--wrong); }

.end-screen { padding: clamp(36px, 8vw, 72px); }
.end-screen:not([hidden]) { display: grid; gap: 20px; }
.end-screen h2 { color: var(--ink); font-size: clamp(48px, 11vw, 80px); letter-spacing: -0.065em; line-height: 0.9; }
.final-score { color: var(--muted); font-size: clamp(22px, 4vw, 30px); }
.final-score strong { display: inline-block; padding: 0.04em 0.18em 0.1em; background: var(--accent); color: var(--accent-ink); box-shadow: 3px 3px 0 var(--ink); }
.takeaway { position: relative; z-index: 1; max-width: 54ch; color: var(--muted); font-size: clamp(17px, 3vw, 21px); line-height: 1.42; }
.end-actions { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 12px; }

noscript { align-self: center; padding: 20px; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--card); }

@media (prefers-reduced-motion: no-preference) {
  .scenario-card.card-enter { animation: card-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  .feedback:not([hidden]) { animation: feedback-in 180ms ease-out both; }
  .end-screen:not([hidden]) { animation: card-in 300ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  @keyframes card-in { from { opacity: 0; transform: translateY(14px) rotate(0.5deg); } to { opacity: 1; transform: translateY(0) rotate(0); } }
  @keyframes feedback-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
}

@media (max-width: 640px) {
  .shape-ring { top: -58px; right: -66px; width: 154px; height: 154px; border-width: 25px; }
  .shape-stripe { left: -86px; opacity: 0.72; }
  .shape-corner { right: -38px; bottom: -45px; }
  .game-shell { padding: 15px 13px 30px; }
  .game-header { align-items: center; }
  .family-mark { width: 38px; height: 38px; }
  h1 { font-size: 20px; }
  .game-meta { min-width: 138px; padding: 8px 9px 9px; }
  .meta-copy { display: grid; gap: 3px; }
  #progress { font-size: 11px; }
  .intro-card { padding: 30px 23px 34px; }
  .intro-card h2 { font-size: 30px; }
  .intro-copy { font-size: 16px; }
  .scenario-card { min-height: 330px; padding: 30px 24px; }
  .statement p { font-size: 23px; }
  .answers { grid-template-columns: 1fr; gap: 9px; }
  .answer-button { min-height: 71px; }
  .feedback:not([hidden]) { align-items: stretch; flex-direction: column; }
  .next-button { width: 100%; }
  .end-screen { padding: 38px 25px 42px; }
  .end-actions { align-items: stretch; flex-direction: column; }
  .end-actions > * { width: 100%; }
}

@media (max-height: 740px) and (min-width: 641px) {
  .game-shell { padding-block: 14px 26px; gap: 12px; }
  .scenario-card { min-height: 250px; padding-block: 28px; }
  .answer-button { min-height: 68px; }
}

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