:root {
  --bg-wall: #0a1712;
  --bg-wall-mid: #10241c;
  --bg-wall-light: #163227;
  --gold-bright: #f4d68c;
  --gold-mid: #c89d47;
  --gold-dark: #7d5b1f;
  --ivory: #f5efe4;
  --ivory-muted: rgba(245, 239, 228, 0.72);
  --plaque-bg: #1e1810;
  --font-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  min-height: 100dvh;
  background-color: #08150f;
  background-image:
    radial-gradient(circle at 12% 10%, rgba(212, 46, 62, 0.16) 0%, transparent 32%),
    radial-gradient(circle at 88% 12%, rgba(244, 214, 140, 0.16) 0%, transparent 34%),
    radial-gradient(circle at 50% 0%, rgba(244, 214, 140, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 16% 62%, rgba(244, 214, 140, 0.08) 0%, transparent 28%),
    radial-gradient(circle at 84% 76%, rgba(190, 32, 48, 0.12) 0%, transparent 32%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%23e8c474' stroke-opacity='0.065' stroke-width='1'%3E%3Cpath d='M48 8L50.5 15.5L58 18L50.5 20.5L48 28L45.5 20.5L38 18L45.5 15.5Z'/%3E%3Cpath d='M48 68V88M39.3 73L56.7 83M56.7 73L39.3 83'/%3E%3Cpath d='M16 40C20 44 20 52 16 56C12 52 12 44 16 40ZM80 40C84 44 84 52 80 56C76 52 76 44 80 40Z'/%3E%3Ccircle cx='16' cy='18' r='1.3' fill='%23d93848' fill-opacity='0.14' stroke='none'/%3E%3Ccircle cx='80' cy='78' r='1.3' fill='%23d93848' fill-opacity='0.14' stroke='none'/%3E%3C/g%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 35%, #163729 0%, #0e241b 52%, #07130e 100%);
  background-attachment: fixed;
  color: var(--ivory);
  font-family: var(--font-sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

.is-hidden {
  display: none !important;
}

.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;
}

/* Neve ambientale */
#ambient-snow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.screen {
  position: relative;
  z-index: 3;
  min-height: 100dvh;
}

/* =========================================================
   1. SCHERMATA DI ACCESSO (INVITO PRIVATO)
   ========================================================= */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  transition: opacity 420ms ease;
}

.auth-screen.is-fading-out {
  opacity: 0;
  pointer-events: none;
}

.auth-backdrop-glow {
  position: fixed;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 214, 140, 0.16) 0%, transparent 70%);
  pointer-events: none;
}

.invite-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 8px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold-mid) 45%, var(--gold-dark) 80%, var(--gold-mid));
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.65),
    0 0 40px rgba(200, 157, 71, 0.14);
}

.invite-inner {
  background:
    radial-gradient(circle at 50% 0%, rgba(244, 214, 140, 0.08), transparent 60%),
    linear-gradient(180deg, #11261e 0%, #0b1914 100%);
  border-radius: 14px;
  padding: 30px 22px 26px;
  text-align: center;
  border: 1px solid rgba(244, 214, 140, 0.25);
}

.invite-ornament {
  color: var(--gold-bright);
  font-size: 1.35rem;
  margin-bottom: 8px;
  text-shadow: 0 0 12px rgba(244, 214, 140, 0.45);
}

.invite-eyebrow {
  margin: 0 0 10px;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-bright);
  font-weight: 600;
}

.invite-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 2.05rem;
  line-height: 1.08;
  font-weight: 600;
  color: var(--ivory);
}

.invite-subtitle {
  margin: 8px 0 0;
  font-size: 0.84rem;
  color: var(--ivory-muted);
}

.invite-divider {
  width: 68px;
  height: 1px;
  margin: 20px auto;
  background: linear-gradient(90deg, transparent, var(--gold-mid), transparent);
}

