:root {
  --floor: #2a3142;
  --floor-deep: #1e2433;
  --purple: #7b4fb8;
  --purple-deep: #5c3590;
  --cream: #f0e6d4;
  --ink-soft: rgba(240, 230, 212, 0.88);
  --font: "Raleway", system-ui, sans-serif;
  --window: min(38vh, 360px);
  --kegel: calc(var(--window) * 0.175);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  height: 100dvh;
  font-family: var(--font);
  font-weight: 400;
  background: var(--floor-deep);
  color: var(--cream);
  overflow: hidden;
  touch-action: manipulation;
}

body.is-modal-open {
  overflow: hidden;
}

.scene {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.scene__floor {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 55% at 50% 38%, rgba(50, 58, 78, 0.95), transparent 60%),
    linear-gradient(165deg, #343b50 0%, var(--floor) 42%, var(--floor-deep) 100%);
}

.grain {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 6;
  opacity: 0.22;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

/* —— Hero: title + window —— */
.hero {
  position: relative;
  z-index: 8;
  margin-top: 8vh;
  transform: translateY(-20%);
  animation: stageIn 1s cubic-bezier(0.22, 0.8, 0.28, 1) both;
}

@keyframes stageIn {
  from {
    opacity: 0;
    transform: translateY(calc(-20% + 14px));
  }
  to {
    opacity: 1;
    transform: translateY(-20%);
  }
}

.brand {
  margin: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  font-weight: 800;
}

.brand__left {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex-shrink: 0;
  z-index: 1;
  /* оптический стык правой грани «7» с окном */
  margin-right: -0.045em;
}

.brand__sixty-seven {
  display: block;
  height: var(--window);
  font-family: var(--font);
  font-weight: 800;
  font-size: calc(var(--window) * 0.96);
  line-height: 0.92;
  letter-spacing: -0.06em;
  color: var(--purple);
  opacity: 0.55;
  text-shadow:
    0 6px 0 rgba(92, 53, 144, 0.22),
    0 22px 56px rgba(92, 53, 144, 0.38);
  animation: purpleGlow 5s ease-in-out infinite;
  /* правая грань 7 встык с окном */
  margin: 0;
  padding: 0;
}

.brand__steps {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 0.08em;
  font-family: var(--font);
  font-weight: 800;
  font-size: var(--kegel);
  line-height: 1;
  letter-spacing: 0;
  color: var(--purple);
  opacity: 0.55;
  text-shadow: 0 10px 28px rgba(92, 53, 144, 0.3);
}

.brand__steps span {
  display: block;
}

.brand__right {
  display: block;
  align-self: center;
  margin-left: 0.55em;
  font-family: var(--font);
  font-weight: 800;
  font-size: var(--kegel);
  line-height: 1.2;
  color: var(--purple);
  opacity: 0.55;
  text-shadow: 0 10px 28px rgba(92, 53, 144, 0.3);
  white-space: nowrap;
  z-index: 1;
}

@keyframes purpleGlow {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.08);
  }
}

/* —— Window —— */
.window {
  position: relative;
  display: block;
  width: var(--window);
  height: var(--window);
  flex-shrink: 0;
  z-index: 2;
}

.scene__window-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 110%;
  height: 110%;
  z-index: 0;
  background: radial-gradient(
    ellipse 55% 45% at 50% 45%,
    rgba(212, 200, 224, 0.24),
    rgba(212, 200, 224, 0.07) 45%,
    transparent 70%
  );
  pointer-events: none;
  animation: glowPulse 7s ease-in-out infinite;
}

@keyframes glowPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.82;
  }
}

.scene__light {
  position: absolute;
  inset: 6%;
  z-index: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  transform: perspective(900px) rotateX(52deg) rotateZ(-3deg) skewX(-3deg);
  transform-origin: center center;
  opacity: 0.92;
  pointer-events: none;
  filter: blur(0.3px);
  animation: lightBreathe 8s ease-in-out infinite;
}

@keyframes lightBreathe {
  0%,
  100% {
    opacity: 0.88;
    filter: blur(0.3px) brightness(1);
  }
  50% {
    opacity: 1;
    filter: blur(0.2px) brightness(1.06);
  }
}

.scene__pane {
  display: block;
  background: linear-gradient(
    145deg,
    rgba(232, 223, 208, 0.55) 0%,
    rgba(212, 200, 224, 0.42) 40%,
    rgba(196, 184, 214, 0.28) 100%
  );
  box-shadow:
    inset 0 0 40px rgba(255, 255, 255, 0.12),
    0 0 60px rgba(212, 200, 224, 0.15);
}

.mom-shadow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 92%;
  height: auto;
  z-index: 2;
  transform: translate(-50%, -50%);
  transform-origin: 50% 80%;
  pointer-events: none;
  animation: shadowSway 9s ease-in-out infinite;
  mix-blend-mode: multiply;
  opacity: 0.92;
}

.mom-shadow__rag {
  transform-origin: 340px 100px;
  animation: ragFlutter 4.2s ease-in-out infinite;
}

@keyframes shadowSway {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  50% {
    transform: translate(calc(-50% + 5px), -50%) rotate(0.55deg);
  }
}

@keyframes ragFlutter {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(3deg) translate(2px, -2px);
  }
}

