/* ============================================================
   Сайт-квест «Гатчина» для 2 класса · Умный Ёжик
   ============================================================ */

:root {
  --green-dark: #2e7d32;
  --green: #43a047;
  --green-light: #c8e6c9;
  --sun: #ffb300;
  --sun-light: #ffe082;
  --sky: #4fc3f7;
  --sky-deep: #0288d1;
  --cream: #fff8e1;
  --berry: #e53935;
  --brown: #a9744f;
  --ink: #3e2c23;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Rubik', 'Segoe UI', sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #aee4ff 0%, #d9f4ff 45%, #eefbe8 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, .game-logo, .btn, .letter-btn, .answer-btn, .quiz-text, .cert-title {
  font-family: 'Nunito', 'Rubik', sans-serif;
}

/* ---------- Небо и декорации ---------- */
.sky-decor { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.sun {
  position: absolute; top: 24px; right: 40px;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, #fff176, #ffd54f 60%, #ffca28);
  box-shadow: 0 0 60px 20px rgba(255, 213, 79, .55);
  animation: sunPulse 4s ease-in-out infinite;
}

.cloud { position: absolute; font-size: 64px; opacity: .8; animation: cloudDrift linear infinite; }
.cloud-1 { top: 60px; left: -80px; animation-duration: 60s; }
.cloud-2 { top: 150px; left: -140px; animation-duration: 85s; font-size: 44px; }
.cloud-3 { top: 300px; left: -200px; animation-duration: 70s; font-size: 38px; }

@keyframes cloudDrift {
  from { transform: translateX(0); }
  to   { transform: translateX(calc(100vw + 300px)); }
}

@keyframes sunPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

/* ---------- Шапка ---------- */
.game-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(46, 125, 50, .92);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}

.game-logo { color: #fff; font-weight: 900; font-size: 1.35rem; }
.game-logo span { color: var(--sun-light); }

.progress-dots { display: flex; gap: 8px; padding-bottom: 10px; flex-wrap: wrap; }

.progress-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,.35);
  border: 2px solid rgba(255,255,255,.65);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .7rem; transition: all .3s ease;
}

.progress-dot.done { background: var(--sun); border-color: #fff; transform: scale(1.12); }
.progress-dot.current { background: #fff; border-color: var(--sun); animation: dotPulse 1.2s infinite; }
.progress-dot.final-dot { font-size: .85rem; }

@keyframes dotPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.22); }
}

/* ---------- Шаги квеста ---------- */
.step { display: none; position: relative; z-index: 1; }