.invite-note {
  margin: 0 0 22px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: rgba(245, 239, 228, 0.86);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 11px;
  border: 1px solid rgba(244, 214, 140, 0.32);
  background: rgba(6, 15, 11, 0.75);
  color: var(--ivory);
  font-family: var(--font-sans);
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.auth-form input::placeholder {
  color: rgba(245, 239, 228, 0.4);
}

.auth-form input:focus {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(244, 214, 140, 0.16);
}

.btn-gold {
  padding: 13px 18px;
  border-radius: 11px;
  border: 1px solid rgba(255, 240, 199, 0.45);
  background: linear-gradient(135deg, #f3d488 0%, #c8973e 55%, #9f7126 100%);
  color: #181108;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  transition: transform 140ms ease, filter 180ms ease;
}

.btn-gold:active {
  transform: scale(0.98);
}

.auth-error {
  min-height: 18px;
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: #f4a49a;
}

/* =========================================================
   2. VIDEO INTRODUTTIVO 9:16
   ========================================================= */
.intro-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #0a1712;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 580ms ease;
}

.intro-screen.is-fading-out {
  opacity: 0;
  pointer-events: none;
}

.intro-stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: calc(100dvh * 9 / 16);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0a1712;
}

.intro-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.intro-controls {
  position: absolute;
  top: calc(14px + var(--safe-top));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 3;
  pointer-events: none;
}

.pill-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid rgba(244, 214, 140, 0.35);
  background: rgba(10, 23, 18, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--ivory);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

.pill-btn--skip {
  border-color: rgba(244, 214, 140, 0.5);
  color: var(--gold-bright);
}

.intro-tap-play {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 0;
  background: rgba(10, 23, 18, 0.52);
  color: var(--ivory);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  cursor: pointer;
}

.tap-play-circle {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold-mid));
  color: #161006;
  font-size: 1.5rem;
  padding-left: 4px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

/* =========================================================
   3. PARETE DELLA GALLERIA (24 CORNICI)
   ========================================================= */
.gallery-screen {
  position: relative;
  padding: calc(46px + var(--safe-top)) 14px calc(18px + var(--safe-bottom));
  max-width: 980px;
  margin: 0 auto;
  overflow-x: hidden;
}

/* Festone natalizio superiore */
.christmas-garland-top {
  position: absolute;
  top: var(--safe-top);
  left: -4px;
  right: -4px;
  height: 76px;
  pointer-events: none;
  z-index: 4;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.65));
}

.garland-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.garland-sway-a {
  animation: garlandSway 4.2s ease-in-out infinite alternate;
}
.garland-sway-b {
  animation: garlandSway 4.8s ease-in-out 0.7s infinite alternate-reverse;
}

@keyframes garlandSway {
  from { transform: rotate(-2.2deg); }
  to { transform: rotate(2.2deg); }
}

.fairy-bulb {
  animation: fairyPulse 2.6s ease-in-out infinite;
}
.fairy-bulb.fairy-b { animation-delay: 0.85s; }
.fairy-bulb.fairy-c { animation-delay: 1.7s; }

@keyframes fairyPulse {
  0%, 100% { opacity: 0.58; }
  50% { opacity: 1; }
}

.gallery-header {
  position: relative;
  z-index: 5;
  text-align: center;
  margin-bottom: 24px;
}

.gallery-title-crest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.75rem;
  color: var(--gold-bright);
}

.crest-holly {
  display: inline-block;
  font-size: 0.9rem;
  filter: saturate(1.25);
}
.crest-holly--flip {
  transform: scaleX(-1);
}
.crest-berries {
  color: #dc3545;
  font-size: 0.45rem;
  letter-spacing: 2px;
}
.crest-star {
  font-size: 1rem;
  text-shadow: 0 0 12px rgba(244, 214, 140, 0.75);
}

/* Scena natalizia alla base della galleria */
.christmas-hearth-scene {
  margin: 26px -14px 0;
  pointer-events: none;
  overflow: hidden;
}

.hearth-svg {
  width: 100%;
  height: auto;
  max-height: 155px;
  display: block;
}

.candle-flame {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: candleFlicker 1.7s ease-in-out infinite alternate;
}

@keyframes candleFlicker {
  0% { transform: scaleY(0.94) scaleX(0.98); opacity: 0.88; }
  50% { transform: scaleY(1.06) scaleX(1.02); opacity: 1; }
  100% { transform: scaleY(0.97) scaleX(0.96); opacity: 0.92; }
}

.gallery-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.gallery-progress {
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-bright);
  background: rgba(244, 214, 140, 0.09);
  border: 1px solid rgba(244, 214, 140, 0.22);
  padding: 6px 11px;
  border-radius: 999px;
}

.icon-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(244, 214, 140, 0.25);
  background: rgba(15, 34, 26, 0.72);
  color: var(--ivory);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