/* —— Menu dock (bottom center) —— */
.dock {
  position: absolute;
  left: 50%;
  bottom: 6vh;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(92vw, 520px);
  animation: menuIn 1.1s 0.12s cubic-bezier(0.22, 0.8, 0.28, 1) both;
}

.dock:has(.levels:not([hidden])),
.dock.is-levels {
  width: min(96vw, 1180px);
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%);
  }
}

.menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

.menu[hidden] {
  display: none !important;
}

.menu__item {
  font-family: var(--font);
  font-style: normal;
  font-weight: 700;
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
  color: var(--ink-soft);
  text-decoration: none;
  letter-spacing: 0.03em;
  padding: 0.15em 0;
  border: none;
  background: none;
  cursor: pointer;
  transition:
    color 0.25s ease,
    transform 0.25s ease,
    text-shadow 0.25s ease;
  position: relative;
  text-align: center;
}

.menu__item::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.05em;
  height: 1px;
  background: currentColor;
  opacity: 0;
  transform: scaleX(0.4);
  transform-origin: center;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}

.menu__item:hover,
.menu__item:focus-visible,
.menu__item.is-hot {
  color: #fff;
  transform: translateY(-2px);
  text-shadow: 0 0 24px rgba(212, 200, 224, 0.35);
  outline: none;
}

.menu__item:hover::after,
.menu__item:focus-visible::after,
.menu__item.is-hot::after {
  opacity: 0.45;
  transform: scaleX(1);
}

/* —— Levels carousel —— */
.levels {
  width: 100%;
  animation: levelsIn 0.45s cubic-bezier(0.22, 0.8, 0.28, 1) both;
}

.levels[hidden] {
  display: none !important;
}

@keyframes levelsIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.levels__head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
  position: relative;
}

.levels__title {
  margin: 0;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: var(--cream);
}

.levels__back {
  position: absolute;
  left: 0;
  border: none;
  background: none;
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  transition: color 0.2s ease, transform 0.2s ease;
}

.levels__back:hover,
.levels__back:focus-visible {
  color: #fff;
  transform: translateX(-3px);
  outline: none;
}

.levels__carousel {
  display: flex;
  gap: 0.85rem;
  overflow-x: auto;
  overflow-y: visible;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 0.85rem 0.35rem 1.1rem;
  margin: -0.35rem;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 200, 224, 0.35) transparent;
  touch-action: pan-x;
  justify-content: flex-start;
}

.levels__carousel:active {
  cursor: grabbing;
}

.levels__carousel::-webkit-scrollbar {
  height: 4px;
}

.levels__carousel::-webkit-scrollbar-thumb {
  background: rgba(212, 200, 224, 0.35);
  border-radius: 999px;
}

.level-card {
  flex: 0 0 auto;
  width: 132px;
  text-decoration: none;
  color: inherit;
  scroll-snap-align: start;
  display: block;
  transition: transform 0.25s cubic-bezier(0.22, 0.8, 0.28, 1);
  transform-origin: center center;
  cursor: pointer;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.level-card:hover,
.level-card:focus-visible {
  transform: scale(1.08);
  outline: none;
  z-index: 2;
}

.level-card__preview {
  display: block;
  width: 132px;
  height: 132px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

/* —— Settings popup —— */
.settings {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.settings[hidden] {
  display: none !important;
}

.settings__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 22, 32, 0.55);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.25s ease;
}

.settings__card {
  position: relative;
  z-index: 1;
  max-width: 340px;
  width: 100%;
  padding: 28px 26px 24px;
  background: linear-gradient(165deg, #3a4258 0%, #2a3142 100%);
  border: 1px solid rgba(212, 200, 224, 0.14);
  border-radius: 6px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.4);
  animation: popIn 0.35s cubic-bezier(0.22, 0.8, 0.28, 1);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.settings__close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(240, 230, 212, 0.55);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font);
}

.settings__close:hover,
.settings__close:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.settings__text {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--cream);
  text-align: center;
  padding: 0 8px;
}

.version {
  position: absolute;
  left: 5%;
  bottom: 3%;
  z-index: 8;
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: rgba(240, 230, 212, 0.35);
}

@media (max-width: 720px) {
  :root {
    --window: min(24vh, 200px);
  }

  .hero {
    margin-top: max(6vh, env(safe-area-inset-top, 0px));
    width: 100%;
    padding: 0 12px;
  }

  .brand {
    flex-wrap: wrap;
    justify-content: center;
  }

  .brand__right {
    width: 100%;
    margin: 0.6em 0 0;
    text-align: center;
  }

  .dock {
    bottom: max(3vh, env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    width: min(96vw, 520px);
  }

  .dock.is-levels,
  .dock:has(.levels:not([hidden])) {
    width: min(96vw, 1180px);
  }

  .level-card {
    width: 104px;
  }

  .level-card__preview {
    width: 104px;
    height: 104px;
  }

  .levels__carousel {
    padding: 0.6rem 0.25rem 0.9rem;
    gap: 0.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scene__window-glow,
  .scene__light,
  .mom-shadow,
  .mom-shadow__rag,
  .brand__sixty-seven,
  .hero,
  .dock,
  .levels,
  .settings__backdrop,
  .settings__card {
    animation: none !important;
  }

  .hero {
    transform: translateY(-20%);
  }

  .level-card {
    transition: none;
  }
}
