/* Tema liquid glass come Organized, in versione natalizia: notte calda, rosso e oro */
:root {
  --bg: #140a10;
  --text: #f8f1ea;
  --text-2: #d9ccc3;
  --muted: #a8968c;
  --gold: #f2c97d;
  --red: #c8283f;
  --glass: rgba(255, 255, 255, 0.08);
  --rim: rgba(255, 255, 255, 0.16);
  --gloss: rgba(255, 255, 255, 0.28);
  --shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(200, 40, 63, 0.45), transparent 60%),
    radial-gradient(80% 50% at 100% 100%, rgba(242, 201, 125, 0.12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
/* app dalla Home: iOS sbaglia l'altezza con la barra di stato traslucida (vedi Organized) */
@media (display-mode: standalone) { html, body { min-height: 100lvh; } }

button, input { font: inherit; color: inherit; }

.lg {
  background: var(--glass);
  border: 1px solid var(--rim);
  backdrop-filter: blur(20px) saturate(170%);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  box-shadow: inset 0 1px 0 var(--gloss), inset 0 -8px 16px rgba(0, 0, 0, 0.08), var(--shadow);
}

main {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 28px);
}

/* ---------- schermate a scheda (installa, codice, notifiche) ---------- */
.center { min-height: calc(100lvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 48px); display: flex; flex-direction: column; justify-content: center; align-items: center; }
.card { width: 100%; border-radius: 30px; padding: 30px 24px 24px; text-align: center; }
.big { font-size: 52px; line-height: 1; margin-bottom: 12px; }
h1 { font-size: 26px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 8px; font-weight: 700; }
p { color: var(--text-2); line-height: 1.45; margin: 0 0 16px; font-size: 16px; }
.err { color: #ff8a80; min-height: 1.2em; margin: 8px 0 4px; font-size: 14px; }
.err:empty { margin: 0; min-height: 0; }

.steps { list-style: none; padding: 0; margin: 20px 0 0; text-align: left; display: grid; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 18px; background: rgba(255, 255, 255, 0.06); font-size: 15px; color: var(--text-2); }
.steps b { color: var(--text); font-weight: 600; }
.step-ic { flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.1); font-size: 18px; }
.step-ic svg { width: 20px; height: 20px; stroke: #5eb0ff; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.arrow { margin-top: 18px; font-size: 30px; color: var(--gold); animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(8px); } }

input {
  width: 100%; margin-top: 4px; padding: 15px 16px; border-radius: 16px; border: 1px solid var(--rim);
  background: rgba(255, 255, 255, 0.06); font-size: 22px; text-align: center; letter-spacing: 0.25em; font-weight: 600; outline: none;
}
input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 201, 125, 0.2); }
input::placeholder { color: var(--muted); letter-spacing: 0.05em; font-weight: 400; }

.btn {
  display: block; width: 100%; margin-top: 12px; padding: 15px; border: 0; border-radius: 16px; cursor: pointer;
  font-size: 17px; font-weight: 600; text-decoration: none; text-align: center; color: #2a1408;
  background: linear-gradient(#f7d99a, var(--gold));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 6px 16px rgba(242, 201, 125, 0.25);
  transition: transform 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; }
.btn.ghost { background: none; box-shadow: none; color: var(--text-2); font-weight: 500; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- griglia delle caselle ---------- */
.head { padding: 6px 4px 18px; }
.kicker { text-transform: uppercase; letter-spacing: 0.16em; font-size: 12px; font-weight: 700; color: var(--gold); margin: 0 0 6px; }
.head h1 { font-size: 32px; }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-flow: dense; gap: 10px; perspective: 900px; }
.door {
  position: relative; aspect-ratio: 1; border-radius: 22px; cursor: pointer; padding: 0; overflow: hidden;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  animation: doorin 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.1) backwards; animation-delay: calc(var(--i) * 25ms);
  transition: transform 0.2s;
}
.door:active { transform: scale(0.95); }
.door.wide { grid-column: span 2; aspect-ratio: 2; }
.door.wide.tall { grid-row: span 2; aspect-ratio: 1; background: linear-gradient(145deg, rgba(200, 40, 63, 0.55), rgba(120, 18, 32, 0.4)); }
.door:nth-child(3n) { background: rgba(200, 40, 63, 0.22); }
.door:nth-child(5n) { background: rgba(242, 201, 125, 0.12); }
.num { padding: 10px 12px 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.tall .num { font-size: 56px; padding: 16px 18px 0; color: var(--gold); }
.emo { align-self: flex-end; padding: 0 10px 8px; font-size: 20px; }
.tall .emo { font-size: 40px; padding: 0 16px 14px; }
.door.locked { opacity: 0.55; }
.door.locked .emo { font-size: 13px; }
.door.seen { background: rgba(242, 201, 125, 0.16); border-color: rgba(242, 201, 125, 0.35); }
.door.today { border-color: var(--gold); box-shadow: inset 0 1px 0 var(--gloss), 0 0 0 2px rgba(242, 201, 125, 0.35), 0 0 22px rgba(242, 201, 125, 0.35); animation: doorin 0.5s backwards, glow 2.4s ease-in-out 0.6s infinite; }
.door.flip { animation: flip 0.45s cubic-bezier(0.3, 0.7, 0.3, 1); }
@keyframes doorin { from { opacity: 0; transform: translateY(14px) scale(0.94); } }
@keyframes glow { 50% { box-shadow: inset 0 1px 0 var(--gloss), 0 0 0 2px rgba(242, 201, 125, 0.5), 0 0 34px rgba(242, 201, 125, 0.55); } }
@keyframes flip { 50% { transform: rotateY(-70deg) scale(1.05); } }

.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- foglio della sorpresa ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0.5); animation: fadein 0.25s;
}
.overlay[hidden] { display: none; }
.sheet {
  position: relative; width: 100%; max-width: 520px; max-height: 88lvh; overflow-y: auto; overscroll-behavior: contain;
  border-radius: 32px 32px 0 0; padding: 28px 22px calc(env(safe-area-inset-bottom) + 26px); text-align: center;
  background: rgba(40, 22, 28, 0.96); animation: sheetin 0.42s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.overlay.out { animation: fadein 0.22s reverse forwards; }
.overlay.out .sheet { animation: sheetin 0.22s reverse forwards; }
.sheet h2 { font-size: 24px; letter-spacing: -0.02em; margin: 0 0 14px; }
.sheet #s-text { white-space: pre-line; font-size: 18px; color: var(--text); }
.sheet #s-text:empty { display: none; }
.sheet img { display: block; width: 100%; max-height: 58lvh; object-fit: cover; border-radius: 22px; margin: 0 0 16px; box-shadow: var(--shadow); }
.close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.12); cursor: pointer; font-size: 14px; }
@keyframes sheetin { from { transform: translateY(100%); } }
@keyframes fadein { from { opacity: 0; } }
.pop { animation: pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1); }
@keyframes pop { from { opacity: 0; transform: scale(0.94) translateY(10px); } }

/* ---------- neve ---------- */
.snow { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.snow i { position: absolute; top: -10px; aspect-ratio: 1; border-radius: 50%; background: #fff; animation: fall linear infinite; }
@keyframes fall { to { transform: translate3d(30px, 105lvh, 0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .snow { display: none; }
}