.gallery-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.85rem, 6vw, 2.75rem);
  font-weight: 600;
  line-height: 1.08;
  color: var(--ivory);
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

.gallery-subtitle {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--ivory-muted);
  letter-spacing: 0.04em;
}

.preview-banner {
  margin: 14px auto 0;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(244, 214, 140, 0.12);
  border: 1px dashed rgba(244, 214, 140, 0.45);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--gold-bright);
}

.preview-reset-btn {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(244, 214, 140, 0.5);
  background: rgba(10, 23, 18, 0.7);
  color: var(--ivory);
  font-size: 0.74rem;
  cursor: pointer;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  gap: 32px 13px;
  padding: 10px 2px 16px;
}

@media (min-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 30px 18px;
  }
}

@media (min-width: 900px) {
  .gallery-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 34px 22px;
  }
}

/* Singola cornice sulla parete (disposizione "a quadreria") */
.wall-frame {
  position: relative;
  appearance: none;
  border: 0;
  background: transparent;
  width: calc(100% * var(--frame-scale, 1));
  padding: 16px 0 0;
  margin-top: var(--frame-offset-y, 0px);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  color: inherit;
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.wall-frame:active {
  transform: scale(0.95);
}

/* Faretto caldo sopra la cornice */
.wall-spotlight {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, #7f5d22, #e5bf69, #7f5d22);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  opacity: 0.5;
}

.wall-frame--opened .wall-spotlight,
.wall-frame--today .wall-spotlight {
  opacity: 1;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.65),
    0 8px 20px rgba(244, 214, 140, 0.48);
}

/* Cordino dorato + chiodino in ottone da galleria */
.wall-hanger-wire {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 44%;
  height: 16px;
  pointer-events: none;
}

.wall-hanger-wire::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 50%;
  width: 5px;
  height: 5px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff2c2, #c2913b 65%, #664512);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  z-index: 2;
}

.wall-hanger-wire::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  width: 24px;
  height: 24px;
  transform: translateX(-50%) rotate(45deg);
  border-top: 1px solid rgba(226, 189, 107, 0.45);
  border-left: 1px solid rgba(226, 189, 107, 0.45);
}

.wall-bezel {
  position: relative;
  width: 100%;
  aspect-ratio: var(--frame-ratio, 3 / 4);
  padding: 7px;
  border-radius: 6px;
  color: var(--orn-color, #f4d68c);
  box-shadow:
    0 14px 26px rgba(0, 0, 0, 0.6),
    inset 0 1px 1.5px rgba(255, 248, 220, 0.5),
    inset 0 -2px 4px rgba(30, 18, 4, 0.65);
  display: flex;
}

.wall-mat {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 3px;
  border-radius: 3px;
  display: flex;
  box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.65);
}

.wall-frame--today .wall-bezel {
  animation: todayGlow 2.4s ease-in-out infinite;
}

@keyframes todayGlow {
  0%,
  100% {
    box-shadow:
      0 14px 26px rgba(0, 0, 0, 0.58),
      0 0 14px rgba(244, 214, 140, 0.42);
  }
  50% {
    box-shadow:
      0 14px 30px rgba(0, 0, 0, 0.64),
      0 0 28px rgba(244, 214, 140, 0.78);
  }
}

.wall-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 2px;
  overflow: hidden;
  background: #0d1d17;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45);
}

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

/* =========================================================
   STILI CORNICI UNICHE (8 FINITURE · 5 FORME · 6 MODANATURE · 5 MAT)
   ========================================================= */

