/* ===== base.css — «Зомби против Растений» =====
 * Палитра: дневной газон, тёмно-зелёный HUD, солнечный акцент.
 * Мобильная адаптация обязательна (газон сжимается, панели липнут сверху).
 */
:root {
  /* v3: фон приглушён (замечание владельца — цветастый фон сливался с персонажами) */
  --lawn1: #8fbf58;
  --lawn2: #7cae48;
  --lawn-border: #47702e;
  --ink: #1c2b16;
  --ink-soft: #3f5233;
  --panel: #fdfff6;
  --panel-2: #f0f7e6;
  --border: #cfe3b8;
  --border-strong: #a8cd85;
  --accent: #ffb340;
  --accent-2: #ff8c42;
  --good: #2e9e4f;
  --bad: #d13b54;
  --hud: #23411b;
  --hud-2: #2f5524;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(28, 60, 20, 0.25);
  --font: 'Comfortaa', 'Comic Sans MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: #73984f;
  min-height: 100dvh;
  /* flex-колонка: футер прилипает к низу и на index (через .app-root),
     и на leaderboard/answers, где футер — прямой потомок body */
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

.app-root {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1020px;
  margin: 0 auto;
  padding: 16px 14px 24px;
  position: relative;
  z-index: 2;
}

.app-footer {
  margin-top: auto;
  background: var(--hud);
  color: #d9f2c8;
  text-align: center;
  font-size: 0.78rem;
  padding: 12px 14px 14px;
  position: relative;
  z-index: 2;
}

/* ================= фон (v3: спокойная палитра — мягкое небо, без крика) ================= */

.zbg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.zbg .sky {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #9db8c9 0%, #b5c6ae 46%, #86a75a 47%, #6a8f47 100%);
}
.zbg .cloud {
  position: absolute;
  width: 130px; height: 44px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  filter: blur(1.5px);
  animation: cloudDrift 46s linear infinite;
}
.zbg .cloud::after {
  content: ''; position: absolute; top: -20px; left: 26px;
  width: 60px; height: 34px; background: inherit; border-radius: 999px;
}
.zbg .c1 { top: 7%; animation-duration: 52s; }
.zbg .c2 { top: 16%; transform: scale(0.7); animation-duration: 68s; animation-delay: -22s; }
.zbg .c3 { top: 3%; transform: scale(0.55); animation-duration: 80s; animation-delay: -50s; }
@keyframes cloudDrift {
  from { left: -160px; } to { left: 110%; }
}
.zbg .mist {
  position: absolute; bottom: -6%;
  width: 140%; height: 26%;
  background: radial-gradient(ellipse at center, rgba(205, 224, 190, 0.4), transparent 65%);
  animation: mistPulse 9s ease-in-out infinite;
}
.zbg .m1 { left: -20%; }
.zbg .m2 { right: -30%; bottom: 2%; animation-delay: -4.5s; }
@keyframes mistPulse {
  0%, 100% { opacity: 0.55; } 50% { opacity: 0.9; }
}

/* ================= кнопки ================= */

.btn-play {
  font-family: inherit; font-weight: 700; cursor: pointer;
  background: linear-gradient(135deg, #58b647, #2e9e4f);
  color: #fff; border: 0;
  border-radius: 999px;
  padding: 15px 34px;
  font-size: 1.12rem;
  box-shadow: 0 8px 22px rgba(46, 158, 79, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.btn-play:hover { transform: translateY(-2px); filter: brightness(1.06); }
.btn-play:active { transform: translateY(1px) scale(0.99); }
.btn-play:disabled { filter: grayscale(0.5); opacity: 0.7; cursor: default; }

.btn-primary {
  font-family: inherit; font-weight: 700; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: 0; border-radius: 12px;
  padding: 11px 22px; font-size: 0.98rem;
  box-shadow: 0 6px 16px rgba(255, 140, 66, 0.4);
  transition: transform 0.12s, filter 0.12s;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-primary:disabled { filter: grayscale(0.6); opacity: 0.65; cursor: default; }

.btn-ghost {
  font-family: inherit; font-weight: 700; cursor: pointer;
  display: inline-block; text-decoration: none;
  background: var(--panel); color: var(--ink-soft);
  border: 1.5px solid var(--border-strong); border-radius: 999px;
  padding: 10px 18px; font-size: 0.9rem;
  transition: transform 0.12s, border-color 0.15s;
}
.btn-ghost:hover { transform: translateY(-1px); border-color: var(--hud-2); }
.btn-ghost:disabled { filter: grayscale(0.5); opacity: 0.65; cursor: default; }
.btn-ghost:disabled:hover { transform: none; border-color: var(--border-strong); }

/* ================= стартовый экран ================= */

#screen-start { display: flex; justify-content: center; }

.start-card {
  width: 100%; max-width: 660px;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 26px 24px 24px;
  text-align: center;
}

.start-logo .logo-z {
  font-size: 3.2rem;
  display: inline-block;
  animation: zSway 3.2s ease-in-out infinite;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.25));
}
@keyframes zSway {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg) translateY(-4px); }
}
.start-logo h1 {
  margin: 6px 0 4px;
  font-size: clamp(1.5rem, 5.4vw, 2.1rem);
  color: var(--hud);
  letter-spacing: 0.02em;
}
.start-sub { margin: 0 0 14px; color: var(--ink-soft); font-size: 0.88rem; }

.start-rules {
  background: var(--panel-2);
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 18px;
  text-align: left;
}
.start-rules p { margin: 5px 0; font-size: 0.88rem; line-height: 1.5; }

.start-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-bottom: 20px;
  text-align: left;
}
@media (max-width: 620px) { .start-row { grid-template-columns: 1fr; } }

