:root {
  --bg: #0d1b2a;
  --bg-2: #142a40;
  --door: #b3261e;
  --door-2: #8f1d17;
  --door-alt: #1f6f4a;
  --door-alt-2: #175438;
  --gold: #f2c14e;
  --text: #f6f1e7;
  --muted: #a9b8c8;
  --inside: #fbf6ec;
  --inside-text: #2b2b2b;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at top, var(--bg-2), var(--bg) 70%) fixed;
  background-color: var(--bg);
}

#snow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.header,
main,
.footer {
  position: relative;
  z-index: 1;
}

/* ---------- Header ---------- */
.header {
  text-align: center;
  padding: 48px 16px 24px;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-size: 0.8rem;
  font-weight: 600;
}

h1 {
  margin: 4px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 10vw, 5.5rem);
  font-weight: 400;
  line-height: 1;
}

.status {
  margin: 0;
  color: var(--muted);
}

/* ---------- Calendar grid ---------- */
.calendar {
  list-style: none;
  margin: 0 auto;
  padding: 16px;
  max-width: 960px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  grid-auto-flow: dense;
  gap: 14px;
}

.cell {
  aspect-ratio: 1;
  perspective: 900px;
}

/* Some cells are bigger to make the calendar feel hand-made */
.cell.wide {
  grid-column: span 2;
  aspect-ratio: auto;
}

.door-button {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.door-button:disabled {
  cursor: not-allowed;
}

.door-button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
  border-radius: var(--radius);
}

/* What's behind the door */
.inside {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--inside);
  color: var(--inside-text);
  font-size: 2.4rem;
  box-shadow: inset 0 4px 14px rgba(0, 0, 0, 0.25);
}

/* The door itself */
.door {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--door), var(--door-2));
  border: 2px solid rgba(242, 193, 78, 0.45);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  transform-origin: left center;
  transition: transform 0.8s cubic-bezier(0.3, 0.7, 0.2, 1), box-shadow 0.3s;
  backface-visibility: hidden;
}

.cell:nth-child(3n) .door {
  background: linear-gradient(145deg, var(--door-alt), var(--door-alt-2));
}

.door-number {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.2rem;
  color: var(--gold);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.door-button:not(:disabled):hover .door {
  transform: rotateY(-12deg);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45);
}

.cell.open .door,
.cell.open .door-button:hover .door {
  transform: rotateY(-105deg);
}

.cell.locked .door {
  filter: saturate(0.55) brightness(0.8);
}

.cell.locked .door::after {
  content: "🔒";
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 0.85rem;
  opacity: 0.7;
}

.cell.today .door {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(242, 193, 78, 0.35), 0 6px 16px rgba(0, 0, 0, 0.35);
  animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
  50% {
    box-shadow: 0 0 0 6px rgba(242, 193, 78, 0.2), 0 6px 16px rgba(0, 0, 0, 0.35);
  }
}

.cell.shake .door {
  animation: shake 0.4s;
}

@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 24px 16px 48px;
}

.link-button {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
}

.link-button:hover {
  color: var(--text);
}

/* ---------- Dialog ---------- */
.dialog {
  width: min(420px, calc(100% - 32px));
  border: 0;
  border-radius: 18px;
  padding: 32px 24px 24px;
  background: var(--inside);
  color: var(--inside-text);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.dialog::backdrop {
  background: rgba(5, 12, 20, 0.7);
  backdrop-filter: blur(3px);
}

.dialog[open] {
  animation: pop 0.35s cubic-bezier(0.3, 1.4, 0.5, 1);
}

@keyframes pop {
  from { transform: scale(0.85); opacity: 0; }
}

.dialog-day {
  margin: 0;
  color: var(--door);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.dialog-emoji {
  font-size: 4rem;
  margin: 8px 0;
}

.dialog h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: 1.8rem;
}

.dialog p {
  line-height: 1.5;
}

.button {
  margin-top: 8px;
  padding: 10px 28px;
  border: 0;
  border-radius: 999px;
  background: var(--door);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button:hover {
  background: var(--door-2);
}

/* ---------- Small screens ---------- */
@media (max-width: 520px) {
  .calendar {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .cell.wide {
    grid-column: span 1;
    aspect-ratio: 1;
  }

  .door-number {
    font-size: 1.7rem;
  }

  .inside {
    font-size: 1.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .door,
  .dialog[open],
  .cell.today .door {
    transition: none;
    animation: none;
  }
}
