:root {
  --background: #fff8e8;
  --background-deep: #ffe9b0;
  --card: #fffdf7;
  --text: #3a2f1c;
  --muted: #8a7a5c;
  --yellow: #f5c542;
  --yellow-bright: #ffd65a;
  --yellow-light: #fff1b8;
  --yellow-deep: #c99200;
  --border: #f0e0b0;
  --shadow: 0 12px 30px rgba(201, 146, 0, 0.12);
  --radius: 24px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Nunito", sans-serif;
  --font-hand: "Caveat", cursive;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #ffe58a 0%, transparent 55%),
    radial-gradient(ellipse 70% 45% at 100% 5%, #ffd56a 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 50% 100%, #ffeab0 0%, transparent 55%),
    linear-gradient(180deg, #fffaf0 0%, var(--background) 40%, #fff3d0 100%);
  overflow-x: hidden;
}

body.locked {
  overflow: hidden;
}

/* ——— Intro gate ——— */
.intro-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 30% 20%, #ffe58a 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, #ffd56a 0%, transparent 45%),
    #fff6d8;
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

.intro-gate.is-open {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-card {
  position: relative;
  width: min(92vw, 420px);
  padding: 56px 36px 40px;
  text-align: center;
  background: var(--card);
  border: 2px solid var(--yellow);
  border-radius: 28px;
  box-shadow:
    0 20px 50px rgba(201, 146, 0, 0.2),
    0 0 0 8px rgba(245, 197, 66, 0.15);
  animation: floatIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.intro-seal {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: var(--yellow);
  border-radius: 50%;
  box-shadow: 0 8px 20px rgba(201, 146, 0, 0.35);
  animation: heartBeat 1.6s ease-in-out infinite;
}

.intro-to {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 28px;
  color: var(--yellow-deep);
}

.intro-title {
  margin: 6px 0 14px;
  font-family: var(--font-display);
  font-size: clamp(40px, 10vw, 50px);
  letter-spacing: -1px;
  line-height: 1.05;
}

.intro-note {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.open-gift-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 16px 36px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--text);
  font-family: var(--font-hand);
  font-size: 28px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(201, 146, 0, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.open-gift-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 28px rgba(201, 146, 0, 0.4);
}

.open-gift-btn:active {
  transform: translateY(0) scale(0.98);
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes heartBeat {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }
  50% {
    transform: translateX(-50%) scale(1.08);
  }
}

/* ——— Confetti + floating hearts ——— */
#confettiCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1100;
}

#background-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-heart {
  position: absolute;
  bottom: -40px;
  font-size: 18px;
  opacity: 0.35;
  animation: floatUp linear infinite;
  user-select: none;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.4;
  }
  90% {
    opacity: 0.25;
  }
  100% {
    transform: translateY(-110vh) rotate(25deg);
    opacity: 0;
  }
}

/* ——— Site ——— */
.site {
  position: relative;
  z-index: 1;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.8s ease 0.15s, transform 0.8s ease 0.15s;
}

body.is-revealed .site {
  opacity: 1;
  transform: translateY(0);
}

.hero {
  padding: 56px 20px 28px;
  text-align: center;
}

.hero-heart {
  font-size: 44px;
  animation: softBounce 2.4s ease-in-out infinite;
  filter: drop-shadow(0 6px 12px rgba(245, 197, 66, 0.45));
}

@keyframes softBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

h1 {
  margin: 10px 0;
  font-family: var(--font-display);
  font-size: clamp(44px, 9vw, 76px);
  letter-spacing: -2px;
  line-height: 1.05;
  background: linear-gradient(135deg, #8a6800 0%, #c99200 45%, #e8b020 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 26px;
  color: var(--muted);
}

#stats {
  margin-top: 28px;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.stat {
  min-width: 108px;
  padding: 16px 22px;
  background: rgba(255, 253, 247, 0.85);
  border: 2px dashed var(--yellow);
  border-radius: 22px;
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease;
}

.stat:hover {
  transform: rotate(-2deg) scale(1.04);
}

.stat:nth-child(2):hover {
  transform: rotate(2deg) scale(1.04);
}

.stat span {
  display: block;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  color: var(--yellow-deep);
}

.stat small {
  color: var(--muted);
  font-weight: 600;
}

main {
  padding: 12px 20px 40px;
}

#calendar-section {
  max-width: 1400px;
  margin: auto;
}

#calendar-section h2 {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 40px);
}

.section-hint {
  margin: 8px 0 28px;
  text-align: center;
  font-family: var(--font-hand);
  font-size: 22px;
  color: var(--muted);
}

#calendarContainer {
  display: grid;
  grid-template-columns: repeat(3, minmax(280px, 1fr));
  gap: 24px;
}

.month {
  background: rgba(255, 253, 247, 0.92);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.month:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(201, 146, 0, 0.16);
}

.month-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text);
}

.weekdays,
.days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.weekdays div {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.day {
  aspect-ratio: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 600;
  cursor: default;
  transition: 0.2s ease;
}

.day:not(.empty):not(.has-meeting):not(.has-note):hover {
  background: #fff3c8;
}

.day.has-meeting {
  background: var(--yellow-light);
  color: #8a6800;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(245, 197, 66, 0.35);
}

.day.has-meeting:hover {
  background: var(--yellow);
  transform: scale(1.14) rotate(-4deg);
  box-shadow: 0 6px 14px rgba(201, 146, 0, 0.3);
}

.day.has-note {
  background: #e8e6e1;
  color: #5a574f;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(90, 87, 79, 0.18);
}

.day.has-note:hover {
  background: #d4d1c9;
  transform: scale(1.1);
  box-shadow: 0 6px 12px rgba(60, 55, 45, 0.15);
}

.day.is-highlighted {
  background: linear-gradient(145deg, var(--yellow-bright), var(--yellow));
  color: #5c4300;
  box-shadow: 0 0 0 3px rgba(245, 197, 66, 0.55), 0 8px 18px rgba(201, 146, 0, 0.35);
  animation: sparklePulse 1.8s ease-in-out infinite;
}

@keyframes sparklePulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

button {
  font-family: inherit;
}

#randomButton {
  position: fixed;
  right: 25px;
  bottom: 25px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--yellow);
  border: none;
  padding: 14px 20px;
  border-radius: 50px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(201, 146, 0, 0.35);
  transition: transform 0.2s ease;
}

