:root {
  --bg: #0c0d0f;
  --panel: #111214;
  --text-primary: #f2f4f8;
  --text-secondary: rgba(242, 244, 248, 0.78);
  --text-muted: rgba(242, 244, 248, 0.64);
  --accent: #f8634e;
  --font-sans: 'Inter', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg);
  overflow-x: hidden;
}

a,
a:active,
a:visited,
a:hover,
a:focus {
  color: inherit;
  text-decoration: none;
}

.memories-shell {
  position: relative;
  width: min(1260px, calc(100vw - 48px));
  min-height: 100svh;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  container-type: inline-size;
}

.back-link {
  position: fixed;
  top: 34px;
  left: max(24px, calc(50vw - 416px));
  z-index: 3;
  display: inline-flex;
}

.back-link__circle {
  width: 50px;
  height: 50px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.back-link__icon {
  width: 24px;
  height: 24px;
  display: block;
  filter: brightness(0) saturate(100%) invert(100%);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.back-link:focus-visible {
  outline: none;
}

.back-link:hover .back-link__circle,
.back-link:focus-visible .back-link__circle {
  border-color: rgba(242, 244, 248, 0.08);
  box-shadow:
    0 10px 26px rgba(2, 4, 10, 0.42),
    0 2px 8px rgba(2, 4, 10, 0.26);
}

.back-link:hover .back-link__icon,
.back-link:focus-visible .back-link__icon {
  transform: scale(1.08);
}

.memories-stage {
  position: relative;
  width: 100%;
  margin-top: 0;
}

.memories-word {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  margin: 0;
  text-align: center;
  font-size: 200px;
  font-weight: 700;
  line-height: 0.86;
  letter-spacing: -0.038em;
  color: var(--accent);
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
  z-index: 0;
}

.memories-grid {
  position: relative;
  z-index: 1;
  min-height: clamp(560px, 74svh, 760px);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px minmax(0, 1fr);
  column-gap: 52px;
  align-items: center;
}

.memories-panel {
  max-width: 240px;
  padding-bottom: 0;
}

.memories-panel--left {
  justify-self: end;
  align-self: end;
  transform: translateY(-24px);
}

.memories-panel--right {
  justify-self: start;
  align-self: end;
  max-width: 300px;
  transform: translateY(40px);
}

.memories-heading {
  margin: 0 0 20px;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: #ffffff;
}

.memories-meta {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.25;
  font-weight: 400;
  color: var(--text-primary);
}

.memories-meta__label {
  color: var(--accent);
  font-weight: 500;
  margin-right: 0;
}

.case-button {
  margin-top: 26px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  appearance: none;
  background: transparent;
  cursor: pointer;
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.case-button:hover,
.case-button:focus-visible {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

body.case-modal-open {
  overflow: hidden;
}

.case-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 7, 11, 0.7);
  backdrop-filter: blur(8px) saturate(112%);
  -webkit-backdrop-filter: blur(8px) saturate(112%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.case-modal-backdrop.is-open {
  opacity: 1;
}

.case-modal-backdrop[hidden] {
  display: none !important;
}

.case-modal {
  position: relative;
  width: min(440px, 100%);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(160deg, rgba(21, 24, 31, 0.92), rgba(17, 18, 20, 0.94));
  box-shadow:
    0 28px 72px rgba(2, 4, 10, 0.56),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 24px 24px 14px;
  transform: translateY(12px) scale(0.986);
  opacity: 0.96;
  transition: transform 0.24s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.24s ease;
}

.case-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.82;
  transition: opacity 0.18s ease;
}

.case-modal__close:hover,
.case-modal__close:focus-visible {
  opacity: 1;
}

.case-modal__close-icon {
  width: 24px;
  height: 24px;
  display: block;
  filter: brightness(0) saturate(100%) invert(100%);
}

.case-modal-backdrop.is-open .case-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.case-modal__title {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  font-weight: 500;
  color: rgba(242, 244, 248, 0.96);
}

.case-modal__input {
  width: 100%;
  margin-top: 14px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 13, 15, 0.82);
  padding: 0 14px;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.case-modal__input:focus {
  border-color: rgba(242, 244, 248, 0.2);
  box-shadow: 0 0 0 1px rgba(242, 244, 248, 0.08);
  background: rgba(12, 13, 15, 0.94);
}

.case-modal__input::placeholder {
  color: rgba(242, 244, 248, 0.46);
}

.case-modal__input[aria-invalid='true'] {
  border-color: rgba(248, 99, 78, 0.72);
}

.case-modal__error {
  margin: 10px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  color: rgba(248, 99, 78, 0.9);
}

.case-button__lock {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.case-button__lock svg {
  width: 16px;
  height: 16px;
  display: block;
}

.phone-stage-wrap {
  width: 300px;
  grid-column: 2;
  align-self: center;
  justify-self: center;
  opacity: 0;
  transform-origin: 50% 84%;
  animation: phone-stage-enter 960ms cubic-bezier(0.16, 0.88, 0.26, 1) 80ms forwards;
}

.phone-stage {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  --shift-x: 0px;
  --shift-y: 0px;
  --scale: 1;
  --hover-scale: 1;
  --lift: 0px;
  --pointer-x: 50%;
  --pointer-y: 50%;
  position: relative;
  width: 300px;
  border-radius: 36px;
  overflow: hidden;
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  clip-path: inset(0 round 36px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0f1118;
  transform: perspective(1200px) translate3d(var(--shift-x), calc(var(--lift) + var(--shift-y)), 0) rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) scale(calc(var(--scale) * var(--hover-scale)));
  transform-style: preserve-3d;
  transition: transform 0.18s cubic-bezier(0.22, 0.61, 0.36, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow:
    0 20px 40px rgba(2, 4, 10, 0.38),
    0 34px 62px rgba(2, 4, 10, 0.3);
  will-change: transform;
}

.phone-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(260px circle at var(--pointer-x) var(--pointer-y), rgba(188, 212, 255, 0.2) 0%, rgba(112, 145, 232, 0.12) 32%, rgba(16, 20, 31, 0) 70%);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.phone-stage:hover,
.phone-stage:focus-visible {
  --lift: -4px;
  --hover-scale: 1.03;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow:
    0 24px 46px rgba(2, 4, 10, 0.44),
    0 38px 68px rgba(2, 4, 10, 0.34);
}

.phone-stage:hover::before,
.phone-stage:focus-visible::before {
  opacity: 0.62;
}

.phone-video {
  display: block;
  width: 300px;
  height: auto;
  border-radius: inherit;
  transform: translateZ(0);
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}

@keyframes phone-stage-enter {
  0% {
    opacity: 0;
    transform: translateY(88px) rotateZ(2.2deg) scale(0.955);
    filter: blur(12px) saturate(0.82);
  }
  68% {
    opacity: 1;
    transform: translateY(-6px) rotateZ(-0.45deg) scale(1.012);
    filter: blur(0) saturate(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotateZ(0deg) scale(1);
    filter: blur(0) saturate(1);
  }
}

.memories-panel--right {
  color: var(--text-secondary);
}

.memories-panel--right p {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.55;
  font-weight: 400;
}

.memories-panel--right p:last-child {
  margin-bottom: 0;
}

@media (max-width: 1100px) {
  .memories-shell {
    width: calc(100vw - 48px);
    min-height: auto;
    margin: 40px auto 44px;
    display: block;
    padding: 0;
  }

  .back-link {
    position: fixed;
    top: 34px;
    left: max(24px, calc(50vw - 416px));
    margin-left: 0;
    margin-bottom: 0;
  }

  .memories-word {
    top: 36%;
    font-size: clamp(108px, 20vw, 180px);
  }

  .memories-grid {
    min-height: auto;
    padding: 24px 0 0;
    grid-template-columns: minmax(0, 1fr);
    justify-content: center;
    justify-items: stretch;
    row-gap: 0;
  }

  .memories-panel {
    max-width: none;
    width: 100%;
    padding-bottom: 0;
  }

  .memories-panel--left {
    display: contents;
  }

  .memories-panel--left .memories-heading {
    order: 2;
    grid-column: 1;
    justify-self: stretch;
    margin-top: 40px;
  }

  .memories-panel--left .memories-meta {
    order: 3;
    grid-column: 1;
    justify-self: stretch;
  }

  .memories-panel--left .case-button {
    order: 5;
    grid-column: 1;
    justify-self: start;
    margin-top: 24px;
  }

  .phone-stage-wrap {
    order: 1;
    grid-column: 1;
    justify-self: center;
    margin-inline: auto;
  }

  .memories-panel--right {
    order: 4;
    transform: none;
    grid-column: 1;
    justify-self: stretch;
    max-width: none;
    width: 100%;
    margin-top: 12px;
  }

  .memories-panel--right p {
    line-height: 1.72;
  }

  .memories-heading {
    font-size: 24px;
  }

  .memories-meta {
    font-size: 12px;
  }
}

@media (max-width: 1100px) and (min-width: 821px) {
  .memories-panel--left .memories-heading,
  .memories-panel--left .memories-meta,
  .memories-panel--right {
    padding-left: 40px;
    padding-right: 40px;
  }

  .memories-panel--left .case-button {
    margin-left: 40px;
  }
}

@media (max-width: 820px) {
  .memories-shell {
    width: calc(100vw - 28px);
    margin: 40px auto 44px;
    padding: 0;
  }

  .back-link {
    margin-left: 0;
  }

  .back-link__circle {
    width: 50px;
    height: 50px;
  }

  .back-link__icon {
    width: 24px;
    height: 24px;
  }

  .memories-word {
    display: none;
  }

  .memories-grid {
    row-gap: 0;
  }

  .memories-panel--left .memories-heading,
  .memories-panel--left .memories-meta,
  .memories-panel--right {
    padding-left: 24px;
    padding-right: 24px;
  }

  .memories-panel--left .case-button {
    margin-left: 24px;
  }

  .memories-heading {
    font-size: 24px;
  }

  .memories-meta {
    font-size: 12px;
  }

  .phone-stage-wrap,
  .phone-stage,
  .phone-video {
    width: min(300px, 100%);
  }

}

@media (prefers-reduced-motion: reduce) {
  .back-link__circle,
  .back-link__icon,
  .phone-stage,
  .case-modal-backdrop,
  .case-modal {
    transition: none;
  }

  .back-link__icon {
    transform: none;
  }

  .phone-stage-wrap {
    animation: none;
    opacity: 1;
    transform: none;
    filter: none;
  }

  .phone-stage {
    transform: none;
  }
}
