@font-face {
  font-family: 'Monotype Corsiva';
  src: url('fonts/Monotype-Corsiva-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}

:root {
  --test-red: #840306;
  --test-paper: #fbf8f0;
  --map-width: 1920px;
}

body.test-page {
  overflow-x: hidden;
  background: #1a1818;
}

.test-page-container {
  background-color: var(--test-paper);
  background-image: url('images/test/test_background_pattern_none_blend.svg');
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
  background-blend-mode: overlay;
}

.test-page .main-header {
  position: sticky;
}

.test-map {
  position: relative;
  isolation: isolate;
  min-width: 1900px;
  width: auto !important;
  aspect-ratio: 33 / 83 !important;
  margin: -100px auto 0 auto !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  overflow: visible;
  background-image: url('images/test/background_map.webp');
  background-repeat: no-repeat;
  background-position: center top;
  background-size: 100% 100%;
}

.test-intro {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 50%;
  width: 1000px;
  height: 847px;
  padding-top: 199px;
  text-align: center;
  color: var(--test-red);
  transform: translateX(-50%);
  pointer-events: none;
}

.test-intro h1 {
  margin: 0 0 7px;
  color: #000;
  font-family: var(--font-serif);
  font-size: 38px;
  font-weight: 400;
  line-height: 44px;
  letter-spacing: .074px;
}

.test-intro p {
  margin: 0 0 16px;
  font-family: 'Monotype Corsiva', cursive;
  font-size: 25px;
  font-weight: 400;
  line-height: 28px;
}

.question-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.question-card {
  position: absolute;
  width: 511px;
  min-height: 184px;
  padding: 30px 62px 25px;
  overflow: visible;
  border: 0;
  border-radius: 42px;
  background: rgba(255, 250, 239, 0.73);
  box-shadow: 0px 10px 7px rgba(183, 166, 165, 0.28);
  backdrop-filter: blur(6.5px);
  opacity: 0;
  transform: translateY(42px) scale(.94);
  transform-origin: center;
}

.question-card.is-visible {
  animation: question-arrive .72s cubic-bezier(.22, .9, .32, 1.15) forwards;
}

.question-card.is-answered {
  opacity: .55;
  filter: saturate(.72);
}

.question-title {
  margin: 0 0 13px;
  color: var(--test-red);
  font-family: var(--font-serif);
  font-size: 27.3px;
  font-weight: 400;
  line-height: 32px;
  text-align: center;
  text-transform: uppercase;
}

.answer-list {
  display: grid;
  gap: 3px;
}

.test-answer {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 24px;
  padding: 0;
  overflow: visible;
  color: #000;
  font-family: 'Monotype Corsiva', cursive;
  font-size: 21.8px;
  font-weight: 400;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  border: 0;
  background: transparent;
  transition: color .18s ease, transform .18s ease;
  user-select: none;
}

.test-answer:hover:not(:disabled),
.test-answer:focus-visible {
  color: var(--test-red);
  outline: none;
  transform: scale(1.025);
}

.test-answer:focus-visible::after {
  position: absolute;
  inset: -4px -8px;
  border: 1px solid var(--test-red);
  border-radius: 12px;
  content: '';
}

.test-answer:disabled {
  cursor: default;
}

.decor {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 12px;
}

.svg-arrow {
  width: 6px;
  height: 6px;
  position: absolute;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
}

.decor.left .svg-arrow {
  left: 0;
}

.decor.right .svg-arrow {
  right: 0;
}

.svg-line {
  position: absolute;
  width: 20px;
  height: 1px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  transition: width 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.decor.left .svg-line {
  left: 5px;
}

.decor.right .svg-line {
  right: 5px;
}

.test-answer:hover:not(:disabled) .svg-line,
.test-answer.is-selected .svg-line {
  width: calc(100% - 7px);
}

.answer-burst {
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 15px;
  opacity: 0;
  color: var(--test-red);
  transform: translate(-50%, -50%);
}

.answer-burst::before,
.answer-burst::after {
  position: absolute;
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1;
  content: '✦';
}

.answer-burst::before {
  left: -50px;
  top: -5px;
}

.answer-burst::after {
  right: -50px;
  bottom: -5px;
}

.test-answer.is-selected {
  color: var(--test-red);
}

.test-answer.is-selected .answer-burst {
  animation: burst .56s ease-out both;
}

.altar {
  position: absolute;
  z-index: 3;
  top: 84.4176%;
  /* 3841px / 4550px */
  left: 50%;
  width: 42.302%;
  height: auto;
  transform: translateX(-50%);
  pointer-events: none;
}

.result-card {
  position: absolute;
  z-index: 5;
  top: 72.3297%;
  /* 3200px / 4550px (50px closer to the altar) */
  left: 50%;
  width: 16.7188%;
  /* 321px / 1920px */
  height: 11.1648%;
  /* 508px / 4550px */
  visibility: hidden;
  transform: translateX(-50%);
  transform-origin: center center;
  will-change: transform, opacity;
  cursor: pointer;
}

.result-card.is-visible {
  visibility: visible;
  animation: card-rise var(--card-rise-duration, 1.2s) cubic-bezier(.2, .85, .2, 1) forwards;
}

.card-scene {
  width: 100%;
  height: 100%;
  perspective: 1200px;
  transform-style: preserve-3d;
  transition: transform 0.15s ease-out;
  will-change: transform;
}

/* Эффект глянцевого блика (glare) при наклоне карты */
.card-scene::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 10;
  border-radius: 24px;
  background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
      rgba(255, 255, 255, 0.22) 0%,
      rgba(255, 255, 255, 0) 55%);
  pointer-events: none;
  mix-blend-mode: overlay;
  opacity: 0;
  transition: opacity 0.3s ease;
  transform: translateZ(1px);
  /* Держит блик поверх лица/рубашки в 3D пространстве */
}

.result-card.is-visible:hover .card-scene::after {
  opacity: 1;
}

.card-flip {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--card-flip-duration, 1s) cubic-bezier(.2, .85, .2, 1);
}

