/* La Mesa — hoja de estilos única. Móvil primero, oscuro, sin dependencias externas. */

/* Instrument Serif (SIL OFL), alojada aquí: ni una petición fuera del servidor.
   Subconjunto latin — cubre á é í ó ú ñ ü ¿ ¡. Va en títulos y marca; las CIFRAS
   nunca, que ahí manda poder compararlas de un vistazo. */
@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/instrument-serif.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/instrument-serif-italic.woff2') format('woff2');
}

:root {
  --bg:        #0A0D0B;
  --surface:   #121814;
  --surface-2: #18211C;
  --surface-3: #1F2A23;
  --line:      #26332B;
  --line-soft: #1C261F;

  --felt:      #17402D;
  --gold:      #D4A94A;
  --gold-dim:  #8A6F2E;
  --win:       #4ADE80;
  --lose:      #F87171;

  --text:      #EAF0EC;
  --text-2:    #B4C2BA;
  --muted:     #7E8F86;

  --r-lg: 18px;   /* tarjeta exterior */
  --r-md: 12px;   /* elemento anidado: 18 − 6 de padding */
  --r-sm: 8px;

  --pad: 16px;
  --nav-h: 66px;
  --sombra: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.7);

  --fuente: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --fuente-titular: 'Instrument Serif', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* El atributo `hidden` del navegador es `display:none`, pero cualquier regla nuestra que
   ponga `display` lo anula sin avisar (pasó con los botones del buscador de fichas: se
   marcaban como ocultos y seguían viéndose). Esto lo deja zanjado para toda la app. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--fuente);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

/* Números: siempre tabulares y a la derecha, para poder compararlos de un vistazo. */
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.win  { color: var(--win); }
.lose { color: var(--lose); }
.cero { color: var(--muted); }

#app { padding: var(--pad); padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); max-width: 780px; margin: 0 auto; }
#app.cargando::after { content: 'Cargando…'; color: var(--muted); display: block; padding: 40px 0; text-align: center; }
#app.ancho-libre { padding: 0; max-width: none; }   /* la entrada ocupa la pantalla entera */

/* ---------------------------------------------------------------- cabecera */
.cab { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; min-height: 40px; }
.cab h1 { font-family: var(--fuente-titular); font-size: 30px; font-weight: 400; letter-spacing: -.01em; line-height: 1.1; flex: 1; }
.cab .sub { font-family: var(--fuente); font-size: 13px; color: var(--muted); font-weight: 400; display: block; letter-spacing: 0; margin-top: 2px; }
.volver {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); font-size: 18px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
}
/* Volver: se desplaza hacia donde va, que es hacia atrás. */
.volver { transition: transform .14s ease, background .14s ease; }
.volver:active { background: var(--surface-3); transform: translateX(-3px); }

/* Botón de perfil, arriba a la derecha de todas las vistas. */
.btn-perfil {
  width: 42px; height: 42px; flex: 0 0 42px; padding: 3px;
  border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line);
  transition: border-color .14s ease, transform .14s ease;
}
.btn-perfil img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.btn-perfil:active { transform: scale(.94); border-color: var(--gold); }

/* ----------------------------------------------------------------- tarjeta */
.tarjeta {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: var(--pad);
  margin-bottom: 14px;
  box-shadow: var(--sombra);
}
.tarjeta.plana { box-shadow: none; }
.tarjeta > h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.tarjeta > h2 .mas { margin-left: auto; }

/* ------------------------------------------------------------- saldo grande */
.saldo-hero { text-align: center; padding: 26px var(--pad) 22px; position: relative; overflow: hidden; }
.saldo-hero::before {
  content: ''; position: absolute; inset: -60% 20% auto; height: 180px;
  background: radial-gradient(ellipse at center, rgba(212,169,74,.13), transparent 70%);
  pointer-events: none;
}
.saldo-hero .etiqueta { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.saldo-hero .cifra { font-size: 44px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: 6px 0 2px; }
.saldo-hero .pie { font-size: 13px; color: var(--text-2); }

/* --------------------------------------------------------------- jugadores */
.fila {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft);
}
.fila:last-child { border-bottom: 0; padding-bottom: 0; }
.fila:first-of-type { padding-top: 0; }
/* Fila: no se mueve ni se encoge — se enciende por el canto izquierdo. */
.fila.pulsable {
  cursor: pointer; border-radius: var(--r-md); padding-left: 12px; padding-right: 8px; margin: 0 -8px;
  box-shadow: inset 2px 0 0 transparent; transition: box-shadow .14s ease, background .14s ease;
}
.fila.pulsable:active { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--gold); }

