:root {
  color-scheme: light dark;
  --page: #f3b563;
  --ink: #183136;
  --muted: #526368;
  --card: #fffaf0;
  --accent: #176b6f;
  --accent-ink: #f9fffc;
  --success: #1d7450;
  --success-soft: #dcefe2;
  --wrong: #a43e35;
  --wrong-soft: #f7dfd9;
  --shadow: rgba(74, 54, 20, 0.24);
  --shape: rgba(24, 49, 54, 0.28);
  --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: #172b2d;
    --ink: #f5f7ed;
    --muted: #bdcbc7;
    --card: #243d3e;
    --accent: #8ed5c8;
    --accent-ink: #142728;
    --success: #9ce0b8;
    --success-soft: #214d3a;
    --wrong: #ff9c8d;
    --wrong-soft: #5a302d;
    --shadow: rgba(3, 14, 14, 0.42);
    --shape: rgba(142, 213, 200, 0.22);
  }
}

* {
  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 {
  font: inherit;
}

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

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

.shape {
  position: absolute;
  display: block;
  border: 5px solid var(--shape);
}

.shape-ring {
  left: max(-90px, calc(50% - 650px));
  bottom: -86px;
  width: clamp(190px, 27vw, 350px);
  aspect-ratio: 1;
  border-width: clamp(24px, 4vw, 52px);
  border-radius: 50%;
}

.shape-slash {
  top: 8%;
  right: max(3vw, calc(50% - 570px));
  width: clamp(55px, 8vw, 96px);
  height: clamp(190px, 32vh, 340px);
  border: 0;
  border-radius: var(--radius);
  background: var(--shape);
  transform: rotate(30deg);
}

.shape-corner {
  top: 15%;
  left: max(4vw, calc(50% - 560px));
  width: 84px;
  height: 84px;
  border-right: 0;
  border-bottom: 0;
  transform: rotate(-10deg);
}

.game-shell {
  position: relative;
  width: min(100%, 820px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 32px) 16px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: clamp(18px, 3vh, 30px);
}

.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: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 950;
  transform: rotate(-6deg);
}

h1 {
  max-width: 10ch;
  font-size: clamp(23px, 5.6vw, 38px);
  font-weight: 950;
  letter-spacing: -0.06em;
  line-height: 0.92;
}

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

.game-meta {
  min-width: 116px;
  display: grid;
  gap: 8px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.meta-copy {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  white-space: nowrap;
}

#progress {
  font-size: 16px;
}

#score {
  color: var(--muted);
  font-size: 13px;
}

.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);
  transition: transform 180ms ease, background-color 180ms ease;
}

.progress-mark.is-complete {
  background: var(--ink);
}

.progress-mark.is-current {
  background: var(--accent);
  transform: scaleY(1.8);
}

.play-screen {
  width: 100%;
  align-self: center;
  display: grid;
  gap: 13px;
}

.scenario-card {
  position: relative;
  isolation: isolate;
  min-height: clamp(250px, 42dvh, 380px);
  padding: clamp(26px, 7vw, 56px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 8px 8px 0 var(--shadow);
}

.scenario-card::before {
  content: "";
  position: absolute;
  right: -92px;
  bottom: -115px;
  z-index: -1;
  width: 260px;
  aspect-ratio: 1;
  border: 42px solid color-mix(in srgb, var(--accent) 17%, transparent);
  border-radius: 50%;
}

.card-label {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.11em;
}

.scenario-text {
  max-width: 24ch;
  font-size: clamp(26px, 6.3vw, 44px);
  font-weight: 900;
  letter-spacing: -0.042em;
  line-height: 1.05;
  text-wrap: balance;
}

.card-mark {
  position: absolute;
  right: 18px;
  bottom: -15px;
  z-index: -1;
  color: color-mix(in srgb, var(--accent) 22%, transparent);
  font-size: 120px;
  font-weight: 950;
  line-height: 1;
  transform: rotate(8deg);
}

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

.answer-button,
.next-button,
.play-again-button {
  min-height: 62px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-weight: 950;
  cursor: pointer;
  transition: transform 150ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 150ms ease,
    background-color 150ms ease;
}

.answer-button {
  position: relative;
  padding: 13px 44px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font-size: clamp(18px, 4.5vw, 23px);
}

.answer-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--ink);
}

.answer-button:active:not(:disabled),
.next-button:active,
.play-again-button:active {
  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);
  opacity: 1;
}

.answer-button.is-wrong {
  background: var(--wrong-soft);
  opacity: 1;
}

kbd {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  transform: translateY(-50%);
}

.feedback {
  min-height: 96px;
  padding: 14px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
}

.feedback:not([hidden]) {
  display: flex;
  animation: feedback-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.feedback strong {
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
}

.feedback p {
  max-width: 48ch;
  color: var(--muted);
  font-size: clamp(16px, 2.7vw, 18px);
  line-height: 1.35;
}

.feedback.is-correct strong {
  color: var(--success);
}

.feedback.is-wrong strong {
  color: var(--wrong);
}

.next-button,
.play-again-button {
  flex: 0 0 auto;
  padding: 13px 24px;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 0 var(--ink);
  white-space: nowrap;
}

.end-screen {
  position: relative;
  align-self: center;
  padding: clamp(30px, 8vw, 66px);
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 9px 9px 0 var(--shadow);
}

.end-screen:not([hidden]) {
  display: grid;
  gap: 22px;
  animation: card-in 300ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.end-screen h2 {
  max-width: 10ch;
  font-size: clamp(42px, 10vw, 76px);
  letter-spacing: -0.065em;
  line-height: 0.9;
}

.end-screen h2 span {
  color: var(--accent);
  white-space: nowrap;
}

.takeaway {
  max-width: 55ch;
  color: var(--muted);
  font-size: clamp(18px, 3.6vw, 22px);
  line-height: 1.42;
}

.play-again-button {
  width: min(100%, 280px);
}

.result-stamp {
  position: absolute;
  top: 30px;
  right: -36px;
  padding: 8px 45px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 12px;
  transform: rotate(10deg);
}

.card-enter {
  animation: card-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.correct-pop {
  animation: correct-pop 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.game-error {
  align-self: center;
  padding: 28px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 20px;
  line-height: 1.4;
}

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

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) rotate(-0.6deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
}

@keyframes feedback-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes correct-pop {
  50% {
    transform: rotate(-0.6deg) scale(1.012);
  }
}

@media (max-width: 600px) {
  .game-shell {
    padding: 16px 13px;
  }

  .game-header {
    align-items: center;
  }

  .family-mark {
    width: 40px;
    height: 40px;
  }

  h1 {
    max-width: 8ch;
    font-size: 21px;
  }

  .game-meta {
    min-width: 108px;
  }

  .meta-copy {
    gap: 9px;
  }

  .scenario-card {
    min-height: clamp(235px, 39dvh, 320px);
  }

  .answers {
    grid-template-columns: 1fr;
    gap: 9px;
  }

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

  .feedback:not([hidden]) {
    align-items: stretch;
    flex-direction: column;
  }

  .next-button {
    width: 100%;
  }

  .shape-corner {
    display: none;
  }
}

@media (max-height: 710px) and (min-width: 601px) {
  .game-shell {
    padding-block: 14px;
    gap: 12px;
  }

  .scenario-card {
    min-height: 220px;
  }

  .answer-button {
    min-height: 54px;
  }
}

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