.start-block h3 {
  margin: 0 0 8px; font-size: 0.92rem; color: var(--hud);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.start-block h3:not(:first-child) { margin-top: 14px; }

.grade-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade-btn {
  font-family: inherit; font-weight: 700; cursor: pointer;
  font-size: 1.15rem; padding: 12px 0;
  background: var(--panel-2); color: var(--ink);
  border: 1.5px solid var(--border); border-radius: 12px;
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
}
.grade-btn:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.grade-btn.active {
  background: linear-gradient(135deg, #58b647, #2e9e4f);
  color: #fff; border-color: transparent;
  box-shadow: 0 6px 14px rgba(46, 158, 79, 0.4);
}

#nameInput {
  width: 100%;
  font-family: inherit; font-weight: 700; font-size: 1rem;
  padding: 12px 14px;
  border: 1.5px solid var(--border-strong); border-radius: 12px;
  background: #fff; color: var(--ink);
  outline: none;
}
#nameInput:focus { border-color: var(--good); box-shadow: 0 0 0 4px rgba(46, 158, 79, 0.15); }

.av-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.av-btn {
  font-family: inherit; font-size: 1.5rem; cursor: pointer;
  padding: 8px 0; background: var(--panel-2);
  border: 1.5px solid var(--border); border-radius: 12px;
  transition: transform 0.12s, background 0.15s;
}
.av-btn:hover { transform: translateY(-2px); }
.av-btn.active { background: #fff7e0; border-color: var(--accent); box-shadow: 0 4px 12px rgba(255, 179, 64, 0.35); }

.start-links { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* ================= игровой экран ================= */

.game-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: linear-gradient(135deg, var(--hud), var(--hud-2));
  border-radius: 16px;
  padding: 10px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  color: #eaf7dd;
}
.hud-left { display: flex; align-items: center; gap: 12px; }
.sun-counter {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 1.05rem;
  white-space: nowrap;
}
.sun-counter b { font-size: 1.15rem; color: #ffd166; }
.hearts { display: flex; gap: 3px; font-size: 1.15rem; }
.heart { transition: opacity 0.3s, transform 0.3s; }
.heart.lost { opacity: 0.22; transform: scale(0.8); filter: grayscale(1); }
.wave-label { font-size: 0.95rem; white-space: nowrap; }
.wave-label b { color: #ffd166; }
.hud-right { display: flex; gap: 8px; }
.hud-btn {
  font-family: inherit; font-size: 1.1rem; cursor: pointer;
  width: 44px; height: 44px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  transition: transform 0.12s, background 0.15s;
}
.hud-btn:hover { background: rgba(255, 255, 255, 0.22); transform: translateY(-1px); }

/* панель растений (v2: спрайты + горизонтальный скролл на узких экранах) */
.seedbar {
  display: flex; gap: 10px;
  justify-content: flex-start;
  margin-bottom: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 900px) {
  .seedbar { flex-wrap: wrap; justify-content: center; overflow-x: visible; }
}
.seed {
  font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 8px 14px 6px;
  min-width: 86px;
  flex: 0 0 auto;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 10px rgba(28, 60, 20, 0.12);
}
.seed:hover { transform: translateY(-2px); }
.seed-emoji { font-size: 1.7rem; line-height: 1.1; }
.seed-emoji img { display: block; width: 38px; height: 38px; object-fit: contain; }
.seed-cost { font-size: 0.8rem; font-weight: 700; color: #c77000; white-space: nowrap; }
.seed.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 179, 64, 0.35), 0 6px 14px rgba(255, 140, 66, 0.3);
  transform: translateY(-2px);
}
.seed.poor { filter: grayscale(0.85); opacity: 0.55; cursor: not-allowed; }

/* ================= поле ================= */

.field-wrap { text-align: center; }

.field {
  position: relative;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  aspect-ratio: 9 / 5.4;
  border: 4px solid var(--lawn-border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--lawn1);
  user-select: none;
  -webkit-user-select: none;
}

/* v2: фон-газон (AI-картинка по эталону: <img> + object-fit:cover)
   v3: приглушаем насыщенность/яркость фильтром — персонажи «выпрыгивают» из фона,
   плюс новый малоконтрастный bg_lawn.jpg (см. scripts/gen_art_zombie_v3.ts) */
.field-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
  filter: saturate(0.52) brightness(0.84) contrast(0.94);
}

.lawn-grid { position: absolute; inset: 0; z-index: 1; }
.lawn-cell {
  position: absolute;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: filter 0.12s, box-shadow 0.12s;
}
.lawn-cell.dark { background: rgba(15, 38, 8, 0.16); }
.lawn-cell:hover { filter: brightness(1.15); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55); }

.house {
  position: absolute;
  left: 0.3%; top: 50%;
  transform: translateY(-50%);
  width: 9.5%;
  max-width: 92px;
  z-index: 20;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
  pointer-events: none;
}

.field.shake-red { animation: fieldShake 0.5s; }
@keyframes fieldShake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

.field-hint {
  margin: 10px auto 0;
  font-size: 0.8rem;
  color: #22421a;
  background: rgba(255, 255, 255, 0.55);
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
}

/* сущности */
.ent-layer { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.ent { position: absolute; }

.plant { z-index: 15; transition: opacity 0.3s; width: 7.8%; }
.p-emoji {
  display: block;
  line-height: 1;
  /* v3: живое покачивание + дыхание (плюс кадры-костюмы меняет JS-цикл) */
  animation: plantIdle 3.2s ease-in-out infinite;
  transform-origin: 50% 92%;
}
.p-emoji img {
  display: block;
  width: 100%; height: auto;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.3));
}
@keyframes plantIdle {
  0%, 100% { transform: rotate(-2deg) scale(0.99); }
  50% { transform: rotate(2deg) scale(1.05); }
}
/* отдача при выстреле (v3) */
.plant.recoil .p-emoji { animation: shootRecoil 0.19s ease-out; }
@keyframes shootRecoil {
  0% { transform: translateX(0) scale(1); }
  40% { transform: translateX(-9%) scale(0.96); }
  100% { transform: translateX(0) scale(1.03); }
}
.plant.p-die { opacity: 0; transform: scale(0.4); }
/* Кусака жуёт */
.plant.chewing .p-emoji img { animation: chompSquash 0.5s ease-in-out infinite; filter: saturate(1.35) drop-shadow(0 3px 4px rgba(0,0,0,0.3)); }
@keyframes chompSquash {
  0%, 100% { transform: scale(1.04) rotate(-2deg); }
  50% { transform: scale(0.94) rotate(2deg); }
}
/* мина: заряжается / готова */
.plant.arming .p-emoji img { filter: grayscale(0.85) brightness(0.92) drop-shadow(0 3px 4px rgba(0,0,0,0.25)); }
.plant.armed .p-emoji img { animation: mineReady 1.1s ease-in-out infinite; }
@keyframes mineReady {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(255, 80, 40, 0.5)); }
  50% { filter: drop-shadow(0 0 9px rgba(255, 80, 40, 1)); }
}