.avatar {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
  background: var(--surface-3); border: 1px solid var(--line);
  object-fit: cover; padding: 3px;
}
.avatar.grande { width: 76px; height: 76px; flex-basis: 76px; padding: 6px; }
.avatar.mini   { width: 28px; height: 28px; flex-basis: 28px; padding: 2px; }

.nombre { flex: 1; min-width: 0; }
.nombre b { font-weight: 600; font-size: 15px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nombre small { color: var(--muted); font-size: 12.5px; }

.puesto {
  width: 22px; flex: 0 0 22px; text-align: center; font-size: 13px;
  font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums;
}
.puesto.oro { color: var(--gold); }

.pastilla {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line);
}
.pastilla.viva   { background: rgba(74,222,128,.12); color: var(--win);  border-color: rgba(74,222,128,.28); }
.pastilla.torneo { background: rgba(212,169,74,.12); color: var(--gold); border-color: rgba(212,169,74,.28); }

/* ------------------------------------------------------------------ botones */
button, .boton {
  font-family: inherit; font-size: 15px; font-weight: 600;
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  padding: 12px 16px; cursor: pointer; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .12s ease, transform .08s ease, opacity .12s ease;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: .45; cursor: not-allowed; }

/* Cada familia de botón tiene su propia señal al pulsar. Nada de un scale() global:
   se nota que es la misma animación pegada en todo y delata la plantilla. */
.fantasma:active, button:not([class]):active { border-color: var(--gold-dim); background: var(--surface-3); }
button:focus-visible, .boton:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}

/* Primario: se hunde, como una tecla. */
.primario { background: var(--gold); color: #16110A; border-color: var(--gold); box-shadow: 0 2px 0 var(--gold-dim); }
.primario:active { background: var(--gold); box-shadow: 0 0 0 var(--gold-dim); transform: translateY(2px); }
.fantasma  { background: transparent; }
.peligro   { color: var(--lose); border-color: rgba(248,113,113,.3); background: rgba(248,113,113,.07); }
.ancho     { width: 100%; }
.chico     { padding: 7px 12px; min-height: 36px; font-size: 13.5px; border-radius: var(--r-sm); }

/* Rebuy: la ficha cae sobre el tapete — baja de golpe y pierde la sombra. */
.btn-rebuy {
  flex: 0 0 auto; min-height: 40px; padding: 0 14px;
  background: var(--felt); border-color: #235C41; color: #C9F2DC;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 0 #0E2C1F;
}
.btn-rebuy:active { background: #1D5238; box-shadow: 0 0 0 #0E2C1F; transform: translateY(3px); }

.acciones { display: flex; gap: 10px; margin-top: 14px; }
.acciones > * { flex: 1; }

/* ------------------------------------------------------------------ formularios */
label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  font-family: inherit; font-size: 16px; /* 16px evita el zoom automático en iOS */
  width: 100%; padding: 12px 14px; min-height: 46px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); color: var(--text);
}
input::placeholder { color: #5F6F66; }
input[type=number] { font-variant-numeric: tabular-nums; }
.campo { margin-bottom: 14px; }
.campos-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.opciones { display: flex; gap: 8px; }
.opciones input { position: absolute; opacity: 0; pointer-events: none; }
.opciones label {
  flex: 1; margin: 0; text-align: center; padding: 12px 8px; font-size: 14.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  color: var(--text-2); cursor: pointer;
}
.opciones input:checked + label { background: var(--gold); border-color: var(--gold); color: #16110A; }

.rejilla-avatares { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.rejilla-avatares button { padding: 6px; min-height: 0; aspect-ratio: 1; border-radius: var(--r-md); }
.rejilla-avatares button img { width: 100%; height: 100%; object-fit: contain; }
.rejilla-avatares button[aria-pressed=true] { border-color: var(--gold); background: rgba(212,169,74,.12); }

.marca-check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); }
.marca-check input { width: 20px; height: 20px; min-height: 0; flex: 0 0 20px; accent-color: var(--gold); }

/* --------------------------------------------------------------------- login */
.pantalla-entrada {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 24px 20px calc(28px + env(safe-area-inset-bottom));
  background: var(--bg);
  position: relative; overflow: hidden;
}
/* La foto NO es un fondo a pantalla completa con un velo encima (eso se nota a la legua):
   es una imagen encuadrada que se disuelve en la página por abajo. */
.pantalla-entrada::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 66%;
  /* hero.jpg ya viene recortado (1080×1498) a la lámpara y la mesa: el encuadre está
     decidido en el fichero, no delegado al object-cover. */
  background: url('/img/hero.jpg') center top / cover no-repeat;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 74%, transparent 100%);
          mask-image: linear-gradient(180deg, #000 0%, #000 74%, transparent 100%);
}
/* Sombra corta solo detrás del wordmark, no sobre toda la foto. */
.pantalla-entrada::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 30%;
  background: linear-gradient(180deg, rgba(10,13,11,.72), transparent);
}
.pantalla-entrada > * { position: relative; z-index: 1; }
.marca { text-align: center; margin-bottom: auto; padding-top: 7vh; }
.marca img { width: 88px; height: 88px; filter: drop-shadow(0 10px 26px rgba(0,0,0,.75)); }
.marca h1 {
  font-family: var(--fuente-titular); font-size: 46px; font-weight: 400;
  letter-spacing: -.01em; line-height: 1; margin-top: 12px;
  text-shadow: 0 2px 18px rgba(0,0,0,.7);
}
.marca p {
  font-family: var(--fuente-titular); font-style: italic; font-size: 18px;
  color: var(--text-2); margin-top: 8px; text-wrap: balance;
  text-shadow: 0 1px 12px rgba(0,0,0,.8);
}
.caja-entrada { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--sombra); }
.pestanas { display: flex; gap: 6px; margin-bottom: 18px; background: var(--surface-2); padding: 4px; border-radius: var(--r-md); }
.pestanas button { flex: 1; background: transparent; border: 0; min-height: 38px; font-size: 14px; color: var(--muted); border-radius: var(--r-sm); }
.pestanas button[aria-selected=true] { background: var(--surface-3); color: var(--text); }

