/* ============================================================
   «Флаги и столицы» — стили
   ============================================================ */

:root {
  --accent: #FF7A59;
  --accent2: #4EC5F1;
  --ok: #3BC97D;
  --bad: #FF5A6E;
  --ink: #2E2A4F;
  --card: #FFFFFF;
  --soft: #F4F1FF;
  /* фон и акцент темы — переопределяются из game.js */
  --bg1: #EAF4FF; --bg2: #DCEBFB; --bg3: #EFE6FF;
  --theme-accent: #2F7FD6;
  /* цвета карты мира */
  --sea: #CFE6F5; --ice: #F2F9FE;
  --c-eu: #5B8FD6; --c-as: #D4763F; --c-af: #D9A93C;
  --c-na: #57A06C; --c-sa: #35A98A; --c-oc: #9061C4;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: "Naukino Emoji", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2) 55%, var(--bg3));
  transition: background .6s ease;
  background-attachment: fixed;
  padding: 72px 12px 40px;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 1000px; position: relative; z-index: 1; margin: 0 auto; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border-radius: 28px;
  padding: clamp(14px, 3.5vw, 30px);
  box-shadow: 0 14px 34px rgba(46, 42, 79, .14);
}

.title {
  font-size: clamp(26px, 5.6vw, 40px);
  margin: 0 0 10px; text-align: center; color: var(--accent);
}
.subtitle {
  margin: 0 auto 18px; max-width: 640px; text-align: center;
  font-size: clamp(15px, 2.4vw, 18px); line-height: 1.5; color: #5B5478;
}
.section-title {
  font-size: clamp(18px, 3vw, 22px); margin: 22px 0 12px; text-align: center;
}

/* ---------- Украшения темы ---------- */
.theme-deco { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.theme-deco span { position: absolute; opacity: .3; filter: saturate(.85); }

/* ---------- Кнопки звука ---------- */
.top-buttons { position: fixed; top: 10px; right: 10px; display: flex; gap: 8px; z-index: 60; }
.icon-btn {
  width: 46px; height: 46px; border: none; border-radius: 16px;
  background: #fff; font-size: 22px; cursor: pointer;
  box-shadow: 0 3px 0 rgba(61, 52, 85, .12);
}
.icon-btn:hover { background: #F2EFFF; }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(61, 52, 85, .12); }
.icon-btn:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.icon-btn.off { opacity: .45; }

/* ---------- Лисёнок ---------- */
.hero-panel {
  display: flex; align-items: center; gap: 12px;
  max-width: 640px; margin: 16px auto; padding: 12px 14px;
  background: var(--soft); border-radius: 22px;
}
.hero-panel.compact { margin: 12px auto 4px; padding: 10px 12px; }
.hero-art { font-size: 42px; line-height: 1; flex: none; }
.hero-art.jump { animation: heroJump .5s ease; }
.hero-art.shake { animation: heroShake .5s ease; }
@keyframes heroJump { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-14px) scale(1.08); } }
@keyframes heroShake { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }
.bubble {
  background: #fff; border-radius: 18px; padding: 10px 14px;
  font-size: clamp(14px, 2.3vw, 17px); line-height: 1.45; flex: 1;
  box-shadow: 0 2px 8px rgba(46, 42, 79, .08);
}

