@import url("https://fonts.googleapis.com/css2?family=Caveat:wght@600;700&family=Nunito:wght@400;600;800&display=swap");

:root {
  --bg: #fff6f0;
  --bg-2: #ffe3ec;
  --card: #ffffff;
  --ink: #2b2140;
  --muted: #7a6f8a;
  --accent: #ff5d8f;
  --accent-ink: #ffffff;
  --gold: #ffb703;
  --ok: #06a77d;
  --bad: #e5484d;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(43, 33, 64, 0.12);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, var(--bg-2) 0, transparent 40%),
    radial-gradient(circle at 90% 80%, #e6f4ff 0, transparent 45%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.5;
}

main {
  overflow-x: clip;
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

h1, h2, .hand { font-family: "Caveat", cursive; font-weight: 700; }
h1 { font-size: clamp(2.4rem, 8vw, 3.6rem); line-height: 1.05; margin: 0 0 8px; }
h2 { font-size: 2rem; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.level-tag {
  display: inline-block;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.progress { display: flex; gap: 6px; margin-bottom: 24px; }
.progress span {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(43, 33, 64, 0.1);
}
.progress .done { background: var(--accent); }
.progress .now { background: var(--gold); animation: pulse 1.4s infinite; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  padding: 14px 16px;
  border: 2px solid rgba(43, 33, 64, 0.15);
  border-radius: 14px;
  outline: none;
  background: #fff;
  color: var(--ink);
}
input[type="text"]:focus { border-color: var(--accent); }

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 6px 16px rgba(255, 93, 143, 0.35);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn.ghost {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  border: 2px dashed rgba(43, 33, 64, 0.2);
}

.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.options { display: grid; gap: 10px; margin-top: 12px; }
.options button {
  font: inherit;
  text-align: left;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid rgba(43, 33, 64, 0.12);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.options button:hover { border-color: var(--accent); }
.options button.right { border-color: var(--ok); background: #e7f8f1; }
.options button.wrong { border-color: var(--bad); background: #fdecec; }

/* Фото і заглушки */
.photo {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: #eee;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.placeholder {
  background: linear-gradient(135deg, #ffd6e4, #d9e8ff);
  display: grid;
  place-items: center;
}
.photo.placeholder::after {
  content: "📷 " attr(data-label);
  font-size: 0.75rem;
  color: var(--muted);
  padding: 8px;
  text-align: center;
}

.polaroid {
  background: #fff;
  padding: 8px 8px 28px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.polaroid .caption {
  font-family: "Caveat", cursive;
  font-size: 1.3rem;
  text-align: center;
  margin-top: 6px;
}

/* Рівень 2 — пошук */
.hunt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 520px) { .hunt-grid { grid-template-columns: repeat(2, 1fr); } }
.hunt-grid .tile { cursor: pointer; transition: transform 0.15s, opacity 0.3s; }
.hunt-grid .tile:hover { transform: scale(1.04) rotate(-1deg); }
.hunt-grid .tile.tried { opacity: 0.35; }
.hunt-grid .tile.found { outline: 4px solid var(--gold); transform: scale(1.08); }

/* Рівень 3 — приховане посилання */
.secret-link { color: inherit; text-decoration: none; cursor: text; }
.secret-link.wiggle { display: inline-block; animation: wiggle 0.6s ease-in-out 3; }

/* Рівень 4 — втікаюча кнопка */
.arena { position: relative; height: 260px; }
.arena .btn { position: absolute; transition: left 0.25s, top 0.25s, transform 0.2s; }

/* Фінал */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 18px;
}
.gallery .polaroid:nth-child(odd) { transform: rotate(-2deg); }
.gallery .polaroid:nth-child(even) { transform: rotate(2deg); }
.gallery .polaroid:hover { transform: rotate(0) scale(1.04); }
.gallery .photo { aspect-ratio: 4 / 5; }
.letter { white-space: pre-line; font-size: 1.1rem; min-height: 6em; }
.signature { font-family: "Caveat", cursive; font-size: 2rem; text-align: right; margin-top: 12px; }

/* Тости, конфеті, анімації */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 50;
  width: min(92vw, 420px);
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: rise 0.25s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(8px); }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

.shake { animation: shake 0.4s; }
.hidden { display: none !important; }
.pop { animation: pop 0.4s ease-out; }

@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
@keyframes wiggle {
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}
@keyframes pulse { 50% { opacity: 0.4; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop { 0% { transform: scale(0.8); opacity: 0; } 70% { transform: scale(1.05); } }

/* Рівень 4 — Мія на посту */
.guard-dog { display: grid; justify-items: center; gap: 12px; margin-bottom: 16px; }
.guard-dog img {
  width: min(340px, 85%);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.guard-dog img.angry { animation: bark 0.45s; }
.guard-dog img.happy { animation: hop 0.5s ease-in-out 4; }
.bubble {
  position: relative;
  max-width: 320px;
  padding: 10px 14px;
  text-align: center;
  font-weight: 800;
  background: var(--bg);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 16px;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 14px;
  height: 14px;
  background: inherit;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: translateX(-50%) rotate(45deg);
}
@keyframes bark {
  30% { transform: scale(1.08) rotate(-4deg); }
  60% { transform: scale(1.05) rotate(4deg); }
}
@keyframes hop { 50% { transform: translateY(-14px); } }