/* ------------------------------------------------------------------ navegación */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: rgba(10,13,11,.92); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
#nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; color: var(--muted); text-decoration: none; padding: 2px;
  -webkit-tap-highlight-color: transparent;
}
#nav a img { width: 25px; height: 25px; opacity: .5; transition: opacity .15s ease, transform .15s ease; }
#nav a[aria-current=page] { color: var(--gold); }
#nav a[aria-current=page] img { opacity: 1; transform: translateY(-1px) scale(1.06); }

/* ---------------------------------------------------------------------- hoja */
.velo { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 50; animation: fundir .18s ease; }
.hoja {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-top: 1px solid var(--line);
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow-y: auto;
  animation: subir .24s cubic-bezier(.32,.72,0,1);
  max-width: 780px; margin: 0 auto;
}
.hoja h3 { font-family: var(--fuente-titular); font-size: 26px; font-weight: 400; margin-bottom: 4px; letter-spacing: -.01em; line-height: 1.15; }
.hoja .aclaracion { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.tirador { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 14px; }
@keyframes subir  { from { transform: translateY(100%); } }
@keyframes fundir { from { opacity: 0; } }

/* --------------------------------------------------------------------- avisos */
#avisos { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 16px); z-index: 60; display: grid; gap: 8px; pointer-events: none; }
.aviso {
  background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px 14px; font-size: 14px; box-shadow: var(--sombra);
  animation: fundir .2s ease; max-width: 780px; margin: 0 auto; width: 100%;
}
.aviso.malo  { border-color: rgba(248,113,113,.4); background: #2A1717; color: #FFD9D9; }
.aviso.bueno { border-color: rgba(74,222,128,.35); background: #12251A; color: #D6F5E3; }

/* ---------------------------------------------------------------------- varios */
.vacio { text-align: center; padding: 32px 16px; color: var(--muted); font-family: var(--fuente-titular); font-style: italic; font-size: 17px; }
.vacio img { width: 56px; height: 56px; opacity: .3; margin-bottom: 10px; }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-stats div { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 12px 10px; text-align: center; }
.mini-stats b { display: block; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.mini-stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.deuda {
  display: flex; align-items: center; gap: 10px; padding: 12px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); margin-bottom: 8px;
}
.deuda .flecha { color: var(--muted); font-size: 15px; }
.deuda .importe { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

.cuadre { font-size: 13.5px; padding: 11px 13px; border-radius: var(--r-md); margin-bottom: 14px; }
.cuadre.ok   { background: rgba(74,222,128,.09);  color: var(--win);  border: 1px solid rgba(74,222,128,.22); }
.cuadre.mal  { background: rgba(248,113,113,.09); color: var(--lose); border: 1px solid rgba(248,113,113,.25); }

.linea-tiempo { list-style: none; font-size: 13px; color: var(--text-2); }
.linea-tiempo li { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); align-items: center; }
.linea-tiempo li:last-child { border-bottom: 0; }
.linea-tiempo .hora { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.linea-tiempo .quitar { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 17px; padding: 2px 8px; min-height: 0; }

.aviso-codigo {
  background: var(--surface-2); border: 1px dashed var(--gold-dim); border-radius: var(--r-md);
  padding: 13px; font-size: 13.5px; color: var(--text-2); margin-bottom: 14px;
}
.aviso-codigo b { color: var(--gold); font-size: 17px; letter-spacing: .12em; font-family: ui-monospace, 'SF Mono', Menlo, monospace; }

/* ═══════════════════════════════ TABLETA (620–899 px) ═══════════════════════
   La barra pasa arriba como pastilla; el contenido sigue en una columna. */
@media (min-width: 620px) and (max-width: 899px) {
  body { padding-top: 12px; }
  #nav {
    position: sticky; top: 12px; bottom: auto;
    max-width: 780px; margin: 0 auto 20px;
    border: 1px solid var(--line); border-radius: var(--r-lg);
  }
  #app { padding-bottom: 40px; }
}

/* ══════════════════════════════════ PC (≥ 900 px) ═══════════════════════════
   Barra lateral fija y contenido centrado. La retícula se activa SOLO cuando
   hay barra (clase `con-nav`, que pone el JS): en la pantalla de entrada no. */
@media (min-width: 900px) {
  body.con-nav { display: grid; grid-template-columns: 244px minmax(0, 1fr); align-items: start; }
  /* En el HTML `#app` va antes que `#nav`, así que hay que colocarlos a mano
     o la retícula los pone al revés. */
  body.con-nav #nav { grid-column: 1; grid-row: 1; }
  body.con-nav #app { grid-column: 2; grid-row: 1; }

  body.con-nav #nav {
    position: sticky; top: 0; height: 100dvh;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 26px 14px;
    background: var(--surface); backdrop-filter: none;
    border-top: 0; border-right: 1px solid var(--line);
  }
  /* El wordmark hace de cabecera de la barra: en móvil no cabe, en PC sí. */
  body.con-nav #nav::before {
    content: 'La Mesa';
    font-family: var(--fuente-titular); font-size: 27px; letter-spacing: -.01em;
    color: var(--text); padding: 0 12px 22px;
  }
  body.con-nav #nav a {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start;
    gap: 12px; font-size: 15px; padding: 11px 12px; border-radius: var(--r-md);
    transition: background .14s ease, color .14s ease;
  }
  body.con-nav #nav a img { width: 26px; height: 26px; }
  body.con-nav #nav a[aria-current=page] { background: var(--surface-3); }
  body.con-nav #nav a[aria-current=page] img { transform: none; }

  /* ⚠️ `width: 100%` es imprescindible: sin él, `margin: 0 auto` sobre un elemento de una
     retícula lo encoge al ancho de su contenido en vez de estirarlo, y el contenido quedaba
     en una cinta de 520 px en medio de una pantalla de 1920. */
  #app { width: 100%; max-width: 1000px; margin-inline: auto; padding: 36px 40px 72px; }

  /* Escala tipográfica algo mayor: en PC se mira desde más lejos. */
  .cab { margin-bottom: 26px; }
  .cab h1 { font-size: 38px; }
  .saldo-hero { padding: 34px 24px 28px; }
  .saldo-hero .cifra { font-size: 56px; }
  .tarjeta { padding: 22px; margin-bottom: 18px; }
  .fila { padding: 13px 0; }
  .mini-stats b { font-size: 22px; }

  /* La hoja deja de ser un cajón que sube y pasa a ser un diálogo centrado. */
  .hoja {
    top: 50%; bottom: auto; transform: translateY(-50%);
    max-width: 540px; border-radius: var(--r-lg); border: 1px solid var(--line);
    padding: 26px; animation: aparecer .2s ease;
  }
  .tirador { display: none; }

  /* Los botones dejan de estirarse a lo ancho de la pantalla. */
  .acciones > * { flex: 0 1 auto; min-width: 190px; }
  .acciones > .ancho { flex: 1 1 auto; }
  #avisos { left: auto; right: 24px; bottom: 24px; max-width: 380px; }

  /* Las seis estadísticas en una sola fila, que hay sitio de sobra. */
  .mini-stats { grid-template-columns: repeat(6, 1fr); }
  .mini-stats + .mini-stats { margin-top: 10px; }

  /* Texto de lección con medida de lectura: 880 px de ancho cansan la vista. */
  .leccion { max-width: 68ch; }
  .leccion p, .leccion li { font-size: 16px; }

  /* La rejilla de fichas aprovecha el ancho del diálogo. */
  .rejilla-avatares { max-height: 300px; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }

  /* El diálogo de perfil es el más largo: se le deja más aire. */
  .hoja { max-height: 86dvh; }
}

