:root {
  --ink: #2c2118;
  --leaf: #2f8a5f;
  --leaf-dark: #1d6042;
  --sky: #9fdaf4;
  --sun: #ffd166;
  --melon: #ff7a59;
  --cream: #fff8df;
  --paper: #fffdf3;
  --line: #2c2118;
  --shadow: 0 16px 0 rgba(44, 33, 24, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Nunito", "Noto Sans Arabic", sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 209, 102, 0.9) 0 88px, transparent 90px),
    linear-gradient(160deg, #88d9f7 0%, #d6f7ff 42%, #f8efb4 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto -8vw -11vw -8vw;
  height: 23vw;
  min-height: 150px;
  background: #58b66d;
  border-top: 6px solid var(--line);
  border-radius: 55% 45% 0 0 / 70% 60% 0 0;
  z-index: -1;
}

body::after {
  inset: auto -12vw -17vw -12vw;
  height: 26vw;
  background: #2f8a5f;
}

.effects-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.language-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px 16px;
}

.language-card {
  width: min(780px, 100%);
  padding: 34px;
  border: 6px solid var(--line);
  border-radius: 30px;
  background: var(--cream);
  box-shadow: var(--shadow);
  text-align: center;
  transform: rotate(-0.35deg);
}

.language-card .mode-pill {
  margin-inline: auto;
}

.resume-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px 16px;
}

.resume-card {
  width: min(660px, 100%);
  padding: 34px;
  border: 6px solid var(--line);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
  transform: rotate(0.35deg);
}

.resume-card .mode-pill {
  margin-inline: auto;
}

.resume-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 26px;
}

.secondary-button {
  background: #fffdf3;
  color: var(--ink);
}

.language-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 26px;
}

.language-button {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 16px 12px;
  border: 5px solid var(--line);
  border-radius: 22px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 9px 0 rgba(44, 33, 24, 0.16);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.language-button:hover {
  background: #fff1a8;
  transform: translateY(-5px) rotate(-1deg);
  box-shadow: 0 14px 0 rgba(44, 33, 24, 0.16);
}

.language-button strong {
  align-self: end;
  font-family: "Baloo 2", "Noto Sans Arabic", cursive;
  font-size: clamp(1.15rem, 2.2vw, 1.65rem);
  line-height: 1;
}

.language-button span {
  align-self: start;
  font-weight: 900;
  color: var(--leaf-dark);
}

.game-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 178px;
  padding: 28px;
  border: 6px solid var(--line);
  border-radius: 28px;
  background: var(--cream);
  box-shadow: var(--shadow);
  transform: rotate(-0.4deg);
}

.mode-pill {
  display: inline-flex;
  margin: 0 0 10px;
  padding: 8px 14px;
  border: 4px solid var(--line);
  border-radius: 999px;
  background: var(--sun);
  font-weight: 900;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: "Baloo 2", cursive;
  font-size: clamp(2.5rem, 7vw, 5.6rem);
  line-height: 0.86;
  letter-spacing: 0;
}

.tagline {
  max-width: 650px;
  margin-top: 12px;
  font-size: 1.15rem;
  font-weight: 700;
}

.score-board {
  display: grid;
  place-items: center;
  width: 148px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border: 6px solid var(--line);
  border-radius: 50%;
  background: var(--melon);
  color: #fffdf3;
  box-shadow: 0 10px 0 rgba(44, 33, 24, 0.2);
  text-shadow: 2px 2px 0 var(--line);
}

.score-board span {
  align-self: end;
  font-weight: 900;
}

.score-board strong {
  align-self: start;
  font-family: "Baloo 2", cursive;
  font-size: 3.6rem;
  line-height: 0.85;
}

.question-panel {
  margin-top: 28px;
  padding: 26px;
  border: 6px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 253, 243, 0.94);
  box-shadow: var(--shadow);
}

.result-panel {
  margin-top: 28px;
  padding: 34px;
  border: 6px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 253, 243, 0.96);
  box-shadow: var(--shadow);
  text-align: center;
}

.result-panel .mode-pill {
  margin-inline: auto;
}

.result-score {
  margin: 14px 0 8px;
  font-family: "Baloo 2", "Noto Sans Arabic", cursive;
  font-size: clamp(2.2rem, 7vw, 5rem);
  font-weight: 900;
  line-height: 1;
  color: var(--melon);
  text-shadow: 3px 3px 0 rgba(44, 33, 24, 0.12);
}

.result-panel .validate-button {
  margin-top: 22px;
}

.seo-content {
  width: min(920px, calc(100% - 32px));
  margin: 24px auto 48px;
  padding: 24px;
  border: 5px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 253, 243, 0.9);
  box-shadow: 0 10px 0 rgba(44, 33, 24, 0.12);
}

.seo-content h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.seo-content p {
  margin-top: 10px;
  font-weight: 700;
  line-height: 1.5;
}

.site-footer {
  width: min(920px, calc(100% - 32px));
  margin: -24px auto 48px;
  text-align: center;
}

.site-footer a,
.back-link,
.legal-card a {
  color: var(--leaf-dark);
  font-weight: 900;
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
}

.legal-page {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.back-link {
  display: inline-block;
  margin-bottom: 18px;
}

.legal-card {
  padding: 34px;
  border: 6px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 253, 243, 0.96);
  box-shadow: var(--shadow);
}

.legal-card h1 {
  margin-bottom: 10px;
}

.legal-updated {
  margin-bottom: 26px;
  font-weight: 900;
  color: var(--leaf-dark);
}

.legal-card section {
  margin-top: 24px;
}

.legal-card h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
}

.legal-card p,
.legal-card li {
  margin-top: 10px;
  font-weight: 700;
  line-height: 1.55;
}

