/* «Найди картинку» — same palette as «Скажи по-английски» */

:root {
  --ink: #3d2b2f;
  --muted: #8b7576;
  --sky: #d7f0ff;
  --cream: #fff8ec;
  --pig: #ff7096;          /* main colour — the listen button */
  --pig-dark: #e04f78;
  --ok: #22a35a;
  --ok-bg: #dcf8e7;
  --bad: #e5484d;
  --accent: #f2b31c;
  --accent-soft: #fff1c9;
  --line: #eadfcd;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--sky) 0%, var(--cream) 55%) fixed;
  color: var(--ink);
  font-family: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
button:disabled { cursor: default; }
[hidden] { display: none !important; }

/* ---------- Topics and score ---------- */

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 0;
}

.score {
  font-size: 26px;
  font-weight: 900;
  padding: 4px 18px;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--accent-soft);
}
.score.bump { animation: pop 0.45s ease-out; }

.topics {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1100px;
}

.topic {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 8px;
  background: rgba(255, 255, 255, 0.7);
  border: 3px solid transparent;
  border-radius: 16px;
  transition: transform 0.15s, background 0.15s;
}
.topic:hover { transform: translateY(-2px); }
.topic.current { background: #fff; border-color: var(--accent); box-shadow: 0 4px 0 var(--accent-soft); }
.topic.done { border-color: var(--ok); }
.topic-icon { font-size: 24px; line-height: 1; }
.topic-name { font-weight: 800; font-size: 15px; }
.topic-count { font-size: 13px; color: var(--muted); }
.topic.done .topic-count { color: var(--ok); }

/* ---------- Listen button and message ---------- */

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 18px 16px 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.listen {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 30px 10px 14px;
  border: none;
  border-radius: 999px;
  background: var(--pig);
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  box-shadow: 0 6px 0 var(--pig-dark);
  transition: transform 0.1s, box-shadow 0.1s;
}
.listen-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  font-size: 36px;
}
.listen:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--pig-dark); }
.listen:disabled { opacity: 0.5; }

#message { margin: 0; max-width: 100%; min-height: 1.4em; font-size: 28px; font-weight: 900; text-align: center; }
#message.ok { color: var(--ok); animation: pop 0.3s ease-out; }
#message.miss { color: var(--pig-dark); }

/* ---------- Picture cards ---------- */

.cards {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 8px;
  background: #fff;
  border: 4px solid #fff;
  border-radius: 28px;
  box-shadow: 0 6px 0 var(--line), 0 10px 24px rgba(61, 43, 47, 0.08);
  transition: transform 0.12s, opacity 0.25s, border-color 0.2s;
}
.option:hover:not(:disabled) { transform: translateY(-4px); }
.option:active:not(:disabled) { transform: translateY(2px); }
.option img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 18px; }
.option-label { min-height: 1.4em; font-size: 20px; text-align: center; color: var(--muted); }
.option-label b { color: var(--ink); font-weight: 900; }

.option.right { border-color: var(--ok); background: var(--ok-bg); box-shadow: 0 6px 0 #b9ebcd; animation: hop 0.5s ease-out; }
.option.right .option-label b { color: var(--ok); }
.option.wrong { opacity: 0.55; border-color: var(--bad); animation: shake 0.4s; position: relative; }
.option.wrong::after {
  content: "✗";
  position: absolute;
  top: 8px;
  right: 14px;
  color: var(--bad);
  font-size: 34px;
  font-weight: 900;
}
.option.dim { opacity: 0.35; }

/* ---------- Dialog ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(61, 43, 47, 0.35);
}
.card {
  max-width: 440px;
  width: 100%;
  padding: 28px 24px;
  background: #fff;
  border-radius: 28px;
  text-align: center;
  box-shadow: 0 10px 0 var(--accent-soft), 0 20px 50px rgba(0, 0, 0, 0.2);
  animation: pop 0.35s ease-out;
}
.card-icon { font-size: 84px; line-height: 1.1; }
.card h2 { margin: 10px 0 6px; font-size: 30px; font-weight: 900; }
.card p { margin: 0 0 22px; color: var(--muted); font-size: 18px; }

.btn {
  font-size: 22px;
  font-weight: 800;
  padding: 12px 30px;
  border-radius: 999px;
  border: 3px solid var(--pig);
  background: var(--pig);
  color: #fff;
  box-shadow: 0 4px 0 var(--pig-dark);
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--pig-dark); }

/* ---------- Confetti ---------- */

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.confetti span { position: absolute; top: -50px; animation: fall 1.8s ease-in forwards; }

/* ---------- Animations ---------- */

@keyframes pop { 0% { transform: scale(0.85); } 70% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-8%); } }
@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
@keyframes fall {
  to { transform: translate(var(--drift, 0), 110vh) rotate(540deg); opacity: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Narrow screens: 2 × 2 ---------- */

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

@media (max-width: 700px) {
  header { padding: 10px 8px 0; gap: 8px; }
  .score { font-size: 22px; }
  .topics { gap: 5px; }
  .topic { flex-direction: column; gap: 0; padding: 4px 7px; border-radius: 12px; }
  .topic-name { display: none; }
  .topic-icon { font-size: 22px; }
  .topic-count { font-size: 11px; }
  main { gap: 12px; padding-top: 12px; padding-bottom: 80px; }
  .listen { font-size: 21px; padding: 8px 24px 8px 10px; }
  .listen-icon { width: 52px; height: 52px; font-size: 30px; }
  #message { font-size: 22px; }
  .cards { gap: 12px; }
  .option { padding: 6px 6px 4px; border-radius: 22px; border-width: 3px; }
  .option-label { font-size: 16px; }
  .option.wrong::after { font-size: 28px; right: 10px; }
}