/* ═════════════════════ PANTALLA ANCHA (≥ 1280 px) ══════════════════════════
   En un monitor de verdad, una sola columna de tarjetas deja media pantalla en
   negro. Dos columnas solo donde tiene sentido: inicio y cuentas tienen bloques
   independientes; las listas largas (partidas, clasificación, escuela) se leen
   mejor en una columna y se quedan como están. */
@media (min-width: 1280px) {
  #app { max-width: 1180px; }

  #app[data-vista="inicio"], #app[data-vista="deudas"], #app[data-vista="jugador"], #app[data-vista="perfil"] {
    display: grid; grid-template-columns: 1fr 1fr;
    column-gap: 20px; align-items: start;
  }
  /* La cabecera, el resultado y los botones de acción cruzan las dos columnas. */
  #app[data-vista="inicio"] > .cab,
  #app[data-vista="deudas"] > .cab,
  #app[data-vista="jugador"] > .cab,
  #app[data-vista="perfil"] > .cab,
  #app[data-vista="inicio"] > .saldo-hero,
  #app[data-vista="jugador"] > .saldo-hero,
  #app[data-vista="inicio"] > .acciones { grid-column: 1 / -1; }

  .saldo-hero .cifra { font-size: 64px; }
  .leccion { max-width: 72ch; }
}
@keyframes aparecer { from { opacity: 0; transform: translateY(calc(-50% + 10px)); } }

