:root {
  --bg: #0d1a15;
  --bg2: #17261f;
  --red: #b3203a;
  --red2: #7d1228;
  --green: #1f5a43;
  --green2: #143a2c;
  --gold: #f2c46d;
  --gold2: #d49a3a;
  --cream: #fbf3e4;
  --ink: #2b1d1a;
  --muted: #a9b8b0;
  --danger: #ff7b8f;
  --font-display: Georgia, 'Times New Roman', serif;
  --font-hand: 'Segoe Script', 'Bradley Hand', 'Snell Roundhand', 'Comic Sans MS', cursive;
  color-scheme: dark;
}

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

html, body { margin: 0; min-height: 100%; }

body {
  background: radial-gradient(120% 80% at 50% -10%, #234a39 0%, var(--bg) 55%, #08110e 100%) fixed;
  color: var(--cream);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.45;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body.adv-lock { overflow: hidden; }

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

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

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 700;
  text-decoration: none;
  transition: transform .15s, filter .15s, opacity .15s;
}
.btn:active { transform: scale(.96); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-gold { background: linear-gradient(180deg, #ffe09a, var(--gold2)); color: #3b2406; box-shadow: 0 6px 18px rgba(212, 154, 58, .35); }
.btn-red { background: linear-gradient(180deg, #d63553, var(--red2)); color: #fff; }
.btn-ghost { background: rgba(255, 255, 255, .08); color: var(--cream); border: 1px solid rgba(255, 255, 255, .16); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(255, 123, 143, .4); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  z-index: 1;
}
.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 28px;
  padding: 34px 26px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  animation: rise .8s cubic-bezier(.2, .9, .25, 1) both;
}
.login-card img { width: 84px; height: 84px; border-radius: 22px; margin-bottom: 14px; animation: float 4s ease-in-out infinite; }
.login-card h1 { font-family: var(--font-display); font-size: 1.8rem; margin: 0 0 6px; color: var(--gold); }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.login-card input {
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  text-align: center;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(0, 0, 0, .3);
  color: var(--cream);
  margin-bottom: 14px;
}
.login-card input:focus { outline: 2px solid var(--gold); border-color: transparent; }
.login-card .btn { width: 100%; }
.form-error { color: var(--danger); min-height: 1.4em; margin: 0 0 10px !important; font-size: .95rem; }
.shake { animation: shake .45s; }

/* ---------- Calendario ---------- */
header.top { text-align: center; padding: 28px 16px 8px; }
header.top .for { color: var(--gold); letter-spacing: .18em; text-transform: uppercase; font-size: .78rem; margin: 0; }
header.top h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 8vw, 2.8rem);
  margin: 6px 0 8px;
  line-height: 1.1;
  background: linear-gradient(180deg, #fff3cf, var(--gold) 60%, var(--gold2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
header.top .sub { margin: 0; color: var(--muted); font-size: .95rem; min-height: 1.4em; }
.progress { max-width: 260px; height: 6px; margin: 14px auto 0; border-radius: 6px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold2), #ffe09a); transition: width 1s ease; }

main.cal { max-width: 560px; margin: 0 auto; padding: 16px 14px 30px; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (min-width: 640px) {
  main.cal { max-width: 760px; }
  .grid { grid-template-columns: repeat(6, 1fr); gap: 16px; }
}

.door {
  position: relative;
  aspect-ratio: 3 / 4;
  border: 0;
  padding: 0;
  background: none;
  perspective: 700px;
  border-radius: 12px;
  --door: var(--red);
  --door2: var(--red2);
  animation: rise .6s cubic-bezier(.2, .9, .25, 1) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}
.door.c1 { --door: #2a7656; --door2: var(--green2); }
.door.c2 { --door: #c9922f; --door2: #8d5f16; }
.door.c3 { --door: #8c2b4a; --door2: #561429; }

.door-back {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.9rem;
  background: radial-gradient(circle at 50% 55%, #fff1c2 0%, #f0b955 55%, #9a5b1c 100%);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, .45);
}
.door-front {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 40%),
    linear-gradient(180deg, var(--door), var(--door2));
  box-shadow: 0 6px 14px rgba(0, 0, 0, .4), inset 0 0 0 2px rgba(255, 255, 255, .12);
  transform-origin: left center;
  transition: transform .85s cubic-bezier(.3, .7, .2, 1);
  display: grid;
  place-items: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.door-front::before {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 8px;
  border: 1.5px solid rgba(255, 255, 255, .28);
}
.door-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 7vw, 2.1rem);
  color: #fff6dc;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .45);
}
.door-knob {
  position: absolute;
  right: 12%;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, var(--gold2));
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
.door-lock { position: absolute; bottom: 10%; font-size: .72rem; opacity: .75; }
.door-tag {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: #3b2406;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  z-index: 3;
}
.door.open .door-front { transform: rotateY(-118deg); }
.door.opened .door-front { transform: rotateY(-62deg); }
.door.state-today, .door.state-available { animation: rise .6s both, glow 2.2s ease-in-out infinite; animation-delay: calc(var(--i, 0) * 35ms), 0s; }
.door.state-missed { opacity: .4; filter: grayscale(.7); }
.door.state-locked { opacity: .92; }
.door:active:not(.open) { transform: scale(.96); }

footer.foot { text-align: center; padding: 6px 16px 34px; color: var(--muted); font-size: .85rem; }
footer.foot button { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px; }

/* ---------- Avisos ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 30px);
  background: rgba(20, 20, 20, .92);
  border: 1px solid rgba(242, 196, 109, .5);
  color: var(--cream);
  padding: 12px 18px;
  border-radius: 16px;
  max-width: min(92vw, 420px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast small { display: block; color: var(--gold); margin-top: 4px; }

/* ---------- Animaciones ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes float { 50% { transform: translateY(-6px); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 196, 109, .0), 0 0 12px 1px rgba(242, 196, 109, .35); }
  50% { box-shadow: 0 0 0 4px rgba(242, 196, 109, .15), 0 0 26px 6px rgba(242, 196, 109, .6); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