.p-hp {
  display: block;
  width: 74%; height: 5px;
  margin: 2px auto 0;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  overflow: hidden;
}
.p-hp i { display: block; height: 100%; background: #b98a4a; border-radius: 999px; transition: width 0.2s; }

.zombie {
  z-index: 30;
  width: 8.4%;
  text-align: center;
  transition: opacity 0.4s;
}
.zombie.big { width: 12%; z-index: 32; }
.z-body {
  display: block;
  line-height: 1;
  animation: zWalk 0.9s ease-in-out infinite;
  transform-origin: 50% 90%;
}
.z-body img {
  display: block;
  width: 100%; height: auto;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35));
}
@keyframes zWalk {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}
.zombie.k-runner .z-body { animation-duration: 0.42s; }
.zombie.k-boss .z-body { animation-duration: 1.7s; }
.zombie.eating .z-body { animation: zChomp 0.5s ease-in-out infinite; }
@keyframes zChomp {
  0%, 100% { transform: rotate(-9deg) scale(1.02); }
  50% { transform: rotate(0deg) scale(1.08); }
}
/* замороженный зомби */
.zombie.chilled .z-body img { filter: sepia(1) hue-rotate(175deg) saturate(2.6) brightness(1.05) drop-shadow(0 0 6px rgba(120, 210, 255, 0.8)); }
/* Газетчик в ярости (v3): красная пульсация + быстрый шаг */
.zombie.rage .z-body { animation-duration: 0.4s; }
.zombie.rage .z-body img {
  filter: sepia(1) hue-rotate(-38deg) saturate(3.2) brightness(1.08) drop-shadow(0 0 7px rgba(255, 90, 60, 0.75));
  animation: rageThrob 0.55s ease-in-out infinite;
}
@keyframes rageThrob {
  0%, 100% { filter: sepia(1) hue-rotate(-38deg) saturate(3.2) brightness(1.08) drop-shadow(0 0 4px rgba(255, 90, 60, 0.55)); }
  50% { filter: sepia(1) hue-rotate(-38deg) saturate(3.6) brightness(1.16) drop-shadow(0 0 10px rgba(255, 90, 60, 0.95)); }
}
/* Щитоносец: «дзынь» — дверь держит удар (v3) */
.zombie.shieldhit .z-body { animation: shieldClink 0.26s ease-out; }
@keyframes shieldClink {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(5%) rotate(2deg); }
  65% { transform: translateX(-3%) rotate(-1deg); }
}
/* Танцор призывает (v3) */
.zombie.summoning .z-body { animation: summonPulse 0.7s ease-in-out; }
@keyframes summonPulse {
  0%, 100% { transform: scale(1) rotate(0); }
  30% { transform: scale(1.12) rotate(-6deg); }
  60% { transform: scale(1.1) rotate(6deg); }
}
/* прыжок Прыгуна */
.zombie.jumping .z-body { animation: zJump 0.46s ease-out; }
@keyframes zJump {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-64%) scale(0.94); }
  100% { transform: translateY(0) scale(1); }
}
.z-hp {
  display: block;
  width: 82%; height: 5px;
  margin: 2px auto 0;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  overflow: hidden;
}
.z-hp i { display: block; height: 100%; background: #7ed957; border-radius: 999px; transition: width 0.2s; }
.zombie.dying { opacity: 0; transform: rotate(80deg) translateY(30%); transition: opacity 0.45s, transform 0.45s; }
.zombie.eaten { opacity: 0; transform: scale(0.15) rotate(-25deg); transition: opacity 0.36s, transform 0.36s; }

.pea {
  z-index: 25;
  width: 1.5%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translateY(-40%);
  background: radial-gradient(circle at 35% 30%, #c8f79c, #4caf3f 72%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
}
.pea.icy { background: radial-gradient(circle at 35% 30%, #e6f9ff, #57c7f5 72%); box-shadow: 0 0 6px rgba(87, 199, 245, 0.8); }

.sun-drop {
  z-index: 60;
  width: 6.5%;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  animation: sunPulse 1.6s ease-in-out infinite;
  transition: transform 0.15s;
}
/* расширенная зона клика (тач-таргет) */
.sun-drop::after { content: ''; position: absolute; inset: -38%; border-radius: 50%; }
.sun-drop img { display: block; width: 100%; height: auto; filter: drop-shadow(0 0 8px rgba(255, 209, 102, 0.9)); }
.sun-drop:hover { transform: scale(1.18); }
@keyframes sunPulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 209, 102, 0.8)); }
  50% { filter: drop-shadow(0 0 14px rgba(255, 209, 102, 1)); }
}