/* ═══════════ ENTRADA EN PC: foto a un lado, formulario al otro ═══════════ */
@media (min-width: 900px) {
  .pantalla-entrada {
    display: grid; grid-template-columns: 1fr minmax(400px, 36%);
    align-items: center; padding: 0;
  }
  .pantalla-entrada::before {
    inset: 0; right: 36%; height: auto;
    background-position: center center;
    -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 74%, transparent 100%);
            mask-image: linear-gradient(90deg, #000 0%, #000 74%, transparent 100%);
  }
  .pantalla-entrada::after {
    inset: 0; right: 36%; height: auto;
    background: linear-gradient(90deg, rgba(10,13,11,.62), rgba(10,13,11,.12) 55%, transparent);
  }
  .marca { margin: 0; padding: 0 56px; text-align: left; }
  .marca img { width: 62px; height: 62px; }
  .marca h1 { font-size: 68px; margin-top: 16px; }
  .marca p { font-size: 21px; max-width: 20ch; margin-top: 12px; }
  .caja-entrada { margin: 0 48px 0 12px; padding: 28px; }
}

/* Estados de ratón: solo donde de verdad hay ratón. */
@media (hover: hover) {
  .fila.pulsable:hover { background: var(--surface-2); }
  body.con-nav #nav a:hover { background: var(--surface-2); color: var(--text-2); }
  body.con-nav #nav a:hover img { opacity: .85; }
  .primario:hover { filter: brightness(1.05); }
  .btn-rebuy:hover { background: #1D5238; }
  .volver:hover { background: var(--surface-3); }
  .peligro:hover { background: rgba(248,113,113,.13); }
}

/* ══════════════════════════════════ EFECTOS ═══════════════════════════════ */
@keyframes entrar   { from { opacity: 0; transform: translateY(14px); } }
@keyframes sacudida { 10%,90% { transform: translateX(-2px); } 30%,70% { transform: translateX(4px); } 50% { transform: translateX(-6px); } }
@keyframes ondear   { to { transform: scale(1); opacity: 0; } }
@keyframes saltar   { to { transform: translate(var(--dx), var(--dy)) rotate(var(--giro)); opacity: 0; } }

.onda {
  position: absolute; border-radius: 50%; pointer-events: none;
  transform: scale(0); opacity: .7; animation: ondear .6s ease-out forwards;
}

.capa-fichas { position: fixed; inset: 0; pointer-events: none; z-index: 90; }
.capa-fichas i {
  position: absolute; width: 15px; height: 15px; border-radius: 50%;
  background: var(--tono); border: 2.5px dashed rgba(0,0,0,.28);
  animation: saltar 1.25s cubic-bezier(.15,.6,.4,1) forwards;
}

/* ══════════════════════════════════ ESCUELA ═══════════════════════════════ */
.barra-progreso { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.barra-progreso i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-dim), var(--gold)); transition: width .7s cubic-bezier(.22,.61,.36,1); }

