/* «Наследие» — оформление по бумажным карточкам: светлый фон, рамки по категории,
   PT Serif для названий, PT Sans для текста. Рассчитано на ребёнка 9–11 лет. */

@font-face { font-family: 'PT Serif'; font-weight: 700; font-style: normal; font-display: swap;
  src: url('./fonts/pt-serif-700-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'PT Serif'; font-weight: 700; font-style: normal; font-display: swap;
  src: url('./fonts/pt-serif-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'PT Sans'; font-weight: 400; font-style: normal; font-display: swap;
  src: url('./fonts/pt-sans-400-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'PT Sans'; font-weight: 400; font-style: normal; font-display: swap;
  src: url('./fonts/pt-sans-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'PT Sans'; font-weight: 400; font-style: italic; font-display: swap;
  src: url('./fonts/pt-sans-400-italic-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'PT Sans'; font-weight: 400; font-style: italic; font-display: swap;
  src: url('./fonts/pt-sans-400-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'PT Sans'; font-weight: 700; font-style: normal; font-display: swap;
  src: url('./fonts/pt-sans-700-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'PT Sans'; font-weight: 700; font-style: normal; font-display: swap;
  src: url('./fonts/pt-sans-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #f6f1e7;
  --paper: #fffdf8;
  --ink: #2b2622;
  --muted: #7a7068;
  --line: #d9cfbf;
  --terra: #b4532a;
  --terra-soft: #f3e1d6;
  --forest: #2d5a3d;
  --forest-soft: #dde9df;
  --right: #2e7d32;
  --wrong: #c62828;
  --bar-h: 72px;
  --radius: 22px;
  --tap: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'PT Sans', system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ---------- Кнопки ---------- */

.btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 20px;
  border: 2px solid transparent;
  border-radius: 16px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-primary { background: var(--terra); color: #fff; }
.btn-secondary { background: var(--paper); border-color: var(--terra); color: var(--terra); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-small { width: auto; font-size: 18px; background: var(--paper); border-color: var(--line); }
.btn-right { background: var(--right); color: #fff; }
.btn-wrong { background: var(--wrong); color: #fff; }
.btn:focus-visible, .option:focus-visible, .toggle:focus-visible, .flip:focus-visible {
  outline: 3px solid #1d4ed8; outline-offset: 3px;
}

/* ---------- Стартовый экран ---------- */

.screen-start {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  justify-content: center;
}
.start-head { text-align: center; }
.title {
  margin: 0;
  font-family: 'PT Serif', Georgia, serif;
  font-size: 44px;
  color: var(--terra);
}
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 18px; }

.choice {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 10px;
}
.choice legend {
  padding: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.toggle {
  min-height: var(--tap);
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.toggle-name { display: block; font-size: 20px; font-weight: 700; }
.toggle-hint { display: block; font-size: 16px; color: var(--muted); }
.toggle[aria-pressed="true"] { border-color: var(--ink); background: #efe6d6; box-shadow: inset 0 0 0 1px var(--ink); }
.toggle-culture[aria-pressed="true"] { border-color: var(--terra); background: var(--terra-soft); box-shadow: inset 0 0 0 1px var(--terra); }
.toggle-nature[aria-pressed="true"] { border-color: var(--forest); background: var(--forest-soft); box-shadow: inset 0 0 0 1px var(--forest); }

/* ---------- Игра ---------- */

.screen-play {
  display: flex;
  flex-direction: column;
  padding-top: 0;
}
.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
}
.score { margin: 0; font-size: 20px; font-weight: 700; }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.photo-slot {
  margin: 0;
  flex: 0 0 auto;
  height: 50vh;
  height: 50dvh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
  border: 6px solid var(--paper);
  box-shadow: 0 0 0 1px var(--line);
}
.photo-slot img { flex: 1; min-height: 0; width: 100%; object-fit: cover; display: block; border-radius: 14px; }
.photo-slot figcaption { display: flex; min-width: 0; font-size: 13px; color: var(--muted); padding: 4px 6px 0; white-space: nowrap; }
.cap-author { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cap-license { flex: none; margin-left: 0.3em; }

.card-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Карточка: рамка по категории, двойная линия как у бумажной */
.card { flex: 1; display: flex; min-height: 0; }
.face {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 20px 22px;
  background: var(--paper);
  border: 6px solid var(--cat);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 6px var(--cat-soft), 0 2px 10px rgba(60, 40, 20, 0.08);
  text-align: center;
}
.cat-culture { --cat: var(--terra); --cat-soft: #e3b8a3; }
.cat-nature { --cat: var(--forest); --cat-soft: #a9c4b1; }

.plaque {
  margin: 0;
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--cat);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
}
.ask { margin: 0; font-style: italic; color: var(--muted); font-size: 19px; }
.desc { margin: 0; font-size: 20px; line-height: 1.45; }
.dash { display: block; width: 56px; height: 3px; border-radius: 2px; background: var(--cat); opacity: 0.7; }
.name {
  margin: 0;
  font-family: 'PT Serif', Georgia, serif;
  font-weight: 700;
  font-size: 28px;
  line-height: 1.2;
  color: var(--cat);
}
.region { margin: 0; font-size: 17px; color: var(--muted); }
.num { margin: 0; font-size: 16px; color: var(--muted); font-weight: 700; }

/* «Выбери ответ» */
.options { display: grid; gap: 10px; }
.option {
  min-height: var(--tap);
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.option:disabled { cursor: default; opacity: 1; color: var(--ink); }
.option.right { background: var(--right); border-color: var(--right); color: #fff; }
.option.wrong { background: var(--wrong); border-color: var(--wrong); color: #fff; }

/* «Проверь себя»: переворот карточки */
.flip {
  perspective: 1400px;
  cursor: pointer;
  border-radius: var(--radius);
  touch-action: manipulation;
}
.flip-inner {
  flex: 1;
  display: grid;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}
.flip .face {
  grid-area: 1 / 1;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.flip .face-back { transform: rotateY(180deg); }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip.flipped { cursor: default; }
.hint { margin: 0; text-align: center; color: var(--muted); font-size: 17px; }
.marks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (prefers-reduced-motion: reduce) {
  .flip-inner { transition: none; }
}

/* ---------- Итог ---------- */

.screen-result { display: flex; align-items: center; justify-content: center; }
.result-box {
  width: 100%;
  max-width: 440px;
  display: grid;
  gap: 12px;
  text-align: center;
}
.result-label {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.result-score {
  margin: 0 0 12px;
  font-family: 'PT Serif', Georgia, serif;
  font-weight: 700;
  font-size: 40px;
  color: var(--terra);
}

/* ---------- Авторы фото ---------- */

.link-small {
  justify-self: center;
  align-self: center;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 15px;
  text-decoration: underline;
  cursor: pointer;
}
.screen-credits { max-width: 640px; margin: 0 auto; display: grid; gap: 12px; align-content: start; }
.credits-title { margin: 0; font-family: 'PT Serif', Georgia, serif; font-size: 30px; color: var(--terra); }
.credits-note { margin: 0; color: var(--muted); font-size: 15px; }
.credits-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 15px; line-height: 1.35; }
.credit { padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.credit a { color: var(--terra); }

/* ---------- Повёрнутый телефон: фото слева, карточка стоячая, варианты столбцом рядом — без прокрутки ---------- */

@media (orientation: landscape) {
  :root { --bar-h: 62px; }
  .screen-start { max-width: 760px; display: grid; grid-template-columns: 1fr 1fr; align-content: center; column-gap: 24px; }
  .screen-start .start-head, #btn-start, #btn-credits { grid-column: 1 / -1; }

  .screen-play {
    height: 100vh;
    height: 100dvh;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .stage {
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 12px;
    max-width: none;
  }
  .stage.with-photo .photo-slot { flex: 1 1 0; min-width: 0; height: auto; }

  /* Карточка слева в колонке, варианты или «Верно/Неверно» — столбцом справа от неё */
  .card-col {
    flex: 0 1 550px;
    display: grid;
    grid-template-columns: minmax(0, 240px) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    column-gap: 12px;
    row-gap: 6px;
    align-content: start;
  }
  .card-col > .card { grid-column: 1; grid-row: 1 / -1; min-height: 0; overflow: hidden; }
  .card-col > :not(.card) { grid-column: 2; }

  .face { padding: 10px 12px; gap: 6px; border-width: 5px; }
  .plaque { font-size: 11px; padding: 3px 8px; }
  .ask { font-size: 15px; }
  .desc { font-size: 15px; line-height: 1.35; }
  .name { font-size: 21px; }
  .region { font-size: 14px; }
  .num { font-size: 14px; }

  .options { gap: 6px; }
  .option { padding: 6px 10px; font-size: 15px; line-height: 1.2; }
  .hint { text-align: left; font-size: 15px; }
  .marks { grid-template-columns: 1fr 1fr; gap: 8px; }
  .marks .btn, .btn-next { padding: 8px 12px; }
}