.boom {
  z-index: 70;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%,
    rgba(255, 240, 180, 0.98) 0%,
    rgba(255, 190, 80, 0.9) 28%,
    rgba(255, 110, 50, 0.55) 52%,
    rgba(255, 80, 40, 0.25) 68%,
    transparent 76%);
  animation: boomAnim 0.65s ease-out forwards;
  pointer-events: none;
}
@keyframes boomAnim {
  0% { transform: scale(0.2); opacity: 0.6; }
  45% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}
/* огонь Халапеньо по всему ряду */
.firerow {
  z-index: 70;
  left: 0;
  width: 100%;
  border-radius: 12px;
  background: linear-gradient(90deg,
    transparent 0%, rgba(255, 120, 40, 0.65) 10%,
    rgba(255, 205, 70, 0.92) 30%, rgba(255, 230, 120, 0.95) 50%,
    rgba(255, 205, 70, 0.92) 70%, rgba(255, 120, 40, 0.65) 90%, transparent 100%);
  animation: fireRow 0.9s ease-out forwards;
  pointer-events: none;
}
@keyframes fireRow {
  0% { opacity: 0; transform: scaleY(0.3); }
  30% { opacity: 1; transform: scaleY(1); }
  100% { opacity: 0; transform: scaleY(1.15); }
}