/* 8 Finiture museali */
.finish--gold-baroque {
  --orn-color: #ffe7a8;
  background: linear-gradient(142deg, #fae096 0%, #c89436 32%, #754e12 66%, #e2b458 100%);
}

.finish--walnut-gold {
  --orn-color: #ebc97c;
  background: linear-gradient(145deg, #6e4427 0%, #442715 38%, #28150a 72%, #5c361e 100%);
  box-shadow:
    0 14px 26px rgba(0, 0, 0, 0.62),
    inset 0 0 0 1.5px rgba(235, 201, 124, 0.55),
    inset 0 -2px 5px rgba(15, 7, 2, 0.8);
}

.finish--antique-brass {
  --orn-color: #f0d797;
  background: linear-gradient(138deg, #d7bc74 0%, #967b3b 42%, #52411c 74%, #b59852 100%);
}

.finish--ebony-gold {
  --orn-color: #f0cd79;
  background: linear-gradient(145deg, #323134 0%, #19181b 45%, #0c0b0e 78%, #2a282c 100%);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.72),
    inset 0 0 0 1.5px rgba(240, 205, 121, 0.62),
    inset 0 0 0 3.5px rgba(15, 14, 17, 0.9);
}

.finish--florentine-bronze {
  --orn-color: #f2c8a2;
  background: linear-gradient(140deg, #b87349 0%, #7d4729 40%, #472514 75%, #9e5d38 100%);
}

.finish--mahogany-gold {
  --orn-color: #f2cf83;
  background: linear-gradient(145deg, #742828 0%, #4a1517 44%, #2b0b0c 78%, #632022 100%);
  box-shadow:
    0 14px 26px rgba(0, 0, 0, 0.65),
    inset 0 0 0 1.5px rgba(242, 207, 131, 0.58),
    inset 0 -2px 5px rgba(20, 4, 5, 0.8);
}

.finish--winter-silver {
  --orn-color: #eef5fc;
  background: linear-gradient(140deg, #e7eef5 0%, #a5b4c4 38%, #5e6d7d 72%, #cfdbe6 100%);
}

.finish--rose-gold-ivory {
  --orn-color: #ffe2d1;
  background: linear-gradient(142deg, #f1c5b1 0%, #c18772 40%, #7c4d3e 74%, #dfa894 100%);
}

/* 5 Silhouette */
.shape--rect {
  border-radius: 5px;
}

.shape--arch {
  border-radius: 50% 50% 6px 6px / 28% 28% 6px 6px;
}
.shape--arch .wall-mat,
.shape--arch .frame-mat,
.shape--arch .wall-canvas,
.shape--arch .painting-viewport {
  border-radius: 50% 50% 4px 4px / 27% 27% 4px 4px;
}

.shape--pill-arch {
  border-radius: 999px 999px 8px 8px;
}
.shape--pill-arch .wall-mat,
.shape--pill-arch .frame-mat,
.shape--pill-arch .wall-canvas,
.shape--pill-arch .painting-viewport {
  border-radius: 999px 999px 5px 5px;
}

.shape--oval {
  border-radius: 50%;
}
.shape--oval .wall-mat,
.shape--oval .frame-mat,
.shape--oval .wall-canvas,
.shape--oval .painting-viewport {
  border-radius: 50%;
}

.shape--chamfer {
  border-radius: 14px 4px 14px 4px;
}
.shape--chamfer .wall-mat,
.shape--chamfer .frame-mat,
.shape--chamfer .wall-canvas,
.shape--chamfer .painting-viewport {
  border-radius: 10px 2px 10px 2px;
}

/* 6 Modanature */
.molding--stepped {
  padding: 8px;
  outline: 1px solid rgba(255, 240, 199, 0.28);
  outline-offset: -3px;
}

.molding--beaded {
  padding: 8px;
  outline: 2px dotted rgba(255, 244, 212, 0.42);
  outline-offset: -4px;
}

.molding--double {
  padding: 8px;
  outline: 1.5px double rgba(255, 242, 204, 0.5);
  outline-offset: -4px;
}

.molding--fluted {
  padding: 8px;
  outline: 1px dashed rgba(255, 240, 198, 0.36);
  outline-offset: -3.5px;
}

.molding--filigree {
  padding: 9px;
  outline: 1.5px solid rgba(255, 243, 206, 0.46);
  outline-offset: -4px;
}

.ornate-frame--modal.molding--stepped,
.ornate-frame--modal.molding--beaded,
.ornate-frame--modal.molding--double,
.ornate-frame--modal.molding--fluted,
.ornate-frame--modal.molding--filigree {
  padding: 13px;
  outline-offset: -6px;
}

/* 5 Passe-partout / Mat interni */
.mat--dark {
  background: linear-gradient(180deg, #1b1711, #100e0a);
}
.mat--ivory {
  background: linear-gradient(180deg, #efe7d7, #dfd3bc);
}
.mat--forest {
  background: linear-gradient(180deg, #163326, #0d2118);
}
.mat--burgundy {
  background: linear-gradient(180deg, #4b1820, #2f0d13);
}
.mat--gold-lip {
  background: linear-gradient(145deg, #d7b25f, #8f6823);
}

/* Ornamenti SVG su angoli e sommità */
.frame-ornaments {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.orn-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  opacity: 0.88;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.6));
}
.ornate-frame--modal .orn-corner {
  width: 30px;
  height: 30px;
}

.orn-tl { top: 2px; left: 2px; }
.orn-tr { top: 2px; right: 2px; transform: scaleX(-1); }
.orn-bl { bottom: 2px; left: 2px; transform: scaleY(-1); }
.orn-br { bottom: 2px; right: 2px; transform: scale(-1); }

.orn-crest {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 34px;
  height: 12px;
  opacity: 0.94;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.65));
}
.ornate-frame--modal .orn-crest {
  width: 58px;
  height: 20px;
}

.orn-crest--top { top: -5px; }
.orn-crest--bottom { bottom: -5px; }

.orn-crest--royal {
  width: 58px;
  height: 21px;
  top: -12px;
}
.ornate-frame--modal .orn-crest--royal {
  width: 104px;
  height: 36px;
  top: -21px;
}

.orn-crest--bottom-royal {
  width: 40px;
  height: 13px;
  bottom: -7px;
}
.ornate-frame--modal .orn-crest--bottom-royal {
  width: 72px;
  height: 22px;
  bottom: -12px;
}

.orn-clasp {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 16px;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 35%, #fff6d4, currentColor 65%, rgba(0, 0, 0, 0.55));
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
}
.orn-clasp--left { left: -3px; }
.orn-clasp--right { right: -3px; }
.ornate-frame--modal .orn-clasp {
  width: 10px;
  height: 28px;
}
.ornate-frame--modal .orn-clasp--left { left: -5px; }
.ornate-frame--modal .orn-clasp--right { right: -5px; }

/* Livelli di elaborazione delle cornici: Classic, Baroque, Royal */
.tier--baroque {
  padding: 9px;
  box-shadow:
    0 16px 30px rgba(0, 0, 0, 0.68),
    inset 0 2px 2px rgba(255, 248, 218, 0.55),
    inset 0 -3px 5px rgba(28, 16, 3, 0.72),
    inset 0 0 0 3px rgba(0, 0, 0, 0.25),
    inset 0 0 0 4.5px rgba(255, 240, 198, 0.34);
}
.ornate-frame--modal.tier--baroque {
  padding: 15px;
  box-shadow:
    0 28px 60px rgba(0, 0, 0, 0.78),
    inset 0 2px 3px rgba(255, 248, 218, 0.65),
    inset 0 -4px 8px rgba(28, 16, 3, 0.75),
    inset 0 0 0 5px rgba(0, 0, 0, 0.28),
    inset 0 0 0 7px rgba(255, 240, 198, 0.36);
}

.tier--royal {
  padding: 10px;
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.75),
    0 0 18px rgba(244, 214, 140, 0.18),
    inset 0 2px 3px rgba(255, 250, 224, 0.72),
    inset 0 -3px 6px rgba(32, 18, 2, 0.8),
    inset 0 0 0 2.5px rgba(48, 28, 5, 0.55),
    inset 0 0 0 4.5px rgba(255, 236, 178, 0.52),
    inset 0 0 0 6.5px rgba(48, 28, 5, 0.45);
}
.ornate-frame--modal.tier--royal {
  padding: 17px;
  box-shadow:
    0 30px 65px rgba(0, 0, 0, 0.82),
    0 0 30px rgba(244, 214, 140, 0.22),
    inset 0 2px 4px rgba(255, 250, 224, 0.76),
    inset 0 -5px 9px rgba(32, 18, 2, 0.82),
    inset 0 0 0 5px rgba(48, 28, 5, 0.55),
    inset 0 0 0 8px rgba(255, 236, 178, 0.55),
    inset 0 0 0 11px rgba(48, 28, 5, 0.45);
}

.tier--baroque .orn-corner,
.tier--royal .orn-corner {
  width: 24px;
  height: 24px;
  opacity: 0.96;
}
.ornate-frame--modal.tier--baroque .orn-corner,
.ornate-frame--modal.tier--royal .orn-corner {
  width: 40px;
  height: 40px;
}

.tier--royal .orn-tl { top: -2px; left: -2px; }
.tier--royal .orn-tr { top: -2px; right: -2px; }
.tier--royal .orn-bl { bottom: -2px; left: -2px; }
.tier--royal .orn-br { bottom: -2px; right: -2px; }

.orn-stud {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff, currentColor 65%, rgba(0, 0, 0, 0.5));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}
.ornate-frame--modal .orn-stud {
  width: 8px;
  height: 8px;
}
.orn-stud--tl { top: 4px; left: 4px; }
.orn-stud--tr { top: 4px; right: 4px; }
.orn-stud--bl { bottom: 4px; left: 4px; }
.orn-stud--br { bottom: 4px; right: 4px; }

.orn-inner-rule {
  position: absolute;
  inset: 3.5px;
  border: 1px solid currentColor;
  border-radius: inherit;
  opacity: 0.45;
}
.ornate-frame--modal .orn-inner-rule {
  inset: 5px;
}

/* Stato brina / bloccato / oggi */
.wall-frost {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.35), transparent 55%),
    linear-gradient(155deg, #cadceb 0%, #98b4cc 55%, #6d89a3 100%);
  color: #162b3d;
  position: relative;
}

.wall-frame--locked .wall-frost {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.16), transparent 60%),
    linear-gradient(155deg, #2b4453 0%, #1d313d 60%, #15242e 100%);
  color: rgba(238, 224, 192, 0.78);
}

.wall-frame--today .wall-frost::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.45) 50%, transparent 65%);
  animation: frostShimmer 3.2s ease-in-out infinite;
}

@keyframes frostShimmer {
  0% { transform: translateX(-60%) rotate(8deg); }
  55%, 100% { transform: translateX(85%) rotate(8deg); }
}

.wall-frost-number {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.wall-frost-icon {
  font-size: 0.72rem;
  opacity: 0.65;
  position: relative;
  z-index: 1;
}

.wall-today-tag {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(20, 32, 42, 0.78);
  color: var(--gold-bright);
  position: relative;
  z-index: 1;
}

.wall-plaque {
  margin-top: 6px;
  min-width: 28px;
  padding: 1px 8px;
  border-radius: 3px;
  background: linear-gradient(180deg, #b68c3e, #846021);
  color: #191207;
  font-family: var(--font-serif);
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.gallery-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(245, 239, 228, 0.5);
}

/* =========================================================
   4. MODALE ZOOM + GRATTA LA NEVE + FLIP 3D
   ========================================================= */
.artwork-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 10, 8, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 320ms ease;
}

.artwork-modal.is-visible .modal-backdrop {
  opacity: 1;
}

.modal-topbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  margin-bottom: 6px;
}

.music-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(244, 214, 140, 0.38);
  background: rgba(15, 34, 26, 0.82);
  color: var(--ivory);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease;
}

.music-btn.is-playing {
  border-color: var(--gold-bright);
  background: rgba(200, 157, 71, 0.22);
  color: var(--gold-bright);
}

.music-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 13px;
}

