:root {
  color-scheme: light;
  --background: #f7f2e8;
  --background-deep: #eee5d7;
  --paper: #f4dfa0;
  --paper-light: #f8e9b8;
  --ink: #1b1a18;
  --ink-soft: #5c5750;
  --line: rgba(27, 26, 24, 0.18);
  --shadow-soft: 0 18px 55px rgba(64, 52, 37, 0.11);
  --shadow-paper: 0 22px 45px rgba(69, 55, 32, 0.18);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 4%, rgba(255, 255, 255, 0.9), transparent 30%),
    radial-gradient(circle at 92% 85%, rgba(232, 219, 199, 0.55), transparent 32%),
    var(--background);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.background-hearts {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.background-hearts span {
  position: absolute;
  top: var(--y);
  left: var(--x);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--size);
  line-height: 1;
  opacity: 0.11;
  animation: background-float var(--duration) ease-in-out var(--delay) infinite;
}

.screen {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  padding:
    max(1.25rem, env(safe-area-inset-top))
    max(1.1rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom))
    max(1.1rem, env(safe-area-inset-left));
}

.lock-screen {
  display: grid;
  place-items: center;
  transition: opacity 650ms ease, transform 650ms ease;
}

.lock-screen.is-leaving {
  opacity: 0;
  transform: scale(1.015);
  pointer-events: none;
}

.lock-card {
  width: min(100%, 29rem);
  padding: clamp(2rem, 8vw, 3.5rem) clamp(1.4rem, 7vw, 3rem);
  text-align: center;
  background: rgba(255, 253, 248, 0.6);
  border: 1px solid rgba(27, 26, 24, 0.08);
  border-radius: 1.25rem;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(6px);
}

.hero-heart,
.small-heart {
  color: #111;
  font-family: var(--serif);
  line-height: 1;
}

.hero-heart {
  margin-bottom: 1.35rem;
  font-size: 3rem;
  animation: gentle-heartbeat 2.8s ease-in-out infinite;
}

.small-heart {
  margin-bottom: 1.25rem;
  font-size: 2.15rem;
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.19em;
  line-height: 1.4;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1,
h2 {
  font-family: var(--serif);
  font-weight: 400;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 9vw, 3.45rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.lock-help {
  max-width: 22rem;
  margin: 1.15rem auto 1.8rem;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.7;
}

.unlock-form {
  display: grid;
  gap: 0.9rem;
}

.unlock-form label {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

#code-input {
  width: min(100%, 14rem);
  min-height: 3.7rem;
  margin: 0 auto;
  padding: 0.75rem 1.1rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(27, 26, 24, 0.25);
  border-radius: 0.8rem;
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: 0.7em;
  line-height: 1;
  text-align: center;
  text-indent: 0.7em;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

#code-input:hover {
  border-color: rgba(27, 26, 24, 0.5);
}

#code-input[aria-invalid="true"] {
  border-color: #59413f;
}

#code-input.is-shaking {
  animation: shake 420ms ease;
}

.primary-button {
  width: min(100%, 14rem);
  min-height: 3.35rem;
  margin: 0 auto;
  padding: 0.8rem 1.4rem;
  color: #fffdf8;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 9px 22px rgba(27, 26, 24, 0.14);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  transition: transform 180ms ease, background-color 180ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  background: #000;
}

.primary-button:active {
  transform: translateY(0);
}

.primary-button.is-success {
  width: 3.35rem;
  padding-inline: 0;
  background: #111;
  border-radius: 50%;
  font-size: 1.15rem;
  animation: confirm-pop 460ms ease both;
}

.primary-button:disabled {
  cursor: default;
}

.form-message {
  min-height: 1.35rem;
  margin: 0.95rem 0 0;
  color: #4d3432;
  font-size: 0.86rem;
  font-weight: 650;
}

.main-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.state-panel,
.daily-experience {
  width: min(100%, 45rem);
}

.before-start {
  display: grid;
  place-items: center;
  flex: 1;
  align-content: center;
  padding: 3rem 0 5rem;
  text-align: center;
  animation: content-enter 700ms ease both;
}

.before-start h1 {
  max-width: 36rem;
}

.countdown-intro {
  margin: 1.1rem 0 1.75rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.countdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.35rem, 2.4vw, 0.8rem);
  width: min(100%, 27rem);
}