.result-card.is-flipped .card-flip {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /*box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4), 0 10px 20px rgba(0, 0, 0, 0.2);*/
  border-radius: 24px;
}

.card-face--back {
  transform: rotateY(180deg);
}

.test-page .main-footer {
  margin-top: 150px;
  /* Spacing of 150px below map boundary, leaving ~83px clear under the altar */
}

/* Кнопка "Еще разок" над картой */
.restart-btn {
  display: flex;
  flex-direction: column-reverse;
  /* компенсирует переворот flex-элементов из-за scaleY(-1) */
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 266px;
  height: 90px;
  background: rgba(251, 248, 240, 0.91);
  border: 1px solid #BCB26B;
  box-shadow: 0px 10px 7px rgba(183, 166, 165, 0.28);
  cursor: pointer;

  position: absolute;
  top: -150px;

  /* Находится прямо над карточкой */
  left: 50%;
  transform: translate(-50%, -10px) matrix(1, 0, 0, -1, 0, 0);
  opacity: 0;
  visibility: hidden;
  transition: transform var(--restart-btn-duration, 0.4s) cubic-bezier(0.25, 1, 0.5, 1), background 0.3s ease, opacity var(--restart-btn-duration, 0.4s) ease, visibility var(--restart-btn-duration, 0.4s) ease;
  z-index: 10;
  border-radius: 30px;
}

.restart-btn.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) matrix(1, 0, 0, -1, 0, 0);
}

.restart-btn:hover {
  background: rgba(250, 222, 222, 1);
  transform: translate(-50%, -2px) scale(1.03) matrix(1, 0, 0, -1, 0, 0);
}

/* Кнопочка (становится серой при блокировке) */
.restart-btn.is-locked {
  background: rgba(204, 204, 204, 0.91) !important;
  border: 1px solid #696767 !important;
  box-shadow: 0px 10px 7px rgba(183, 166, 165, 0.28) !important;
  cursor: not-allowed;
  pointer-events: none;
}

/* таймер над кнопкой 24 часа */
.restart-timer {
  position: absolute;
  top: -202px;
  /* на 16px выше кнопки (верх кнопки -150px - 16px - высота текста 36px = -202px) */
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Oranienbaum', serif;
  font-style: normal;
  font-weight: 400;
  font-size: 31.2px;
  line-height: 36px;
  letter-spacing: 0.0078125em;
  color: #840306;
  z-index: 10;
  text-align: center;
  white-space: nowrap;
}

.restart-text,
.restart-attempts {
  transform: matrix(1, 0, 0, -1, 0, 0);
}

.restart-text {
  font-family: var(--font-serif), 'Oranienbaum', serif;
  font-weight: 400;
  font-size: 31.2px;
  line-height: 37px;
  letter-spacing: 0.0078125em;
  color: #840306;
}