/* ================= баннер волны ================= */

.wave-banner {
  position: fixed;
  top: 34%; left: 0; right: 0;
  z-index: 80;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.3s, transform 0.3s;
}
.wave-banner.show { opacity: 1; transform: scale(1); }
.banner-text {
  display: inline-block;
  font-size: clamp(1.6rem, 6vw, 3rem);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, rgba(35, 65, 27, 0.92), rgba(46, 158, 79, 0.92));
  padding: 14px 40px;
  border-radius: 20px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}
/* v3: строка «Новый зомби: …» под баннером волны */
.banner-sub {
  display: block;
  margin: 10px auto 0;
  width: fit-content;
  font-size: clamp(0.95rem, 3.6vw, 1.3rem);
  font-weight: 700;
  color: #ffe9b8;
  background: rgba(28, 22, 40, 0.88);
  border: 1.5px solid rgba(255, 200, 100, 0.55);
  padding: 8px 22px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ================= модалка задачи ================= */

.task-overlay, .pause-overlay {
  position: fixed; inset: 0;
  z-index: 90;
  display: none;
  align-items: center; justify-content: center;
  padding: 18px;
  background: rgba(12, 28, 8, 0.55);
  backdrop-filter: blur(3px);
}
.task-overlay.open, .pause-overlay.open { display: flex; }

.task-card {
  width: min(600px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--panel);
  border: 2px solid var(--border-strong);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
  animation: cardPop 0.25s ease-out;
}
@keyframes cardPop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.task-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.task-ic { font-size: 1.7rem; }
.task-theme {
  font-size: 0.78rem; font-weight: 700; color: var(--hud-2);
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 4px 12px; border-radius: 999px;
}
.task-reward {
  margin-left: auto;
  font-size: 0.85rem; font-weight: 700; color: #c77000;
  background: #fff3dd; border: 1px solid rgba(255, 179, 64, 0.5);
  padding: 4px 12px; border-radius: 999px;
}
.task-title { margin: 0 0 6px; font-size: 1.15rem; color: var(--hud); }
.task-q { margin: 0 0 16px; font-size: 1.02rem; line-height: 1.55; }

.task-opts { display: grid; gap: 10px; margin-bottom: 14px; }
.task-opts.cols-2 { grid-template-columns: 1fr 1fr; }
.task-opts.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 520px) { .task-opts.cols-4 { grid-template-columns: 1fr 1fr; } }

.task-opt {
  font-family: inherit; font-weight: 700; font-size: 1.05rem;
  cursor: pointer; padding: 14px 10px;
  background: var(--panel-2); color: var(--ink);
  border: 2px solid var(--border); border-radius: 14px;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}
