:root {
  --papel: #F6F1E7;
  --papel-2: #EFE7D8;
  --tinta: #182D27;
  --tinta-2: #46564F;
  --verde: #18533E;
  --verde-claro: #DDE8E1;
  --cobre: #9A4528;
  --cobre-claro: #F3E1D7;
  --regla: #D9D1C2;
  --borde: #857A68;
  --error: #9D3026;
  --error-claro: #F6DEDA;
  --titular: 'Fraunces', Georgia, 'Times New Roman', serif;
  --texto: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --radio: 10px;
  --ancho: 42rem;
}
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
html.t-2 { font-size: 112.5%; }
html.t-3 { font-size: 125%; }
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--papel); color: var(--tinta);
  font-family: var(--texto); font-size: 1.0625rem; line-height: 1.55;
}
body.lectura-facil { --titular: var(--texto); }
h1, h2, h3 { font-family: var(--titular); font-weight: 600; line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.875rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; font-family: var(--texto); }
p { margin: 0 0 .9rem; }
a { color: var(--verde); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--verde); outline-offset: 2px; }
.saltar { position: absolute; left: -999px; top: 0; background: var(--tinta); color: var(--papel); padding: .5rem 1rem; z-index: 10; }
.saltar:focus { left: .5rem; }
.oculto { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cifra { font-variant-numeric: tabular-nums; }

/* Barra superior fija */
.barra { position: sticky; top: 0; z-index: 5; background: var(--papel); border-bottom: 1px solid var(--regla); }
.barra-int { max-width: var(--ancho); margin: 0 auto; padding: .6rem 1rem .55rem; }
.barra-fila { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.marca { font-family: var(--titular); font-weight: 600; font-size: 1.2rem; text-decoration: none; color: var(--tinta); display: inline-flex; align-items: center; gap: .45rem; margin-right: auto; }
.sello { width: 1.35rem; height: 1.35rem; border-radius: 50%; border: 2px solid var(--cobre); display: inline-grid; place-items: center; font-size: .62rem; font-family: var(--texto); font-weight: 600; color: var(--cobre); }
.guardado { font-size: .8125rem; color: var(--tinta-2); white-space: nowrap; }
.guardado .largo { display: none; }
@media (min-width: 30rem) { .guardado .largo { display: inline; } }
.ajustes { display: flex; gap: .35rem; }
.chico { min-height: 44px; min-width: 44px; padding: 0 .7rem; border: 1.5px solid var(--borde); border-radius: var(--radio); background: transparent; color: var(--tinta); font: inherit; font-size: .875rem; cursor: pointer; }
.chico[aria-pressed="true"] { background: var(--verde-claro); border-color: var(--verde); }
.progreso { margin-top: .45rem; display: flex; align-items: center; gap: .6rem; font-size: .8125rem; color: var(--tinta-2); }
.pista { flex: 1; height: 6px; background: var(--regla); border-radius: 3px; overflow: hidden; }
.relleno { display: block; height: 100%; width: 0; background: var(--verde); transition: width .3s ease; }

/* Contenido */
main { max-width: var(--ancho); margin: 0 auto; padding: 1.25rem 1rem 3rem; outline: none; }
.antetitulo { font-size: .875rem; color: var(--tinta-2); margin-bottom: .35rem; letter-spacing: .01em; }
.lead { font-size: 1.125rem; }
.nota { font-size: .875rem; color: var(--tinta-2); }
.tarjeta { background: var(--papel-2); border: 1px solid var(--regla); border-radius: 14px; padding: 1.1rem 1.2rem; margin: 1rem 0; }
.aviso { border-left: 4px solid var(--cobre); background: var(--cobre-claro); padding: .8rem 1rem; border-radius: 0; margin: 1rem 0; font-size: .9375rem; }
.lista { padding-left: 1.2rem; margin: 0 0 1rem; }
.lista li { margin-bottom: .35rem; }

/* Botones */
.acciones { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; }
.btn { min-height: 48px; padding: .7rem 1.25rem; border-radius: var(--radio); border: 1.5px solid var(--verde); background: var(--verde); color: var(--papel); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn:hover { background: #123F2F; }
.btn-sec { background: transparent; color: var(--verde); }
.btn-sec:hover { background: var(--verde-claro); }
.btn-texto { background: none; border: none; color: var(--verde); text-decoration: underline; padding: .7rem .2rem; min-height: 44px; font: inherit; cursor: pointer; }

/* Saldo y cuentas */
.saldo { margin: .25rem 0 .75rem; }
.saldo .valor { font-family: var(--titular); font-size: 2.75rem; line-height: 1.05; font-weight: 600; font-variant-numeric: tabular-nums; }
.saldo .etiqueta { font-size: .875rem; color: var(--tinta-2); }
.cuentas { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: .5rem; margin: 0 0 1rem; }
.cuenta { border-top: 1px solid var(--regla); padding-top: .4rem; }
.cuenta .k { font-size: .8125rem; color: var(--tinta-2); display: block; }
.cuenta .v { font-variant-numeric: tabular-nums; font-weight: 500; }
.cuenta.deuda .v { color: var(--cobre); }

/* Reto */
.situacion { font-family: var(--titular); font-size: 1.3rem; line-height: 1.35; font-weight: 500; margin: .5rem 0 .75rem; }
body.lectura-facil .situacion { font-weight: 500; }
fieldset.opciones { border: 0; padding: 0; margin: 1rem 0 0; display: grid; gap: .6rem; min-width: 0; }
fieldset.opciones legend { font-weight: 600; margin-bottom: .6rem; padding: 0; }
.opcion { display: flex; gap: .75rem; align-items: flex-start; min-height: 48px; padding: .85rem 1rem; border: 1.5px solid var(--borde); border-radius: var(--radio); background: var(--papel); cursor: pointer; }
.opcion input { appearance: none; -webkit-appearance: none; width: 1.25rem; height: 1.25rem; margin: .15rem 0 0; border: 2px solid var(--borde); border-radius: 50%; flex: none; background: var(--papel); }
.opcion input:checked { border-color: var(--verde); background: var(--verde); box-shadow: inset 0 0 0 3px var(--papel); }
.opcion:has(input:checked) { border-color: var(--verde); background: var(--verde-claro); }
.opcion:has(input:focus-visible) { outline: 3px solid var(--verde); outline-offset: 2px; }
.opcion input:focus-visible { outline: none; }
.opcion.no-disponible { border-style: dashed; cursor: not-allowed; color: var(--tinta-2); }
.opcion .motivo { display: block; font-size: .8125rem; margin-top: .2rem; }
.opcion .texto-op { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.error { color: var(--error); background: var(--error-claro); padding: .6rem .85rem; border-radius: var(--radio); margin-top: .75rem; font-size: .9375rem; }
.obligatorio { color: var(--error); font-weight: 600; }

/* Resultado de una decisión */
.resultado { border: 1.5px solid var(--verde); border-radius: 14px; padding: 1rem 1.15rem; margin: 1rem 0; background: var(--papel); }
.resultado.medio { border-color: var(--borde); }
.resultado.bajo { border-color: var(--cobre); }
.veredicto { font-weight: 600; margin-bottom: .35rem; }
.antes-despues { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .9375rem; margin: .5rem 0; font-variant-numeric: tabular-nums; }
.formula { font-family: 'IBM Plex Mono', ui-monospace, Consolas, monospace; font-size: .875rem; background: var(--papel-2); border: 1px solid var(--regla); border-radius: 8px; padding: .65rem .8rem; overflow-wrap: anywhere; }

/* Libreta de movimientos */
.libro { list-style: none; padding: 0; margin: .5rem 0 0; }
.libro li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .75rem; align-items: baseline; padding: .55rem 0; border-bottom: 1px solid var(--regla); font-size: .9375rem; }
.libro li.nuevo { animation: resaltar 1.4s ease-out; }
@keyframes resaltar { from { background: var(--cobre-claro); } to { background: transparent; } }
.libro .c { overflow-wrap: anywhere; }
.libro .c small { display: block; color: var(--tinta-2); font-size: .8125rem; }
.libro .m { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
.libro .m.mas { color: var(--verde); }
.libro .m.menos { color: var(--tinta); }
.libro .m.deuda { color: var(--cobre); }
.libro .m.mueve { color: var(--tinta-2); font-weight: 400; }
.vacio { color: var(--tinta-2); font-size: .9375rem; }

/* Niveles e insignias */
.niveles { display: grid; gap: .6rem; margin: 1rem 0; padding: 0; list-style: none; }
.niveles li { border: 1px solid var(--regla); border-radius: var(--radio); padding: .8rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.insignias { list-style: none; padding: 0; display: grid; gap: .5rem; }
.insignias li { display: flex; gap: .65rem; align-items: flex-start; }
.insignias .marca-i { width: 1.6rem; height: 1.6rem; flex: none; border-radius: 50%; border: 2px solid var(--cobre); display: grid; place-items: center; color: var(--cobre); font-size: .75rem; font-weight: 600; }
.insignias li.no .marca-i { border-color: var(--regla); color: var(--regla); }
.insignias li.no { color: var(--tinta-2); }
.puntaje { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .6rem; margin: 1rem 0; }
.puntaje div { background: var(--papel-2); border-radius: var(--radio); padding: .75rem .9rem; }
.puntaje .k { font-size: .8125rem; color: var(--tinta-2); display: block; }
.puntaje .v { font-family: var(--titular); font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
table.dominios { width: 100%; border-collapse: collapse; font-size: .9375rem; font-variant-numeric: tabular-nums; }
table.dominios th, table.dominios td { text-align: left; padding: .45rem .3rem; border-bottom: 1px solid var(--regla); }
table.dominios th:not(:first-child), table.dominios td:not(:first-child) { text-align: right; }

/* Escritorio: la libreta acompaña al reto */
@media (min-width: 62rem) {
  :root { --ancho: 64rem; }
  .con-libreta { display: grid; grid-template-columns: minmax(0, 1fr) 21rem; gap: 2.5rem; align-items: start; }
  .con-libreta aside { position: sticky; top: 7rem; max-height: calc(100vh - 8rem); overflow: auto; }
  .solo-movil { display: none; }
}
@media (max-width: 61.99rem) {
  .con-libreta aside { margin-top: 1.5rem; }
}
@media (max-width: 26rem) {
  h1 { font-size: 1.6rem; }
  .saldo .valor { font-size: 2.35rem; }
  .situacion { font-size: 1.18rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Pie */
.pie { max-width: var(--ancho); margin: 0 auto; padding: 1.25rem 1rem 2rem; border-top: 1px solid var(--regla); font-size: .8125rem; color: var(--tinta-2); }

/* Página de esquema */
.esquema section { margin: 2.25rem 0; }
.esquema .diagrama { width: 100%; height: auto; display: block; margin: .75rem 0; }
.esquema .diagrama text { font-family: var(--texto); fill: var(--tinta); font-size: 13px; }
.esquema .diagrama .t2 { fill: var(--tinta-2); font-size: 11.5px; }
.esquema .rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .75rem; }
.esquema .rejilla .tarjeta { margin: 0; }
.esquema table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.esquema th, .esquema td { text-align: left; vertical-align: top; padding: .5rem .4rem; border-bottom: 1px solid var(--regla); }
.esquema code { font-family: 'IBM Plex Mono', ui-monospace, Consolas, monospace; font-size: .85em; background: var(--papel-2); padding: .05rem .3rem; border-radius: 4px; }
.tabla-scroll { overflow-x: auto; }
.estado { display: inline-block; font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--borde); white-space: nowrap; }
.estado.listo { border-color: var(--verde); color: var(--verde); background: var(--verde-claro); }
.estado.pend { border-color: var(--cobre); color: var(--cobre); background: var(--cobre-claro); }
