/* =====================================================================
   Studappy · tema nocturno
   Inspirado en el video de presentación (azul noche, cartas del logo y
   marca en tipografía pixel), en versión sobria: brillos suaves, pocas
   animaciones y la letra pixel solo como acento.
   Se carga después de styles.css y solo cambia el aspecto visual.
   ===================================================================== */

/* ---------- Tipografías (servidas desde el propio sitio) ---------- */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Silkscreen";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/silkscreen-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Silkscreen";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/silkscreen-latin-ext-400.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Silkscreen";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/silkscreen-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Silkscreen";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/silkscreen-latin-ext-700.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Inter Tight (Google Fonts, OFL): solo para el título "Studappy" de la portada. */
@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/inter-tight-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Paleta y tokens ---------- */

html.dark-mode {
  --bg: #060a16;
  --surface: #0c1325;
  --surface-soft: #111a30;
  --text: #e4ebf7;
  --text-muted: #9aa8c2;
  --text-faint: #69768f;
  --border: rgba(148, 170, 214, 0.13);
  --border-strong: rgba(148, 170, 214, 0.24);
  --accent: #7ab8ec;
  --accent-strong: #a9d2f5;
  --accent-rgb: 122, 184, 236;
  --accent-soft: rgba(var(--accent-rgb), 0.12);
  --sky: #7ab8ec;
  --sky-soft: rgba(var(--accent-rgb), 0.1);
  --ok: #5fcfa5;
  --ok-soft: rgba(95, 207, 165, 0.12);
  --danger: #f08a99;
  --danger-soft: rgba(240, 138, 153, 0.12);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 9px;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.28);

  /* Colores del logo, algo apagados. */
  --brand-a: #8fdcf2;
  --brand-b: #4a78e0;
  --brand-grad: linear-gradient(100deg, #9fe0f3 0%, #66b3ec 45%, #4a78e0 100%);
  --card-fill: linear-gradient(180deg, #0d1528, #0a1122);
  --surface-deep: #0a1122;
  --surface-raise: #0f182e;
  --estrella-rgb: 170, 200, 240;
  --cielo-rgb: 40, 72, 150;
  --ia-grad: linear-gradient(110deg, #3a6fe0, #4fa9e0, #6a62d0, #3a6fe0);
  --progreso-a: #6fb8ec;
  --progreso-b: #4a78e0;
  --carta-a: #4d86c4;
  --carta-b: #3a5fae;
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-pixel: "Silkscreen", ui-monospace, "Cascadia Mono", monospace;

  /* Esquinas escalonadas chicas (cartas del fondo de la portada). */
  --px-sm: polygon(
    0 4px, 2px 4px, 2px 2px, 4px 2px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 2px, calc(100% - 2px) 2px, calc(100% - 2px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 2px) calc(100% - 4px), calc(100% - 2px) calc(100% - 2px), calc(100% - 4px) calc(100% - 2px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 4px), 0 calc(100% - 4px)
  );

  /* Esquinas escalonadas como las cartas del logo. */
  --px-corners: polygon(
    0 10px, 5px 10px, 5px 5px, 10px 5px, 10px 0,
    calc(100% - 10px) 0, calc(100% - 10px) 5px, calc(100% - 5px) 5px, calc(100% - 5px) 10px, 100% 10px,
    100% calc(100% - 10px), calc(100% - 5px) calc(100% - 10px), calc(100% - 5px) calc(100% - 5px), calc(100% - 10px) calc(100% - 5px), calc(100% - 10px) 100%,
    10px 100%, 10px calc(100% - 5px), 5px calc(100% - 5px), 5px calc(100% - 10px), 0 calc(100% - 10px)
  );
}

/* ---------- Fondo: azul noche con unas pocas estrellas quietas ---------- */

html.dark-mode,
html.dark-mode body {
  background-color: var(--bg);
}

html.dark-mode body {
  background-image: none;
  font-family: var(--font-ui);
  font-feature-settings: "cv11", "ss01";
}

::selection {
  background: rgba(var(--accent-rgb), 0.28);
  color: #fff;
}

html.dark-mode body::before {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 0;
  width: auto;
  height: auto;
  border-radius: 0;
  background:
    radial-gradient(circle 1px at 7% 14%, rgba(var(--estrella-rgb), 0.4) 98%, transparent),
    radial-gradient(circle 1px at 22% 46%, rgba(var(--estrella-rgb), 0.25) 98%, transparent),
    radial-gradient(circle 1px at 34% 80%, rgba(var(--estrella-rgb), 0.3) 98%, transparent),
    radial-gradient(circle 1px at 47% 24%, rgba(var(--estrella-rgb), 0.25) 98%, transparent),
    radial-gradient(circle 1px at 58% 62%, rgba(var(--estrella-rgb), 0.3) 98%, transparent),
    radial-gradient(circle 1px at 71% 10%, rgba(var(--estrella-rgb), 0.35) 98%, transparent),
    radial-gradient(circle 1px at 83% 38%, rgba(var(--estrella-rgb), 0.25) 98%, transparent),
    radial-gradient(circle 1px at 92% 72%, rgba(var(--estrella-rgb), 0.3) 98%, transparent),
    radial-gradient(circle 1px at 14% 90%, rgba(var(--estrella-rgb), 0.25) 98%, transparent),
    radial-gradient(ellipse 70% 45% at 50% -8%, rgba(var(--cielo-rgb), 0.22), transparent 72%);
  content: "";
  filter: none;
  opacity: 1;
  pointer-events: none;
}

html.dark-mode body::after {
  display: none;
}

/* El contenido queda por encima del fondo. */
html.dark-mode #app,
html.dark-mode .footer {
  position: relative;
  z-index: 1;
}

/* ---------- Tipografía ---------- */

/* La letra pixel queda solo en la marca y en las etiquetas pequeñas. */
.eyebrow,
.bento-label,
.modal-kicker,
.flashcard-kicker,
.store-kicker,
.confirm-kicker,
.update-kicker {
  font-family: var(--font-pixel);
  font-weight: 400;
  letter-spacing: 0.08em;
}

/* Textos que antes eran monoespaciados: ahora Inter. */
.footer,
.topbar-tag,
.study-counter,
.deck-pct,
.toolbar-stats,
.study-stats,
.study-foot,
.guided-dot,
.gen-dot,
.store-badge,
.deck-owned-badge,
.breadcrumb,
.account-note,
.account-btn,
.deck-foot,
.flashcard-hint,
.card-row-num,
.gen-card-num,
.btn-grade kbd {
  font-family: var(--font-ui);
  letter-spacing: 0.02em;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.7rem;
}

.breadcrumb {
  font-size: 0.72rem;
}

.topbar-tag,
.account-btn {
  font-size: 0.7rem;
}

.study-counter,
.flashcard-hint {
  font-size: 0.74rem;
}

.study-foot {
  font-size: 0.78rem;
}

.admin-title h1,
.store-header h1,
.study-ready h1,
.study-summary h1,
.empty-state h2 {
  color: var(--text);
  font-weight: 750;
  letter-spacing: -0.025em;
}

h1, h2, h3 {
  letter-spacing: -0.02em;
}

/* ---------- Encabezado ---------- */

html.dark-mode .topbar {
  border-color: var(--border);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.brand {
  font-family: var(--font-pixel);
  font-size: 1.02rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand:hover {
  color: transparent;
  opacity: 0.85;
}

.brand-logo {
  filter: saturate(0.82) brightness(0.95);
}

.main-nav {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.main-nav a {
  color: var(--text-muted);
}

.main-nav a:hover,
.main-nav a[aria-current="page"] {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent-strong);
  box-shadow: none;
}

.topbar-tag {
  color: var(--text-faint);
}

.account-btn,
.google-btn {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.account-btn:hover,
.google-btn:hover {
  border-color: rgba(var(--accent-rgb), 0.45);
  box-shadow: none;
}

.avatar-auto {
  background: linear-gradient(135deg, var(--progreso-a), var(--progreso-b)) !important;
  box-shadow: none;
}

/* ---------- Botones (mismo lugar y función; solo cambia el aspecto) ---------- */

.btn {
  border-radius: 12px;
  font-family: var(--font-ui);
}

.btn.primary,
html.dark-mode .btn.primary {
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  background: #13203d;
  color: #dcecff;
  box-shadow: none;
}

.btn.primary:hover,
html.dark-mode .btn.primary:hover {
  border-color: rgba(var(--accent-rgb), 0.75);
  background: #182848;
  color: #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.btn.ghost {
  border: 1px solid var(--border-strong);
  background: #0b1224;
  color: var(--text-muted);
}

.btn.ghost:hover {
  border-color: rgba(var(--accent-rgb), 0.4);
  background: var(--surface-raise);
  color: var(--text);
  box-shadow: none;
}

.btn.danger {
  border: 1px solid rgba(240, 138, 153, 0.3);
  background: rgba(240, 138, 153, 0.08);
  color: #f3a3ae;
}

.btn.danger:hover {
  background: rgba(240, 138, 153, 0.16);
  color: #fff;
  box-shadow: none;
}

.icon-btn {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
}

.icon-btn:hover {
  border-color: rgba(var(--accent-rgb), 0.4);
  color: var(--accent-strong);
  box-shadow: none;
}

.icon-btn.danger:hover {
  border-color: rgba(240, 138, 153, 0.5);
  color: var(--danger);
  box-shadow: none;
}

.link-btn {
  color: var(--text-muted);
}

.link-btn:hover {
  color: var(--accent-strong);
}

/* El botón de IA sigue destacando, pero con un movimiento lento y suave. */
.btn.btn-ia {
  background: var(--ia-grad);
  background-size: 300% 100%;
  color: #fff;
  text-shadow: none;
  box-shadow: 0 6px 18px rgba(20, 40, 100, 0.35);
  animation: ia-flujo 14s linear infinite;
}

.btn.btn-ia:hover {
  filter: brightness(1.06);
}

.btn.btn-ia::after {
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.16), transparent);
  animation: ia-destello 8s ease-in-out infinite;
}

.btn.btn-ia .ic {
  animation: none;
}

/* ---------- Tarjetas y superficies ---------- */

.deck-card,
.bento-box,
.store-card,
.empty-state,
.study-ready,
.study-summary,
.toolbar .search,
.cards-editor,
.guided-review {
  border: 1px solid var(--border);
  background: var(--card-fill);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.deck-card {
  border-radius: var(--radius);
}

.deck-card:hover,
.deck-card:focus-within {
  border-color: color-mix(in srgb, var(--deck-color, var(--accent)) 38%, transparent);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
}

.deck-dot {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--deck-color, var(--accent)) 14%, transparent);
}

.deck-link h3 {
  color: var(--text);
  font-weight: 700;
}

.deck-card.owned {
  border-top: 1px solid color-mix(in srgb, var(--deck-color, var(--accent)) 45%, transparent);
}

/* Barras de progreso por bloques: un guiño discreto al pixel. */
.mini-bar {
  height: 6px;
  border-radius: 2px;
  background: rgba(148, 170, 214, 0.12);
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 6px, transparent 6px 8px);
  mask-image: repeating-linear-gradient(90deg, #000 0 6px, transparent 6px 8px);
}

.mini-bar > span {
  border-radius: 0;
  background: linear-gradient(90deg, var(--progreso-a), var(--progreso-b));
  box-shadow: none;
}

.deck-card .mini-bar > span {
  background: var(--deck-color, var(--accent));
  opacity: 0.8;
}

.deck-pct,
.deck-count,
.toolbar-stats {
  color: var(--text-faint);
  font-size: 0.74rem;
}

/* Campos de texto */
.search input,
.field input,
.field textarea,
.card-row textarea,
.gen-step textarea,
.gen-card textarea,
.gen-field input {
  color: var(--text);
}

.toolbar .search:focus-within,
.field input:focus,
.card-row textarea:focus,
.gen-step textarea:focus,
.gen-card textarea:focus,
.gen-field input:focus {
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
  outline: none;
}

/* ---------- Modo estudio: la carta con las esquinas del logo ---------- */

.flashcard {
  filter: drop-shadow(0 14px 30px rgba(0, 0, 0, 0.35));
}

.flashcard-face {
  isolation: isolate;
  border: 0;
  border-radius: 0;
  background: linear-gradient(140deg, var(--carta-a), var(--carta-b));
  box-shadow: none;
  clip-path: var(--px-corners);
}

.flashcard-face::before {
  position: absolute;
  inset: 2px;
  z-index: -1;
  background: linear-gradient(180deg, var(--surface-raise), var(--surface-deep));
  clip-path: var(--px-corners);
  content: "";
}

.flashcard-front,
.flashcard-back {
  border-top: 0;
}

.flashcard-back {
  background: linear-gradient(140deg, #3f9c86, #3a68a8);
}

.flashcard-kicker {
  color: var(--accent);
  font-size: 0.7rem;
  text-shadow: none;
}

.flashcard-back .flashcard-kicker {
  color: var(--ok);
}

.flashcard-text {
  color: #eef3fb;
}

.flashcard-hint {
  color: var(--text-faint);
}

.study-head h1 {
  font-weight: 750;
  letter-spacing: -0.03em;
}

.study-counter {
  color: var(--text-faint);
}

.btn-grade {
  border-radius: 12px;
  font-family: var(--font-ui);
}

.btn-grade.sabe { border-color: rgba(111, 211, 154, 0.42); color: #74d6a0; }
.btn-grade.no { border-color: rgba(240, 138, 153, 0.42); color: #f0909d; }
.btn-grade.pendiente { border-color: rgba(232, 184, 90, 0.42); color: #e8bb62; }
.btn-grade.sabe:hover { border-color: #74d6a0; }
.btn-grade.no:hover { border-color: #f0909d; }
.btn-grade.pendiente:hover { border-color: #e8bb62; }
.btn-grade.sabe { background: linear-gradient(rgba(34, 197, 94, 0.12), rgba(34, 197, 94, 0.12)), var(--surface-deep); }
.btn-grade.no { background: linear-gradient(rgba(239, 68, 68, 0.12), rgba(239, 68, 68, 0.12)), var(--surface-deep); }
.btn-grade.pendiente { background: linear-gradient(rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.12)), var(--surface-deep); }
.btn-grade.sabe:hover { background: linear-gradient(rgba(34, 197, 94, 0.22), rgba(34, 197, 94, 0.22)), var(--surface-deep); }
.btn-grade.no:hover { background: linear-gradient(rgba(239, 68, 68, 0.22), rgba(239, 68, 68, 0.22)), var(--surface-deep); }
.btn-grade.pendiente:hover { background: linear-gradient(rgba(245, 158, 11, 0.22), rgba(245, 158, 11, 0.22)), var(--surface-deep); }

.btn-grade kbd {
  font-size: 0.66rem;
}

.ready-icon,
.summary-icon,
.empty-icon,
.guided-icon,
.gen-icon,
.bento-icon {
  border: 1px solid var(--border-strong);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent);
  box-shadow: none;
}

.summary-icon.ok {
  border-color: rgba(95, 207, 165, 0.3);
  background: rgba(95, 207, 165, 0.08);
  color: var(--ok);
}

.shuffle-choice {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}

/* ---------- Ventanas (editor, generador, confirmaciones) ---------- */

.overlay,
.confirm-overlay {
  background: rgba(2, 4, 10, 0.7);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal,
.generador-overlay .gen-modal,
.confirm-dialog {
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #0e162b, var(--surface-deep));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.modal-head,
.modal-foot {
  border-color: var(--border);
}

.modal-kicker {
  color: var(--accent);
  font-size: 0.66rem;
}

.guided-dot,
.gen-dot {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-faint);
}

.guided-dot.active,
.gen-dot.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  box-shadow: none;
}

.guided-dot.complete,
.gen-dot.done {
  border-color: rgba(95, 207, 165, 0.45);
  color: var(--ok);
}

.gen-drop {
  border-color: rgba(var(--accent-rgb), 0.28);
  background: rgba(var(--accent-rgb), 0.03);
}

.gen-drop:hover,
.gen-drop.drag-over {
  border-color: rgba(var(--accent-rgb), 0.55);
  background: rgba(var(--accent-rgb), 0.06);
  box-shadow: none;
}

.gen-tabs {
  background: rgba(255, 255, 255, 0.03);
}

.gen-tab.active {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent-strong);
}

.app-toast,
.update-banner {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--surface-deep) 94%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* Avisos de js/supabase.js (Novedades): abajo a la derecha. */
.update-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 450;
  max-width: min(380px, calc(100vw - 36px));
  padding: 12px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  animation: update-entra 0.25s ease-out;
}

.update-banner .update-kicker {
  color: var(--accent);
  font-size: 0.62rem;
}

.update-banner p {
  margin: 5px 0 0;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.45;
}

.update-banner.update-error {
  border-color: rgba(255, 123, 134, 0.45);
}

.update-banner.update-error .update-kicker {
  color: var(--danger);
}

@keyframes update-entra {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 520px) {
  .update-banner {
    right: 12px;
    bottom: 12px;
    left: 12px;
    max-width: none;
  }
}

/* ---------- Tienda ---------- */

.store-card {
  border-radius: var(--radius);
}

.store-card:hover {
  border-color: rgba(var(--accent-rgb), 0.3);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
}

.store-kicker {
  color: var(--accent);
}

.store-badge.free {
  border-color: rgba(95, 207, 165, 0.35);
  background: rgba(95, 207, 165, 0.08);
  color: var(--ok);
}

.store-tags span {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}

/* ---------- Pie de página ---------- */

.footer {
  border-top-color: var(--border);
  color: var(--text-faint);
  font-size: 0.74rem;
}

/* =====================================================================
   Portada (antes de iniciar sesión)
   ===================================================================== */

/* Inicio: el mago de Studappy sobre fondo índigo, con la marca encima. */
.landing-hero.hero-mago {
  --mago-w: min(820px, 96vw);
  --indigo: #0b0025;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: none;
  margin-top: -40px;
  padding: 0 0 76px;
  text-align: center;
}

/* Cielo nocturno a todo el ancho (también detrás del encabezado): azul
   noche con un toque violeta, que abajo se funde con el resto de la página. */
.landing-hero.hero-mago::before {
  position: absolute;
  top: -240px;
  bottom: 0;
  left: calc(50% - 50vw);
  z-index: -2;
  width: 100vw;
  background:
    radial-gradient(ellipse 34% 30% at 50% 38%, rgba(98, 62, 214, 0.26), transparent 72%),
    radial-gradient(ellipse 58% 46% at 50% 30%, rgba(38, 120, 220, 0.12), transparent 74%),
    linear-gradient(180deg, #080724 0%, #0a0a2b 46%, #08102a 74%, rgba(6, 10, 22, 0) 100%);
  content: "";
  pointer-events: none;
}

/* ---------- Fondo mágico: cartas, brillos y anillo ---------- */

.hero-fondo {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 50vw);
  z-index: -1;
  width: 100vw;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 62%, transparent 96%);
  mask-image: linear-gradient(180deg, #000 0%, #000 62%, transparent 96%);
}

/* Resplandor suave detrás del mago, con los colores de su magia. */
.hf-aura {
  position: absolute;
  top: calc(var(--mago-w) * 0.42);
  left: 50%;
  width: min(900px, 120vw);
  aspect-ratio: 1.3;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 38% 45%, rgba(62, 220, 255, 0.11), transparent 58%),
    radial-gradient(ellipse at 62% 52%, rgba(130, 90, 255, 0.13), transparent 60%);
  transform: translate(-50%, -50%);
  animation: hf-respirar 12s ease-in-out infinite;
}

/* Anillo mágico de puntos que gira muy lento. */
.hf-anillo {
  position: absolute;
  top: calc(var(--mago-w) * 0.44);
  left: 50%;
  width: min(1040px, 150vw);
  height: auto;
  aspect-ratio: 1;
  opacity: 0.2;
  transform: translate(-50%, -50%);
  animation: hf-girar 240s linear infinite;
}

/* Cartas como las del mago: borde cian→azul, esquinas pixel y un rombo. */
.hf-carta {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: var(--w);
  aspect-ratio: 5 / 7;
  opacity: var(--o);
  filter: drop-shadow(0 0 10px rgba(62, 200, 255, 0.3));
  transform: translate(-50%, 0) rotate(var(--r));
  animation: hf-flotar var(--t) ease-in-out var(--d) infinite;
}

.hf-carta b {
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, #7fe6ff, #3fa8f0 45%, #4b5ee8);
  clip-path: var(--px-sm);
}

.hf-carta b::before {
  position: absolute;
  inset: 2px;
  background: linear-gradient(180deg, #101543, #0a0c2c);
  clip-path: var(--px-sm);
  content: "";
}

.hf-carta i {
  position: absolute;
  inset: 18% 16%;
  border: 1px solid rgba(110, 215, 255, 0.4);
}

.hf-carta i::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34%;
  aspect-ratio: 1;
  border: 2px solid #6fe0ff;
  transform: translate(-50%, -50%) rotate(45deg);
  content: "";
}

/* Brillos en cruz de pixeles (como los del mago) que titilan despacio. */
.hf-chispa {
  --c: #a6ecff;
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: var(--s);
  height: var(--s);
  background: #ffffff;
  box-shadow:
    0 calc(var(--s) * -1) var(--c), 0 var(--s) var(--c),
    calc(var(--s) * -1) 0 var(--c), var(--s) 0 var(--c),
    0 calc(var(--s) * -2) rgba(166, 236, 255, 0.35), 0 calc(var(--s) * 2) rgba(166, 236, 255, 0.35),
    calc(var(--s) * -2) 0 rgba(166, 236, 255, 0.35), calc(var(--s) * 2) 0 rgba(166, 236, 255, 0.35);
  opacity: 0.15;
  animation: hf-titilar var(--t) ease-in-out var(--d) infinite;
}

.hf-chispa.lila {
  --c: #cdbdff;
}

@keyframes hf-flotar {
  0%, 100% { transform: translate(-50%, 0) rotate(var(--r)); }
  50% { transform: translate(-50%, -14px) rotate(calc(var(--r) + 5deg)); }
}

@keyframes hf-titilar {
  0%, 100% { opacity: 0.12; }
  50% { opacity: 0.9; }
}

@keyframes hf-girar {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes hf-respirar {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

.hero-escena {
  position: relative;
  z-index: -1;
  width: var(--mago-w);
  aspect-ratio: 1;
  pointer-events: none;
}

/* El personaje se desvanece hacia abajo, detrás del texto. */
.hero-mago-img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-mask-image: linear-gradient(180deg, #000 38%, rgba(0, 0, 0, 0.62) 56%, rgba(0, 0, 0, 0.18) 70%, transparent 82%);
  mask-image: linear-gradient(180deg, #000 38%, rgba(0, 0, 0, 0.62) 56%, rgba(0, 0, 0, 0.18) 70%, transparent 82%);
  animation: flotar-mago 9s ease-in-out infinite;
}

@keyframes flotar-mago {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.hero-mago .hero-copy {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 660px;
  margin-top: calc(var(--mago-w) * -0.42);
  padding: 0 16px;
}

.hero-mago .eyebrow {
  color: #b3a7ff;
  text-shadow: 0 0 18px rgba(11, 0, 37, 0.9);
}

.landing-hero.hero-mago h1.wordmark {
  margin: 12px 0 0;
  font-family: "Inter Tight", var(--font-ui);
  font-size: clamp(2.9rem, 12vw, 6.6rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  text-transform: uppercase;
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
  text-shadow: 0 2px 30px rgba(11, 0, 37, 0.95), 0 0 70px rgba(11, 0, 37, 0.8);
}

.landing-hero.hero-mago p {
  max-width: 520px;
  margin: 20px auto 30px;
  color: #c4bfe4;
  font-size: clamp(1.02rem, 1.7vw, 1.2rem);
  line-height: 1.55;
  text-shadow: 0 1px 18px rgba(11, 0, 37, 0.9);
}

.hero-mago .landing-actions {
  justify-content: center;
}

.landing-login {
  padding: 13px 22px;
}

html.dark-mode .hero-mago .btn.primary {
  border: 1px solid rgba(165, 145, 255, 0.55);
  background: #1a0f4d;
  color: #f1edff;
}

html.dark-mode .hero-mago .btn.primary:hover {
  border-color: rgba(190, 175, 255, 0.9);
  background: #22145f;
  color: #fff;
}

html.dark-mode .hero-mago .btn.ghost {
  border-color: rgba(165, 145, 255, 0.24);
  background: #120836;
  color: #d2ccf2;
}

html.dark-mode .hero-mago .btn.ghost:hover {
  border-color: rgba(190, 175, 255, 0.5);
  background: #190b47;
  color: #fff;
}

.landing-hero.hero-mago small {
  margin-top: 14px;
  color: #8d86b8;
}

/* ---------- Cinta de flashcards de ejemplo ---------- */

.marquee {
  position: relative;
  display: grid;
  gap: 16px;
  width: 100vw;
  margin: 18px 0 56px calc(50% - 50vw);
  padding: 14px 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
}

.marquee-row {
  overflow: hidden;
}

/* Cada mitad mide unos 6.900 px (24 cartas): la duración da ~24 px por segundo. */
.marquee-track {
  display: flex;
  width: max-content;
  animation: cinta 290s linear infinite;
  will-change: transform;
}

.marquee-row.reverse .marquee-track {
  animation-direction: reverse;
  animation-duration: 320s;
}

/* La cinta corre sola y sin pausa, siempre (también si Windows tiene las
   animaciones desactivadas o el mouse está encima). */
.marquee-track,
.marquee-row:hover .marquee-track {
  animation-play-state: running;
}

.marquee-set {
  display: flex;
  gap: 16px;
  padding: 6px 16px 6px 0;
}

@keyframes cinta {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.mq-card {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 270px;
  min-height: 150px;
  flex: none;
  padding: 18px 18px 16px;
  background: linear-gradient(140deg, #3f6fa6, #34539a);
  clip-path: var(--px-corners);
}

.mq-card::before {
  position: absolute;
  inset: 2px;
  z-index: -1;
  background: linear-gradient(180deg, var(--surface-raise), var(--surface-deep));
  clip-path: var(--px-corners);
  content: "";
}

.marquee-row.reverse .mq-card {
  background: linear-gradient(140deg, #3a8a7c, #36609a);
}

.mq-tema {
  color: var(--accent);
  font-family: var(--font-pixel);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.marquee-row.reverse .mq-tema {
  color: var(--ok);
}

.mq-q {
  margin: 0;
  color: #e8eef8;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.35;
}

.mq-a {
  margin: auto 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 0.86rem;
}

.mq-a .mq-r {
  color: var(--accent);
  font-weight: 700;
}

.mq-card .katex {
  font-size: 1.02em;
  white-space: nowrap;
}

/* ---------- Funciones (bento) ---------- */

.bento-box {
  border-radius: var(--radius);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bento-box:hover {
  border-color: rgba(var(--accent-rgb), 0.25);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
}

.bento-label {
  color: var(--accent);
  font-size: 0.64rem;
}

.bento-box h2 {
  color: var(--text);
}

.bento-box p {
  color: var(--text-muted);
}

.bento-icon.blue {
  border-color: rgba(140, 150, 230, 0.28);
  background: rgba(110, 115, 220, 0.1);
  color: #aab4f0;
}

.bento-icon.mint {
  border-color: rgba(95, 207, 165, 0.28);
  background: rgba(95, 207, 165, 0.08);
  color: var(--ok);
}

/* ---------- Celular ---------- */

@media (max-width: 720px) {
  .landing-hero.hero-mago {
    margin-top: -24px;
    padding-bottom: 56px;
  }

  /* En pantallas angostas el mago ocupa casi todo el ancho: cartas más
     chicas y tenues, y solo algunas. */
  .hf-carta {
    width: calc(var(--w) * 0.62);
    opacity: calc(var(--o) * 0.7);
  }

  .hf-carta.bajo,
  .hf-chispa.centro {
    display: none;
  }

  .landing-hero.hero-mago p {
    margin: 16px auto 24px;
  }

  .hero-mago .landing-actions {
    flex-direction: column;
    align-items: stretch;
    width: min(100%, 340px);
  }

  .mq-card {
    width: 230px;
    min-height: 140px;
  }

  /* Cartas más angostas: misma velocidad con una duración menor. */
  .marquee-track {
    animation-duration: 250s;
  }

  .marquee-row.reverse .marquee-track {
    animation-duration: 275s;
  }

  .marquee {
    margin-bottom: 40px;
  }

  .brand {
    font-size: 0.9rem;
  }
}


/* =====================================================================
   Mazo del mago (PAES Ciencias): tarjeta destacada, submazos y química
   en pixel art. Mismo cielo nocturno y magia que la portada.
   ===================================================================== */

.deck-card.deck-mago,
.mago-portada,
.store-card.store-mago {
  --cielo-mago:
    radial-gradient(ellipse 55% 70% at 24% 46%, rgba(98, 62, 214, 0.3), transparent 70%),
    radial-gradient(ellipse 45% 60% at 18% 32%, rgba(38, 120, 220, 0.16), transparent 72%),
    linear-gradient(135deg, #0a0726 0%, #0b0a2c 52%, #0a1030 100%);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid rgba(150, 120, 255, 0.34);
  background: var(--cielo-mago);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), 0 0 40px rgba(110, 80, 240, 0.1);
}

/* ---------- Tarjeta en Mis mazos ---------- */

.deck-card.deck-mago {
  order: -1;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  min-height: 380px;
  padding: 0;
}

.deck-card.deck-mago:hover,
.deck-card.deck-mago:focus-within {
  border-color: rgba(170, 145, 255, 0.55);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.45), 0 0 46px rgba(120, 90, 255, 0.16);
}

.mago-lado {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 380px;
}

.mago-escena {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.mago-aura {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120%;
  aspect-ratio: 1.15;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 40% 45%, rgba(62, 220, 255, 0.12), transparent 58%),
    radial-gradient(ellipse at 60% 55%, rgba(150, 90, 255, 0.2), transparent 60%);
  transform: translate(-50%, -50%);
  animation: hf-respirar 12s ease-in-out infinite;
}

.mago-anillo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 130%;
  height: auto;
  aspect-ratio: 1;
  opacity: 0.15;
  transform: translate(-50%, -50%);
  animation: hf-girar 240s linear infinite;
}

/* Química en pixel art que flota alrededor del mago. */
.mago-flota {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: var(--s);
  height: var(--s);
  opacity: 0.85;
  filter: drop-shadow(0 0 8px rgba(120, 200, 255, 0.35));
  transform: rotate(var(--r));
  animation: mago-flotar var(--t) ease-in-out var(--d) infinite;
}

.px-icono {
  display: block;
  image-rendering: pixelated;
}

.mago-flota .px-icono {
  width: 100%;
  height: 100%;
}

@keyframes mago-flotar {
  0%, 100% { transform: translateY(0) rotate(var(--r)); }
  50% { transform: translateY(-10px) rotate(calc(var(--r) + 6deg)); }
}

.mago-img {
  position: relative;
  z-index: 1;
  display: block;
  height: auto;
  -webkit-mask-image: linear-gradient(180deg, #000 72%, transparent 98%);
  mask-image: linear-gradient(180deg, #000 72%, transparent 98%);
  animation: flotar-mago 9s ease-in-out infinite;
}

.mago-lado .mago-img {
  width: min(420px, 94%);
  margin: -6px 0 -26px;
}

.mago-cuerpo {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: 26px 28px 26px 6px;
}

.deck-mago .deck-top .eyebrow,
.mago-portada .eyebrow {
  color: #b3a7ff;
  font-size: 0.64rem;
}

.deck-mago .deck-link {
  flex: 0 0 auto;
}

.deck-mago .deck-link h3 {
  margin: 2px 0 8px;
  color: #ffffff;
  font-family: "Inter Tight", var(--font-ui);
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.02;
}

.deck-mago .deck-link p {
  max-width: 48ch;
  color: #c4bfe4;
  font-size: 0.9rem;
}

.mago-chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.mago-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 12px 8px 8px;
  border: 1px solid rgba(150, 130, 255, 0.22);
  border-radius: 12px;
  background: rgba(12, 10, 44, 0.72);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.mago-chip:hover,
.mago-chip:focus-visible {
  border-color: rgba(150, 200, 255, 0.55);
  background: rgba(22, 18, 70, 0.9);
  transform: translateY(-1px);
}

.mago-chip .px-icono {
  flex: none;
  width: 32px;
  height: 32px;
}

.mago-chip-txt {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.mago-chip-num,
.submazo-num {
  color: #9d92e8;
  font-family: var(--font-pixel);
  font-size: 0.56rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mago-chip strong {
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mago-chip-pct {
  flex: none;
  color: var(--text-faint);
  font-size: 0.72rem;
}

.mago-chip.completo {
  border-color: rgba(95, 207, 165, 0.45);
}

.mago-chip.completo .mago-chip-pct {
  color: var(--ok);
}

.deck-mago .deck-foot {
  margin-top: 18px;
}

.deck-mago .mini-bar > span,
.mago-portada .mini-bar > span,
.submazo .mini-bar > span {
  background: linear-gradient(90deg, #5fd8ff, #8a6bff);
  opacity: 1;
}

.mago-abrir {
  align-self: flex-start;
  margin-top: 18px;
}

html.dark-mode .deck-mago .btn.primary,
html.dark-mode .mago-portada .btn.primary {
  border: 1px solid rgba(165, 145, 255, 0.55);
  background: #1a0f4d;
  color: #f1edff;
}

html.dark-mode .deck-mago .btn.primary:hover,
html.dark-mode .mago-portada .btn.primary:hover {
  border-color: rgba(190, 175, 255, 0.9);
  background: #22145f;
  color: #ffffff;
}

/* ---------- Pantalla del mazo: elegir submazo ---------- */

.mago-portada {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
  padding: 34px 38px;
  border-radius: 24px;
}

.mago-portada-texto {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.mago-portada h1 {
  margin: 10px 0 8px;
  color: #ffffff;
  font-family: "Inter Tight", var(--font-ui);
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
}

.mago-portada p {
  max-width: 46ch;
  margin: 0;
  color: #c4bfe4;
}

.mago-progreso {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0 22px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.mago-progreso .mini-bar {
  width: 190px;
}

.mago-portada-img {
  position: relative;
  z-index: 1;
  align-self: stretch;
  display: grid;
  place-items: center;
  min-height: 300px;
}

.mago-portada-img .mago-escena {
  inset: -34px -38px -34px -10px;
  overflow: visible;
}

.mago-portada-img .mago-aura {
  width: 105%;
}

.mago-portada-img .mago-img {
  width: min(340px, 100%);
  margin: -24px auto -46px;
}

.submazos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.submazo {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-fill);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.submazo:hover,
.submazo:focus-visible {
  border-color: rgba(150, 130, 255, 0.5);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.36), 0 0 26px rgba(120, 90, 255, 0.12);
  transform: translateY(-2px);
}

.submazo.completo {
  border-color: rgba(95, 207, 165, 0.42);
}

.submazo-icono {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  margin-bottom: 8px;
  border: 1px solid rgba(150, 130, 255, 0.26);
  border-radius: 16px;
  background: radial-gradient(circle, rgba(130, 100, 255, 0.22), rgba(20, 16, 60, 0.6));
}

.submazo-icono .px-icono,
.ready-px .px-icono {
  width: 48px;
  height: 48px;
}

.submazo h2 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.submazo p {
  flex: 1;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.submazo-pie {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  color: var(--text-faint);
  font-size: 0.74rem;
}

.submazo-pie .mini-bar {
  display: block;
  flex: 1;
}

.submazo .deck-pend {
  margin-top: 4px;
}

.submazo-jugar {
  position: absolute;
  top: 20px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid rgba(165, 145, 255, 0.45);
  border-radius: 999px;
  background: #1a0f4d;
  color: #f1edff;
  font-size: 0.78rem;
  font-weight: 650;
}

.submazo:hover .submazo-jugar {
  border-color: rgba(190, 175, 255, 0.9);
  background: #22145f;
}

.ready-icon.ready-px {
  border: 1px solid rgba(150, 130, 255, 0.26);
  background: radial-gradient(circle, rgba(130, 100, 255, 0.24), rgba(20, 16, 60, 0.6));
}

/* ---------- Tienda: tarjeta compacta del mago ---------- */

/* Arriba, una franja con el cielo, el mago y su química; abajo, el texto. */
.store-card.store-mago {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
}

.store-card.store-mago:hover {
  border-color: rgba(170, 145, 255, 0.55);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42), 0 0 40px rgba(120, 90, 255, 0.16);
}

.sm-arte {
  position: relative;
  display: grid;
  height: 168px;
  place-items: start center;
  overflow: hidden;
}

.sm-arte .mago-img {
  width: 236px;
  margin-top: -6px;
  -webkit-mask-image: linear-gradient(180deg, #000 52%, transparent 74%);
  mask-image: linear-gradient(180deg, #000 52%, transparent 74%);
}

.sm-arte .mago-flota {
  width: calc(var(--s) * 0.62);
  height: calc(var(--s) * 0.62);
}

.sm-arte .mago-anillo {
  top: 62%;
  width: 120%;
}

.sm-arte .mago-escena {
  -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 62%, transparent 100%);
}

.store-badge.sm-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  border: 1px solid rgba(95, 207, 165, 0.35);
  background: #0c2427;
}

.store-badge.sm-badge.soon {
  border-color: rgba(var(--accent-rgb), 0.35);
  background: #0f1b3a;
}

.sm-cuerpo {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 4px 20px 20px;
}

.sm-cuerpo .eyebrow {
  color: #b3a7ff;
  font-size: 0.58rem;
}

.store-mago h2 {
  margin: 6px 0 6px;
  color: #ffffff;
  font-family: "Inter Tight", var(--font-ui);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.05;
}

.sm-cuerpo > p:not(.store-message) {
  margin: 0;
  color: #c4bfe4;
  font-size: 0.84rem;
  line-height: 1.5;
}

.sm-submazos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 10px;
}

.sm-submazo {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(150, 130, 255, 0.25);
  border-radius: 10px;
  background: rgba(12, 10, 44, 0.72);
}

.sm-submazo .px-icono {
  width: 32px;
  height: 32px;
}

.store-mago .store-message {
  flex: 1;
  min-height: 1.4em;
  margin: 8px 0 10px;
}

html.dark-mode .store-mago .btn.primary {
  border: 1px solid rgba(165, 145, 255, 0.55);
  background: #1a0f4d;
  color: #f1edff;
}

html.dark-mode .store-mago .btn.primary:hover {
  border-color: rgba(190, 175, 255, 0.9);
  background: #22145f;
  color: #ffffff;
}

/* =====================================================================
   Aurora química: mazos de estequiometría que se canjean con puntos.
   Cielo polar con cintas de aurora, partículas que suben como burbujas y
   química en pixel art. Usa la estructura del Mazo del mago con otros colores.
   ===================================================================== */

.deck-card.deck-aq,
.mago-portada.aq-portada,
.store-card.store-aq {
  --aq-cielo:
    radial-gradient(ellipse 70% 60% at 25% -10%, rgba(95, 224, 192, 0.24), transparent 70%),
    radial-gradient(ellipse 60% 55% at 85% 0%, rgba(106, 92, 255, 0.2), transparent 72%),
    linear-gradient(180deg, #031418 0%, #04191e 55%, #061a28 100%);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid rgba(95, 224, 192, 0.32);
  background: var(--aq-cielo);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), 0 0 40px rgba(47, 184, 160, 0.1);
}

.aq-escena {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Cintas de aurora: bandas difusas que ondulan despacio. */
.aq-cinta {
  position: absolute;
  left: -25%;
  width: 150%;
  height: 58%;
  border-radius: 50%;
  filter: blur(14px);
  mix-blend-mode: screen;
  opacity: 0.65;
  transform: rotate(var(--r));
  animation: aq-ondear var(--t) ease-in-out var(--d) infinite alternate;
}

.aq-cinta.c1 {
  --r: -9deg;
  --t: 13s;
  --d: 0s;
  top: -22%;
  background: linear-gradient(100deg, transparent 8%, rgba(95, 224, 192, 0.6) 34%, rgba(166, 242, 223, 0.45) 50%, transparent 74%);
}

.aq-cinta.c2 {
  --r: 7deg;
  --t: 18s;
  --d: -6s;
  top: -8%;
  background: linear-gradient(100deg, transparent 18%, rgba(47, 159, 208, 0.5) 44%, rgba(106, 92, 255, 0.42) 64%, transparent 86%);
}

.aq-cinta.c3 {
  --r: -3deg;
  --t: 22s;
  --d: -11s;
  top: 6%;
  height: 38%;
  background: linear-gradient(100deg, transparent 28%, rgba(95, 224, 192, 0.34) 54%, transparent 80%);
}

@keyframes aq-ondear {
  from { transform: translateX(-6%) rotate(var(--r)) scaleY(0.9); opacity: 0.5; }
  to { transform: translateX(6%) rotate(var(--r)) scaleY(1.12); opacity: 0.88; }
}

/* Resplandor bajo el matraz. */
.aq-brillo {
  position: absolute;
  bottom: -30%;
  left: 50%;
  width: 70%;
  aspect-ratio: 1.6;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(95, 224, 192, 0.24), transparent 65%);
  transform: translateX(-50%);
}

/* Partículas cuadradas (pixel) que suben como burbujas. */
.aq-part {
  position: absolute;
  bottom: -8px;
  left: var(--x);
  width: var(--s);
  height: var(--s);
  background: #a6f2df;
  box-shadow: 0 0 6px rgba(95, 224, 192, 0.9);
  opacity: 0;
  animation: aq-subir var(--t) linear var(--d) infinite;
}

.aq-part:nth-of-type(3n) {
  background: #9fe4ff;
  box-shadow: 0 0 6px rgba(102, 220, 255, 0.9);
}

.aq-part:nth-of-type(4n) {
  background: #b9a6ff;
  box-shadow: 0 0 6px rgba(148, 120, 255, 0.9);
}

@keyframes aq-subir {
  0% { transform: translateY(0); opacity: 0; }
  12% { opacity: 0.95; }
  75% { opacity: 0.6; }
  100% { transform: translateY(-340px); opacity: 0; }
}

.aq-flota {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: var(--s);
  height: var(--s);
  opacity: 0.8;
  filter: drop-shadow(0 0 8px rgba(95, 224, 192, 0.4));
  transform: rotate(var(--r));
  animation: mago-flotar var(--t) ease-in-out var(--d) infinite;
}

.aq-flota .px-icono {
  width: 100%;
  height: 100%;
}

.aq-img {
  position: relative;
  z-index: 1;
  display: block;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 18px rgba(95, 224, 192, 0.35)) drop-shadow(0 6px 0 rgba(0, 0, 0, 0.35));
  animation: flotar-mago 8s ease-in-out infinite;
}

.aq-nivel {
  position: absolute;
  bottom: 12px;
  left: 14px;
  z-index: 2;
  padding: 4px 10px;
  border: 1px solid rgba(166, 242, 223, 0.45);
  border-radius: 999px;
  background: rgba(3, 26, 30, 0.82);
  color: #a6f2df;
  font-family: var(--font-pixel);
  font-size: 0.56rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ---------- Tarjeta en Mis mazos ---------- */

.deck-card.deck-aq {
  display: flex;
  flex-direction: column;
  padding: 0;
}

.deck-card.deck-aq:hover,
.deck-card.deck-aq:focus-within {
  border-color: rgba(166, 242, 223, 0.55);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.45), 0 0 46px rgba(47, 184, 160, 0.18);
}

.aq-arte {
  position: relative;
  display: grid;
  flex: none;
  height: 100px;
  place-items: center;
  overflow: hidden;
}

.aq-arte .aq-img {
  width: 84px;
  margin: 6px 44px 0 0;   /* un poco a la izquierda: a la derecha van ✓ y quitar */
}

.aq-arte .aq-flota {
  width: calc(var(--s) * 0.7);
  height: calc(var(--s) * 0.7);
}

.aq-cuerpo {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 12px 16px 14px;
}

/* «Adquirido» y quitar, sobre la franja de arte. */
.aq-menu {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}

.aq-menu .deck-owned-badge,
.aq-menu .icon-btn {
  background: rgba(3, 26, 30, 0.82);
}

/* «Adquirido» solo con el ✓, para no tapar el matraz. */
.deck-owned-badge.aq-adquirido {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border-radius: 50%;
}

.aq-oculto {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.aq-cuerpo > .eyebrow {
  flex: none;
  overflow: hidden;
  font-size: 0.56rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Submazos compactos: dos botones lado a lado. */
.aq-chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: auto;
}

.aq-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid rgba(95, 224, 192, 0.24);
  border-radius: 10px;
  background: rgba(3, 30, 34, 0.72);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.aq-sub:hover,
.aq-sub:focus-visible {
  border-color: rgba(166, 242, 223, 0.6);
  background: rgba(6, 44, 48, 0.9);
  transform: translateY(-1px);
}

.aq-sub.completo {
  border-color: rgba(95, 207, 165, 0.5);
}

.aq-sub .px-icono {
  flex: none;
  width: 26px;
  height: 26px;
}

.aq-sub-txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.aq-sub-num {
  overflow: hidden;
  color: #6fd9bd;
  font-family: var(--font-pixel);
  font-size: 0.5rem;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.aq-sub-txt strong {
  font-size: 0.78rem;
  font-weight: 650;
}

.aq-cuerpo > .eyebrow,
.aq-portada .eyebrow,
.store-aq .sm-cuerpo .eyebrow {
  color: #7ff0d0;
}

.deck-aq .deck-link {
  flex: none;
}

.deck-aq .deck-link h3 {
  display: -webkit-box;
  margin: 4px 0 8px;
  overflow: hidden;
  color: #ffffff;
  font-family: "Inter Tight", var(--font-ui);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.aq-submazos .submazo-num {
  color: #6fd9bd;
}

.deck-aq .deck-foot {
  margin-top: 10px;
}

.deck-aq .deck-pend {
  margin-top: 6px;
}

/* ---------- Mis mazos: todas las tarjetas del mismo tamaño ---------- */

/* El Mazo del mago ocupa su propia fila; las demás miden lo mismo, así una
   tarjeta más alta no estira a las de su fila. */
.deck-grid > .deck-card:not(.deck-mago) {
  height: 300px;
  min-height: 0;
  overflow: hidden;
}

.deck-grid > .deck-card:not(.deck-mago) .deck-link {
  min-height: 0;
  overflow: hidden;
}

.deck-grid > .deck-card:not(.deck-mago) .deck-link h3 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.deck-grid > .deck-card:not(.deck-mago):not(.deck-aq) .deck-link p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.deck-aq .mini-bar > span,
.aq-portada .mini-bar > span,
.aq-submazos .submazo .mini-bar > span {
  background: linear-gradient(90deg, #a6f2df, #2fb8a0 45%, #2f9fd0 75%, #6a5cff);
  opacity: 1;
}

html.dark-mode .deck-aq .btn.primary,
html.dark-mode .aq-portada .btn.primary,
html.dark-mode .store-aq .btn.primary {
  border: 1px solid rgba(95, 224, 192, 0.55);
  background: #073a38;
  color: #e8fff8;
}

html.dark-mode .deck-aq .btn.primary:hover,
html.dark-mode .aq-portada .btn.primary:hover,
html.dark-mode .store-aq .btn.primary:hover {
  border-color: rgba(166, 242, 223, 0.95);
  background: #0a4a47;
  color: #ffffff;
}

/* ---------- Portada del mazo y submazos ---------- */

.mago-portada.aq-portada {
  border-color: rgba(95, 224, 192, 0.32);
}

.aq-portada p {
  color: #b9d9d3;
}

/* La aurora se funde hacia el texto (sin corte a la izquierda). */
.mago-portada-img .aq-escena {
  inset: -34px -38px -34px -120px;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 45%);
  mask-image: linear-gradient(90deg, transparent 0, #000 45%);
}

.mago-portada-img .aq-img {
  width: min(250px, 80%);
}

.aq-submazos .submazo:hover,
.aq-submazos .submazo:focus-visible {
  border-color: rgba(95, 224, 192, 0.5);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.36), 0 0 26px rgba(47, 184, 160, 0.14);
}

.aq-submazos .submazo-icono,
.study-aq .ready-icon.ready-px {
  border-color: rgba(95, 224, 192, 0.3);
  background: radial-gradient(circle, rgba(47, 184, 160, 0.26), rgba(3, 30, 34, 0.7));
}

.aq-submazos .submazo-jugar {
  border-color: rgba(95, 224, 192, 0.5);
  background: #073a38;
  color: #e8fff8;
}

.aq-submazos .submazo:hover .submazo-jugar {
  border-color: rgba(166, 242, 223, 0.95);
  background: #0a4a47;
}

/* ---------- Tienda ---------- */

.store-card.store-aq {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
}

.store-card.store-aq:hover {
  border-color: rgba(166, 242, 223, 0.55);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42), 0 0 40px rgba(47, 184, 160, 0.18);
}

.sa-arte {
  position: relative;
  display: grid;
  height: 176px;
  place-items: center;
  overflow: hidden;
}

.sa-arte .aq-img {
  width: 128px;
}

.sa-arte .aq-flota {
  width: calc(var(--s) * 0.66);
  height: calc(var(--s) * 0.66);
}

.store-aq h2 {
  margin: 6px 0 6px;
  color: #ffffff;
  font-family: "Inter Tight", var(--font-ui);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.08;
}

.store-aq .sm-cuerpo > p:not(.store-message) {
  color: #b9d9d3;
}

.store-aq .sm-submazo {
  border-color: rgba(95, 224, 192, 0.25);
  background: rgba(3, 30, 34, 0.72);
}

.store-aq .store-message {
  flex: 1;
  min-height: 1.4em;
  margin: 8px 0 10px;
}

.sa-pie {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sa-precio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffe6a6;
  font-family: var(--font-pixel);
  font-size: 0.9rem;
}

.sa-precio .px-ico {
  image-rendering: pixelated;
}

.store-badge.sa-badge {
  border-color: rgba(95, 224, 192, 0.45);
  background: #06302d;
  color: #a6f2df;
}

/* Mazos por puntos: misma grilla que los mazos de la tienda. */
.store-grid.eco-mazos-puntos > .eco-item {
  height: 100%;
}

/* Portada apilada (arte arriba): la aurora se funde hacia abajo. */
@media (max-width: 900px) {
  .mago-portada-img .aq-escena {
    inset: -34px -38px -10px;
    -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 62%, transparent 100%);
  }
}

@media (max-width: 720px) {
  .sa-arte .aq-img {
    width: 112px;
  }

  .mago-portada-img .aq-img {
    width: min(190px, 60%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .aq-cinta,
  .aq-part,
  .aq-flota,
  .aq-img {
    animation: none;
  }

  .aq-part {
    display: none;
  }
}

/* ---------- Pantallas angostas ---------- */

@media (max-width: 900px) {
  .deck-card.deck-mago,
  .mago-portada {
    grid-template-columns: 1fr;
  }

  .mago-lado {
    min-height: 270px;
  }

  .mago-lado .mago-img {
    width: min(300px, 74%);
    margin: 0 0 -30px;
  }

  .mago-cuerpo {
    padding: 4px 20px 22px;
  }

  .mago-portada {
    padding: 0 22px 26px;
  }

  .mago-portada-img {
    order: -1;
    min-height: 250px;
  }

  .mago-portada-img .mago-escena {
    inset: 0 -22px;
  }

  .mago-portada-img .mago-img {
    width: min(260px, 70%);
    margin: 0 auto -30px;
  }
}

@media (max-width: 520px) {
  .mago-chips {
    grid-template-columns: 1fr;
  }

  .mago-abrir {
    align-self: stretch;
    justify-content: center;
  }
}

/* ---------- Generador: límite diario y API key propia ---------- */
.gen-cuota {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  width: fit-content;
  max-width: 100%;
  margin: -8px 0 16px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: rgba(var(--accent-rgb), 0.06);
  color: var(--text-muted);
  font-size: 0.78rem;
}

.gen-cuota[hidden] {
  display: none;
}

.gen-cuota-txt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.gen-cuota-txt .ic {
  flex: none;
  color: var(--accent);
}

.gen-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.gen-link:hover,
.gen-link:focus-visible {
  color: var(--text);
}

.gen-clave-pasos {
  display: grid;
  gap: 7px;
  max-width: 600px;
  margin: 0 0 20px;
  padding: 14px 18px 14px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.gen-clave-pasos li {
  padding-left: 2px;
}

.gen-clave-pasos li::marker {
  color: var(--accent);
  font-weight: 700;
}

.gen-clave-pasos a {
  color: var(--accent);
  font-weight: 600;
  text-underline-offset: 3px;
}

.gen-clave-pasos strong {
  color: var(--text);
  font-weight: 600;
}

.gen-clave .gen-field {
  max-width: 600px;
  margin-bottom: 4px;
}

.gen-clave #gen-clave {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

.gen-clave #gen-clave:focus {
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
  outline: none;
}

.gen-clave .gen-status {
  max-width: 600px;
}

.gen-clave-nota {
  max-width: 600px;
  margin: 12px 0 0;
  color: var(--text-faint);
  font-size: 0.74rem;
  line-height: 1.5;
}

@media (max-width: 560px) {
  .gen-clave-pasos {
    padding: 12px 14px 12px 32px;
    font-size: 0.82rem;
  }

  #gen-clave-guardar {
    padding-inline: 14px;
    white-space: nowrap;
  }

  #gen-clave-guardar .ic {
    display: none;
  }
}