.leccion section { margin-bottom: 26px; }
.leccion section:last-child { margin-bottom: 0; }
.leccion h3 {
  font-family: var(--fuente-titular); font-size: 23px; font-weight: 400;
  line-height: 1.2; margin-bottom: 10px; color: var(--gold);
}
.leccion p { font-size: 15.5px; line-height: 1.62; color: var(--text-2); margin-bottom: 11px; }
.leccion p:last-child { margin-bottom: 0; }
.leccion b { color: var(--text); font-weight: 600; }
.leccion ul { list-style: none; margin: 4px 0 0; }
.leccion li {
  font-size: 15px; line-height: 1.5; color: var(--text-2);
  padding: 9px 0 9px 20px; border-bottom: 1px solid var(--line-soft); position: relative;
}
.leccion li::before { content: '·'; position: absolute; left: 6px; color: var(--gold); font-weight: 700; }
.leccion li:last-child { border-bottom: 0; }

.pregunta { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.pregunta:last-of-type { border-bottom: 0; }
.enunciado { font-size: 15.5px; font-weight: 600; margin-bottom: 12px; line-height: 1.45; }
.opciones-test { display: grid; gap: 8px; }
.opcion {
  width: 100%; justify-content: flex-start; text-align: left;
  font-weight: 500; font-size: 14.5px; padding: 12px 14px;
}
.opcion:disabled { opacity: 1; }
.opcion.buena { background: rgba(74,222,128,.13); border-color: rgba(74,222,128,.45); color: var(--win); }
.opcion.mala  { background: rgba(248,113,113,.11); border-color: rgba(248,113,113,.42); color: var(--lose); }
.explicacion { margin-top: 11px; font-size: 13.5px; line-height: 1.5; padding: 11px 13px; border-radius: var(--r-md); }
.explicacion.ok  { background: rgba(74,222,128,.08);  color: var(--text-2); border: 1px solid rgba(74,222,128,.2); }
.explicacion.mal { background: rgba(248,113,113,.08); color: var(--text-2); border: 1px solid rgba(248,113,113,.22); }
.resultado-test { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); text-align: center; }
.resultado-test b { font-size: 19px; font-family: var(--fuente-titular); font-weight: 400; }

/* ══════════════════════════ PANEL DE PERFIL ══════════════════════════════ */
.previo-perfil {
  display: flex; align-items: center; gap: 14px; margin-bottom: 20px;
  padding: 14px; background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: var(--r-md);
}
.previo-perfil img { margin: 0; flex: 0 0 64px; width: 64px; height: 64px; }
.previo-perfil b { display: block; font-size: 18px; font-weight: 650; }
.previo-perfil small { color: var(--muted); font-size: 12.5px; line-height: 1.35; display: block; margin-top: 3px; }

.contador { float: right; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }

.plegable { border-top: 1px solid var(--line-soft); margin-bottom: 16px; }
.plegable summary {
  cursor: pointer; padding: 14px 0 2px; font-size: 14px; font-weight: 600;
  color: var(--text-2); list-style: none;
}
.plegable summary::-webkit-details-marker { display: none; }
.plegable summary::before { content: '＋ '; color: var(--gold); font-weight: 400; }
.plegable[open] summary::before { content: '－ '; }

input[type=search] { -webkit-appearance: none; }