/* ---------- Кнопки ---------- */
.big-btn {
  display: block; margin: 16px auto 0; padding: 14px 34px;
  border: none; border-radius: 22px;
  background: var(--accent); color: #fff;
  font: inherit; font-size: clamp(17px, 3vw, 21px); font-weight: 800;
  cursor: pointer; box-shadow: 0 5px 0 rgba(0, 0, 0, .13);
}
.big-btn:hover { filter: brightness(1.06); }
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .13); }
.big-btn:focus-visible { outline: 3px solid var(--accent2); outline-offset: 3px; }
.big-btn.ghost { background: #EFEAFF; color: #4A4270; }
.start-links { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.start-links .big-btn { margin-top: 14px; }

.mini-btn {
  border: none; border-radius: 14px; padding: 9px 13px; flex: none;
  background: #EFEAFF; color: #4A4270; font: inherit; font-weight: 700;
  font-size: 15px; cursor: pointer;
}
.mini-btn:hover { background: #E3DBFF; }
.mini-btn:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }

.levels { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.level-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 12px; border: 3px solid transparent; border-radius: 22px;
  background: var(--soft); font: inherit; color: var(--ink); cursor: pointer; text-align: center;
}
.level-btn:hover { background: #E9E3FF; }
.level-btn:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.level-btn.on { border-color: var(--accent); background: #FFF0EA; }
.level-emoji { font-size: 30px; }
.level-name { font-weight: 800; font-size: 17px; }
.level-desc { font-size: 13px; color: #6B648C; }

.hint-line, .how-line {
  text-align: center; font-size: 14px; color: #7A7396; margin: 14px 0 0;
}

/* ---------- Шапка экрана ---------- */
.game-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.progress-info { flex: 1; min-width: 0; text-align: center; font-size: 14px; font-weight: 700; }
.progress-bar { height: 9px; border-radius: 6px; background: #EDE8FB; margin-top: 6px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 6px; background: var(--theme-accent); transition: width .35s ease; }
.theme-chip { margin-left: 8px; font-weight: 600; color: #6B648C; font-size: 13px; }
.score-badge {
  flex: none; background: var(--soft); border-radius: 14px;
  padding: 8px 12px; font-weight: 800; font-size: 15px;
}
.score-badge .flag-svg { width: 34px; border-radius: 3px; vertical-align: -3px; }

/* ---------- Карта мира ---------- */
.map-box { margin: 0 auto; max-width: 760px; }
.map-svg { width: 100%; height: auto; display: block; border-radius: 18px; }
.map-svg .cont { stroke: #fff; stroke-width: 2; stroke-linejoin: round; transition: filter .18s ease; }
/* Антарктида: обводка её же цветом — она сглаживает зубцы кромки льда. */
.map-svg .ice { fill: var(--ice); stroke: var(--ice); stroke-width: 2; stroke-linejoin: round; }
.map-svg .cont[data-cont="eu"] { fill: var(--c-eu); }
.map-svg .cont[data-cont="as"] { fill: var(--c-as); }
.map-svg .cont[data-cont="af"] { fill: var(--c-af); }
.map-svg .cont[data-cont="na"] { fill: var(--c-na); }
.map-svg .cont[data-cont="sa"] { fill: var(--c-sa); }
.map-svg .cont[data-cont="oc"] { fill: var(--c-oc); }
.map-svg .cont[tabindex] { cursor: pointer; }
.map-svg .cont[tabindex]:hover { filter: brightness(1.15); }
.map-svg .cont[tabindex]:focus-visible { outline: none; stroke: var(--ink); stroke-width: 5; }
.map-svg .cont.right { filter: brightness(1.25) saturate(1.4); stroke: #1F8A4C; stroke-width: 6; }
.map-svg .cont.wrong { animation: mapShake .45s ease; stroke: var(--bad); stroke-width: 6; }
.map-svg .pin { fill: #E2483C; stroke: #fff; stroke-width: 2; }
@keyframes mapShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Главы ---------- */
.chapters { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.chapter {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 13px 15px; border: 3px solid transparent; border-radius: 22px;
  background: var(--soft); font: inherit; color: var(--ink); cursor: pointer;
}
.chapter:hover { background: #E9E3FF; }
.chapter:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.chapter.locked { opacity: .5; cursor: not-allowed; }
.chapter-icon { font-size: 32px; flex: none; }
.chapter-name { font-weight: 800; display: block; font-size: 17px; }
.chapter-sub { font-size: 13px; color: #6B648C; }
.chapter-about { text-align: center; color: #6B648C; font-size: 15px; margin: 12px 0 16px; }

/* ---------- Заставка главы ---------- */
.splash {
  height: clamp(110px, 22vw, 190px); border-radius: 20px; margin-bottom: 4px;
  background: var(--theme-accent) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(48px, 12vw, 90px); color: #fff;
}

/* ---------- Страны главы ---------- */
.country-grid { display: grid; gap: 11px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.country-btn {
  padding: 10px; border: 3px solid transparent; border-radius: 18px;
  background: var(--soft); font: inherit; color: var(--ink); cursor: pointer; text-align: center;
}
.country-btn:hover { background: #E9E3FF; }
.country-btn:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.country-btn.done { border-color: var(--ok); background: #ECFBF2; }
.country-btn .flag-svg { width: 100%; height: auto; border-radius: 5px; display: block; }
.country-btn b {
  display: block; margin-top: 7px; font-size: 14px; line-height: 1.2;
  overflow-wrap: anywhere; hyphens: auto;
}
.country-btn .cstars { font-size: 13px; letter-spacing: 1px; color: #E8A21C; }

/* ---------- Сцена задания ---------- */
.stage { margin: 6px auto 16px; max-width: 560px; text-align: center; }
.stage .flag-svg { width: min(100%, 420px); height: auto; border-radius: 8px;
  box-shadow: 0 6px 18px rgba(46, 42, 79, .16); }
.stage .sight-pic {
  width: min(100%, 420px); aspect-ratio: 4 / 3; border-radius: 18px; object-fit: cover;
  box-shadow: 0 6px 18px rgba(46, 42, 79, .16); display: block; margin: 0 auto;
}
.stage .sight-emoji {
  width: min(100%, 300px); aspect-ratio: 4 / 3; border-radius: 18px; margin: 0 auto;
  background: var(--soft); display: flex; align-items: center; justify-content: center;
  font-size: clamp(56px, 16vw, 110px);
}
.stage .sight-name { margin: 10px 0 0; font-weight: 800; font-size: clamp(17px, 3vw, 21px); }
.stage .big-word { font-size: clamp(30px, 7vw, 52px); font-weight: 900; color: var(--theme-accent); }
.stage .hint-card {
  background: var(--soft); border-radius: 18px; padding: 12px 16px; margin-top: 10px;
  font-size: clamp(15px, 2.5vw, 18px); line-height: 1.45; text-align: left;
}

.quest {
  display: block; margin: 0 auto 14px; border: none; background: none;
  font: inherit; font-size: clamp(20px, 4vw, 30px); font-weight: 900;
  color: var(--ink); cursor: pointer; text-align: center; line-height: 1.25;
}
.quest:focus-visible { outline: 3px solid var(--accent2); outline-offset: 3px; border-radius: 12px; }

/* ---------- Ответы ---------- */
.answers { display: grid; gap: 11px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.answers.flags { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.answers.wide { grid-template-columns: 1fr; }
/* Карта — единственная ячейка сетки ответов. `margin: 0 auto` из общего
   правила перебивает растягивание в grid, и svg падал к 300 px. */
.answers .map-box { max-width: 100%; width: 100%; margin: 0; }
.ans {
  padding: 14px 12px; border: 3px solid transparent; border-radius: 20px;
  background: var(--soft); font: inherit; font-size: clamp(16px, 2.6vw, 20px);
  font-weight: 700; color: var(--ink); cursor: pointer; text-align: center;
}
.ans:hover:not(:disabled) { background: #E9E3FF; }
.ans:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.ans:disabled { cursor: default; }
.ans .flag-svg { width: 100%; height: auto; border-radius: 5px; display: block; }
.ans .ans-label { display: block; margin-top: 8px; font-size: 15px; }
.ans.right { border-color: var(--ok); background: #E4FBEE; }
.ans.wrong { border-color: var(--bad); background: #FFE9EC; animation: ansShake .45s ease; }
.ans.faded { opacity: .45; }
@keyframes ansShake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 60% { transform: translateX(8px); } }

.hint-btn { margin: 12px auto 0; display: block; }

/* ---------- Итог ---------- */
.stars { text-align: center; font-size: clamp(34px, 8vw, 54px); letter-spacing: 6px; min-height: 56px; }
.stars span { display: inline-block; opacity: 0; transform: scale(.4); animation: starPop .45s ease forwards; }
@keyframes starPop { to { opacity: 1; transform: scale(1); } }
.result-score { text-align: center; font-size: clamp(16px, 2.8vw, 20px); font-weight: 700; }
.fact-line {
  max-width: 620px; margin: 12px auto; padding: 12px 16px; border-radius: 18px;
  background: var(--soft); text-align: center; font-size: clamp(14px, 2.4vw, 17px); line-height: 1.5;
}
.result-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.stamp-wrap { display: flex; justify-content: center; margin: 6px 0 2px; }
.stamp {
  width: clamp(120px, 30vw, 170px); padding: 10px; border-radius: 16px;
  border: 4px dashed var(--theme-accent); text-align: center;
  transform: rotate(-6deg) scale(.4); opacity: 0;
  animation: stampIn .5s .25s cubic-bezier(.2, 1.5, .5, 1) forwards;
}
.stamp .flag-svg { width: 100%; height: auto; border-radius: 4px; }
.stamp b { display: block; font-size: 14px; margin-top: 6px; line-height: 1.2; }
.stamp small { color: #6B648C; font-size: 12px; }
@keyframes stampIn { to { transform: rotate(-6deg) scale(1); opacity: 1; } }

.parents { max-width: 640px; margin: 16px auto 0; }
.parents summary { cursor: pointer; font-weight: 800; padding: 10px 14px; background: var(--soft); border-radius: 16px; }
.parents-body { padding: 12px 6px; font-size: 15px; line-height: 1.5; }
.parents-body ul { margin: 8px 0 0; padding-left: 20px; }
.parents-body li { margin-bottom: 8px; }

/* ---------- Паспорт и награды ---------- */
.stamp-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); margin-top: 18px; }
.pstamp { padding: 8px; border-radius: 16px; background: var(--soft); text-align: center; }
.pstamp.empty { opacity: .42; }
.pstamp .flag-svg { width: 100%; height: auto; border-radius: 4px; }
.pstamp .blank { width: 100%; aspect-ratio: 3 / 2; border-radius: 4px; background: #DDD6F3; }
.pstamp b {
  display: block; font-size: 13px; margin-top: 6px; line-height: 1.2;
  overflow-wrap: anywhere; hyphens: auto;
}
.pstamp small { display: block; color: #6B648C; font-size: 11px; }
.pstamp .cstars { font-size: 12px; color: #E8A21C; letter-spacing: 1px; }

.award-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 18px; }
.award { padding: 14px 10px; border-radius: 20px; background: var(--soft); text-align: center; }
.award.locked { opacity: .4; filter: grayscale(1); }
.award .aemoji { font-size: 38px; }
.award b { display: block; font-size: 14px; margin-top: 6px; }
.award small { color: #6B648C; font-size: 12px; }
.new-awards { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.new-awards .award { animation: starPop .5s ease forwards; opacity: 0; transform: scale(.4); }

/* ---------- Конфетти ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i {
  position: absolute; width: 10px; height: 16px; border-radius: 3px;
  animation: fall 2.4s linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0; } }

/* ---------- Кнопка «Выйти» ---------- */
.exit-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 46px; padding: 0 16px; flex: none;
  border: none; border-radius: 16px;
  background: #fff; color: #3D3455;
  font: inherit; font-size: 16px; font-weight: 800; line-height: 1;
  white-space: nowrap; cursor: pointer;
  box-shadow: 0 3px 0 rgba(61, 52, 85, .12);
}
.exit-btn:hover { background: #F2EFFF; }
.exit-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(61, 52, 85, .12); }
.exit-btn:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.exit-btn--float { position: fixed; top: 10px; left: 10px; z-index: 60; }

@media (max-width: 640px) {
  body { padding-top: 64px; }
  .hero-art { font-size: 34px; }
  .country-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .stamp-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
}
@media (max-width: 480px) {
  .exit-btn { height: 40px; padding: 0 12px; font-size: 14px; }
  .exit-btn--float { top: 6px; left: 6px; }
  .icon-btn { width: 40px; height: 40px; font-size: 19px; }
  .top-buttons { top: 6px; right: 6px; }
}

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

/* На окне ноутбука карта занимала весь экран, и кнопки материков — то, ради
   чего сюда пришли, — оказывались под сгибом целиком. Ограничиваем карту по
   высоте окна и ужимаем сами кнопки. */
@media (max-height: 800px) {
  .map-svg { max-height: 46vh; width: auto; margin: 0 auto; }
  .map-box { display: flex; justify-content: center; }
  .chapters { gap: 8px; }
  .chapter { padding: 8px 12px; gap: 9px; }
  .chapter-icon { font-size: 24px; }
  .hero-panel { padding: 7px 11px; margin: 8px 0; }
  .hero-art { font-size: clamp(26px, 5vw, 34px); }
  .bubble { padding: 7px 11px; font-size: clamp(14px, 2.4vw, 16px); }
}