.restart-attempts {
  font-family: var(--font-serif), 'Oranienbaum', serif;
  font-weight: 400;
  font-size: 22.9582px;
  line-height: 28px;
  color: #840306;
}

/* Эффект свечения/вспышки при призыве карты */
.card-glow-effect {
  position: absolute;
  inset: -30px;
  z-index: 6;
  background: radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(255, 235, 180, 0.8) 40%, rgba(255, 255, 255, 0) 70%);
  mix-blend-mode: color-dodge;
  opacity: 0;
  pointer-events: none;
  border-radius: 42px;
}

.card-glow-effect.flash {
  animation: card-flash 0.8s ease-out;
}

@keyframes card-flash {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }

  30% {
    opacity: 1;
    transform: scale(1.3);
  }

  100% {
    opacity: 0;
    transform: scale(1);
  }
}

.orientation-notice {
  display: none;
}

@keyframes question-arrive {
  0% {
    opacity: 0;
    transform: translateY(42px) scale(.94);
  }

  66% {
    opacity: 1;
    transform: translateY(-7px) scale(1.012);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes arrow-left {
  0% {
    transform: translateX(0);
  }

  55% {
    transform: translateX(-30px) scaleX(1.35);
  }

  100% {
    transform: translateX(-12px) scaleX(1.05);
  }
}

@keyframes arrow-right {
  0% {
    transform: scaleX(-1) translateX(0);
  }

  55% {
    transform: scaleX(-1) translateX(-30px) scaleX(1.35);
  }

  100% {
    transform: scaleX(-1) translateX(-12px) scaleX(1.05);
  }
}

@keyframes burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(.2) rotate(-20deg);
  }

  45% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.35) rotate(12deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.9) rotate(24deg);
  }
}

@keyframes card-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, 775px) scale(0) rotate(0deg);
  }

  75% {
    opacity: 1;
    transform: translate(-50%, -20px) scale(1.08) rotate(720deg);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1) rotate(720deg);
  }
}

/* Tablet Layout (Fixed centered width, no stretching/diagonal scaling on resize) */
@media (min-width: 901px) and (max-width: 1365px) {
  .test-map {
    width: 1200px !important;
    aspect-ratio: 33 / 83 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    margin: -100px auto 0 auto !important;
  }
}

