:root {
  color-scheme: light;
  --night: #102b59;
  --winter-blue: #183f78;
  --winter-blue-light: #37649c;
  --wood: #713715;
  --wood-dark: #3f1d0d;
  --berry: #b42e2f;
  --berry-dark: #792026;
  --pine: #275637;
  --gold: #f2bd42;
  --gold-pale: #ffe5a2;
  --snow: #fff8eb;
  --paper: #fffaf0;
  --ink: #352014;
  --muted: #746253;
  --shadow: 0 24px 70px rgb(9 24 55 / 35%);
  font-family: ui-rounded, "Trebuchet MS", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 300px;
  background: var(--night);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--paper);
  background:
    radial-gradient(circle at 8% 18%, rgb(255 255 255 / 75%) 0 1px, transparent 2px),
    radial-gradient(circle at 88% 6%, rgb(255 255 255 / 65%) 0 1.5px, transparent 2.5px),
    linear-gradient(180deg, #27518d 0%, var(--winter-blue) 48%, var(--night) 100%);
  background-size: 74px 74px, 127px 127px, auto;
}

button,
input {
  font: inherit;
}

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

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid #fff2a9;
  outline-offset: 3px;
}

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  min-width: 300px;
  padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
  background:
    radial-gradient(circle at 16% 14%, rgb(255 255 255 / 70%) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 28%, rgb(255 255 255 / 60%) 0 1.5px, transparent 2.5px),
    linear-gradient(160deg, #28548e, var(--night));
  background-size: 73px 73px, 121px 121px, auto;
}

.access-card {
  width: min(100%, 390px);
  padding: clamp(28px, 8vw, 44px) clamp(22px, 7vw, 36px);
  border: 1px solid rgb(255 231 157 / 48%);
  border-radius: 26px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}

.access-card h1 {
  margin: 0 0 24px;
  color: var(--winter-blue);
  font-size: clamp(1.55rem, 7vw, 2rem);
  line-height: 1.12;
}

.access-form {
  display: grid;
  gap: 10px;
  text-align: left;
}

