@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --sky-top: #87d7ff;
  --sky-bottom: #dff7ff;
  --grass: #7ed957;
  --panel: rgba(255,255,255,0.84);
  --panel-border: rgba(255,255,255,0.65);
  --text: #234;
  --shadow: 0 14px 40px rgba(31, 70, 108, 0.18);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --transition: 260ms cubic-bezier(.2,.8,.2,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Vazirmatn', system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  overflow-x: hidden;
}
button, input { font-family: inherit; }

.scene {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.sun {
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  top: 28px;
  left: 36px;
  background: radial-gradient(circle at 35% 35%, #fff6a5, #ffd43b 60%, #ffbd2f 100%);
  box-shadow: 0 0 0 16px rgba(255, 223, 94, 0.18), 0 0 60px rgba(255, 211, 64, 0.45);
  animation: pulseSun 3.2s infinite ease-in-out;
}
.cloud {
  position: absolute;
  width: 150px;
  height: 50px;
  background: rgba(255,255,255,0.95);
  border-radius: 50px;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.08));
}
.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.95);
  border-radius: 50%;
}
.cloud::before { width: 60px; height: 60px; right: 18px; top: -26px; }
.cloud::after { width: 76px; height: 76px; right: 54px; top: -34px; }
.cloud-1 { top: 80px; right: -180px; animation: moveCloud 28s linear infinite; }
.cloud-2 { top: 170px; right: -200px; transform: scale(1.18); animation: moveCloud 34s linear infinite 4s; }
.cloud-3 { top: 36px; right: -220px; transform: scale(.9); animation: moveCloud 40s linear infinite 10s; }
.grass {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 18vh;
  min-height: 120px;
  background: linear-gradient(180deg, #8ee967, var(--grass));
  border-top-left-radius: 60% 30px;
  border-top-right-radius: 60% 30px;
}
.flowers {
  position: absolute;
  bottom: 60px;
  width: 130px;
  height: 90px;
  opacity: .7;
}
.flowers::before, .flowers::after {
  content: '🌼🌷🌸';
  position: absolute;
  font-size: 28px;
}
.flowers-left { left: 22px; }
.flowers-right { right: 22px; }
.flowers-left::before { left: 0; bottom: 0; }
.flowers-right::after { right: 0; bottom: 0; }

.app {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 18px 16px 32px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.7);
  padding: 12px 16px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.brand-badge {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  font-size: 28px;
  border-radius: 20px;
  background: linear-gradient(135deg, #ffb703, #ff6b6b, #7b61ff);
  color: white;
  box-shadow: inset 0 2px 10px rgba(255,255,255,0.4);
}
.brand h1 { margin: 0; font-size: clamp(1.5rem, 4vw, 2.2rem); }
.brand p { margin: 2px 0 0; color: #4c6682; }
.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.stat-pill {
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(255,255,255,0.8);
  padding: 12px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 1rem;
}
.panel { display: none; }
.panel.active { display: block; animation: fadeIn .35s ease; }
.panel-inner {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  border-radius: var(--radius-xl);
  padding: 24px;
}
.hero-card, .end-card {
  text-align: center;
  max-width: 900px;
  margin: 20px auto 0;
}
.hero-emoji { font-size: clamp(2rem, 5vw, 4rem); }
.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  margin: 24px 0;
}
.legend-item {
  background: rgba(255,255,255,0.7);
  padding: 12px;
  border-radius: 20px;
  box-shadow: inset 0 2px 8px rgba(255,255,255,0.6), 0 8px 24px rgba(0,0,0,0.06);
}
.legend-swatch {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  margin: 0 auto 8px;
  border: 3px solid rgba(255,255,255,0.8);
}
.game-card { min-height: 70vh; }
.question-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.label {
  display: inline-block;
  background: #fff5be;
  color: #8a6400;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .95rem;
  margin-bottom: 8px;
}
.question-row h2 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.4rem);
}
.progress-wrap { margin-bottom: 16px; }
.progress-bar {
  height: 22px;
  background: rgba(255,255,255,0.9);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.08);
}
.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6ed96e, #ffdd57, #ff9f68, #ff6b81, #7b61ff);
  transition: width .35s ease;
}
.feedback {
  min-height: 60px;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px;
  margin-bottom: 18px;
  background: rgba(255,255,255,0.65);
  border-radius: 20px;
}
.feedback.success { color: #147a31; background: #ecffe9; }
.feedback.error { color: #b92f3d; background: #ffe9ec; }
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.color-card {
  position: relative;
  border: 0;
  border-radius: 28px;
  padding: 14px;
  min-height: 150px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
  box-shadow: 0 16px 26px rgba(26, 48, 72, 0.14);
  overflow: hidden;
}
.color-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.38), rgba(255,255,255,0));
  pointer-events: none;
}
.color-card:hover, .color-card:active { transform: translateY(-2px) scale(1.03); }
.color-card:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
.color-card .emoji { font-size: 2rem; display: block; margin-bottom: 12px; }
.color-card .name {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.78);
  color: #17324d;
  font-weight: 700;
}
.color-card.correct {
  transform: scale(1.08);
  box-shadow: 0 0 0 6px rgba(255,255,255,0.7), 0 0 0 14px rgba(255, 230, 0, 0.22), 0 20px 40px rgba(0,0,0,.18);
  animation: glowCard .8s ease;
}
.color-card.wrong {
  animation: wrongFlash .4s ease;
}
.color-card.dimmed { filter: grayscale(.18) opacity(.72); }
.actions-row {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}
.btn {
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 14px 22px;
  font-size: 1rem;
  font-weight: 700;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  box-shadow: 0 14px 24px rgba(49, 71, 96, 0.18);
}
.btn:hover, .btn:active { transform: translateY(-2px) scale(1.02); }
.btn-primary {
  background: linear-gradient(135deg, #ff9f1c, #ff5d8f);
  color: white;
}
.btn-voice {
  background: linear-gradient(135deg, #60a5fa, #7c3aed);
  color: white;
  min-width: 126px;
}
.btn-xl { font-size: 1.15rem; padding: 16px 28px; }
.hidden { display: none !important; }
.shake { animation: shake .45s linear; }
.trophy { font-size: clamp(3rem, 8vw, 5rem); }
.final-score {
  margin: 14px auto 20px;
  font-size: 1.4rem;
  font-weight: 700;
  background: #fff;
  border-radius: 999px;
  width: fit-content;
  padding: 14px 22px;
}

#effects-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 20;
}
.particle, .balloon {
  position: absolute;
  will-change: transform, opacity;
}
.particle {
  animation: particleFly var(--dur, 1200ms) ease-out forwards;
}
.balloon {
  font-size: 2rem;
  animation: balloonRise var(--dur, 3000ms) linear forwards;
}
.sparkle {
  position: absolute;
  font-size: 1.2rem;
  animation: sparkle var(--dur, 1400ms) ease-out forwards;
}

@keyframes moveCloud {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-100vw - 420px)); }
}
@keyframes pulseSun {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes glowCard {
  0% { transform: scale(1); }
  50% { transform: scale(1.11); }
  100% { transform: scale(1.08); }
}
@keyframes wrongFlash {
  0%,100% { filter: none; }
  50% { filter: saturate(.7) brightness(.95); box-shadow: 0 0 0 6px rgba(255, 82, 82, 0.28); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}
@keyframes particleFly {
  from { opacity: 1; transform: translate3d(0,0,0) rotate(0deg) scale(1); }
  to { opacity: 0; transform: translate3d(var(--x, 0), var(--y, -160px), 0) rotate(var(--r, 360deg)) scale(.6); }
}
@keyframes balloonRise {
  from { opacity: 0; transform: translateY(0) scale(.8); }
  10% { opacity: 1; }
  to { opacity: 0; transform: translateY(-110vh) translateX(var(--drift, 0px)) scale(1.15); }
}
@keyframes sparkle {
  from { opacity: 0; transform: scale(.4) translateY(0); }
  20% { opacity: 1; }
  to { opacity: 0; transform: scale(1.6) translateY(-40px); }
}

@media (max-width: 960px) {
  .cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .topbar, .question-row { flex-direction: column; align-items: stretch; }
  .stats { justify-content: stretch; }
  .stats > * { flex: 1; text-align: center; }
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .color-card { min-height: 130px; }
  .app { padding: 14px 12px 24px; }
  .panel-inner { padding: 18px; }
}
@media (max-width: 440px) {
  .cards-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .color-card { min-height: 120px; border-radius: 22px; }
  .brand-badge { width: 48px; height: 48px; font-size: 24px; }
}
