:root {
  color-scheme: light;
  --ink: #243049;
  --muted: #675b78;
  --paper: rgba(255, 255, 255, 0.88);
  --rose: #ff5f91;
  --orange: #ff9f43;
  --lemon: #ffe56f;
  --teal: #38cfd1;
  --green: #56c96f;
  --blue: #4f7cff;
  --violet: #8a5cff;
  --shadow: 0 18px 42px rgba(36, 48, 73, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  min-height: 100svh;
  overflow: hidden;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Comic Sans MS", system-ui, sans-serif;
  background:
    radial-gradient(circle at 13% 13%, rgba(255, 229, 111, 0.9) 0 104px, transparent 106px),
    radial-gradient(circle at 86% 14%, rgba(56, 207, 209, 0.54) 0 108px, transparent 110px),
    radial-gradient(circle at 82% 88%, rgba(255, 95, 145, 0.42) 0 130px, transparent 132px),
    linear-gradient(135deg, #9be8ff 0%, #fff0a6 38%, #ffd0e0 69%, #d7ffc3 100%);
}

button,
a {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

a {
  text-decoration: none;
}

.game-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(10px, 2vw, 18px);
  width: min(1240px, 100vw);
  height: 100svh;
  margin: 0 auto;
  padding: clamp(10px, 2vw, 18px);
}

.topbar {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) minmax(146px, auto);
  align-items: center;
  gap: 12px;
}

.home-link {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 4px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 0 rgba(36, 48, 73, 0.14), var(--shadow);
  font-size: 1.45rem;
  font-weight: 1000;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: #5e4599;
  font-size: clamp(0.74rem, 1.8vw, 0.9rem);
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 7vw, 4.85rem);
  line-height: 0.94;
  letter-spacing: 0;
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.6);
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(82px, 1fr));
  gap: 8px;
}

.scoreboard span {
  display: grid;
  place-items: center;
  min-height: 50px;
  padding: 8px 10px;
  border: 4px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
  color: #35415f;
  font-size: clamp(0.84rem, 1.8vw, 1rem);
  font-weight: 950;
  white-space: nowrap;
}

.play-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: clamp(10px, 2vw, 16px);
  min-height: 0;
}

.card-table,
.tower-panel {
  position: relative;
  overflow: hidden;
  border: 5px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.38)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.26) 0 28px, rgba(255, 255, 255, 0.08) 28px 56px);
  box-shadow: var(--shadow);
}

.card-table {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: clamp(14px, 3vw, 30px);
}

.spark-sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.spark {
  position: absolute;
  width: 32px;
  height: 32px;
  background: var(--spark-color, var(--lemon));
  clip-path: polygon(50% 0, 61% 34%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 34%);
  opacity: 0.44;
  animation: bob 3s ease-in-out infinite;
}

.spark.one {
  --spark-color: var(--rose);
  top: 12%;
  left: 9%;
}

.spark.two {
  --spark-color: var(--teal);
  top: 22%;
  right: 12%;
  animation-delay: -1.2s;
}

.spark.three {
  --spark-color: var(--orange);
  right: 24%;
  bottom: 18%;
  animation-delay: -2.1s;
}

.spark.four {
  --spark-color: var(--violet);
  left: 18%;
  bottom: 18%;
  animation-delay: -0.7s;
}

.spark.five {
  --spark-color: var(--green);
  top: 45%;
  left: 7%;
  animation-delay: -1.8s;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }

  50% {
    transform: translateY(-14px) rotate(7deg);
  }
}

.question-card {
  position: relative;
  z-index: 1;
  display: grid;
  gap: clamp(16px, 3vw, 24px);
  width: min(650px, 96%);
  min-height: min(620px, 100%);
  padding: clamp(18px, 4vw, 34px);
  border: 6px solid #ffffff;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.82)),
    linear-gradient(135deg, rgba(255, 229, 111, 0.9), rgba(56, 207, 209, 0.5));
  box-shadow: 0 18px 0 rgba(36, 48, 73, 0.12), 0 24px 46px rgba(36, 48, 73, 0.24);
}

.question-card.is-correct {
  animation: correctPop 360ms ease;
}

.question-card.is-wrong {
  animation: wrongShake 360ms ease;
}

@keyframes correctPop {
  50% {
    transform: translateY(-8px) scale(1.02);
  }
}

@keyframes wrongShake {
  20%,
  60% {
    transform: translateX(-9px) rotate(-1deg);
  }

  40%,
  80% {
    transform: translateX(9px) rotate(1deg);
  }
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-topline span,
.card-topline strong {
  display: grid;
  place-items: center;
  min-height: 42px;
  border-radius: 999px;
  font-weight: 1000;
}

.card-topline span {
  padding: 0 14px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--rose), var(--violet));
}

.card-topline strong {
  width: 48px;
  color: #5a3c00;
  background: var(--lemon);
  box-shadow: inset 0 -5px 0 rgba(90, 60, 0, 0.12);
}