.step.active { display: block; animation: fadeUp .5s ease both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

.intro-card {
  background: var(--cream);
  border-radius: 28px;
  border: 4px solid var(--sun);
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
}

.game-title { font-weight: 900; font-size: clamp(1.6rem, 4vw, 2.5rem); }
.text-gatchina { color: var(--green-dark); }

/* ---------- Карточки фото ---------- */
.photo-frame, .map-frame {
  border-radius: 22px;
  border: 6px solid #fff;
  box-shadow: 0 12px 26px rgba(0,0,0,.18);
  overflow: hidden;
  background: #fff;
  position: relative;
}

.photo-frame img, .map-frame svg { display: block; width: 100%; }

.photo-caption {
  display: block; padding: 6px 12px;
  background: rgba(46, 125, 50, .92); color: #fff;
  font-size: .85rem; font-weight: 600; text-align: center;
}

/* ---------- Факты и кнопки ---------- */
.step-badge {
  background: var(--sun); color: #5d4000;
  font-size: .85rem; padding: .45em .9em; border-radius: 50px;
  font-weight: 800;
}

.step h2 { font-weight: 900; margin-top: .5rem; }

.fact-text {
  font-size: 1.1rem; line-height: 1.6;
  background: rgba(255,255,255,.75);
  padding: 14px 18px; border-radius: 16px;
  border-left: 8px solid var(--green);
}

.btn-listen {
  background: var(--sun); color: #5d4000;
  font-weight: 800; font-size: 1.05rem;
  border-radius: 50px; padding: .6em 1.4em;
  border: none; box-shadow: 0 6px 0 #c77f00;
  transition: all .15s ease;
}

.btn-listen:hover { background: var(--sun-light); color: #5d4000; transform: translateY(-2px); }
.btn-listen:active { transform: translateY(3px); box-shadow: 0 2px 0 #c77f00; }

.btn-next, .btn-next-lg {
  background: var(--green); color: #fff;
  font-weight: 900; font-size: 1.25rem;
  border-radius: 50px; padding: .7em 2em;
  border: none; box-shadow: 0 7px 0 #1b5e20;
  transition: all .15s ease;
}

.btn-next-lg { font-size: 1.35rem; }

.btn-next:hover, .btn-next-lg:hover { background: var(--green); color: #fff; transform: translateY(-2px); }
.btn-next:active, .btn-next-lg:active { transform: translateY(4px); box-shadow: 0 2px 0 #1b5e20; }

.btn-next:disabled, .btn-next-lg:disabled {
  background: #bdbdbd; box-shadow: 0 7px 0 #8d8d8d;
  cursor: not-allowed; transform: none;
}

.btn-final-go { background: var(--berry); box-shadow: 0 7px 0 #8e0000; }
.btn-final-go:disabled { background: #bdbdbd; box-shadow: 0 7px 0 #8d8d8d; }

.btn-next.enabled-pop { animation: btnPop .5s ease; }

@keyframes btnPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  70%  { transform: scale(.97); }
  100% { transform: scale(1); }
}

/* ---------- Задания ---------- */
.quest-box {
  background: #fff;
  border-radius: 20px;
  padding: 16px;
  border: 4px dashed var(--sun);
  box-shadow: inset 0 0 0 3px #fff, 0 6px 16px rgba(0,0,0,.08);
  margin-bottom: 1rem;
}

.quest-title { font-weight: 900; color: var(--green-dark); font-size: 1.15rem; }
.quest-hint { color: #6d5c4a; margin-bottom: .6rem; font-size: .98rem; }

.quest-message { min-height: 1.4em; font-weight: 700; margin-top: .5rem; font-size: 1rem; }
.quest-message.ok   { color: var(--green-dark); }
.quest-message.err  { color: var(--berry); }
.quest-message.info { color: var(--sky-deep); }

/* Шаг 1 — буквы */
.letter-slots { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }

.letter-slot {
  width: 52px; height: 60px;
  border: 3px dashed #cfb98a; border-radius: 12px;
  background: #fffdf5;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 900; color: var(--green-dark);
  transition: all .25s ease;
}

.letter-slot.filled { border-style: solid; border-color: var(--green); background: var(--green-light); animation: popIn .3s ease; }

@keyframes popIn {
  0% { transform: scale(.4); }
  70% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.letter-bank { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.letter-btn {
  width: 58px; height: 66px; font-size: 1.8rem; font-weight: 900;
  background: var(--sun); color: #5d4000;
  border: none; border-radius: 14px;
  box-shadow: 0 6px 0 #c77f00;
  transition: all .15s ease;
}

.letter-btn:hover:not(:disabled) { transform: translateY(-3px) rotate(-3deg); background: var(--sun-light); }
.letter-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #c77f00; }
.letter-btn:disabled { opacity: .35; cursor: default; box-shadow: none; transform: none; }

.letter-btn.wrong { animation: shakeX .4s ease; background: var(--berry); color: #fff; }

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* Шаг 2 — карта */
.map-frame { background: #eaf7fb; }

#regionMap { touch-action: manipulation; }

.map-shape { fill: #b9e4b3; stroke: #5d8f58; stroke-width: 3; }
.water { fill: #90caf9; stroke: #4a90c9; stroke-width: 2; }
.river { fill: none; stroke: #90caf9; stroke-width: 5; stroke-linecap: round; }

.city { cursor: pointer; }
.city circle { fill: var(--berry); stroke: #fff; stroke-width: 3; transition: all .2s ease; }
.city text {
  font-size: 17px; font-weight: 800; fill: var(--ink);
  text-anchor: middle; paint-order: stroke;
  stroke: #fff; stroke-width: 4px; stroke-linejoin: round;
  pointer-events: none;
}
.city:hover circle { fill: var(--sun); transform-origin: center; }
.city.pulse circle { animation: cityPulse .7s ease infinite alternate; }
.city.found circle { fill: var(--green); }
.city.city-mark { cursor: default; }
.city.city-mark circle { fill: #7b1fa2; }

@keyframes cityPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.35); }
}

/* Ответы (шаги 3, 7, 8) */
.answer-grid { display: flex; flex-direction: column; gap: 10px; }

.answer-btn {
  background: #eef6ee; color: var(--ink);
  border: 3px solid var(--green-light);
  border-radius: 14px; font-weight: 800; font-size: 1.05rem;
  padding: .65em 1.2em; text-align: left;
  transition: all .15s ease;
}

.answer-btn:hover { background: var(--green-light); border-color: var(--green); }
.answer-btn.correct { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }
.answer-btn.wrong { background: #ffebee; border-color: var(--berry); color: var(--berry); animation: shakeX .4s ease; }

/* «Найди лишнее» */
.spot-wrap { position: relative; border-radius: 16px; overflow: hidden; }

.spot-item {
  position: absolute; width: 46px; height: 46px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,.85);
  box-shadow: 0 3px 8px rgba(0,0,0,.3);
  font-size: 1.5rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
  animation: bob 2.4s ease-in-out infinite;
}

.spot-item:nth-of-type(even) { animation-delay: .8s; }
.spot-item:nth-of-type(3n) { animation-delay: 1.4s; }

@keyframes bob {
  0%, 100% { transform: translate(-50%, -52%); }
  50%      { transform: translate(-50%, -48%); }
}

.spot-item:hover { transform: translate(-50%, -50%) scale(1.25); }

.spot-item.found-bad { animation: popGone .5s ease forwards; }

@keyframes popGone {
  0% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  40% { transform: translate(-50%,-50%) scale(1.5) rotate(15deg); }
  100% { transform: translate(-50%,-50%) scale(0); opacity: 0; }
}

.spot-item.good-tap { animation: wiggle .5s ease; }

@keyframes wiggle {
  0%,100% { transform: translate(-50%,-50%) rotate(0); }
  30% { transform: translate(-50%,-50%) rotate(-18deg) scale(1.15); }
  70% { transform: translate(-50%,-50%) rotate(18deg) scale(1.15); }
}

.found-counter { font-weight: 800; margin-top: 8px; color: var(--green-dark); font-size: 1.05rem; }

@media (max-width: 576px) {
  .spot-item { width: 40px; height: 40px; font-size: 1.25rem; }
}

/* Викторина */
.quiz-q { display: none; }
.quiz-q.active { display: block; animation: fadeUp .4s ease both; }
.quiz-text { font-weight: 800; font-size: 1.15rem; }

.tf-question { display: none; margin-bottom: 12px; padding: 12px; border-radius: 14px; background: #f6f9f6; }
.tf-question.active { display: block; animation: fadeUp .4s ease both; }
.tf-question.passed { background: var(--green-light); }
.tf-question .tf-mark { float: right; font-size: 1.4rem; }

/* ---------- Финал ---------- */
.medal {
  font-size: 6rem; display: inline-block;
  animation: medalSpin 2.5s ease-in-out infinite;
}

@keyframes medalSpin {
  0%, 100% { transform: rotate(-12deg) scale(1); }
  50% { transform: rotate(12deg) scale(1.12); }
}

.certificate {
  max-width: 560px;
  background: linear-gradient(160deg, #fffde7, #fff8e1);
  border: 6px double var(--sun);
  border-radius: 24px;
  padding: 26px 20px;
  box-shadow: 0 10px 28px rgba(0,0,0,.16);
}

.cert-title { font-size: 1.6rem; font-weight: 900; color: var(--green-dark); }
.cert-line { color: #6d5c4a; }
.cert-name { font-size: 1.5rem; font-weight: 900; color: var(--berry); margin: 10px 0; }
.cert-sign { color: #8d6e63; font-weight: 700; }

.know-list { list-style: none; padding: 0; margin: 0; }
.know-list li { padding: 6px 0; font-size: 1.08rem; border-bottom: 1px dashed #e0d5b8; }

/* Салют */
.salute { position: fixed; inset: 0; pointer-events: none; z-index: 3; }

.firework {
  position: absolute; width: 8px; height: 8px; border-radius: 50%;
  animation: boom 1.6s ease-out infinite;
}

@keyframes boom {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; }
}

/* ---------- Ёжик ---------- */
.hedgehog-area { position: fixed; right: 14px; bottom: 14px; z-index: 100; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.hedgehog-btn {
  width: 108px; height: 104px; border: none; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffe082, #ffb300);
  box-shadow: 0 8px 20px rgba(0,0,0,.3);
  cursor: pointer; padding: 6px;
  transition: transform .2s ease;
}

.hedgehog-btn:hover { transform: scale(1.08) rotate(-4deg); }
.hedgehog-btn.talking { animation: hedgehogTalk .45s ease infinite alternate; }

@keyframes hedgehogTalk {
  from { transform: translateY(0) rotate(-2deg); }
  to   { transform: translateY(-10px) rotate(2deg); }
}

.hedgehog-bubble {
  display: none; max-width: 300px;
  background: #fff; color: var(--ink);
  border-radius: 18px; padding: 10px 14px;
  font-weight: 700; font-size: .95rem; line-height: 1.4;
  box-shadow: 0 6px 18px rgba(0,0,0,.2);
  border: 3px solid var(--sun);
  position: relative;
}

.hedgehog-bubble.show { display: block; animation: fadeUp .3s ease both; }

.hedgehog-bubble::after {
  content: ''; position: absolute; right: 30px; bottom: -13px;
  border: 8px solid transparent; border-top-color: var(--sun);
}

@media (max-width: 576px) {
  .hedgehog-area { right: 8px; bottom: 8px; }
  .hedgehog-btn { width: 84px; height: 80px; }
  .hedgehog-bubble { max-width: 240px; font-size: .85rem; }
}

/* ---------- Футер ---------- */
.game-footer {
  position: relative; z-index: 5;
  background: rgba(46, 125, 50, .9); color: #e8f5e9;
  margin-top: 30px;
}

.game-footer a { color: var(--sun-light); font-weight: 700; }

.footer-meta { opacity: .8; color: #e8f5e9; }

/* Маленький QR-код */
.footer-qr-link {
  display: inline-block;
  background: #fff;
  border-radius: 12px;
  padding: 5px;
  box-shadow: 0 4px 10px rgba(0,0,0,.25);
  transition: transform .2s ease;
}

.footer-qr-link:hover { transform: scale(1.07) rotate(-2deg); }

.footer-qr {
  display: block; width: 78px; height: 78px;
  border-radius: 8px; object-fit: contain;
}

.footer-qr-caption { font-size: .78rem; color: var(--green-light); margin-top: 4px; font-weight: 600; }

/* Сообщение о кружке */
.footer-course-msg {
  font-size: 1.02rem; line-height: 1.55;
  background: rgba(255,255,255,.12);
  border: 2px solid rgba(255,255,255,.28);
  border-radius: 16px;
  padding: 12px 16px;
  min-height: 82px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  transition: opacity .4s ease;
}

.footer-course-msg.fading { opacity: 0; }

.footer-course-msg a {
  color: #fff; font-weight: 800;
  text-decoration: underline; text-underline-offset: 3px;
}

.footer-course-msg a:hover { color: var(--sun-light); }

.footer-course-emoji { margin-right: 4px; }

@media (max-width: 576px) {
  .footer-course-msg { min-height: 96px; font-size: .95rem; }
}

/* ---------- Утилиты ---------- */
.fw-black { font-weight: 900; }