:root {
  --bg: #0b1020;
  --bg2: #111833;
  --panel: #151d3b;
  --panel2: #1b2550;
  --line: #27315e;
  --text: #eef1ff;
  --muted: #98a2cf;
  --gold: #ffcb05;
  --gold2: #f5a300;
  --blue: #3d7dca;
  --red: #e3350d;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Outfit", system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255, 203, 5, 0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(61, 125, 202, 0.18), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--gold); }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 14px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 16px; cursor: pointer; color: var(--text);
  background: var(--panel); text-decoration: none; white-space: nowrap;
  transition: background .15s, transform .1s, border-color .15s;
}
.btn:hover { background: var(--panel2); border-color: #3a4785; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.primary { background: var(--gold); color: #1a1400; border-color: var(--gold); }
.btn.primary:hover { background: #ffd83d; }
.btn.google { background: #fff; color: #1f1f1f; border: 0; padding: 13px 22px; font-size: 16px; box-shadow: var(--shadow); }
.btn.google:hover { background: #f1f3f4; }

/* ------- badge 30 */
.badge30 {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  display: grid; place-items: center; position: relative;
  background: linear-gradient(180deg, var(--red) 0 46%, #111 46% 54%, #fff 54%);
  box-shadow: 0 0 0 3px #111, 0 6px 18px rgba(227, 53, 13, .35);
}
.badge30 span {
  width: 52%; height: 52%; border-radius: 50%; background: #fff; border: 3px solid #111;
  display: grid; place-items: center; font-weight: 800; font-size: 11px; color: #111;
}
.badge30.big { width: 110px; height: 110px; margin: 0 auto 18px; }
.badge30.big span { font-size: 22px; border-width: 5px; }

/* ------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  max-width: 440px; text-align: center; padding: 40px 32px;
  background: linear-gradient(180deg, rgba(27, 37, 80, .9), rgba(17, 24, 51, .9));
  border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 40px; margin: 0 0 8px; letter-spacing: -.02em; }
.login-card p { color: var(--muted); line-height: 1.5; margin: 0 0 28px; }
.login-card { display: flex; flex-direction: column; gap: 14px; text-align: left; width: min(400px, 100%); }
.login-card .badge30, .login-card h1 { align-self: center; }
.login-card h1 { text-align: center; }
.login-card p { text-align: center; margin: 0 0 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.login-card input {
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
}
.login-card input:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.btn.wide { justify-content: center; padding: 12px; font-size: 16px; margin-top: 6px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible, .chip:focus-visible, .member:focus-visible, .art:focus-visible, .stepper button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.member-list { list-style: none; padding: 0; margin: 0 0 4px; display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow: auto; }
.member-list li { display: flex; align-items: center; gap: 10px; }
.member-list li span:nth-child(2) { flex: 1; min-width: 0; }
.member-list small { color: var(--muted); }
.login-error { color: #ff8a7a !important; margin: 18px 0 0 !important; }

/* ------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 24px; background: rgba(11, 16, 32, .82); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.me { display: flex; align-items: center; gap: 8px; }

main { max-width: 1440px; margin: 0 auto; padding: 22px 24px 40px; }

/* ------- avatars */
.avatar {
  --c: #64748b; width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
  /* Fondo neutro y medio claro para que resalte cualquier Pokémon, también los oscuros; el color de cada persona queda solo en un aro fino */
  background: radial-gradient(circle, #b4bcdc, #6a749f); overflow: hidden; position: relative;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent);
}
.avatar img { width: 100%; height: 100%; object-fit: contain; transform: scale(1.4); }
.avatar.lg { width: 44px; height: 44px; font-size: 18px; }
.me-avatar { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; display: inline-grid; }
.me-avatar:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; max-height: 60vh; overflow: auto; padding: 2px; }
.avatar-grid button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 92px; min-width: 0; padding: 6px 4px;
  color: var(--text); font: inherit; font-size: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.avatar-grid button:hover { border-color: #3a4785; }
.avatar-grid button.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.avatar-grid img { width: 56px; height: 56px; image-rendering: pixelated; }
.avatar-grid .none-avatar { width: 56px; height: 56px; display: grid; place-items: center; font-size: 22px; font-weight: 700; }

/* ------- summary */
.summary { display: grid; grid-template-columns: 260px 1fr; gap: 16px; margin-bottom: 18px; }
.summary > *, .member, .member > * { min-width: 0; }
.group-stat, .member {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.group-stat {
  background: linear-gradient(140deg, #2a2205, #1b1a2f 60%); border-color: #5a4a10;
  display: flex; flex-direction: column; gap: 6px; justify-content: center;
}
.group-stat .label { color: var(--gold); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.group-stat strong { font-size: 32px; letter-spacing: -.02em; }
.group-stat .sub { color: var(--muted); font-size: 13px; }
.bar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--gold2), var(--gold)); transition: width .4s; }

.members { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.member {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center;
  cursor: pointer; text-align: left; font: inherit; color: inherit; transition: border-color .15s, transform .15s;
}
.member:hover { border-color: #3a4785; transform: translateY(-1px); }
.member.active { border-color: var(--c); box-shadow: 0 0 0 1px var(--c) inset; }
.member .avatar { grid-row: span 2; }
.member .name { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
.member .name span { overflow: hidden; text-overflow: ellipsis; }
.member .name small { color: var(--muted); font-weight: 500; }
.member .bar i { background: var(--c); }
.member .stats { grid-column: 1 / -1; color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; }

/* ------- toolbar */
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.sets { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap;
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer;
}
.chip b { color: var(--text); font-weight: 600; margin-left: 4px; opacity: .7; }
.chip.on { color: #1a1400; background: var(--gold); border-color: var(--gold); }
.chip.on b { color: #1a1400; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters input, .filters select, dialog input, dialog select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0;
}
.filters input { flex: 1 1 260px; }
.filters input:focus, .filters select:focus, dialog input:focus, dialog select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; font-size: 14px; background: var(--panel); color: var(--muted); border: 0; padding: 9px 14px; cursor: pointer; }
.seg button.on { background: var(--panel2); color: var(--text); font-weight: 600; }
.count { color: var(--muted); font-size: 13px; margin: 6px 0 14px; }

/* ------- grid of cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 18px; }
.card {
  --c: var(--gold);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 8px 10px; display: flex; flex-direction: column; gap: 8px; position: relative;
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: #3a4785; }
.card.mine { border-color: var(--c); box-shadow: 0 0 0 1px var(--c) inset, 0 8px 24px rgba(0, 0, 0, .25); }
.art {
  aspect-ratio: 63 / 88; border-radius: 9px; overflow: hidden; position: relative; cursor: zoom-in;
  background: var(--bg2); border: 0; padding: 0; width: 100%; display: block;
}
.art img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; }
.numtag { z-index: 2; }
.card:not(.mine) .art img, .card:not(.mine) .ph { filter: grayscale(.85) brightness(.75); }
.card:not(.mine):hover .art img, .card:not(.mine):hover .ph { filter: none; }
.ph {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between;
  padding: 10px; text-align: left; color: #fff;
  background: linear-gradient(160deg, var(--r1), var(--r2));
}
.ph::after {
  content: ""; position: absolute; inset: 22% 14%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .28), transparent 65%);
}
.upload {
  position: absolute; left: 8px; right: 8px; bottom: 30px; z-index: 2; display: none;
  font-size: 12px; font-weight: 700; text-align: center; padding: 7px 6px; border-radius: 8px;
  background: rgba(0, 0, 0, .7); color: var(--gold); border: 1px dashed var(--gold); cursor: pointer;
}
.art.noimg .upload { display: block; }
.art.noimg .ph { filter: none !important; }
.img-warning {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--gold); cursor: pointer;
  background: rgba(255, 203, 5, .08); border: 1px solid rgba(255, 203, 5, .4); border-radius: 10px; padding: 8px 14px; margin-top: 8px;
}
dialog fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 10px; margin: 0; }
dialog legend { font-size: 13px; color: var(--text); padding: 0 6px; }
.form-error { color: #ff8a7a; font-size: 14px; margin: 0; }
dialog legend b { color: var(--gold); font-weight: 600; }
.ph { padding-top: 34px; }
.ph .no { font-size: 12px; font-weight: 700; opacity: .85; }
.ph .nm { font-size: 17px; font-weight: 800; line-height: 1.1; text-shadow: 0 2px 8px rgba(0, 0, 0, .35); position: relative; z-index: 1; }
.ph .rr { font-size: 11px; font-weight: 600; opacity: .9; }
.numtag {
  position: absolute; top: 6px; left: 6px; font-size: 11px; font-weight: 700;
  background: rgba(0, 0, 0, .65); padding: 2px 7px; border-radius: 99px;
}
.card .meta { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; min-height: 38px; }
.card .meta strong { font-size: 14px; line-height: 1.2; }
.rar { font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.rar::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(135deg, var(--r1), var(--r2)); }
.owners { display: flex; flex-wrap: wrap; gap: 4px; min-height: 26px; padding: 0 2px; }
.owners .avatar { width: 24px; height: 24px; font-size: 11px; box-shadow: 0 0 0 2px var(--panel); }
.owners .avatar sup {
  position: absolute; right: -2px; bottom: -2px; font-size: 9px; background: #000; color: #fff;
  border-radius: 99px; padding: 0 3px; line-height: 13px;
}
.owners .none { font-size: 12px; color: #6b76a8; align-self: center; }
.stepper { display: flex; align-items: center; justify-content: space-between; background: var(--bg2); border-radius: 10px; padding: 3px; }
.stepper button {
  width: 32px; height: 30px; border-radius: 8px; border: 0; cursor: pointer; font: inherit; font-size: 18px; font-weight: 700;
  background: transparent; color: var(--text);
}
.stepper button:hover { background: var(--panel2); }
.stepper button.add { background: var(--gold); color: #1a1400; }
.card.mine .stepper button.add { background: transparent; color: var(--text); }
.card.mine .stepper button.add:hover { background: var(--panel2); }
.stepper span { font-size: 13px; color: var(--muted); }
.stepper span b { color: var(--text); font-size: 15px; }

/* rarezas */
[data-r] { --r1: #4b5563; --r2: #1f2937; }
[data-r="Poco común"] { --r1: #16a34a; --r2: #14532d; }
[data-r="Rara"] { --r1: #2563eb; --r2: #1e3a8a; }
[data-r="Rara doble"] { --r1: #7c3aed; --r2: #3b0764; }
[data-r="Rara Pikachu"] { --r1: #facc15; --r2: #b45309; }
[data-r="Rara ilustración"] { --r1: #0ea5e9; --r2: #0f766e; }
[data-r="Rara ilustración especial"] { --r1: #f472b6; --r2: #9a3412; }
[data-r="Rara futurista"] { --r1: #22d3ee; --r2: #c026d3; }
[data-r="Rara RGB"] { --r1: #ef4444; --r2: #2563eb; }
[data-r="Clásica"] { --r1: #b08d57; --r2: #4a3720; }
[data-r="Promo"] { --r1: #e3350d; --r2: #4c0519; }

/* ------- tabla */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); max-height: 75vh; background: var(--panel); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
thead th { position: sticky; top: 0; background: var(--panel2); z-index: 2; font-size: 13px; }
thead th.u { text-align: center; }
thead th.u .avatar { width: 26px; height: 26px; font-size: 11px; display: grid; margin: 0 auto 4px; }
tbody tr:hover td { background: rgba(255, 255, 255, .03); }
td.n { color: var(--muted); font-variant-numeric: tabular-nums; }
td.q { text-align: center; font-weight: 700; }
td.q .dot { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 99px; background: var(--c); color: #fff; font-size: 12px; padding: 0 6px; }
td.q .no { color: #3e4777; }
td.q.meq { cursor: pointer; }
td.q.meq:hover { background: rgba(255, 203, 5, .08); }
tfoot td { position: sticky; bottom: 0; background: var(--panel2); font-weight: 700; text-align: center; }

/* ------- dialogs */
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); padding: 24px; width: min(480px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(5, 8, 18, .7); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 4px; }
dialog .hint { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
dialog .row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 8px 0 0; }
.card-dialog { width: min(760px, calc(100vw - 32px)); }
.cd { display: grid; grid-template-columns: 300px 1fr; gap: 24px; }
.cd .art { cursor: default; }
.cd h2 { font-size: 28px; }
.cd dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; margin: 14px 0; }
.cd dt { color: var(--muted); }
.cd dd { margin: 0; }
.cd .who { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 16px; }
.cd .who div { display: flex; align-items: center; gap: 10px; }
.cd .close { position: absolute; top: 12px; right: 12px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: #000; color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px; box-shadow: var(--shadow);
}

footer { text-align: center; color: #6b76a8; font-size: 12px; padding: 0 16px 32px; }

@media (max-width: 860px) {
  .summary { grid-template-columns: 1fr; }
  .brand p { display: none; }
  #btn-sync { display: none; }
}
@media (max-width: 600px) {
  .topbar { padding: 10px 16px; }
  main { padding: 16px 16px 32px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .cd { grid-template-columns: 1fr; }
  .cd .art { max-width: 240px; margin: 0 auto; }
  #btn-add { padding: 8px 10px; font-size: 0; }
  #btn-add::before { content: "＋"; font-size: 16px; }
  .members { grid-template-columns: 1fr 1fr; gap: 8px; }
  .member { padding: 12px; gap: 6px 10px; }
  .member .avatar.lg { width: 34px; height: 34px; font-size: 15px; }
  .member .stats { flex-direction: column; }
  .filters select { flex: 1 1 140px; }
}

dialog fieldset .btn { align-self: flex-start; }
@media (max-width: 600px) {
  .topbar { gap: 8px; }
  .brand { gap: 10px; }
  .brand .badge30 { width: 36px; height: 36px; }
  .brand h1 { font-size: 18px; white-space: nowrap; }
  .me { gap: 6px; }
  .me .btn { padding: 7px 10px; }
}
.brand, .brand > div { min-width: 0; }
.brand h1 { overflow: hidden; text-overflow: ellipsis; }
.me { flex: none; }
dialog fieldset { min-width: 0; }
dialog .row > label, dialog input { min-width: 0; }

/* ------- precios */
/* Pegado a la esquina y translúcido: se lee pero no compite con la carta */
.pricetag {
  position: absolute; right: 0; bottom: 0; z-index: 2; padding: 2px 7px; border-radius: 8px 0 0 0;
  font-size: 11px; font-weight: 600; line-height: 1.3; white-space: nowrap; color: rgba(255, 255, 255, .92);
  background: rgba(10, 14, 30, .62);
}
.cd .pricetag { font-size: 13px; padding: 3px 9px; }
.slot .pricetag { padding: 1px 5px; border-radius: 5px 0 0 0; font-size: .68em; }
.member-value { display: inline-flex; align-items: center; gap: 4px; flex: none; color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.member-value .eye { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; color: var(--muted); background: none; border: 0; border-radius: 50%; cursor: pointer; }
.member-value .eye:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
.member-value .eye:focus-visible { outline: 2px solid var(--gold); }
.member-value .eye svg { width: 16px; height: 16px; }
.pref-check { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; font-size: 14px !important; cursor: pointer; }
.pref-check input { width: 18px; height: 18px; accent-color: var(--gold); }
.pref-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 14px; }
.pref-row.off { opacity: .45; }
.price-filter { display: inline-flex; gap: 6px; }
.filters .price-filter select { flex: none; width: 92px; }
.filters .price-filter input { flex: none; width: 86px; }
td.price { white-space: nowrap; text-align: right; color: var(--muted); }

/* ------- pokéball del menú */
#me-avatar .avatar { width: 36px; height: 36px; }
.ball-btn { flex: none; width: 36px; height: 36px; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; transition: transform .15s; }
.ball-btn:hover { transform: rotate(-14deg) scale(1.08); }
.ball-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.ball { position: relative; display: block; width: 100%; height: 100%; perspective: 120px; }
.ball-top, .ball-bottom { position: absolute; left: 0; width: 100%; height: 50%; border: 2px solid #111; }
.ball-top {
  top: 0; border-bottom-width: 2px; border-radius: 999px 999px 0 0; transform-origin: bottom center;
  background: radial-gradient(circle at 34% 30%, #ff8a70, var(--red) 55%, #a81f04);
}
.ball-bottom {
  bottom: 0; border-top-width: 2px; border-radius: 0 0 999px 999px;
  background: radial-gradient(circle at 34% 10%, #fff, #dfe3ef 80%);
}
/* El botón central va en la tapa de abajo y se ve también sobre la de arriba */
.ball-bottom::after {
  content: ""; position: absolute; left: 50%; top: 0; width: 34%; aspect-ratio: 1; border-radius: 50%; z-index: 1;
  background: #fff; border: 2px solid #111; box-shadow: 0 0 0 2px #fff inset; transform: translate(-50%, -50%);
}
.ball-core { position: absolute; left: 12%; right: 12%; top: 12%; bottom: 40%; border-radius: 50%; background: #fff; opacity: 0; box-shadow: 0 0 22px 10px #fff; }
.ball-fx {
  position: fixed; z-index: 40; width: 40px; height: 40px; margin: -20px 0 0 -20px; pointer-events: none;
  animation: ball-grow .7s ease-out forwards;
}
.ball-fx .ball-top { animation: ball-lid .7s ease-out forwards; }
.ball-fx .ball-core { animation: ball-glow .7s ease-out forwards; }
.ball-flash {
  position: fixed; z-index: 39; inset: 0; pointer-events: none;
  background: radial-gradient(circle at center, #fff 0, rgba(255, 255, 255, .95) 12%, rgba(255, 190, 200, .6) 32%, transparent 62%);
  animation: ball-flash .95s ease-out forwards;
}
/* Sale despedida girando hacia el centro de la pantalla y allí se abre */
@keyframes ball-grow {
  0% { transform: translate(0, 0) scale(1) rotate(0); }
  42%, 100% { transform: translate(var(--dx), var(--dy)) scale(3) rotate(720deg); }
}
@keyframes ball-lid {
  0%, 42% { transform: rotateX(0); }
  70%, 100% { transform: rotateX(72deg) translateY(-6%); }
}
@keyframes ball-glow {
  0%, 42% { opacity: 0; }
  62%, 100% { opacity: 1; }
}
@keyframes ball-flash {
  0%, 40% { opacity: 0; transform: scale(.2); }
  68% { opacity: 1; transform: scale(1.3); }
  100% { opacity: 0; transform: scale(1.6); }
}
#dlg-members[open] { max-height: calc(100dvh - 24px); overflow: auto; animation: menu-emerge .32s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes menu-emerge {
  from { opacity: 0; transform: scale(.25); }
  to { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  #dlg-members[open] { animation: none; }
}

/* ------- álbum 3D */
#dlg-album {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #27315e, var(--bg) 70%);
}
#dlg-album[open] { display: flex; flex-direction: column; }
.album-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; }
.album-bar select { flex: 0 1 220px; }
.album-nav { display: flex; align-items: center; gap: 8px; flex: 1 1 240px; min-width: 0; }
.album-nav input { flex: 1; min-width: 60px; padding: 0; accent-color: var(--gold); }
#album-pos { color: var(--muted); font-size: 13px; white-space: nowrap; }
.album-hint { margin: 0; padding: 4px 16px 10px; text-align: center; color: var(--muted); font-size: 12px; }
.album-stage {
  --pw: min(calc((100vw - 64px) / 2), calc((100dvh - 150px) * .74));
  flex: 1; min-height: 0; position: relative; overflow: hidden;
  perspective: 1800px; touch-action: none; user-select: none; cursor: grab;
}
.album-stage.grabbing { cursor: grabbing; }
.album-book {
  position: absolute; top: 50%; left: 50%; width: calc(var(--pw) * 2); height: calc(var(--pw) / .74);
  margin: calc(var(--pw) / -1.48) 0 0 calc(var(--pw) * -1); transform-style: preserve-3d; transition: transform .6s ease; font-size: calc(var(--pw) * .032);
}
.album-block { position: absolute; top: 0; bottom: 0; width: 50%; background: #0d1124; transform: translateZ(-5px); border-radius: 3px; }
.album-block.left { left: 0; box-shadow: -2px 3px 0 #2a3050, -4px 6px 0 #1b2038, -6px 22px 40px rgba(0, 0, 0, .55); }
.album-block.right { left: 50%; box-shadow: 2px 3px 0 #2a3050, 4px 6px 0 #1b2038, 6px 22px 40px rgba(0, 0, 0, .55); }
.album-leaf {
  position: absolute; top: 0; left: 50%; width: 50%; height: 100%;
  transform-origin: left center; transform-style: preserve-3d;
}
.album-leaf.curling { z-index: 2; }
.album-leaf.curling > .album-face { visibility: hidden; }
.album-curl { position: absolute; inset: 0; transform: translateZ(1px); transform-style: preserve-3d; pointer-events: none; }
.curl-strip { position: absolute; top: 0; left: 100%; width: 100%; height: 100%; transform-origin: left center; transform-style: preserve-3d; }
.album-curl > .curl-strip { left: 0; }
/* 0.6px de solape para que no se vean rayas entre tiras */
.curl-face { position: absolute; top: 0; bottom: 0; left: 0; width: calc(100% + .6px); overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.curl-face.back { transform: rotateY(180deg); }
.album-face.curl-page { position: absolute; inset: 0 auto 0 auto; height: 100%; transform: none; backface-visibility: visible; -webkit-backface-visibility: visible; border-radius: 0; }
.curl-shade { position: absolute; inset: 0; pointer-events: none; }
.album-cast {
  position: absolute; inset: 0; opacity: 0; pointer-events: none; transform: translateZ(.6px);
  background: linear-gradient(90deg, transparent 12%, rgba(0, 0, 0, .55) 50%, transparent 88%);
}
.album-face {
  position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: #161a2e; display: flex; flex-direction: column; padding: 3.5%; gap: 2%;
}
.album-face.front { border-radius: 0 3px 3px 0; background-image: linear-gradient(90deg, rgba(0, 0, 0, .55), transparent 9%); }
.album-face.back { transform: rotateY(180deg); border-radius: 3px 0 0 3px; background-image: linear-gradient(270deg, rgba(0, 0, 0, .55), transparent 9%); }
.album-pockets { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 2.2%; }
.album-foot { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .72em; white-space: nowrap; }
.album-foot span:first-child { overflow: hidden; text-overflow: ellipsis; }
.slot {
  position: relative; min-width: 0; min-height: 0; padding: 0; overflow: hidden; cursor: pointer; font: inherit; color: var(--muted);
  border: 1px solid rgba(255, 255, 255, .14); border-radius: 5px; background: rgba(255, 255, 255, .03);
}
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.slot.has::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .16), transparent 32%, transparent 68%, rgba(255, 255, 255, .07));
}
.slot.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6%; border-style: dashed; background: rgba(0, 0, 0, .28); text-align: center; }
.slot .no { font-weight: 700; font-size: .95em; opacity: .75; }
.slot .nm { font-size: .72em; line-height: 1.15; opacity: .6; }
.slot.has .nm { display: grid; place-items: center; height: 100%; padding: 6%; }
.slot sup {
  position: absolute; top: 3%; right: 3%; z-index: 1; padding: 1px 6px; border-radius: 99px;
  color: #1a1400; background: var(--gold); font-size: .8em; font-weight: 700;
}
.slot:hover { border-color: var(--gold); }
.slot:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
/* Portada oficial del binder; el sobrante del ancho se recorta de la solapa derecha */
.album-face.album-cover { background: #fff url(/album/cover.webp) left center / cover no-repeat; }
.album-face.album-backcover { background: linear-gradient(160deg, #ffe27a, #ffc21a 45%, #f5a300); }
.album-inside { align-items: center; justify-content: center; text-align: center; gap: 3%; color: var(--muted); }
.album-inside strong { color: var(--text); font-size: 2.4em; }
.album-inside .bar { width: 70%; }
@media (max-width: 600px) {
  .brand > div:last-child { display: none; }
}
@media (max-width: 760px) {
  .album-stage { --pw: min(calc(100vw - 24px), calc((100dvh - 210px) * .74)); }
  .album-bar select { flex: 1 1 130px; }
  .album-face.back:empty, .curl-face.back .album-face:empty { background: #2a3050; }
  #btn-album { padding: 8px 10px; font-size: 0; }
  #btn-album::before { content: "📖"; font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .album-book { transition: none; }
}
