:root {
  /* Palette notte stellata */
  --night-deep: #0b1528;
  --night-mid: #122342;
  --night-light: #1b335c;
  --green-deep: #315e2e;
  --green-dark: #21431f;
  --green-soft: #e6efe5;

  --bg-card: #ffffff;
  --bg-muted: #e9eef5;
  --text-main: #182235;
  --text-body: #364257;
  --text-muted: #647187;
  --border-subtle: #d4dce8;

  /* Punti di colore Campanellino */
  --gold: #fabe04;
  --gold-soft: #fff8de;
  --red: #d0322a;
  --red-soft: #fdf0ef;
  --blue: #2b90bd;
  --blue-soft: #edf6fa;

  --font-serif: 'Baskervville', Georgia, serif;
  --font-sans: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-script: 'Meow Script', cursive;

  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 6px 18px rgba(4, 10, 22, 0.32);
  --shadow-md: 0 14px 32px rgba(4, 10, 22, 0.44);
  --shadow-lg: 0 24px 60px rgba(4, 10, 22, 0.58);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: #ffffff;
  background-color: #050a14;
  background-image:
    radial-gradient(ellipse 95% 46% at 50% 102%, rgba(235, 130, 68, 0.38) 0%, rgba(186, 86, 94, 0.20) 40%, transparent 74%),
    radial-gradient(circle at 18% 16%, rgba(43, 144, 189, 0.10) 0%, transparent 40%),
    linear-gradient(180deg, #050a14 0%, #091326 42%, #13213e 72%, #2a2644 89%, #4a3248 100%);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Starfield & Shooting Stars */
.star-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.star {
  position: absolute;
  border-radius: 50%;
  background: #ffffff;
  animation: twinkle ease-in-out infinite;
}

@keyframes twinkle {

  0%,
  100% {
    opacity: var(--star-min, 0.25);
    transform: scale(0.9);
  }

  50% {
    opacity: var(--star-max, 0.95);
    transform: scale(1.15);
  }
}

.shooting-star {
  position: absolute;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 248, 220, 0.85) 70%, #ffffff 100%);
  box-shadow: 0 0 8px rgba(255, 248, 220, 0.8);
  transform-origin: left center;
  animation: shoot-across 1.15s ease-out forwards;
}

@keyframes shoot-across {
  0% {
    opacity: 0;
    transform: rotate(var(--shoot-angle, 26deg)) translateX(0);
  }

  15% {
    opacity: 1;
  }

  80% {
    opacity: 0.9;
  }

  100% {
    opacity: 0;
    transform: rotate(var(--shoot-angle, 26deg)) translateX(var(--shoot-dist, 340px));
  }
}

/* Snow layer */
.snow-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.snow-layer-front {
  z-index: 15;
}

.snowflake {
  position: absolute;
  top: -12px;
  color: rgba(255, 255, 255, 0.78);
  text-shadow: 0 1px 3px rgba(4, 10, 22, 0.35);
  user-select: none;
  animation: snowfall linear infinite;
}

@keyframes snowfall {
  0% {
    transform: translateY(-10px) translateX(0) rotate(0deg);
    opacity: 0;
  }

  10% {
    opacity: 0.9;
  }

  90% {
    opacity: 0.75;
  }

  100% {
    transform: translateY(105vh) translateX(24px) rotate(360deg);
    opacity: 0;
  }
}

.snow-hidden .snow-layer {
  display: none;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 21, 40, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.header-inner {
  width: 100%;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  background: #ffffff;
  padding: 7px 16px;
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
}

.brand-logo {
  height: 44px;
  width: auto;
  display: block;
}

.header-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.25rem, 2.2vw, 1.75rem);
  line-height: 1.15;
  margin: 0;
  color: #ffffff;
}