.music-bars i {
  display: block;
  width: 2.5px;
  height: 5px;
  border-radius: 2px;
  background: currentColor;
}

.music-bars i:nth-child(2) { height: 10px; }
.music-bars i:nth-child(3) { height: 7px; }

.music-btn.is-playing .music-bars i {
  animation: eqBar 0.85s ease-in-out infinite alternate;
}
.music-btn.is-playing .music-bars i:nth-child(2) { animation-delay: 0.2s; }
.music-btn.is-playing .music-bars i:nth-child(3) { animation-delay: 0.4s; }

@keyframes eqBar {
  from { height: 4px; }
  to { height: 13px; }
}

.close-btn {
  margin-left: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(244, 214, 140, 0.35);
  background: rgba(15, 34, 26, 0.85);
  color: var(--ivory);
  font-size: 1.05rem;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.modal-content-wrap {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.card-stage {
  width: 100%;
  max-width: 410px;
  height: min(78dvh, 635px);
  perspective: 1400px;
  -webkit-perspective: 1400px;
  will-change: transform, opacity;
}

.card-flipper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 720ms cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
}

.card-flipper.is-flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card-face--front {
  transform: rotateY(0deg) translateZ(1px);
}

.card-face--back {
  transform: rotateY(180deg) translateZ(1px);
}

.spotlight-cone {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  height: 190px;
  background: radial-gradient(ellipse at top, rgba(244, 214, 140, 0.24) 0%, transparent 72%);
  pointer-events: none;
}

/* Cornice unica nel modale */
.ornate-frame--modal {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  padding: 12px;
  color: var(--orn-color, #f4d68c);
  box-shadow:
    0 24px 55px rgba(0, 0, 0, 0.72),
    inset 0 1px 2px rgba(255, 248, 218, 0.65),
    inset 0 -3px 6px rgba(45, 28, 4, 0.65);
  display: flex;
}

.ornate-frame--modal.is-landscape {
  flex: 0 1 auto;
  aspect-ratio: 4 / 3;
  max-height: 54dvh;
}

:where(.ornate-frame--modal) {
  border-radius: 14px;
  background: linear-gradient(145deg, #f3d488 0%, #bf8d39 36%, #6f4c15 68%, #dbb059 100%);
}

.frame-mat {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 8px;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.85);
  display: flex;
}

:where(.frame-mat) {
  border-radius: 8px;
  background: linear-gradient(180deg, #1b1711, #120f0a);
}

.painting-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d1713;
  display: flex;
  align-items: center;
  justify-content: center;
}

:where(.painting-viewport) {
  border-radius: 4px;
}

.painting-viewport.is-frost-covered {
  background: linear-gradient(155deg, #eef5fb 0%, #dce8f4 50%, #cbdceb 100%);
}

.painting-viewport.is-frost-covered img {
  opacity: 0;
}

.painting-viewport img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-select: none;
}

.scratch-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  transition: opacity 600ms ease;
  z-index: 3;
}

.scratch-canvas:active {
  cursor: grabbing;
}

.scratch-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 4;
}