.access-form label {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.access-form input {
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  border: 2px solid #b8aa9c;
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
}

.access-form input[aria-invalid="true"] {
  border-color: var(--berry);
}

.access-form > button[type="submit"] {
  min-height: 48px;
  margin-top: 4px;
  padding: 11px 18px;
  border: 0;
  border-radius: 999px;
  color: #fffaf0;
  background: var(--berry);
  box-shadow: 0 7px 18px rgb(121 32 38 / 25%);
  cursor: pointer;
  font-weight: 850;
}

.access-form > button[type="submit"]:hover {
  background: var(--berry-dark);
}

.access-error {
  margin: 0;
  color: var(--berry-dark);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.4;
}

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

.snow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    radial-gradient(circle, #fff 0 1px, transparent 1.7px),
    radial-gradient(circle, #fff 0 1.6px, transparent 2.4px);
  background-position: 0 0, 31px 48px;
  background-size: 89px 89px, 139px 139px;
  mask-image: linear-gradient(to bottom, #000, transparent 88%);
}

.cover,
main {
  position: relative;
  z-index: 1;
  width: min(100%, 900px);
  margin-inline: auto;
}

.cover {
  overflow: hidden;
  background: var(--winter-blue);
  box-shadow: 0 22px 55px rgb(5 18 44 / 28%);
}

.cover::after {
  position: absolute;
  inset: auto 0 0;
  height: 16%;
  pointer-events: none;
  content: "";
  background: linear-gradient(transparent, rgb(16 43 89 / 26%));
}

.cover__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 899;
  object-fit: cover;
}

.cover__actions {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.text-button {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid rgb(255 237 176 / 80%);
  border-radius: 999px;
  color: #fff8e6;
  background: rgb(70 26 12 / 78%);
  box-shadow: 0 5px 16px rgb(18 11 9 / 24%);
  backdrop-filter: blur(8px);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 800;
}

.text-button:hover {
  background: rgb(95 34 13 / 90%);
}

main {
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

.calendar-section {
  width: 100%;
  padding: 18px 10px 20px;
}

.calendar-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(7px, 2.3vw, 15px);
  margin-top: 0;
  padding: clamp(13px, 3.6vw, 25px);
  border: clamp(5px, 1.8vw, 12px) solid #673113;
  border-radius: clamp(18px, 5vw, 34px);
  background:
    radial-gradient(circle at 20% 15%, rgb(255 255 255 / 18%) 0 1px, transparent 2px),
    linear-gradient(145deg, rgb(255 255 255 / 8%), transparent 36%),
    #4c260f;
  background-size: 41px 41px, auto, auto;
  box-shadow:
    0 22px 44px rgb(4 15 37 / 40%),
    inset 0 0 0 2px rgb(255 210 99 / 25%),
    inset 0 10px 24px rgb(30 10 3 / 32%);
  isolation: isolate;
}

.door-slot {
  min-width: 0;
  animation: reveal 500ms both;
  animation-delay: var(--reveal-delay);
}

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

.door {
  position: relative;
  width: 100%;
  aspect-ratio: 0.78;
  padding: 0;
  border: 0;
  border-radius: 13px 13px 8px 8px;
  color: var(--paper);
  background: transparent;
  cursor: pointer;
  perspective: 700px;
}

.door__inner,
.door__inside,
.door__panel {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: inherit;
}

.door__inner {
  background: #3c210f;
  box-shadow: inset 0 0 0 2px rgb(255 208 91 / 70%), 0 7px 13px rgb(16 6 2 / 34%);
  transform-style: preserve-3d;
}

.door__inside {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
  color: #fff2b8;
  background:
    radial-gradient(circle at 50% 45%, rgb(255 210 73 / 72%), transparent 34%),
    linear-gradient(150deg, #995019, #3b1d0c);
}

.door__inside::before,
.door__inside::after {
  position: absolute;
  width: 1px;
  height: 140%;
  content: "";
  background: rgb(255 224 143 / 22%);
  transform: rotate(45deg);
}

.door__inside::after {
  transform: rotate(-45deg);
}

.door__image {
  position: absolute;
  inset: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  border-radius: 10px 10px 6px 6px;
  object-fit: cover;
}

.door__image {
  visibility: hidden;
  opacity: 0;
}

.door.is-open .door__image {
  visibility: visible;
  opacity: 1;
}

.door__open-number {
  position: absolute;
  top: clamp(2px, 1vw, 4px);
  left: clamp(8px, 1vw, 10px);
  z-index: 4;
  visibility: hidden;
  color: #fff3c5;
  opacity: 0;
  pointer-events: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 4.8vw, 1.55rem);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 3px rgb(7 17 37 / 92%), 0 0 7px rgb(7 17 37 / 72%);
}

.door.is-open .door__open-number {
  visibility: visible;
  opacity: 1;
}

.door.has-image .door__inside::before,
.door.has-image .door__inside::after {
  display: none;
}

.door__panel {
  overflow: hidden;
  border: 2px solid rgb(255 208 96 / 68%);
  background:
    radial-gradient(circle at 24% 18%, rgb(255 255 255 / 18%) 0 1px, transparent 2px),
    linear-gradient(100deg, rgb(255 255 255 / 10%), transparent 30% 76%, rgb(0 0 0 / 14%)),
    var(--berry);
  background-size: 29px 29px, auto, auto;
  box-shadow: inset 0 0 0 3px rgb(255 255 255 / 7%), 0 7px 13px rgb(21 7 4 / 30%);
  transform-origin: left center;
  transition: transform 620ms cubic-bezier(0.2, 0.72, 0.2, 1), filter 220ms ease;
  transform-style: preserve-3d;
  backface-visibility: visible;
}

.door[style*="--door-tone: 2"] .door__panel {
  background-color: #315f94;
}

.door[style*="--door-tone: 3"] .door__panel {
  background-color: var(--pine);
}

.door[style*="--door-tone: 4"] .door__panel {
  background-color: #a74d20;
}

.door__arch {
  position: absolute;
  inset: 9% 13%;
  border: 1px solid rgb(255 226 143 / 58%);
  border-radius: 999px 999px 6px 6px;
  box-shadow: inset 0 0 0 2px rgb(73 24 10 / 12%);
}

.door__number {
  position: absolute;
  top: 61%;
  left: 50%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 7vw, 2.8rem);
  font-weight: 700;
  line-height: 1;
  color: #fff0bf;
  text-shadow: 0 2px 0 rgb(73 24 10 / 34%), 0 0 12px rgb(255 207 73 / 15%);
  transform: translate(-50%, -52%);
}

.door__panel-star {
  position: absolute;
  top: 27%;
  left: 50%;
  color: #ffe49a;
  font-size: clamp(0.78rem, 3.2vw, 1.2rem);
  line-height: 1;
  text-shadow: 0 0 10px rgb(255 211 73 / 68%);
  transform: translateX(-50%);
}

.door__knob {
  position: absolute;
  right: 11%;
  top: 53%;
  width: clamp(5px, 1.7vw, 9px);
  aspect-ratio: 1;
  border: 1px solid #fff0a8;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 1px 3px rgb(0 0 0 / 38%);
}

.door__lock {
  display: none;
}

.door.is-locked {
  cursor: not-allowed;
}

.door.is-locked .door__panel {
  filter: saturate(0.5) brightness(0.78);
}

.door.is-locked .door__lock {
  position: absolute;
  right: 9%;
  bottom: 8%;
  display: block;
  width: 12px;
  height: 10px;
  border-radius: 2px;
  background: rgb(255 241 200 / 82%);
}

.door.is-locked .door__lock::before {
  position: absolute;
  left: 2px;
  top: -7px;
  width: 6px;
  height: 8px;
  border: 2px solid rgb(255 241 200 / 82%);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  content: "";
}

.door:not(.is-locked):hover .door__panel {
  filter: brightness(1.1);
}

.door:not(.is-locked):active {
  transform: translateY(1px);
}

.door.is-open .door__panel {
  transform: rotateY(-104deg);
}

.door.is-open .door__panel-star,
.door.is-open .door__number {
  opacity: 0;
}

.door.is-today:not(.is-open) {
  animation: todayGlow 2.4s ease-in-out infinite;
}

@keyframes todayGlow {
  50% {
    filter: drop-shadow(0 0 9px rgb(255 213 77 / 88%));
  }
}

.door.is-shaking {
  animation: shake 360ms ease;
}

@keyframes shake {
  25% { transform: translateX(-3px) rotate(-1deg); }
  50% { transform: translateX(3px) rotate(1deg); }
  75% { transform: translateX(-2px); }
}

.story-dialog {
  width: min(calc(100% - 24px), 520px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 26px;
  color: var(--ink);
  background: transparent;
  box-shadow: var(--shadow);
}

.story-dialog::backdrop {
  background: rgb(8 25 57 / 82%);
  backdrop-filter: blur(7px);
}

.story-sheet {
  position: relative;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  border: 2px solid rgb(255 224 143 / 82%);
  border-radius: 26px;
  background:
    radial-gradient(circle at 90% 8%, rgb(242 189 66 / 18%), transparent 24%),
    var(--paper);
  overscroll-behavior: contain;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0 0 3px;
  border: 1px solid rgb(71 38 19 / 16%);
  border-radius: 50%;
  color: var(--ink);
  background: rgb(255 250 240 / 92%);
  box-shadow: 0 5px 16px rgb(45 22 8 / 18%);
  cursor: pointer;
  font-size: 1.75rem;
  font-weight: 300;
  line-height: 1;
}

.story-visual {
  margin: 0;
  overflow: hidden;
  border-radius: 24px 24px 0 0;
  background: var(--winter-blue);
}

.story-visual img {
  display: block;
  width: 100%;
  height: auto;
}

.story-copy {
  padding: 30px 26px 8px;
  text-align: center;
}

.story-date {
  margin: 0 0 8px;
  color: var(--berry);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.story-copy h2 {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.audio-player {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 16px;
  margin: 18px 20px 22px;
  padding: 17px;
  border: 1px solid rgb(110 60 24 / 14%);
  border-radius: 20px;
  background: #f2e4c8;
}

.play-button {
  display: grid;
  grid-template-columns: 32px auto;
  align-items: center;
  justify-self: center;
  min-height: 48px;
  padding: 6px 16px 6px 8px;
  border: 0;
  border-radius: 999px;
  color: var(--paper);
  background: var(--berry-dark);
  box-shadow: 0 5px 14px rgb(99 26 29 / 24%);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 780;
}

.play-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.play-button__icon {
  display: grid;
  place-items: center;
  font-size: 0.88rem;
  line-height: 1;
}

.timeline {
  min-width: 0;
}

.seek {
  --progress: 0%;
  display: block;
  width: 100%;
  height: 20px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.seek::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--berry) 0 var(--progress), rgb(70 42 24 / 18%) var(--progress) 100%);
}

.seek::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: rgb(70 42 24 / 18%);
}

.seek::-moz-range-progress {
  height: 4px;
  border-radius: 99px;
  background: var(--berry);
}

.seek::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  appearance: none;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--berry);
  box-shadow: 0 1px 5px rgb(0 0 0 / 23%);
}

.seek::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--berry);
  box-shadow: 0 1px 5px rgb(0 0 0 / 23%);
}

.time-row {
  display: flex;
  justify-content: space-between;
  margin-top: -2px;
  color: var(--muted);
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
}

.player-status {
  grid-column: 1;
  margin: -5px 0 0;
  color: var(--muted);
  font-size: 0.67rem;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 20;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border: 1px solid rgb(255 235 170 / 40%);
  border-radius: 999px;
  color: var(--paper);
  background: rgb(52 24 12 / 95%);
  box-shadow: 0 10px 30px rgb(0 0 0 / 28%);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  transform: translateX(-50%);
}

@media (min-width: 640px) {
  body {
    padding-top: 24px;
  }

  .story-dialog {
    width: min(calc(100% - 60px), 840px);
  }

  .cover {
    width: min(calc(100% - 48px), 900px);
    border-radius: 28px;
  }

  .calendar-section {
    padding: 22px 24px 30px;
  }

  .calendar-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