.script-accent {
  font-family: var(--font-script);
  color: var(--gold);
  font-size: 1.25em;
  display: inline-block;
  padding-left: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Buttons */
.btn-outline,
.btn-ghost,
.btn-ghost-dark,
.btn-primary {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.btn-outline {
  border: 1.5px solid rgba(255, 255, 255, 0.72);
  background: transparent;
  color: #ffffff;
}

.btn-outline:hover {
  background: #ffffff;
  color: var(--night-deep);
  border-color: #ffffff;
}

.btn-ghost {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-ghost-dark {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-body);
}

.btn-ghost-dark:hover:not(:disabled) {
  background: var(--green-soft);
  color: var(--green-dark);
}

.btn-ghost-dark:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  border: none;
  background: var(--green-deep);
  color: #ffffff;
  padding: 11px 20px;
  box-shadow: 0 4px 14px rgba(49, 94, 46, 0.28);
}

.btn-primary:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

/* Fullwidth Scattered Calendar */
.calendar-fullwidth {
  flex: 1;
  width: 100%;
  padding: 36px 28px 64px;
  position: relative;
  z-index: 2;
}

.calendar-scattered {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
  align-items: flex-start;
  gap: 44px 38px;
}

/* Door Card */
.door-card {
  position: relative;
  width: var(--door-w, 152px);
  height: var(--door-h, 198px);
  transform: translate(var(--ox, 0px), var(--oy, 0px)) rotate(var(--rot, 0deg));
  border-radius: var(--radius-md);
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: var(--red);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-shrink: 0;
}

.door-card.door-red {
  background: var(--red);
  color: #ffffff;
}

.door-card.door-green {
  background: var(--green-deep);
  color: #ffffff;
}

.door-card.phase-2::before {
  background: var(--blue);
}

.door-card.phase-3::before {
  background: var(--red);
}

.door-card.is-unlocked:hover {
  transform: translate(var(--ox, 0px), calc(var(--oy, 0px) - 4px)) rotate(0deg) scale(1.03);
  box-shadow: var(--shadow-md);
  border-color: #ffffff;
  z-index: 10;
}

.door-card.is-today {
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.3), var(--shadow-md);
}

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

.door-card.is-locked:hover {
  transform: translate(var(--ox, 0px), var(--oy, 0px)) rotate(var(--rot, 0deg));
}

.door-card.is-day-24 {
  border-width: 3px;
  border-color: #ffffff;
}

.door-card.shake {
  animation: door-shake 0.36s ease;
}

@keyframes door-shake {

  0%,
  100% {
    transform: translate(var(--ox, 0px), var(--oy, 0px)) rotate(var(--rot, 0deg));
  }

  25% {
    transform: translate(calc(var(--ox, 0px) - 5px), var(--oy, 0px)) rotate(var(--rot, 0deg));
  }

  50% {
    transform: translate(calc(var(--ox, 0px) + 5px), var(--oy, 0px)) rotate(var(--rot, 0deg));
  }

  75% {
    transform: translate(calc(var(--ox, 0px) - 3px), var(--oy, 0px)) rotate(var(--rot, 0deg));
  }
}

@media (max-width: 720px) {
  .header-inner {
    padding: 10px 16px;
  }

  .header-brand {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: nowrap;
  }

  .header-title {
    font-size: 1.15rem;
  }

  .brand-logo {
    height: 30px;
  }

  .header-actions {
    display: none;
  }

  .calendar-fullwidth {
    padding: 22px 14px 44px;
  }

  .calendar-scattered {
    gap: 20px 12px;
    justify-content: space-evenly;
  }

  .door-card {
    width: calc(43% - 6px);
    max-width: 152px;
    height: calc(var(--door-h, 190px) * 0.72);
    min-height: 126px;
    transform: translate(calc(var(--ox, 0px) * 0.6), var(--oy-mobile, 0px)) rotate(var(--rot, 0deg));
  }

  .door-card.is-unlocked:hover {
    transform: translate(calc(var(--ox, 0px) * 0.6), calc(var(--oy-mobile, 0px) - 4px)) rotate(0deg);
  }

  .door-card.is-locked:hover {
    transform: translate(calc(var(--ox, 0px) * 0.6), var(--oy-mobile, 0px)) rotate(var(--rot, 0deg));
  }
}

.door-closed-face {
  padding: 16px;
  height: 100%;
  width: 100%;
  display: grid;
  place-items: center;
  position: relative;
}

.door-closed-face::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.door-number {
  font-family: var(--font-serif);
  font-size: clamp(2.8rem, 4vw, 3.6rem);
  line-height: 1;
  color: inherit;
}

/* Opened door state */
.door-opened-face {
  position: relative;
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}

.door-opened-cover {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg-muted);
}

.door-opened-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.door-opened-num {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--green-deep);
  color: #ffffff;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.door-opened-footer {
  padding: 8px 10px;
  background: #ffffff;
  border-top: 1px solid var(--border-subtle);
}

.door-opened-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 0.83rem;
  line-height: 1.25;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Typographic fallback cover */