.snow-dust {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.85);
  animation: dustFly 540ms ease-out forwards;
}

.snow-dust--gold {
  width: 7px;
  height: 7px;
  background: var(--gold-bright);
  box-shadow: 0 0 10px rgba(244, 214, 140, 0.95);
}

@keyframes dustFly {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.2);
  }
}

/* Targhetta museale */
.museum-plaque {
  margin-top: 12px;
  width: 88%;
  max-width: 340px;
  padding: 10px 16px 11px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(46, 36, 22, 0.96) 0%, rgba(25, 19, 11, 0.98) 100%);
  border: 1px solid rgba(226, 189, 107, 0.45);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.plaque-day {
  display: block;
  font-size: 0.67rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-bright);
  margin-bottom: 2px;
}

.plaque-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.15;
  font-weight: 600;
  color: var(--ivory);
  transition: opacity 320ms ease;
}

.plaque-artist {
  margin: 3px 0 0;
  font-size: 0.8rem;
  color: var(--ivory-muted);
  font-style: italic;
  transition: opacity 320ms ease;
}

.museum-plaque.is-masked .plaque-title {
  font-style: italic;
  color: rgba(245, 239, 228, 0.72);
}

.museum-plaque.is-masked .plaque-artist {
  color: rgba(244, 214, 140, 0.65);
}