.countdown-unit {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
  padding: 0.85rem 0.2rem 0.75rem;
  background: rgba(255, 253, 248, 0.66);
  border: 1px solid rgba(27, 26, 24, 0.09);
  border-radius: 0.75rem;
  box-shadow: 0 9px 25px rgba(64, 52, 37, 0.07);
}

.countdown-unit strong {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 6vw, 1.85rem);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}

.countdown-unit span {
  color: var(--ink-soft);
  font-size: clamp(0.58rem, 2.5vw, 0.7rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.daily-experience {
  flex: 1;
  padding: 2rem 0 4rem;
  animation: content-enter 700ms ease both;
}

.daily-header {
  margin: 0 auto 2.2rem;
  text-align: center;
}

.daily-header h1 {
  font-size: clamp(2.2rem, 10vw, 4.25rem);
}

.current-date {
  margin: 0.9rem 0 1rem;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 1.04rem;
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  width: min(100%, 20rem);
  margin: 0 auto;
}

.day-progress {
  flex: 0 0 auto;
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.progress-line {
  position: relative;
  flex: 1;
  height: 2px;
  overflow: hidden;
  background: rgba(27, 26, 24, 0.14);
  border-radius: 999px;
}

.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress, 12.5%);
  background: var(--ink);
  border-radius: inherit;
  transition: width 500ms ease;
}

.note-stage {
  display: grid;
  place-items: start center;
  width: 100%;
  min-height: 19rem;
  perspective: 1000px;
}

.closed-note {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 22rem);
  min-height: 17rem;
  padding: 4rem clamp(1.3rem, 7vw, 2.6rem) 2rem;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.18), transparent 40%),
    var(--paper);
  border: 1px solid rgba(64, 52, 37, 0.14);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-paper);
  cursor: pointer;
  transform: rotate(-1.5deg);
  transform-style: preserve-3d;
  transition: transform 300ms ease, box-shadow 300ms ease;
}

.closed-note:hover {
  box-shadow: 0 26px 52px rgba(69, 55, 32, 0.22);
  transform: rotate(0.4deg) scale(1.018);
}

.closed-note:active {
  transform: rotate(0deg) scale(0.99);
}

.closed-note.is-opening {
  animation: note-close-to-open 760ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  pointer-events: none;
}

.fold {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.fold-left {
  background: linear-gradient(
    35deg,
    rgba(210, 183, 106, 0.34) 0 49.5%,
    transparent 50%
  );
  clip-path: polygon(0 0, 53% 50%, 0 100%);
}

.fold-right {
  background: linear-gradient(
    -35deg,
    rgba(255, 242, 195, 0.72) 0 49.5%,
    transparent 50%
  );
  clip-path: polygon(100% 0, 47% 50%, 100% 100%);
}

.closed-note-heart,
.closed-note-prompt {
  position: relative;
  z-index: 1;
}

.closed-note-heart {
  align-self: end;
  margin-bottom: 1rem;
  font-family: var(--serif);
  font-size: 1.65rem;
}

.closed-note-prompt {
  align-self: start;
  max-width: 13rem;
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.45;
}

.note-paper {
  position: relative;
  width: min(100%, 40rem);
  padding: clamp(2.4rem, 9vw, 4.5rem) clamp(1.35rem, 7vw, 4.1rem)
    clamp(2.2rem, 8vw, 3.8rem);
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.12)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 31px,
      rgba(79, 66, 43, 0.055) 32px
    ),
    var(--paper);
  border: 1px solid rgba(64, 52, 37, 0.12);
  border-radius: 0.55rem;
  box-shadow: var(--shadow-paper);
  transform: rotate(-0.55deg);
  transform-origin: top center;
}