body:not(.is-revealed) #randomButton {
  opacity: 0;
  pointer-events: none;
}

#randomButton:hover {
  transform: translateY(-3px) rotate(-2deg);
}

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(58, 47, 28, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(5px);
  z-index: 40;
}

#memoryModal {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(92vw, 680px);
  height: min(82vh, 760px);
  background: var(--card);
  border: 2px solid var(--yellow);
  border-radius: 28px;
  transform: translate(-50%, -45%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 40px 100px rgba(90, 60, 0, 0.28);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

#memoryModal[data-mode="note"] {
  border-color: #c5c1b6;
  height: auto;
  max-height: min(70vh, 520px);
}

body.modal-open #overlay,
body.modal-open #memoryModal {
  opacity: 1;
  pointer-events: auto;
}

body.modal-open #memoryModal {
  transform: translate(-50%, -50%) scale(1);
}

#closeButton {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  transition: 0.2s;
  z-index: 2;
}

#closeButton:hover {
  background: var(--yellow-light);
  color: #806000;
  border-color: var(--yellow);
}

.memory-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 35px;
  padding-bottom: 20px;
}

.memory-header {
  text-align: center;
  padding-right: 30px;
}

#memoryNumber {
  color: var(--yellow-deep);
  font-family: var(--font-hand);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

#memoryDate {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-size: 34px;
  letter-spacing: -1px;
}

.memory-meta {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 25px 0;
}

.pill {
  background: var(--yellow-light);
  color: #806000;
  padding: 9px 16px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 700;
  border: 1px dashed rgba(201, 146, 0, 0.35);
}

.picture-block {
  position: relative;
  margin: 8px 0 8px;
}

#memoryImage {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: 20px;
  display: block;
  border: 2px solid var(--border);
}

.picture-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 220px;
  padding: 28px 20px;
  border-radius: 20px;
  border: 2px dashed #d2c4a0;
  background:
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 10px,
      rgba(245, 197, 66, 0.06) 10px,
      rgba(245, 197, 66, 0.06) 20px
    ),
    #fffaf0;
  text-align: center;
}

.picture-frame {
  width: 64px;
  height: 52px;
  margin-bottom: 8px;
  border: 3px solid #c9a84a;
  border-radius: 8px;
  position: relative;
  opacity: 0.7;
}

.picture-frame::before {
  content: "";
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 18px;
  height: 14px;
  border: 2px solid #c9a84a;
  border-radius: 50% 50% 40% 40%;
}

.picture-frame::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 8px;
  width: 10px;
  height: 10px;
  border: 2px solid #c9a84a;
  border-radius: 50%;
}

.picture-label {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 28px;
  color: var(--yellow-deep);
}

.picture-sublabel {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.picture-block.has-image .picture-placeholder {
  display: none;
}

.hidden {
  display: none !important;
}

.memory-section {
  margin-top: 24px;
  padding: 18px 18px 16px;
  border-radius: 18px;
  background: rgba(255, 241, 184, 0.35);
  border: 1px solid rgba(245, 197, 66, 0.25);
}

.memory-section--soft,
#memoryModal[data-mode="note"] .memory-section {
  background: #f3f2ef;
  border-color: #ddd9d0;
}

.memory-section h3 {
  font-family: var(--font-hand);
  font-size: 26px;
  margin: 0 0 8px;
  color: var(--yellow-deep);
}

.memory-section--soft h3,
#memoryModal[data-mode="note"] .memory-section h3 {
  color: #5a574f;
}

.memory-section p {
  margin: 0;
  color: #5c4d32;
  line-height: 1.75;
  white-space: pre-line;
}

.memory-section--soft p {
  color: #5a574f;
}

#memoryNumber.is-note-label {
  color: #6d6a62;
}

.navigation {
  flex-shrink: 0;
  margin: 0;
  padding: 16px 35px 24px;
  border-top: 2px dashed var(--border);
  background: var(--card);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-radius: 0 0 26px 26px;
}

.navigation button {
  flex: 1;
  border: 2px solid var(--border);
  background: white;
  color: var(--text);
  padding: 13px 18px;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
  transition: 0.2s;
}

.navigation button:hover {
  background: var(--yellow-light);
  border-color: var(--yellow);
}

footer {
  text-align: center;
  padding: 20px 16px 48px;
  font-family: var(--font-hand);
  font-size: 22px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  #calendarContainer {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  #calendarContainer {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 36px;
  }

  .stat {
    min-width: 96px;
  }

  #randomButton span {
    display: none;
  }

  #randomButton {
    width: 56px;
    height: 56px;
    padding: 0;
    justify-content: center;
    font-size: 22px;
  }
}

@media (max-width: 600px) {
  .intro-card {
    padding: 48px 24px 32px;
  }

  #memoryModal {
    width: calc(100vw - 24px);
    height: 85vh;
    border-radius: 22px;
  }

  .memory-content {
    padding: 25px;
  }

  .navigation {
    padding: 14px 25px 20px;
  }

  #memoryDate {
    font-size: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .floating-heart {
    display: none;
  }
}
