@property --angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

:root {
  --bg: #07050f;
  --panel: #120d22;
  --panel-2: #1a1233;
  --ink: #f6f1e7;
  --muted: #a69fba;
  --gold-1: #fff3b0;
  --gold-2: #ffc83d;
  --gold-3: #e08a00;
  --danger: #ff6b81;
  --serif: 'Playfair Display', 'Didot', 'Bodoni MT', Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font-family: var(--sans); line-height: 1.5; -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p, blockquote { margin: 0; }
ol { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 3px solid var(--gold-2); outline-offset: 3px; }

.aurora {
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(60vmax 60vmax at 15% 10%, rgba(124, 77, 255, .32), transparent 60%),
    radial-gradient(55vmax 55vmax at 90% 20%, rgba(255, 61, 139, .24), transparent 60%),
    radial-gradient(50vmax 50vmax at 50% 100%, rgba(255, 200, 61, .16), transparent 60%),
    var(--bg);
  background-size: 140% 140%;
  animation: drift 24s ease-in-out infinite alternate;
}
@keyframes drift { to { background-position: 100% 60%; } }

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

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 10px max(16px, 4vw, env(safe-area-inset-right)) 10px max(16px, 4vw, env(safe-area-inset-left)); backdrop-filter: blur(14px);
  background: linear-gradient(to bottom, rgba(7, 5, 15, .9), rgba(7, 5, 15, 0));
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--serif); font-weight: 800; letter-spacing: .16em; }
.top-actions { display: flex; gap: 8px; }

.btn {
  border: 0; border-radius: 999px; padding: 10px 20px; font-weight: 700; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.btn:active { transform: scale(.97); }
.btn.big { padding: 15px 28px; font-size: 1.05rem; }
.btn.small { padding: 8px 14px; min-height: 40px; font-size: .85rem; }
.btn.primary {
  color: #1c1100;
  background: linear-gradient(110deg, var(--gold-1), var(--gold-2) 40%, var(--gold-3) 70%, var(--gold-2));
  background-size: 220% 100%;
  box-shadow: 0 6px 24px rgba(255, 200, 61, .3), inset 0 1px 0 rgba(255, 255, 255, .6);
  animation: sheen 4s linear infinite;
}
.btn.primary:hover { box-shadow: 0 8px 36px rgba(255, 200, 61, .55), inset 0 1px 0 rgba(255, 255, 255, .6); transform: translateY(-2px); }
.btn.ghost { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .18); }
.btn.ghost:hover { background: rgba(255, 255, 255, .12); }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; justify-self: center; font-size: .85rem; }
@keyframes sheen { to { background-position: -220% 0; } }

.hero { text-align: center; padding: clamp(18px, 4vw, 40px) 16px clamp(8px, 2vw, 16px); }
h1 { font-family: var(--serif); font-size: clamp(1.9rem, 6vw, 3.4rem); line-height: 1.1; font-weight: 900; letter-spacing: -.01em; }
.gold-text {
  background: linear-gradient(100deg, var(--gold-3), var(--gold-1), var(--gold-2), var(--gold-1), var(--gold-3));
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: sheen 5s linear infinite; filter: drop-shadow(0 0 22px rgba(255, 200, 61, .4));
}

.court { max-width: 1000px; margin: 0 auto; padding: 0 16px 60px; }