.task-opt:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--border-strong); }
.task-opt.selected { border-color: var(--accent); background: #fff3dd; box-shadow: 0 0 0 3px rgba(255, 179, 64, 0.35); }
.task-opt.correct { background: #dcf5e3; border-color: var(--good); color: #14562c; }
.task-opt.wrong { background: #fde3e8; border-color: var(--bad); color: #7a1f30; }
.task-opt:disabled { cursor: default; }

/* кнопка «Ответить» для задач с вариантами (v2) */
.task-confirm { display: flex; justify-content: center; margin-bottom: 14px; }
.task-confirm .btn-primary { min-width: 210px; }
.task-confirm .btn-primary:disabled { filter: grayscale(0.6); opacity: 0.65; cursor: default; }

.task-numin { display: flex; gap: 10px; margin-bottom: 14px; }
.task-numin input {
  flex: 1; min-width: 0;
  font-family: inherit; font-weight: 700; font-size: 1.25rem;
  text-align: center;
  padding: 12px 14px;
  border: 2px solid var(--border-strong); border-radius: 14px;
  outline: none;
}
.task-numin input:focus { border-color: var(--good); box-shadow: 0 0 0 4px rgba(46, 158, 79, 0.15); }
.task-numin input.correct { border-color: var(--good); background: #dcf5e3; }
.task-numin input.wrong { border-color: var(--bad); background: #fde3e8; }

.task-hint {
  background: #fff7e0; border: 1.5px dashed rgba(255, 179, 64, 0.7);
  border-radius: 12px; padding: 10px 14px;
  font-size: 0.9rem; margin-bottom: 12px;
  text-align: left;
}
/* v3: блок разбора ответа (кнопка «📝 Разбор ответа») */
.task-solution {
  background: #e9f3fd; border: 1.5px dashed #7fb3e0;
  border-radius: 12px; padding: 10px 14px;
  margin-bottom: 12px; text-align: left;
}
.task-solution .ts-title {
  font-weight: 700; color: #2b6cb0; font-size: 0.85rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.task-solution p { margin: 0; font-size: 0.94rem; line-height: 1.55; color: var(--ink); }
.task-actions { display: flex; justify-content: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.task-feedback {
  border-radius: 14px; padding: 12px 16px;
  font-size: 0.95rem; margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--panel-2); border: 1.5px solid var(--border);
}
.task-feedback .good { color: var(--good); font-size: 1.05rem; }
.task-feedback .bad { color: var(--bad); font-size: 1.05rem; }
.task-feedback .reveal { font-size: 0.88rem; color: var(--ink-soft); text-align: left; line-height: 1.5; }
.task-continue { width: 100%; }

/* ================= пауза ================= */

.pause-card {
  background: var(--panel);
  border-radius: 22px;
  border: 2px solid var(--border-strong);
  padding: 30px 40px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.pause-card h2 { margin: 0 0 6px; color: var(--hud); }
.pause-card p { margin: 0 0 18px; color: var(--ink-soft); }

/* ================= финал ================= */

#screen-final { display: flex; justify-content: center; }

.final-card {
  width: 100%; max-width: 620px;
  background: var(--panel);
  border-radius: 24px;
  border: 2px solid var(--border-strong);
  box-shadow: var(--shadow);
  padding: 30px 24px;
  text-align: center;
  animation: cardPop 0.3s ease-out;
}
.final-card.win { border-color: var(--good); box-shadow: 0 14px 40px rgba(46, 158, 79, 0.35); }
.final-card.lose { border-color: var(--bad); box-shadow: 0 14px 40px rgba(209, 59, 84, 0.3); }
.final-emoji { font-size: 3.4rem; line-height: 1; margin-bottom: 8px; }
.final-card h1 { margin: 0 0 6px; font-size: clamp(1.4rem, 5vw, 1.9rem); color: var(--hud); }
.final-card.lose h1 { color: var(--bad); }
.final-sub { margin: 0 0 16px; color: var(--ink-soft); font-size: 0.92rem; }
.final-score { font-size: 0.9rem; color: var(--ink-soft); margin-bottom: 6px; }
.final-score span {
  display: block;
  font-size: 3rem; font-weight: 700; color: var(--accent-2);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}
.final-stars { font-size: 1.7rem; min-height: 1.4em; letter-spacing: 0.1em; }
.final-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin: 16px 0 20px;
}
@media (max-width: 520px) { .final-stats { grid-template-columns: repeat(2, 1fr); } }
.fstat {
  background: var(--panel-2);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 12px 6px;
  font-size: 1.25rem; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.fstat i { font-style: normal; font-size: 0.68rem; font-weight: 400; color: var(--ink-soft); }

/* ================= магазин растений (v2) ================= */

.shop-overlay {
  position: fixed; inset: 0;
  z-index: 110;
  display: none;
  align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(12, 28, 8, 0.6);
  backdrop-filter: blur(3px);
}
.shop-overlay.open { display: flex; }

.shop-main {
  width: min(780px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--panel);
  border: 2px solid var(--border-strong);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: cardPop 0.25s ease-out;
}
.shop-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.shop-head h2 { margin: 0; font-size: clamp(1.1rem, 4vw, 1.35rem); color: var(--hud); flex: 1; }
.shop-wallet {
  font-weight: 700; color: #9a5b00;
  background: #fff3dd; border: 1.5px solid rgba(255, 179, 64, 0.6);
  padding: 7px 14px; border-radius: 999px;
  font-size: 0.92rem; white-space: nowrap;
}
.shop-wallet b { color: #c77000; }
.shop-close { background: var(--panel-2); border: 1.5px solid var(--border-strong); cursor: pointer; }
/* v3: чип «Волна N отбита · +40» при открытии магазина между волнами */
.shop-bonus {
  font-weight: 700; color: #1c6b38;
  background: #e2f6e6; border: 1.5px solid rgba(46, 158, 79, 0.55);
  padding: 7px 14px; border-radius: 999px;
  font-size: 0.85rem; white-space: nowrap;
  animation: bonusPop 0.4s ease-out;
}
@keyframes bonusPop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.shop-note { font-size: 0.84rem; color: var(--ink-soft); margin: 6px 0 14px; line-height: 1.5; }
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.shop-card {
  background: var(--panel-2);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 12px 10px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.shop-card.owned { border-color: var(--good); background: #f0faf0; }
.shop-img { width: 74px; height: 74px; object-fit: contain; }
.shop-name { font-weight: 700; font-size: 0.92rem; color: var(--ink); }
.shop-tip { font-size: 0.74rem; color: var(--ink-soft); min-height: 2.4em; line-height: 1.4; }
.shop-owned { color: var(--good); font-weight: 700; font-size: 0.9rem; }
.shop-buy-btn { font-size: 0.86rem; padding: 10px 16px; }

/* ================= копилка (v2) ================= */

.wallet-row {
  display: flex; gap: 10px; align-items: center; justify-content: center;
  flex-wrap: wrap; margin: 0 0 16px;
}
.wallet-chip {
  font-weight: 700;
  background: #fff7e0;
  border: 1.5px solid rgba(255, 179, 64, 0.7);
  color: #9a5b00;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.92rem;
}
.wallet-chip b { color: #c77000; font-size: 1.05em; }
.wallet-chip .wallet-delta { font-style: normal; font-weight: 400; font-size: 0.82em; opacity: 0.85; }

/* ================= тосты ================= */

#toastLayer {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 120;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(253, 255, 246, 0.97);
  border: 1.5px solid var(--border-strong);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 14px;
  font-weight: 700; font-size: 0.9rem;
  box-shadow: 0 12px 30px rgba(28, 60, 20, 0.3);
}
.toast.gold { border-color: rgba(255, 179, 64, 0.8); color: #c77000; }

/* ================= мобильная адаптация ================= */

@media (max-width: 640px) {
  .app-main { padding: 10px 8px 18px; }
  .game-top { padding: 8px 10px; gap: 6px; }
  .sun-counter { padding: 5px 10px; font-size: 0.92rem; }
  .wave-label { font-size: 0.78rem; }
  .hearts { font-size: 0.95rem; }
  .hud-btn { width: 38px; height: 38px; font-size: 0.95rem; }
  .seed { min-width: 72px; padding: 6px 10px 5px; }
  .seed-emoji img { width: 30px; height: 30px; }
  .seed-cost { font-size: 0.72rem; }
  .field { border-width: 3px; border-radius: 12px; }
  .field-hint { display: none; }
  .task-card { padding: 16px 14px; }
  .task-q { font-size: 0.95rem; }
  .task-numin { flex-direction: column; }
  .task-confirm .btn-primary { width: 100%; }
  .start-card { padding: 20px 16px; }
  .shop-main { padding: 14px 12px; }
  .shop-grid { grid-template-columns: repeat(2, 1fr); }
  .shop-img { width: 58px; height: 58px; }
  .shop-tip { min-height: 0; }
  .sun-drop { width: 9%; }
  .wallet-chip { font-size: 0.82rem; padding: 8px 12px; }
}

/* очень узкие экраны: HUD в две строки */
@media (max-width: 400px) {
  .game-top { flex-wrap: wrap; }
  .hud-mid { order: 3; width: 100%; text-align: center; }
}