.fallback-cover {
  width: 100%;
  height: 100%;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  color: var(--text-main);
}

.fallback-cover.phase-1 {
  background: linear-gradient(145deg, var(--gold-soft), #f7e6a8);
}

.fallback-cover.phase-2 {
  background: linear-gradient(145deg, var(--blue-soft), #cde6f2);
}

.fallback-cover.phase-3 {
  background: linear-gradient(145deg, var(--green-soft), #c6dec4);
}

.fallback-cover-ornament {
  font-size: 1.2rem;
  opacity: 0.75;
}

.fallback-cover-title {
  font-family: var(--font-serif);
  font-size: 0.96rem;
  line-height: 1.25;
  margin: 6px 0;
}

.fallback-cover-author {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-body);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #ffffff;
  color: var(--green-dark);
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.875rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  text-align: center;
  max-width: calc(100vw - 32px);
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 12, 24, 0.76);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
}

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

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 900px;
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0;
  overflow: hidden;
  animation: modal-in 0.22s ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-main);
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 2;
}

.modal-close:hover {
  background: var(--green-soft);
}

.modal-body {
  display: flex;
  align-items: stretch;
  gap: 36px;
  background: #ffffff;
}

.modal-info-col {
  flex: 1;
  min-width: 0;
  padding: 32px 44px 32px 0;
  background: #ffffff;
  position: relative;
  z-index: 1;
}

.modal-cover-col {
  flex: 0 0 auto;
  min-width: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  margin: 0;
  overflow: hidden;
  box-shadow: 4px 0 20px rgba(24, 48, 22, 0.12);
  background: var(--bg-muted);
  transition: background-color 0.25s ease;
}

.modal-cover-col img {
  width: auto;
  height: 100%;
  max-width: 340px;
  max-height: 540px;
  object-fit: contain;
  object-position: left center;
  display: block;
}

.modal-cover-col .fallback-cover {
  width: 280px;
  min-height: 400px;
}

@media (max-width: 700px) {
  .modal-backdrop {
    display: block;
    padding: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-dialog {
    max-width: 100%;
    min-height: 100dvh;
    height: auto;
    border-radius: 0;
    overflow: visible;
  }

  .modal-close {
    position: fixed;
    top: 12px;
    right: 12px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);
  }

  .modal-body {
    flex-direction: column;
    gap: 0;
    min-height: 100dvh;
  }

  .modal-cover-col {
    width: 100%;
    min-width: 0;
    height: auto;
    max-height: 70dvh;
    margin: 0;
    box-shadow: 0 4px 16px rgba(24, 48, 22, 0.14);
  }

  .modal-cover-col img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 70dvh;
    object-position: center;
  }

  .modal-cover-col .fallback-cover {
    width: 100%;
    min-height: 240px;
    height: auto;
    padding: 36px 24px;
  }

  .modal-info-col {
    padding: 20px 20px 32px;
    flex: 1;
  }

  .modal-meta {
    padding-right: 0;
  }
}

.modal-cover-col .fallback-cover-title {
  font-size: 1.35rem;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-right: 40px;
}

.modal-day-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-deep);
}

.modal-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-title-group {
  min-width: 0;
}

.modal-age-seal {
  flex: 0 0 auto;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.05;
  transform: rotate(-7deg);
  box-shadow: 0 6px 18px rgba(250, 190, 4, 0.42);
  position: relative;
  margin-top: -4px;
}

.modal-age-seal::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1.5px dashed rgba(24, 34, 53, 0.35);
  pointer-events: none;
}

.age-seal-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.75;
}

.age-seal-range {
  font-family: var(--font-serif);
  font-size: 1.18rem;
  font-weight: 700;
  margin: 2px 0 1px;
}

.age-seal-unit {
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.8;
}

.modal-phase-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.modal-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  line-height: 1.2;
  margin: 0 0 4px;
}

.modal-author {
  margin: 0 0 18px;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
}

.modal-section h3,
.modal-why h3 {
  margin: 0 0 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.modal-section p,
.modal-why p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-body);
}

.modal-why {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--green-soft);
  border-left: 4px solid var(--green-deep);
}

.modal-why h3 {
  color: var(--green-dark);
}

.modal-actions {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-nav {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
}

/* Footer */
.site-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 16px 20px;
  text-align: center;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.78);
  position: relative;
  z-index: 2;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: #ffffff;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 3px;
}