/* Tronos */
.podium { display: grid; grid-template-columns: 1.3fr 1fr 1fr; align-items: end; gap: 10px; max-width: 920px; margin: 0 auto; }
.slot { --scale: 1; --c1: var(--gold-1); --c2: var(--gold-2); --c3: var(--gold-3); --robe: #b0124f; display: grid; justify-items: center; }
.slot.p1 { order: 1; --scale: 1; }
.slot.p2 { order: 2; --scale: .82; --c1: #f4f8fc; --c2: #aab6c4; --c3: #5f6d80; --robe: #5b3fd0; }
.slot.p3 { order: 3; --scale: .68; --c1: #ffd2a8; --c2: #c8742f; --c3: #6e3510; --robe: #8a3b1f; }

.throne {
  position: relative; width: calc(var(--scale) * 100%); padding: 0; border: 0; background: none; display: block;
  container-type: inline-size; animation: rise .8s cubic-bezier(.2, .9, .3, 1.2) both; animation-delay: calc(var(--i, 0) * 140ms);
  filter: drop-shadow(0 10px 26px color-mix(in srgb, var(--c2) 35%, transparent));
  transition: transform .25s ease, filter .25s ease;
}
.slot.p1 .throne { filter: drop-shadow(0 0 40px rgba(255, 200, 61, .5)); }
.throne:hover { transform: translateY(-6px); filter: drop-shadow(0 0 46px color-mix(in srgb, var(--c2) 80%, transparent)); }
.throne svg { display: block; width: 100%; height: auto; }
@keyframes rise { from { opacity: 0; transform: translateY(40px) scale(.95); } }

.g-hi { stop-color: var(--c1); } .g-mid { stop-color: var(--c2); } .g-lo { stop-color: var(--c3); }
.velvet { fill: #2a0f3d; } .cushion { fill: #9b1237; } .robe { fill: var(--robe); }
.robe-line { stroke: var(--robe); stroke-width: 15; stroke-linecap: round; fill: none; }
.skin { fill: #f7e6cc; stroke: rgba(0, 0, 0, .25); } .ermine { fill: #f6f1e7; } .dot { fill: #1a1030; }
.prop { stroke: rgba(70, 35, 0, .75); stroke-width: 1; }
.orb-body { fill: #d81b60; } .orb-band { stroke: var(--c2); stroke-width: 2.5; fill: none; }
.finger { stroke: rgba(0, 0, 0, .35); stroke-width: 1; fill: none; }
.gold-line { stroke: var(--c2); stroke-width: 2; fill: none; }
.jewel-a { fill: #ff3d8b; } .jewel-b { fill: #3ddcff; }
.slot.p2 .c1, .slot.p3 .c1, .slot.p1 .c2, .slot.p3 .c2, .slot.p1 .c3, .slot.p2 .c3 { display: none; }
.slot.p3 .scepter, .slot.p2 .orb, .slot.p3 .orb { display: none; }

.face {
  position: absolute; left: 28%; width: 44%; top: 26.5%; height: 13.5%;
  display: grid; place-items: center; text-align: center; color: #2a1740; pointer-events: none;
}
.face-name { font-family: var(--serif); font-weight: 800; line-height: 1.05; overflow-wrap: anywhere; }
.n1 { font-size: max(11px, 10cqw); } .n2 { font-size: max(10px, 7.6cqw); } .n3 { font-size: max(9px, 6cqw); } .n4 { font-size: max(8px, 5cqw); }
.throne.empty svg { opacity: .42; filter: grayscale(.5); }
.throne.empty .face-name { color: #6d5a85; font-style: italic; }

.paid {
  position: absolute; left: 4%; width: 92%; top: 93.6%; height: 5.8%; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 900; font-size: max(9px, 6.4cqw); color: #2a1500; pointer-events: none;
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.bubble {
  position: relative; width: max(150px, calc(var(--scale) * 100% + 24px)); max-width: 100%; margin-bottom: 16px;
  padding: 9px 13px; border-radius: 16px; background: #fff7e6; color: #2a1740; text-align: center;
  font-size: .85rem; line-height: 1.3; font-style: italic; border: 2px solid var(--c2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4); overflow-wrap: anywhere;
}
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -11px; width: 16px; height: 16px; transform: translateX(-50%) rotate(45deg);
  background: #fff7e6; border-right: 2px solid var(--c2); border-bottom: 2px solid var(--c2);
}
.bubble-text { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.slot.p1 .bubble { font-size: 1rem; }
.bubble.ghost { opacity: .35; }
.tier {
  position: absolute; left: 22%; width: 56%; top: 80.5%; height: 9%; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 900; text-transform: uppercase; letter-spacing: .3em; text-indent: .3em;
  font-size: max(8px, 7cqw); color: #2a1500; pointer-events: none;
}

/* Alfombra */
.carpet {
  position: relative; max-width: 640px; margin: 12px auto 0; padding: 26px 28px 40px;
  background-color: #6d0b24;
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 200, 61, .08) 0 2px, transparent 2px 24px),
    repeating-linear-gradient(-45deg, rgba(255, 200, 61, .08) 0 2px, transparent 2px 24px),
    linear-gradient(180deg, #8f1233, #560a1d);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55), inset 0 8px 30px rgba(0, 0, 0, .35);
}
.carpet::before, .carpet::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 12px;
  background: repeating-linear-gradient(180deg, var(--gold-2) 0 14px, var(--gold-3) 14px 18px);
  opacity: .9;
}
.carpet::before { left: 0; } .carpet::after { right: 0; }
.fringe { position: absolute; left: 0; right: 0; bottom: -14px; height: 14px; background: repeating-linear-gradient(90deg, var(--gold-2) 0 3px, transparent 3px 8px); }

.list { display: grid; gap: 10px; }
.row {
  display: grid; grid-template-columns: 3ch 1fr; gap: 14px; align-items: center; width: 100%; text-align: left;
  padding: 12px 16px; border-radius: 12px; border: 1px solid rgba(255, 200, 61, .35);
  background: rgba(22, 5, 18, .6); animation: rise .5s cubic-bezier(.2, .9, .3, 1.1) both; animation-delay: calc(var(--i, 0) * 60ms);
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}
.row:hover { transform: translateX(4px); background: rgba(22, 5, 18, .85); border-color: var(--gold-2); }
.row .num { font-family: var(--serif); font-weight: 900; font-size: 1.2rem; color: var(--gold-2); text-align: center; }
.row .text { min-width: 0; display: grid; }
.row .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .msg { color: #ecd6de; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skeleton { height: 58px; border-radius: 12px; background: linear-gradient(100deg, rgba(0, 0, 0, .15) 30%, rgba(255, 255, 255, .12) 50%, rgba(0, 0, 0, .15) 70%); background-size: 250% 100%; animation: sheen 1.4s linear infinite; }
.sentinel { height: 1px; }
.end { text-align: center; color: #ecd6de; margin-top: 18px; font-size: .9rem; }

.highlight { animation: pulse 1.6s ease-out 3; border-radius: 14px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 61, 139, .9); } 100% { box-shadow: 0 0 0 26px rgba(255, 61, 139, 0); } }

/* Modales */
dialog { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: min(480px, calc(100vw - 24px)); width: 100%; max-height: 100dvh; overflow: visible; }
dialog::backdrop { background: rgba(5, 3, 12, .78); backdrop-filter: blur(8px); }
dialog[open] { animation: pop .3s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(24px) scale(.95); } }
.sheet {
  max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain;
  position: relative; display: grid; gap: 16px; padding: 28px 24px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid rgba(255, 200, 61, .35); border-radius: 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6), 0 0 60px rgba(255, 200, 61, .12);
}
.sheet h2 { font-family: var(--serif); font-size: 1.7rem; overflow-wrap: anywhere; }
.close { position: absolute; top: 4px; right: 6px; width: 44px; height: 44px; background: none; border: 0; font-size: 1.8rem; color: var(--muted); }
.entry { text-align: center; justify-items: center; }
.badge { padding: 4px 16px; border-radius: 999px; font-weight: 800; letter-spacing: .25em; text-transform: uppercase; font-size: .8rem; color: #1c1100; background: linear-gradient(110deg, var(--gold-1), var(--gold-2)); }
.entry blockquote { font-family: var(--serif); font-style: italic; font-size: 1.25rem; overflow-wrap: anywhere; color: #efe7f7; }
.total { font-family: var(--serif); font-weight: 900; font-size: 1.8rem; color: var(--gold-1); font-variant-numeric: tabular-nums; }
.entry-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.report { display: grid; gap: 10px; justify-items: center; width: 100%; }
label, legend { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); font-weight: 600; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; }
input, textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 12px; resize: none;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .16);
}
select option { color: #111; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold-2); box-shadow: 0 0 0 3px rgba(255, 200, 61, .25); }
.counter { justify-self: end; font-weight: 400; }
.center { text-align: center; }
.hint { font-weight: 400; color: var(--muted); }
.secure { text-align: center; color: var(--muted); font-size: .8rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.money-field {
  display: flex; align-items: center; gap: 8px; padding: 6px 18px; border-radius: 18px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 200, 61, .5);
}
.money-field:focus-within { border-color: var(--gold-2); box-shadow: 0 0 0 3px rgba(255, 200, 61, .25); }
.money-field b { font-family: var(--serif); font-size: 2rem; color: var(--gold-2); }
.money-field input {
  min-width: 0; border: 0; background: none; padding: 6px 0; color: var(--gold-1); appearance: textfield;
  font-family: var(--serif); font-weight: 900; font-size: 2.2rem; font-variant-numeric: tabular-nums;
}
.money-field input:focus { box-shadow: none; }
.money-field input::-webkit-outer-spin-button, .money-field input::-webkit-inner-spin-button { appearance: none; margin: 0; }
.quote { min-height: 1.5em; color: var(--gold-1); font-weight: 700; }
.error { color: var(--danger); font-weight: 600; }
.muted { color: var(--muted); }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share-grid .primary { grid-column: 1 / -1; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #1c1100; padding: 12px 22px; border-radius: 999px; font-weight: 700;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5); animation: pop .3s ease; max-width: 92vw; text-align: center;
}
.offscreen { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 18px 16px max(36px, env(safe-area-inset-bottom)); }

@media (max-width: 420px) {
  .brand { letter-spacing: .08em; font-size: .85rem; gap: 6px; }
  .top-actions { gap: 6px; }
  .btn.small { padding: 8px 11px; font-size: .8rem; }
  .sheet { padding: 24px 18px; }
  .share-grid { grid-template-columns: 1fr; }
  .bubble { font-size: .78rem; }
  .slot.p1 .bubble { font-size: .9rem; }
}

@media (max-width: 700px) {
  .podium { grid-template-columns: 1fr 1fr; gap: 14px 8px; }
  .slot.p1 { grid-column: 1 / -1; order: 0; }
  .slot.p1 .throne { width: 62%; }
  .slot.p2 { order: 1; --scale: .96; }
  .slot.p3 { order: 2; --scale: .8; }
  .carpet { padding: 20px 22px 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