@media (max-width: 900px) {

  body.test-page {
    min-width: 100%;
  }

  .orientation-notice {
    display: none !important;
  }

  .test-page-container {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    transform: none !important;
    background-size: cover;
  }

  .test-page .main-header {
    min-width: 0 !important;
    width: 100% !important;
  }

  .test-map {
    min-width: 0 !important;
    width: 100% !important;
    aspect-ratio: auto !important;
    min-height: 2716px !important;
    /* 360px * 3.0 * (83 / 33) */
    background-size: 1193px auto !important;
    background-position: center top !important;
    /* margin-top: -90px !important;*/
  }

  .test-intro {
    position: absolute !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 100% !important;
    max-width: 600px !important;
    height: auto !important;
    padding-top: 120px !important;
    box-sizing: border-box !important;
  }

  .test-intro h1 {
    font-size: 24px !important;
    line-height: 28px !important;
    margin: 0 auto 10px !important;
  }

  .test-intro p {
    font-size: 16px !important;
    line-height: 20px !important;
    margin: 0 auto 12px !important;
  }

  .question-card {
    width: calc(100% - 32px) !important;
    max-width: 440px !important;
    left: 0 !important;
    right: 0 !important;
    margin: 0 auto !important;
    min-height: auto !important;
    padding: 20px 24px 18px !important;
    border-radius: 28px !important;
  }

  .question-title {
    font-size: 18px !important;
    line-height: 22px !important;
    margin-bottom: 12px !important;
  }

  .answer-list {
    gap: 2px !important
  }

  .test-answer {
    font-size: 16px !important;
    line-height: 18px !important;
    min-height: 24px !important;
    gap: 8px !important;
  }

  .decor {
    height: 8px !important;
  }

  .svg-arrow {
    width: 5px !important;
    height: 5px !important;
  }

  .altar {
    width: 100% !important;
    max-width: 450px;
    top: 84.4176% !important;
  }

  .result-card {
    width: 50% !important;
    max-width: 200px !important;
    height: auto !important;
    aspect-ratio: 321 / 508 !important;
    top: 72.3297% !important;
  }

  /* Adjust restart button and timer above card */
  .restart-btn {
    width: 190px !important;
    height: 60px !important;
    top: -90px !important;
    border-radius: 20px !important;
  }

  .restart-text {
    font-size: 20px !important;
    line-height: 24px !important;
  }

  .restart-attempts {
    font-size: 14px !important;
    line-height: 16px !important;
  }

  .restart-timer {
    top: -125px !important;
    font-size: 20px !important;
    line-height: 24px !important;
  }

  /* Footer Adaptation for Mobile */
  .test-page .main-footer {
    min-width: 0 !important;
    height: auto !important;
    margin-top: 0px !important;
    padding-top: 80px !important;
    padding-bottom: 80px !important;
    position: relative !important;
  }

  .test-page .footer-bg-container {
    display: block !important;
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 1 !important;
  }

  .test-page .footer-bg-svg {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  .test-page .footer-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: auto !important;
    padding-top: 0 !important;
    margin: 0 auto !important;
    gap: 35px !important;
    position: relative !important;
    z-index: 2 !important;
  }

  .test-page .footer-col {
    margin-left: 0 !important;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    position: relative !important;
    transform-origin: center center !important;
  }

  .test-page .music-col {
    width: 278.6px !important;
    height: 182px !important;
  }

  .test-page .contacts-col {
    width: 443.8px !important;
    height: 182px !important;
  }

  .test-page .menu-col {
    width: 223.4px !important;
    height: 182px !important;
  }

  .test-page .col-frame-svg {
    display: block !important;
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: fill !important;
    z-index: 1 !important;
  }

  .test-page .col-content {
    padding: 65px 12px 8px 12px !important;
  }

  .test-page .music-col .col-content {
    padding: 65px 35.6px 8px 54px !important;
  }

  .test-page .contacts-col .col-content {
    padding: 65px 72.8px 8px 49px !important;
  }

  .test-page .menu-col .col-content {
    padding: 65px 54.4px 8px 39px !important;
  }

  .test-page .col-title {
    position: absolute !important;
    font-family: var(--font-cursive) !important;
    font-size: 25px !important;
    line-height: 28px !important;
    color: var(--color-text-dark) !important;
    font-style: italic !important;
    font-weight: normal !important;
    text-align: center !important;
    letter-spacing: 1px !important;
  }

  .test-page .music-col .col-title {
    top: 6px !important;
    left: 146.9px !important;
    transform: translateX(-50%) !important;
  }

  .test-page .menu-col .col-title {
    top: 6px !important;
    left: 103.7px !important;
    transform: translateX(-50%) !important;
  }

  .test-page .col-headers-double {
    position: absolute !important;
    top: 6px !important;
    left: 0 !important;
    width: 100% !important;
    height: 28px !important;
    display: block !important;
  }

  .test-page .contacts-col .col-title {
    top: 0 !important;
  }

  .test-page .contacts-col .col-title:first-child {
    left: 134.1px !important;
  }

  .test-page .contacts-col .col-title:last-child {
    left: 284px !important;
  }

  .test-page .col-links-double {
    display: grid !important;
    gap: 20px !important;
  }

  .test-page .music-links-grid {
    grid-template-columns: 78px 1fr !important;
    gap: 28px !important;
  }

  .test-page .contacts-links-grid {
    grid-template-columns: 106px 100px 1fr !important;
    gap: 0 !important;
  }

  .test-page .sub-col {
    display: flex !important;
    flex-direction: column !important;
    gap: 9px !important;
  }

  .test-page .footer-link {
    font-size: 13.6px !important;
    line-height: 14px !important;
    font-family: var(--font-cursive) !important;
    color: var(--color-text-cream) !important;
  }

  .test-page .footer-link.email-link,
  .test-page .footer-link.href {
    font-family: var(--font-serif) !important;
    font-size: 12.6px !important;
    line-height: 15px !important;
  }

  /* Responsive scaling for narrower screens */
  @media (max-width: 480px) {
    .test-page .contacts-col {
      transform: scale(0.8) !important;
      margin-top: -18px !important;
      margin-bottom: -18px !important;
    }
  }

  @media (max-width: 380px) {
    .test-page .contacts-col {
      transform: scale(0.7) !important;
      margin-top: -27px !important;
      margin-bottom: -27px !important;
    }

    .test-page .music-col {
      transform: scale(0.9) !important;
      margin-top: -9px !important;
      margin-bottom: -9px !important;
    }
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}