.interaction-hint {
  margin: 9px 0 0;
  font-size: 0.78rem;
  color: rgba(244, 214, 140, 0.82);
  opacity: 0;
  transition: opacity 350ms ease;
}

.interaction-hint.is-visible,
.interaction-hint--back {
  opacity: 1;
}

/* Retro della cornice (Foto nostra + testo) */
.ornate-frame--back {
  border-radius: 14px;
}

.back-mount {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  padding: 12px;
  background:
    radial-gradient(circle at 50% 0%, rgba(244, 214, 140, 0.08), transparent 60%),
    linear-gradient(180deg, #16241d 0%, #0e1813 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.back-photo-wrap {
  flex: 1.35;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: #f5efe4;
  padding: 7px 7px 14px;
  border-radius: 4px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 2px;
  display: block;
}

.back-text-wrap {
  flex: 0.85;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(8, 17, 13, 0.72);
  border: 1px solid rgba(244, 214, 140, 0.22);
  text-align: center;
}

.back-text-header {
  margin-bottom: 6px;
}

.back-day-chip {
  display: inline-block;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-bright);
  border-bottom: 1px solid rgba(244, 214, 140, 0.3);
  padding-bottom: 2px;
}

.back-dedication {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.12rem;
  line-height: 1.42;
  color: var(--ivory);
  white-space: pre-line;
}

/* =========================================================
   TOAST & ANIMAZIONI DI FEEDBACK
   ========================================================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  transform: translate(-50%, 16px);
  z-index: 80;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(18, 36, 28, 0.94);
  border: 1px solid rgba(244, 214, 140, 0.45);
  color: var(--ivory);
  font-size: 0.84rem;
  text-align: center;
  max-width: calc(100vw - 32px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

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

.shake {
  animation: gentleShake 380ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

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