[hidden] { display: none !important; }
:root {
  --bg: #f4f2ee;
  --beige: #d5c4b5;
  --pink: #f2b6bb;
  --red: #b04547;
  --sage: #a9aa8c;
  --green: #4a6258;
  --ink: #2b2a40;
  --cream: #f8efe2;
  --num-red: #b04547;
  --num-green: #4a6258;
  --radius: 22px;
  --gap: clamp(8px, 1vw, 14px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Nunito', system-ui, sans-serif; }
body { min-height: 100vh; overflow-x: hidden; }

.page {
  display: grid;
  grid-template-columns: minmax(240px, 25%) 1fr;
  gap: clamp(16px, 3vw, 48px);
  min-height: 100vh;
  padding: clamp(20px, 4vw, 60px) clamp(16px, 4vw, 60px) clamp(20px, 4vw, 60px) clamp(16px, 3vw, 40px);
  align-items: center;
}

/* ---------- lateral ---------- */
.side { position: relative; align-self: stretch; display: flex; flex-direction: column; justify-content: flex-start; padding-top: 2vh; min-height: 100%; }
.title { margin: 0; line-height: .9; text-align: left; }
.title-top { display: block; font-family: 'Bebas Neue', sans-serif; font-weight: 400; font-size: clamp(34px, 3.6vw, 60px); letter-spacing: .02em; color: var(--ink); }
.title-script { display: block; font-family: 'Lobster', cursive; font-size: clamp(54px, 5.6vw, 96px); color: var(--red); margin-top: -.05em; }
.title-year { display: block; font-family: 'Lobster', cursive; font-size: clamp(64px, 7.5vw, 130px); color: var(--pink); margin-top: .02em; }
.intro { font-size: 15px; line-height: 1.5; max-width: 30ch; margin: 18px 0 0; color: #5a5868; }

.countdown { position: relative; z-index: 2; margin-top: 22px; background: rgba(255,255,255,.65); backdrop-filter: blur(4px); border-radius: 18px; padding: 14px 16px; max-width: 320px; box-shadow: 0 6px 20px rgba(43,42,64,.06); }
.cd-label { margin: 0 0 8px; font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--red); }
.cd-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.cd-grid b { display: block; font-family: 'Playfair Display', serif; font-weight: 900; font-size: clamp(22px, 2.2vw, 32px); color: var(--ink); font-variant-numeric: tabular-nums; }
.cd-grid span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7a7788; }
.countdown.party .cd-grid { display: none; }
.countdown.party .cd-label { font-family: 'Lobster', cursive; text-transform: none; letter-spacing: 0; font-size: 26px; font-weight: 400; margin: 0; }

.tree-deco { position: absolute; left: calc(-1 * clamp(16px, 3vw, 40px)); bottom: calc(-1 * clamp(20px, 4vw, 60px)); width: 74%; max-width: 300px; pointer-events: none; z-index: 1; }
.tree-deco svg { display: block; width: 100%; height: auto; }

/* ---------- rejilla (escritorio: réplica del diseño) ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: var(--gap);
  width: 100%;
  max-width: 1400px;
  aspect-ratio: 1347 / 877;
  justify-self: center;
}
.cell {
  position: relative;
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: transform .25s ease, box-shadow .25s ease, filter .3s ease;
  -webkit-tap-highlight-color: transparent;
}
.cell:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.cell.bg-beige { background: var(--beige); }
.cell.bg-pink { background: var(--pink); }
.cell.bg-red { background: var(--red); }
.cell.bg-sage { background: var(--sage); }
.cell.bg-green { background: var(--green); }

.num { position: absolute; font-family: 'Playfair Display', serif; font-weight: 900; font-size: clamp(22px, 2.6vw, 46px); line-height: 1; z-index: 2; }
.num.c-red { color: var(--num-red); }
.num.c-ink { color: #141218; }
.num.c-cream { color: #fff; }
.num.c-pink { color: var(--pink); }
.num.c-green { color: var(--num-green); }
.pos-tl { top: 12%; left: 12%; } .pos-tr { top: 12%; right: 12%; }
.pos-bl { bottom: 12%; left: 12%; } .pos-br { bottom: 12%; right: 12%; }

.art { position: absolute; inset: 10%; display: flex; align-items: center; justify-content: center; z-index: 1; pointer-events: none; }
.art svg { max-width: 78%; max-height: 82%; width: auto; height: 100%; }
.art.left { justify-content: flex-start; } .art.right { justify-content: flex-end; }
.art.top { align-items: flex-start; } .art.bottom { align-items: flex-end; }
.art.tall svg { max-height: 92%; }
.hohoho { font-family: 'Bebas Neue', sans-serif; font-size: clamp(32px, 4vw, 70px); line-height: .92; color: transparent; -webkit-text-stroke: 2px var(--pink); letter-spacing: .02em; display: flex; flex-direction: column; margin-top: 18%; }

/* posiciones (diseño original, con el 23 en la casilla grande) */
.d1 { grid-column: 1 / 3; grid-row: 1; }  .d2 { grid-column: 3; grid-row: 1; }
.d15 { grid-column: 4; grid-row: 1; }     .d4 { grid-column: 5; grid-row: 1 / 3; }
.d5 { grid-column: 6; grid-row: 1; }      .d20 { grid-column: 7; grid-row: 1; }
.d11 { grid-column: 1; grid-row: 2 / 4; } .d7 { grid-column: 2; grid-row: 2; }
.d14 { grid-column: 3 / 5; grid-row: 2; } .d8 { grid-column: 6; grid-row: 2; }
.d10 { grid-column: 7; grid-row: 2; }     .d12 { grid-column: 2 / 4; grid-row: 3; }
.d13 { grid-column: 4; grid-row: 3 / 5; } .d17 { grid-column: 5; grid-row: 3; }
.d3 { grid-column: 6 / 8; grid-row: 3; }  .deco { grid-column: 1; grid-row: 4; }
.d16 { grid-column: 2; grid-row: 4; }     .d18 { grid-column: 3; grid-row: 4; }
.d9 { grid-column: 5; grid-row: 4; }      .d23 { grid-column: 6 / 8; grid-row: 4 / 6; }
.d19 { grid-column: 1 / 3; grid-row: 5; } .d6 { grid-column: 3; grid-row: 5; }
.d21 { grid-column: 4; grid-row: 5; }     .d22 { grid-column: 5; grid-row: 5; }

.big-text { position: absolute; top: 9%; left: 8%; right: 8%; text-align: center; font-family: 'Lobster', cursive; font-size: clamp(22px, 2.6vw, 46px); color: var(--green); z-index: 2; transform: rotate(-4deg); }
.d23 .art { inset: 22% 18% 8% 6%; justify-content: flex-start; }
.d23 .num { font-size: clamp(30px, 3.4vw, 60px); }
.deco { cursor: default; background: var(--pink); }

/* ---------- estados ---------- */
.cell.off { filter: grayscale(1) brightness(1.08); opacity: .38; cursor: not-allowed; }
.cell.off .art { opacity: .35; }
.cell.locked .art { opacity: .55; }
.lock {
  position: absolute; z-index: 3; width: clamp(26px, 2.4vw, 36px); height: clamp(26px, 2.4vw, 36px);
  display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.85); color: var(--ink);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.lock svg { width: 60%; height: 60%; }
.lock.pos-tl { top: 9%; left: 9%; } .lock.pos-tr { top: 9%; right: 9%; }
.lock.pos-bl { bottom: 9%; left: 9%; } .lock.pos-br { bottom: 9%; right: 9%; }
.lock.pos-mr { top: 42%; right: 7%; }

.cell.unlocked:hover, .cell.unlocked:focus-visible { transform: translateY(-4px) rotate(-.6deg); box-shadow: 0 12px 26px rgba(43,42,64,.18); }
.cell.today { box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--red); animation: glow 2.2s ease-in-out infinite; }
.cell.today::after {
  content: 'HOY'; position: absolute; z-index: 4; top: 8px; left: 50%; transform: translateX(-50%);
  background: #fff; color: var(--red); font-weight: 800; font-size: 11px; letter-spacing: .14em; padding: 3px 9px; border-radius: 99px;
}
.cell.opened .seen {
  position: absolute; z-index: 3; bottom: 7px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.85); color: var(--red);
  border-radius: 99px; padding: 2px 9px 2px 6px; font-size: 11px; font-weight: 700;
}
.cell .seen { display: none; }
.cell.opened .seen svg { width: 13px; height: 13px; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--red), 0 0 26px 6px rgba(176,69,71,.35); } }
.cell.shake { animation: shake .45s ease; }
@keyframes shake { 20% { transform: translateX(-6px) rotate(-2deg); } 40% { transform: translateX(6px) rotate(2deg); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, calc(100% + 40px));
  background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 99px; font-weight: 700; font-size: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); transition: transform .35s cubic-bezier(.2,1.4,.4,1), opacity .25s; opacity: 0; z-index: 60; text-align: center; max-width: calc(100vw - 32px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.preview-banner { position: fixed; top: 0; left: 0; right: 0; background: var(--green); color: #fff; text-align: center; font-size: 13px; padding: 6px; z-index: 40; }

/* ---------- modal ---------- */
.modal {
  border: 0; padding: 0; border-radius: 26px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  background: var(--cream); color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.35); overflow: auto;
}
.modal::backdrop { background: rgba(43,42,64,.55); backdrop-filter: blur(3px); }
.modal[open] { animation: pop .4s cubic-bezier(.2,1.3,.4,1); }
@keyframes pop { from { transform: scale(.85) rotate(-2deg); opacity: 0; } }
.m-inner { padding: 30px clamp(20px, 5vw, 38px) 34px; }
.m-close { position: sticky; float: right; top: 10px; margin: 10px 10px 0 0; width: 38px; height: 38px; border-radius: 50%; border: 0; background: #fff; font-size: 24px; line-height: 1; cursor: pointer; color: var(--ink); z-index: 2; }
.m-day { margin: 0; font-family: 'Bebas Neue', sans-serif; letter-spacing: .1em; font-size: 18px; color: var(--red); }
.m-title { margin: 2px 0 16px; font-family: 'Lobster', cursive; font-weight: 400; font-size: clamp(30px, 6vw, 42px); color: var(--green); line-height: 1.1; }
.m-photo { margin: 0 0 18px; border-radius: 18px; overflow: hidden; background: #eee; transform: rotate(-1deg); box-shadow: 0 10px 24px rgba(0,0,0,.15); border: 8px solid #fff; }
.m-photo img { display: block; width: 100%; height: auto; max-height: 60vh; object-fit: cover; }
.m-message { white-space: pre-wrap; font-size: 17px; line-height: 1.6; margin: 0 0 18px; }
.m-message:empty { display: none; }
.m-gift { background: #fff; border: 2px dashed var(--pink); border-radius: 18px; padding: 16px 18px; }
.m-gift-label { display: block; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--red); margin-bottom: 4px; }
.m-gift strong { font-family: 'Playfair Display', serif; font-size: 22px; }
.m-gift p { margin: 6px 0 0; white-space: pre-wrap; line-height: 1.5; }
.m-gift p:empty { display: none; }
.m-gift a { display: inline-block; margin-top: 10px; color: #fff; background: var(--red); padding: 8px 16px; border-radius: 99px; text-decoration: none; font-weight: 700; font-size: 14px; }
.m-empty { color: #7a7788; font-style: italic; }
.modal.big { width: min(680px, calc(100vw - 24px)); background: #fff7f2; }
.modal.big .m-title { font-size: clamp(36px, 8vw, 56px); color: var(--red); }

#confetti { position: fixed; inset: 0; margin: 0; padding: 0; border: 0; background: transparent; width: 100vw; height: 100vh; max-width: none; max-height: none; pointer-events: none; z-index: 100; overflow: visible; }
#confetti:not(:popover-open) { display: none; }

/* ---------- tablet / móvil ---------- */
@media (max-width: 980px) {
  .page { grid-template-columns: 1fr; padding: 22px 14px 40px; gap: 18px; align-items: start; }
  .side { padding-top: 0; min-height: 0; align-items: center; text-align: center; }
  .title { text-align: center; display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; column-gap: 12px; }
  .title-top { font-size: 34px; width: 100%; }
  .title-script { font-size: 58px; }
  .title-year { font-size: 58px; }
  .intro { margin: 10px auto 0; text-align: center; }
  .countdown { margin: 16px auto 0; width: 100%; }
  .tree-deco { display: none; }

  .grid { grid-template-columns: repeat(3, 1fr); grid-template-rows: none; grid-auto-rows: 112px; aspect-ratio: auto; }
  .grid .cell { grid-column: auto !important; grid-row: auto !important; order: var(--order); }
  .grid .d23 { grid-column: 1 / -1 !important; grid-row: span 2 !important; }
  .grid .d1, .grid .d22 { grid-column: span 2 !important; }
  .grid .deco { display: none; }
  .num { font-size: 30px; }
  .hohoho { font-size: 26px; margin-top: 10%; }
  .d23 .art { inset: 24% 30% 6% 8%; }
  .big-text { font-size: 32px; }
}
@media (max-width: 420px) {
  .grid { grid-auto-rows: 100px; }
  .num { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .cell, .toast, .modal[open] { transition: none; animation: none !important; }
}