.note-paper.is-opening {
  animation: unfold-paper 850ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.note-paper.is-restored {
  animation: restored-note 360ms ease both;
}

.paper-tape {
  position: absolute;
  top: -0.8rem;
  left: 50%;
  width: 5.4rem;
  height: 1.65rem;
  background: rgba(236, 221, 177, 0.82);
  box-shadow: 0 2px 5px rgba(69, 55, 32, 0.06);
  transform: translateX(-50%) rotate(1.5deg);
}

.note-kicker {
  margin: 0 0 0.75rem;
  color: #514b43;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.note-paper h2 {
  margin: 0 0 1.65rem;
  font-size: clamp(1.65rem, 7.5vw, 2.7rem);
  line-height: 1.16;
  letter-spacing: -0.025em;
}

.note-message {
  font-size: clamp(0.98rem, 3.8vw, 1.07rem);
  line-height: 1.83;
}

.note-message p {
  margin: 0 0 1.25rem;
}

.note-message p:last-child {
  margin-bottom: 0;
}

.note-signature {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  margin-top: 2rem;
  text-align: center;
}

.note-signature img {
  width: clamp(3.8rem, 16vw, 5.2rem);
  aspect-ratio: 1;
  object-fit: cover;
}

.note-signature p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-style: italic;
}

.note-paper.is-opening .note-kicker,
.note-paper.is-opening h2,
.note-paper.is-opening .note-message p,
.note-paper.is-opening .note-signature {
  opacity: 0;
  animation: text-reveal 600ms ease forwards;
}

.note-paper.is-opening .note-kicker {
  animation-delay: 480ms;
}

.note-paper.is-opening h2 {
  animation-delay: 570ms;
}

.note-paper.is-opening .note-message p {
  animation-delay: calc(660ms + var(--paragraph-index) * 115ms);
}

.note-paper.is-opening .note-signature {
  animation-delay: calc(760ms + var(--paragraph-count) * 115ms);
}

.after-message {
  max-width: 35rem;
  margin: 2.3rem auto 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 1.08rem;
  font-style: italic;
  line-height: 1.65;
  text-align: center;
}

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: min(100%, 45rem);
  margin-top: auto;
  padding-top: 1.5rem;
  color: var(--ink-soft);
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-family: var(--serif);
  font-size: 0.8rem;
}

.success-hearts {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
}

.success-heart {
  position: absolute;
  bottom: -2rem;
  left: var(--left);
  color: #111;
  font-family: var(--serif);
  font-size: var(--heart-size);
  opacity: 0;
  animation: rise-heart var(--rise-duration) ease-out var(--rise-delay) both;
}

@keyframes background-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(-3deg);
  }
  50% {
    transform: translate3d(7px, -13px, 0) rotate(4deg);
  }
}

@keyframes gentle-heartbeat {
  0%,
  100% {
    transform: scale(1);
  }
  10% {
    transform: scale(1.08);
  }
  18% {
    transform: scale(1);
  }
  26% {
    transform: scale(1.045);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-7px);
  }
  40%,
  80% {
    transform: translateX(7px);
  }
}

@keyframes confirm-pop {
  0% {
    transform: scale(0.84);
  }
  55% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes rise-heart {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(-8deg) scale(0.8);
  }
  14% {
    opacity: 0.75;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift), -108vh, 0) rotate(10deg) scale(1.05);
  }
}

@keyframes content-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes note-close-to-open {
  0% {
    opacity: 1;
    transform: rotate(-1.5deg) scale(1);
  }
  45% {
    opacity: 1;
    transform: rotate(2deg) scale(1.035);
  }
  100% {
    opacity: 0;
    transform: rotate(0deg) scale(0.94) translateY(-8px);
  }
}

@keyframes unfold-paper {
  0% {
    opacity: 0;
    transform: rotateX(-78deg) rotate(-1.8deg) scaleY(0.55);
  }
  62% {
    opacity: 1;
    transform: rotateX(6deg) rotate(0.3deg) scaleY(1.015);
  }
  100% {
    opacity: 1;
    transform: rotateX(0) rotate(-0.55deg) scaleY(1);
  }
}

@keyframes restored-note {
  from {
    opacity: 0;
    transform: translateY(7px) rotate(-0.55deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(-0.55deg);
  }
}

@keyframes text-reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 40rem) {
  .screen {
    padding-inline: 2rem;
  }

  .daily-experience {
    padding-top: 3rem;
  }

  .note-stage {
    min-height: 21rem;
  }

  .closed-note {
    min-height: 18rem;
  }
}

@media (max-width: 22rem) {
  .countdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-height: 40rem) and (orientation: landscape) {
  .lock-card {
    padding-block: 1.4rem;
  }

  .hero-heart {
    margin-bottom: 0.6rem;
    font-size: 2rem;
  }

  .lock-help {
    margin-block: 0.65rem 0.9rem;
  }

  .daily-experience {
    padding-top: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