/* ═══════════════════════════════ MÚSICA ══════════════════════════════════ */
.lista-estilos { display: flex; flex-wrap: wrap; gap: 8px; }
.estilo {
  flex: 0 1 auto; min-height: 38px; padding: 8px 14px;
  font-size: 14px; font-weight: 500; border-radius: 999px;
}
.estilo[aria-pressed=true] { background: var(--gold); border-color: var(--gold); color: #16110A; font-weight: 650; }
.nota { font-size: 12.5px; line-height: 1.5; color: var(--muted); margin-top: 10px; }

/* La canción que te representa: desplegable + botón de escucha. */
.fila-cancion { display: flex; gap: 8px; align-items: stretch; }
.sel-cancion { flex: 1; min-width: 0; }
.escuchar {
  flex: 0 0 52px; min-height: 46px; font-size: 15px; line-height: 1;
  background: var(--surface-3); border-color: var(--line);
}
.escuchar[data-sonando="1"] { background: var(--gold); border-color: var(--gold); color: #16110A; }

/* ═══════════════════════════════ AÑADIDOS ════════════════════════════════ */
.viva-borde { border-color: rgba(74,222,128,.3); }

select {
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 38px;
}
.pie-idioma { margin: 16px 0 0; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.pie-idioma label { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; }

/* 50 personajes. En el móvil NO lleva scroll propio: un contenedor que se desplaza dentro
   de una hoja que también se desplaza es imposible de manejar con el dedo —el de dentro se
   come el gesto— y encima se ven tres filas cortadas que parecen imágenes superpuestas.
   Aquí crece libre y se desplaza la hoja entera, una sola vez. El buscador es el que acota. */
.rejilla-avatares {
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  padding: 6px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--r-md);
}
/* El botón ya dibuja el círculo: así, mientras las imágenes cargan, se ven 50 huecos
   redondos en vez de una caja vacía. */
.rejilla-avatares button { border-color: transparent; background: var(--surface-2); border-radius: 50%; }
.rejilla-avatares button img { border-radius: 50%; }
.rejilla-avatares button[aria-pressed=true] { background: rgba(212,169,74,.16); border-color: var(--gold); }

/* Con seis pestañas hay que apretar un poco en pantallas estrechas. */
@media (max-width: 400px) {
  #nav a { font-size: 9.5px; }
  #nav a img { width: 23px; height: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .capa-fichas { display: none; }
}

/* ══════════════════════ DIAGRAMAS Y ALLENAMENTO ═══════════════════════════ */
.dibujo { margin: 16px 0 4px; overflow-x: auto; }
/* El lienzo de los diagramas es de 320 (ver diagramas.js): con este tope la escala
   queda en ~1,2 en escritorio y ~0,97 en un móvil de 375 px. */
.dib { width: 100%; height: auto; max-width: 400px; display: block; }

.mesa-ent {
  background: linear-gradient(180deg, #17402D 0%, #123322 100%);
  border-color: #235C41;
}
.marcador-ent {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: #9FD4B8; margin-bottom: 16px;
}
.marcador-ent b { font-size: 17px; color: var(--gold); font-variant-numeric: tabular-nums; }

.zona { margin-bottom: 14px; }
.zona .etiq {
  display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: #8FBBA3; margin-bottom: 6px;
}
/* Las cartas del tablero y las tuyas van en la misma fila si caben. */
.zona .cartas { height: 62px; width: auto; max-width: 100%; display: inline-block; vertical-align: top; }

.enunciado-ent {
  font-size: 16px; font-weight: 600; line-height: 1.4;
  margin: 18px 0 14px; color: var(--text);
}
.mesa-ent .opcion { background: rgba(10,13,11,.45); border-color: #2A6349; }
.mesa-ent .opcion.buena { background: rgba(74,222,128,.18); border-color: rgba(74,222,128,.5); }
.mesa-ent .opcion.mala  { background: rgba(248,113,113,.16); border-color: rgba(248,113,113,.5); }
.mesa-ent .explicacion.ok  { background: rgba(10,13,11,.4); border-color: rgba(74,222,128,.3); }
.mesa-ent .explicacion.mal { background: rgba(10,13,11,.4); border-color: rgba(248,113,113,.3); }

@media (min-width: 900px) {
  .zona .cartas { height: 78px; }
  .enunciado-ent { font-size: 18px; }
}
