/* Ofrenda builder */
.examples { margin-top: .9rem; gap: .4rem; }
.examples .chip { font-size: .85rem; }
.builder {
  display: grid; gap: 1.25rem; grid-template-columns: 1fr; padding-bottom: 1rem;
}
@media (min-width: 960px) {
  .builder { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
  .stage-col { position: sticky; top: 108px; }
}
.h3 { font-size: 1.35rem; }
.label { font-weight: 700; display: block; margin-bottom: .35rem; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
@media (max-width: 420px) { .field.two { grid-template-columns: 1fr; } }

/* ---------- Stage ---------- */
.altar-stage {
  --wall-1: #2c1747; --wall-2: #170b29;
  position: relative; overflow: hidden; border-radius: 22px;
  background: radial-gradient(120% 80% at 50% 30%, var(--wall-1), var(--wall-2));
  border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 58px 3% 0;
  isolation: isolate;
}
[data-theme="light"] .altar-stage { --wall-1: #f0c08e; --wall-2: #c9773f; }
.stage-sky { position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(1.5px 1.5px at 12% 20%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1.5px 1.5px at 78% 12%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(1px 1px at 40% 8%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(1px 1px at 90% 40%, rgba(255,255,255,.35), transparent 60%);
}
.stage-sky::after {
  content: ""; position: absolute; inset: 0; background: rgba(5, 0, 12, 0);
  transition: background 1.6s ease;
}
.altar-stage[data-lit="true"] .stage-sky::after { background: rgba(5, 0, 12, .45); }

.stage-banner { position: absolute; top: 0; left: 0; right: 0; height: 58px; display: flex; justify-content: center; gap: 2px; padding: 0 2%; }
.stage-banner::before { content: ""; position: absolute; top: 6px; left: 0; right: 0; height: 2px; background: rgba(255,255,255,.55); }
.flag { flex: 1 1 0; max-width: 62px; height: 52px; margin-top: 6px; transform-origin: top center; animation: flagsway 4s ease-in-out infinite alternate; filter: drop-shadow(0 3px 2px rgba(0,0,0,.25)); }
.flag:nth-child(2n) { animation-delay: -1.3s; }
.flag:nth-child(3n) { animation-delay: -2.1s; }
.flag svg { width: 100%; height: 100%; display: block; }
@keyframes flagsway { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }
.stage-banner[hidden] { display: none; }

.stage-arch { position: absolute; left: 0; right: 0; top: 40px; height: 0; pointer-events: none; z-index: 0; }
.stage-arch svg { position: absolute; left: 50%; transform: translateX(-50%); width: 82%; top: 0; }
.stage-arch[hidden] { display: none; }

.altar { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 0; padding-top: 24px; }
.altar { container-type: inline-size; }
.tier {
  --s: clamp(24px, 6.4vw, 52px);
  --g: 3px;
  position: relative; display: flex; flex-wrap: nowrap; align-items: flex-end; justify-content: center; gap: var(--g);
  padding: 8px 6px 6px; min-height: calc(var(--s) + 18px);
  background: var(--cloth-top, #fbf4ea);
  border-bottom: 9px solid var(--cloth-edge, #e8dccb);
  box-shadow: 0 8px 16px rgba(0,0,0,.25);
  max-width: 100%;
}
.tier[data-tier="0"] { min-width: 62%; z-index: 3; --s: clamp(22px, 5.4vw, 46px); }
.tier[data-tier="1"] { min-width: 80%; z-index: 2; }
.tier[data-tier="2"] { min-width: 98%; z-index: 1; }
@supports (width: 1cqi) {
  .tier { --s: clamp(26px, 9.4cqi, 60px); --g: clamp(2px, 1cqi, 8px); }
  .tier[data-tier="0"] { --s: clamp(22px, 7.8cqi, 52px); }
}
.altar[data-pattern="lace"] .tier::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -17px; height: 9px;
  background: radial-gradient(circle at 6px 0, var(--cloth-edge) 5px, transparent 5.5px) repeat-x 0 0 / 12px 9px;
}
.altar[data-pattern="stripes"] .tier {
  background: repeating-linear-gradient(90deg, #c0392b 0 14px, #f39c12 14px 20px, #16a085 20px 28px, #8e44ad 28px 34px, #c0392b 34px 40px);
}
.altar[data-pattern="tiles"] .tier {
  background-color: #f5f1e8;
  background-image: radial-gradient(circle at 50% 50%, #1f4e9c 3px, transparent 3.5px), linear-gradient(45deg, transparent 46%, rgba(31,78,156,.35) 47% 53%, transparent 54%), linear-gradient(-45deg, transparent 46%, rgba(31,78,156,.35) 47% 53%, transparent 54%);
  background-size: 18px 18px;
}

.slot-empty {
  width: calc(var(--s) * .62); height: calc(var(--s) * .62); border-radius: 50%;
  border: 2px dashed rgba(0,0,0,.18); background: transparent; cursor: pointer; flex: none; padding: 0;
  margin-bottom: 2px;
}
.altar[data-pattern="plain"] .slot-empty, .altar[data-pattern="stripes"] .slot-empty { border-color: rgba(255,255,255,.35); }
.slot-empty:hover, .slot-empty.target { border-color: var(--marigold); background: rgba(255,159,28,.15); }
.off {
  position: relative; width: var(--s); height: var(--s); flex: none; padding: 0; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: end center; border-radius: 10px;
}
.off.new { animation: pop .35s cubic-bezier(.3,1.6,.5,1); }
.off img { width: 100%; height: 100%; display: block; pointer-events: none; }
.off .emo { font-size: calc(var(--s) * .72); line-height: 1; display: block; filter: drop-shadow(0 3px 2px rgba(0,0,0,.3)); pointer-events: none; }
.off.sel { outline: 3px solid var(--marigold); outline-offset: 2px; background: rgba(255,159,28,.18); }
@keyframes pop { from { transform: scale(.3) translateY(-20px); opacity: 0; } to { transform: none; opacity: 1; } }
.off .flame, .off svg .flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flick 1.2s ease-in-out infinite alternate; }
@keyframes flick { 0% { transform: scale(1, 1) rotate(-2deg); } 50% { transform: scale(.92, 1.08) rotate(2deg); } 100% { transform: scale(1.05, .95) rotate(-1deg); } }
.off svg { width: 100%; height: 100%; display: block; pointer-events: none; overflow: visible; }
.off svg .smoke { animation: smoke 3s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes smoke { 0% { opacity: .2; transform: translateY(4px) scaleY(.8); } 50% { opacity: .9; } 100% { opacity: 0; transform: translateY(-6px) scaleY(1.15); } }
.off.fire::before {
  content: ""; position: absolute; left: 50%; top: 0; width: 220%; aspect-ratio: 1; transform: translate(-50%, -40%);
  background: radial-gradient(circle, rgba(255,190,80,.55), rgba(255,140,30,.15) 40%, transparent 65%);
  opacity: 0; transition: opacity 1.2s ease; pointer-events: none; z-index: -1; border-radius: 50%;
}
.altar-stage[data-lit="true"] .off.fire::before { opacity: 1; animation: glow 2.4s ease-in-out infinite alternate; }
@keyframes glow { from { opacity: .75; } to { opacity: 1; } }

.portrait {
  width: calc(var(--s) * 1.45); height: calc(var(--s) * 1.75); flex: none; margin: 0 4px 2px;
  border: 5px solid #d4a017; border-radius: 8px; background: #fff7e6;
  box-shadow: inset 0 0 0 3px #8a5a00, 0 6px 10px rgba(0,0,0,.35);
  display: grid; place-items: center; overflow: hidden; position: relative;
}
.portrait .emo { font-size: calc(var(--s) * .95); line-height: 1; }
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait .initial { font-family: var(--font-display); font-size: calc(var(--s) * .8); color: #6a2c91; font-weight: 800; }
.altar-stage[data-lit="true"] .portrait { animation: halo 3s ease-in-out infinite alternate; }
@keyframes halo { from { box-shadow: inset 0 0 0 3px #8a5a00, 0 0 12px 3px rgba(255,209,102,.5); } to { box-shadow: inset 0 0 0 3px #8a5a00, 0 0 28px 8px rgba(255,209,102,.8); } }

.stage-floor { position: relative; height: 70px; margin: 0 -3%; z-index: 0; }
.stage-floor svg { width: 100%; height: 100%; display: block; }
.stage-floor .petal { opacity: 0; transition: opacity .4s ease; }
.stage-floor[data-show="true"] .petal { opacity: .95; }
.altar-stage[data-lit="true"] .stage-floor .petal { animation: petalin .6s ease both; }
@keyframes petalin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.stage-dedication { text-align: center; padding: .2rem 1rem 1.1rem; position: relative; z-index: 1; color: #fff4e3; }
[data-theme="light"] .stage-dedication { color: #2a1538; }
[data-theme="light"] .altar-stage[data-lit="true"] .stage-dedication { color: #fff4e3; }
.ded-name { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.4rem, 5vw, 2rem); margin: 0; line-height: 1.1; overflow-wrap: anywhere; }
.ded-dates { margin: .1rem 0 0; font-weight: 700; opacity: .85; }
.ded-msg { margin: .35rem 0 0; font-style: italic; opacity: .9; overflow-wrap: anywhere; }
.ded-dates:empty, .ded-msg:empty { display: none; }
.stage-welcome {
  position: absolute; left: 0; right: 0; top: 46%; text-align: center; pointer-events: none; z-index: 5;
  font-family: var(--font-display); font-weight: 800; font-size: clamp(1.4rem, 6vw, 2.6rem); color: #ffd166;
  text-shadow: 0 2px 14px rgba(0,0,0,.8); opacity: 0; transform: translateY(10px); transition: opacity 1s ease, transform 1s ease;
  padding: 0 1rem;
}
.stage-welcome.show { opacity: 1; transform: none; }

/* ---------- Selection bar + elements ---------- */
.selbar { margin-top: .75rem; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: .7rem .9rem; }
.sel-info { margin-bottom: .5rem; }
.sel-actions .btn { min-height: 38px; }
.elements { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: .75rem; }
.el {
  text-align: center; border-radius: 14px; padding: .5rem .25rem; background: var(--card); border: 1.5px dashed var(--line);
  color: var(--ink-mute); transition: all .3s ease;
}
.el span { font-size: 1.3rem; display: block; filter: grayscale(1); opacity: .6; transition: all .3s ease; }
.el b { display: block; font-size: .85rem; }
.el small { display: block; font-size: .7rem; line-height: 1.2; }
.el.on { border-style: solid; border-color: var(--marigold); color: var(--ink); background: color-mix(in srgb, var(--marigold) 16%, var(--card)); }
.el.on span { filter: none; opacity: 1; }

/* ---------- Controls ---------- */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; margin-bottom: .75rem; }
.tabs button {
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink-soft); border-radius: 12px;
  padding: .55rem .3rem; font-weight: 800; font-size: .85rem; cursor: pointer; min-height: 44px;
}
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.portraits { display: grid; grid-template-columns: repeat(8, 1fr); gap: .3rem; }
@media (max-width: 420px) { .portraits { grid-template-columns: repeat(6, 1fr); } }
.portraits button {
  aspect-ratio: 1; border-radius: 12px; border: 2px solid var(--line); background: var(--bg-2); font-size: 1.4rem; cursor: pointer; padding: 0;
}
.portraits button[aria-checked="true"] { border-color: var(--marigold); background: color-mix(in srgb, var(--marigold) 22%, var(--bg-2)); }
.file-btn { margin: 0; }
.cats { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .6rem; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: .4rem; max-height: 340px; overflow-y: auto; padding: 2px; }
.pal {
  display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .45rem .2rem; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--bg-2); cursor: pointer; font-size: .74rem; font-weight: 700; line-height: 1.15; text-align: center;
  min-height: 74px;
}
.pal:hover { border-color: var(--marigold); }
.pal .pi { width: 34px; height: 34px; display: grid; place-items: center; font-size: 1.7rem; line-height: 1; }
.pal .pi img { width: 34px; height: 34px; }
.pal .cnt { font-size: .68rem; color: var(--marigold); }
.checklist-wrap { margin-top: .8rem; background: var(--bg-2); border-radius: 12px; padding: .6rem .8rem; }
.checklist-wrap summary { cursor: pointer; font-weight: 800; }
.checklist { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .25rem; font-size: .9rem; }
.checklist li::before { content: "○ "; color: var(--ink-mute); }
.checklist li.ok::before { content: "● "; color: var(--marigold); }
.swatch {
  width: 46px; height: 34px; border-radius: 8px; border: 2px solid var(--line); cursor: pointer; padding: 0; overflow: hidden;
  display: flex;
}
.swatch span { flex: 1; }
.swatch[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--marigold); }
.big-light { width: 100%; font-size: 1.15rem; padding: 1rem; }
.sound-row { margin-top: .8rem; font-weight: 700; gap: .4rem; display: flex; }
.gallery-card { margin-top: 1rem; }
.gallery { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.gallery li { display: flex; align-items: center; gap: .5rem; background: var(--bg-2); border-radius: 12px; padding: .4rem .6rem; }
.gallery li a { flex: 1; font-weight: 800; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.gallery li .g-emo { font-size: 1.4rem; }
.visit-banner { margin-bottom: 1rem; }
.visit-card { border-color: var(--marigold); }
.visit-mode .controls-col { display: none; }
.visit-mode .builder { grid-template-columns: 1fr; max-width: 720px; }
.visit-mode .stage-col { position: static; }
.visitor-candles { display: flex; justify-content: center; flex-wrap: wrap; gap: 2px; padding: 0 1rem .6rem; position: relative; z-index: 1; }
.visitor-candles .vc { width: 26px; height: 26px; }
.visitor-candles .vc svg { width: 100%; height: 100%; }
.visitor-candles .vc svg .flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flick 1.2s ease-in-out infinite alternate; }
