:root {
  color-scheme: light dark;
  --page: #b8d8ee;
  --ink: #14263a;
  --muted: #4d6174;
  --card: #f7fbff;
  --line: #14263a;
  --accent: #b64232;
  --accent-ink: #ffffff;
  --success: #176b49;
  --success-soft: #dcefe3;
  --wrong: #a43b32;
  --wrong-soft: #f7dfd9;
  --shape: #2d6e91;
  --shadow: rgba(20, 50, 74, 0.22);
  --radius: 14px;
  font-family: "Arial Narrow", "Aptos Narrow", "Roboto Condensed", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #10263b;
    --ink: #eef7fc;
    --muted: #b5cad8;
    --card: #18354c;
    --line: #eef7fc;
    --accent: #ff8068;
    --accent-ink: #10263b;
    --success: #80d1a5;
    --success-soft: #183c2d;
    --wrong: #ff9483;
    --wrong-soft: #4b2827;
    --shape: #5aa2c8;
    --shadow: rgba(2, 12, 22, 0.42);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  position: relative;
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 49.8%, color-mix(in srgb, var(--ink) 9%, transparent) 50%, transparent 50.2%),
    var(--page);
}

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

.shape {
  position: absolute;
  display: block;
  border: 6px solid color-mix(in srgb, var(--shape) 74%, transparent);
}

.shape-diamond {
  top: 9%;
  left: max(2vw, calc(50% - 610px));
  width: clamp(100px, 16vw, 220px);
  aspect-ratio: 1;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  transform: rotate(19deg);
}

.shape-ring {
  right: max(-45px, calc(50% - 670px));
  bottom: -40px;
  width: clamp(190px, 26vw, 360px);
  aspect-ratio: 1;
  border-width: clamp(28px, 4vw, 58px);
  border-radius: 50%;
}

.shape-bar {
  right: max(4vw, calc(50% - 570px));
  top: 12%;
  width: clamp(55px, 7vw, 92px);
  height: clamp(180px, 30vh, 330px);
  border: 0;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 68%, transparent);
  transform: rotate(34deg);
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 4px;
}

.game-shell {
  position: relative;
  width: min(100%, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 20px 16px 16px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 20px;
}

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

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

.family-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 900;
  transform: rotate(-5deg);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(20px, 6vw, 31px);
  line-height: 0.88;
  letter-spacing: -0.055em;
  font-weight: 950;
}

.game-stats {
  display: grid;
  justify-items: end;
  gap: 3px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

#progress {
  font-size: 18px;
}

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

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

.question-card {
  position: relative;
  isolation: isolate;
  min-height: clamp(230px, 39dvh, 360px);
  padding: clamp(24px, 7vw, 54px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 8px 8px 0 var(--shadow);
}

.question-card::before {
  content: "";
  position: absolute;
  inset: -30% -15% auto auto;
  z-index: -1;
  width: 210px;
  aspect-ratio: 1;
  border: 34px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 50%;
}

.card-label {
  color: var(--accent);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.12em;
}

.question-text {
  max-width: 19ch;
  font-size: clamp(27px, 7vw, 47px);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 850;
  text-wrap: balance;
}

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

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

.answer-button,
.next-button,
.play-again-button {
  min-height: 58px;
  border: 2px solid var(--line);
  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: 12px 42px;
  color: var(--ink);
  background: var(--card);
  box-shadow: 0 4px 0 var(--line);
  font-size: clamp(17px, 4.5vw, 21px);
}

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

.answer-button:active:not(:disabled),
.next-button:active,
.play-again-button:active {
  transform: translateY(3px) scale(0.99);
  box-shadow: 0 1px 0 var(--line);
}

.answer-button:disabled {
  cursor: default;
  opacity: 0.58;
}

.answer-button.is-correct {
  color: var(--ink);
  background: var(--success-soft);
  opacity: 1;
}

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

.key-hint {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  transform: translateY(-50%);
}

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

.feedback:not([hidden]) {
  display: flex;
}

.feedback strong {
  display: block;
  margin-bottom: 3px;
  font-size: 19px;
}

.feedback p {
  max-width: 42ch;
  color: var(--muted);
  font-size: clamp(17px, 2.7vw, 19px);
  line-height: 1.42;
}

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

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

.next-button,
.play-again-button {
  flex: 0 0 auto;
  padding: 12px 18px;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 4px 0 var(--line);
}

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

.end-screen:not([hidden]) {
  display: grid;
  gap: 22px;
}

.end-screen h2 {
  max-width: 9ch;
  font-size: clamp(46px, 13vw, 84px);
  line-height: 0.92;
  letter-spacing: -0.06em;
}

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

.takeaway {
  max-width: 52ch;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.play-again-button {
  width: min(100%, 260px);
  min-height: 62px;
  font-size: 20px;
}

.result-burst span {
  position: absolute;
  right: 8%;
  top: 12%;
  width: 12px;
  height: 28px;
  border-radius: 4px;
  background: var(--accent);
  transform-origin: 50% 120px;
}

.result-burst span:nth-child(2) { transform: rotate(34deg); }
.result-burst span:nth-child(3) { transform: rotate(68deg); }
.result-burst span:nth-child(4) { transform: rotate(102deg); }
.result-burst span:nth-child(5) { transform: rotate(136deg); }

@media (min-width: 620px) {
  .game-shell {
    padding: 28px 28px 20px;
  }

  .answers {
    grid-template-columns: repeat(3, 1fr);
  }

  .answer-button {
    min-height: 72px;
    padding-inline: 32px 12px;
  }
}

@media (max-width: 900px) {
  .shape-diamond {
    left: -58px;
  }

  .shape-bar {
    right: -16px;
    top: 7%;
  }

  .shape-ring {
    right: -105px;
    bottom: -70px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .question-card.card-enter {
    animation: card-enter 280ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .question-card.correct-pop {
    animation: correct-pop 360ms cubic-bezier(0.2, 0.9, 0.25, 1.3);
  }

  .feedback:not([hidden]) {
    animation: feedback-in 180ms ease-out;
  }

  .end-screen:not([hidden]) .result-burst {
    animation: burst-in 500ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes card-enter {
    from { opacity: 0; transform: translateY(14px) rotate(0.7deg); }
    to { opacity: 1; transform: translateY(0) rotate(0); }
  }

  @keyframes correct-pop {
    0%, 100% { transform: scale(1); }
    45% { transform: scale(1.015) rotate(-0.35deg); }
  }

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

  @keyframes burst-in {
    from { opacity: 0; transform: scale(0.4) rotate(-18deg); }
    to { opacity: 1; transform: scale(1) rotate(0); }
  }
}

@media (max-height: 700px) {
  .game-shell {
    gap: 12px;
    padding-block: 12px;
  }

  .question-card {
    min-height: 200px;
    padding-block: 22px;
  }

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