.legal-card ul {
  margin: 8px 0 0;
  padding-left: 22px;
}

.legal-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.question-header,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.round-label {
  display: inline-block;
  margin-bottom: 6px;
  font-weight: 900;
  color: var(--leaf-dark);
}

h2 {
  font-family: "Baloo 2", cursive;
  font-size: clamp(1.8rem, 4vw, 3.3rem);
  line-height: 1;
  letter-spacing: 0;
}

#target-animal {
  color: var(--melon);
  text-transform: uppercase;
  text-shadow: 2px 2px 0 rgba(44, 33, 24, 0.14);
}

.icon-button {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border: 5px solid var(--line);
  border-radius: 18px;
  background: var(--sky);
  color: var(--ink);
  font-size: 2rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 7px 0 rgba(44, 33, 24, 0.2);
}

.choices-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin: 24px 0;
}

.choice-card {
  position: relative;
  display: block;
  min-height: 238px;
  padding: 12px;
  border: 6px solid var(--line);
  border-radius: 24px;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 10px 0 rgba(44, 33, 24, 0.14);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.choice-card:hover {
  transform: translateY(-4px) rotate(-0.5deg);
  box-shadow: 0 14px 0 rgba(44, 33, 24, 0.14);
}

.choice-card[aria-pressed="true"] {
  background: #fff1a8;
  transform: translateY(-6px) rotate(0.6deg);
  box-shadow: 0 16px 0 rgba(44, 33, 24, 0.18);
}

.choice-card.correct {
  background: #c8f5d2;
}

.choice-card.wrong {
  background: #ffd3c7;
}

.choice-card.correct::after,
.choice-card.wrong::after {
  position: absolute;
  right: 10px;
  top: 10px;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 5px solid var(--line);
  border-radius: 50%;
  color: #fffdf3;
  font-family: "Baloo 2", "Noto Sans Arabic", cursive;
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 2px 2px 0 var(--line);
  box-shadow: 0 7px 0 rgba(44, 33, 24, 0.2);
  animation: mark-pop 340ms cubic-bezier(0.17, 0.89, 0.36, 1.35) both;
}

.choice-card.correct::after {
  content: "\2713";
  background: var(--leaf);
}

.choice-card.wrong::after {
  content: "\00d7";
  background: #ff3f3f;
}

.choice-card img {
  width: 100%;
  height: 210px;
  object-fit: cover;
  border: 4px solid var(--line);
  border-radius: 16px;
  background: #d6f7ff;
}

.feedback {
  min-height: 34px;
  font-size: 1.08rem;
  font-weight: 900;
}

.feedback.good {
  color: var(--leaf-dark);
}

.feedback.bad {
  color: #a93320;
}

.validate-button {
  min-width: 158px;
  min-height: 58px;
  border: 5px solid var(--line);
  border-radius: 18px;
  background: var(--leaf);
  color: #fffdf3;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(44, 33, 24, 0.22);
}

.validate-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.45);
  opacity: 0.64;
  transform: none;
}

.validate-button:not(:disabled):active,
.icon-button:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 rgba(44, 33, 24, 0.22);
}

.particle {
  position: absolute;
  border: 3px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 4px 0 rgba(44, 33, 24, 0.14);
  transform: translate(-50%, -50%);
  animation: burst 900ms cubic-bezier(0.16, 0.88, 0.34, 1) forwards;
}

.particle:nth-child(3n) {
  border-radius: 5px;
}

.particle:nth-child(4n) {
  border-radius: 50% 20% 50% 20%;
}

.error-cross {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(42vw, 280px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%) scale(0.6) rotate(-6deg);
  animation: cross-pop 900ms ease forwards;
}

.error-cross span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 32px;
  border: 6px solid var(--line);
  border-radius: 999px;
  background: #ff3f3f;
  box-shadow: 0 10px 0 rgba(44, 33, 24, 0.18);
}

.error-cross span:first-child {
  transform: translate(-50%, -50%) rotate(45deg);
}

.error-cross span:last-child {
  transform: translate(-50%, -50%) rotate(-45deg);
}

@keyframes burst {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
  }

  72% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.12) rotate(var(--spin));
  }
}

@keyframes cross-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.45) rotate(-14deg);
  }

  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(3deg);
  }

  74% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(-4deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.82) rotate(5deg);
  }
}

@keyframes mark-pop {
  0% {
    opacity: 0;
    transform: scale(0.35) rotate(-18deg);
  }

  100% {
    opacity: 1;
    transform: scale(1) rotate(4deg);
  }
}

@media (max-width: 900px) {
  .language-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .choices-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .game-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 12px;
  }

  .hero-panel,
  .language-card,
  .resume-card,
  .result-panel,
  .question-panel {
    padding: 18px;
    border-width: 5px;
    border-radius: 22px;
  }

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

  .language-button {
    min-height: 92px;
  }

  .hero-panel,
  .question-header,
  .action-row,
  .resume-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .score-board {
    width: 100%;
    aspect-ratio: auto;
    grid-template-columns: auto auto;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    border-radius: 18px;
  }

  .score-board span,
  .score-board strong {
    align-self: center;
  }

  .choices-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0;
  }

  .choice-card {
    min-height: 136px;
    padding: 8px;
    border-width: 4px;
    border-radius: 18px;
    box-shadow: 0 7px 0 rgba(44, 33, 24, 0.14);
  }

  .choice-card img {
    height: clamp(104px, 25vh, 150px);
    border-width: 3px;
    border-radius: 12px;
  }

  .choice-card.correct::after,
  .choice-card.wrong::after {
    right: 5px;
    top: 5px;
    width: 38px;
    height: 38px;
    border-width: 4px;
    font-size: 1.9rem;
  }

  .icon-button,
  .validate-button {
    width: 100%;
  }
}