.question-text {
  display: grid;
  place-items: center;
  min-height: 166px;
  padding: 18px;
  border: 4px dashed rgba(79, 124, 255, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: #233052;
  font-size: clamp(2.7rem, 8vw, 5rem);
  font-weight: 1000;
  line-height: 1;
  text-align: center;
}

.question-text.is-wordy {
  font-size: clamp(2.15rem, 6vw, 4.1rem);
  line-height: 1.08;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(10px, 2vw, 14px);
}

.answer-button {
  display: grid;
  place-items: center;
  min-height: clamp(70px, 12vw, 96px);
  border: 4px solid rgba(255, 255, 255, 0.84);
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(180deg, var(--button-top), var(--button-bottom));
  box-shadow: inset 0 -7px 0 rgba(0, 0, 0, 0.16), 0 8px 0 rgba(36, 48, 73, 0.12);
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 1000;
}

.answer-button:focus-visible {
  outline: 5px solid rgba(255, 229, 111, 0.92);
  outline-offset: 2px;
}

.answer-button:active,
.answer-button.is-selected {
  transform: translateY(5px);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.16), 0 3px 0 rgba(36, 48, 73, 0.12);
}

.answer-button.is-correct-answer {
  outline: 5px solid rgba(86, 201, 111, 0.95);
  outline-offset: 2px;
}

.answer-button.is-wrong-answer {
  filter: saturate(0.8) brightness(0.9);
}

.feedback {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 4px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 24px rgba(36, 48, 73, 0.14);
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.18rem);
  font-weight: 950;
  text-align: center;
}

.tower-panel {
  display: grid;
  grid-template-rows: 180px minmax(0, 1fr);
  min-height: 0;
  padding: 14px;
}

.mountain {
  position: relative;
  align-self: end;
  height: 172px;
}

.peak {
  position: absolute;
  bottom: 0;
  width: 0;
  height: 0;
  border-right: 94px solid transparent;
  border-left: 94px solid transparent;
  border-bottom: 154px solid #6cbf75;
  filter: drop-shadow(0 11px 0 rgba(36, 48, 73, 0.1));
}

.peak::after {
  position: absolute;
  left: -40px;
  top: 48px;
  width: 80px;
  height: 54px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: rgba(255, 255, 255, 0.92);
  content: "";
}

.peak.left {
  left: 7px;
}

.peak.right {
  right: 7px;
  border-bottom-color: #3cc0b9;
  transform: scale(0.82);
  transform-origin: bottom right;
}

.flag {
  position: absolute;
  top: 16px;
  left: 50%;
  width: 12px;
  height: 78px;
  border-radius: 999px;
  background: #243049;
  transform: translateX(-50%);
}

.flag::after {
  position: absolute;
  top: 0;
  left: 9px;
  width: 64px;
  height: 38px;
  border-radius: 8px 8px 8px 0;
  background: linear-gradient(135deg, var(--rose), var(--orange));
  content: "";
}

.stack-cards {
  position: relative;
  min-height: 0;
}

.stack-card {
  position: absolute;
  left: 50%;
  bottom: calc(var(--level) * 13px);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  width: min(188px, 88%);
  min-height: 46px;
  padding: 8px 10px;
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--card-color), #ffffff);
  box-shadow: 0 6px 0 rgba(36, 48, 73, 0.12);
  color: #243049;
  font-size: 0.92rem;
  font-weight: 1000;
  transform: translateX(-50%) rotate(var(--tilt));
  animation: stackIn 260ms ease both;
}

.stack-card .mark {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--green);
  font-size: 1rem;
  line-height: 1;
}

.stack-card.is-missed .mark {
  background: #9aa5ba;
}

@keyframes stackIn {
  from {
    opacity: 0;
    transform: translate(-50%, -24px) rotate(var(--tilt));
  }
}

.final-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(45, 55, 84, 0.26);
  backdrop-filter: blur(5px);
}

.final-overlay.hidden {
  display: none;
}

.final-panel {
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(520px, 94vw);
  padding: clamp(22px, 5vw, 36px);
  border: 5px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.84)),
    linear-gradient(135deg, #ffe56f, #a6f3ff);
  box-shadow: 0 22px 48px rgba(36, 48, 73, 0.28);
  text-align: center;
}

.final-panel h2 {
  font-size: clamp(2rem, 7vw, 3.8rem);
  line-height: 0.98;
}

.final-score {
  display: grid;
  place-items: center;
  min-width: 174px;
  min-height: 108px;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.14);
  font-size: clamp(3rem, 11vw, 5.2rem);
  line-height: 1;
}

.final-message {
  color: var(--muted);
  font-size: clamp(1rem, 2.8vw, 1.24rem);
  font-weight: 950;
}

.primary-button {
  min-height: 58px;
  padding: 0 24px;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(180deg, var(--rose), #e73574);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.16), 0 7px 0 rgba(36, 48, 73, 0.14);
  font-size: 1.1rem;
  font-weight: 1000;
}

.primary-button:active {
  transform: translateY(4px);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16), 0 3px 0 rgba(36, 48, 73, 0.14);
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .game-shell {
    height: auto;
    min-height: 100svh;
  }

  .topbar {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .home-link {
    width: 46px;
    height: 46px;
  }

  .scoreboard {
    grid-column: 1 / -1;
  }

  .play-area {
    grid-template-columns: 1fr;
  }

  .card-table {
    min-height: 620px;
  }

  .tower-panel {
    grid-template-rows: 112px 180px;
    min-height: 320px;
  }

  .mountain {
    height: 112px;
  }

  .peak {
    border-right-width: 74px;
    border-left-width: 74px;
    border-bottom-width: 112px;
  }
}

@media (max-width: 520px) {
  .card-table {
    min-height: 570px;
    padding: 10px;
  }

  .question-card {
    width: 100%;
    min-height: 500px;
    padding: 14px;
  }

  .question-text {
    min-height: 128px;
  }

  .answer-grid {
    gap: 8px;
  }

}
