/*
  stbrain.online (fase 31): primero para el móvil, legible en una tele. Letra grande (los lectores son adultos),
  botones de 48 px como mínimo, foco bien visible y claro u oscuro según el sistema.
  Los colores del tablero son los de la app (SudokuBoard.cs, Palette.Light y Palette.Dark).
*/

:root {
    color-scheme: light dark;
    --fondo: #fafafa;
    --texto: #1b1b1b;
    --suave: #5c5c5c;
    --borde: #c8c8c8;
    --acento: #1e5dba;
    --acento-texto: #ffffff;
    --foco: #c25e00;
    --error: #b3261e;
    --tarjeta: #ffffff;

    --t-fondo: #ffffff;
    --t-casa: #fff4cc;
    --t-patron: #cfe2ff;
    --t-origen: #ffe2bf;
    --t-objetivo: #ffe0e0;
    --t-colocada: #d3f1db;
    --t-clave: #e9ddfb;
    --t-segunda: #d4f0e8;
    --t-contradiccion: #ffb3b3;
    --t-vecina: #f1f1f1;
    --t-mismo: #dce8fa;
    --t-fina: #ababab;
    --t-gruesa: #222222;
    --t-diagonal: #b8b8b8;
    --t-pista: #111111;
    --t-colocado: #1e5dba;
    --t-nuevo: #117a2e;
    --t-candidato: #6a6a6a;
    --t-k-patron: #0b4db8;
    --t-quitado: #c62828;
    --t-k-segundo: #0b7a5e;
    --t-etiqueta: #7a7a7a;
    --t-seleccion: #1e78d7;
    --t-enlace: #7b3fc4;
    --t-hipotetico: #b4530a;
    --t-r0: #7b3fc4;
    --t-r1: #0b7a5e;
    --t-r2: #c25e00;
    --t-r3: #1e5dba;
    --t-r4: #b0307a;
    --t-r5: #5e7a00;

    --letra: clamp(1.125rem, 0.95rem + 0.8vw, 1.6rem);
    --hueco: clamp(0.75rem, 0.5rem + 1vw, 1.5rem);
}

@media (prefers-color-scheme: dark) {
    :root {
        --fondo: #121212;
        --texto: #ececec;
        --suave: #b0b0b0;
        --borde: #4a4a4a;
        --acento: #8ab4f8;
        --acento-texto: #0d1b30;
        --foco: #f4a94e;
        --error: #ff8a80;
        --tarjeta: #1e1e1e;

        --t-fondo: #1e1e1e;
        --t-casa: #3b3520;
        --t-patron: #213b61;
        --t-origen: #4e361a;
        --t-objetivo: #4b2424;
        --t-colocada: #1f462a;
        --t-clave: #3f2d5e;
        --t-segunda: #1c4a3e;
        --t-contradiccion: #6e2a2a;
        --t-vecina: #292929;
        --t-mismo: #26384f;
        --t-fina: #4e4e4e;
        --t-gruesa: #d6d6d6;
        --t-diagonal: #5c5c5c;
        --t-pista: #f2f2f2;
        --t-colocado: #8ab4f8;
        --t-nuevo: #72d78e;
        --t-candidato: #a3a3a3;
        --t-k-patron: #9cc4ff;
        --t-quitado: #ff7373;
        --t-k-segundo: #6fddbf;
        --t-etiqueta: #9a9a9a;
        --t-seleccion: #5aaaf5;
        --t-enlace: #c9a2f2;
        --t-hipotetico: #f4a94e;
        --t-r0: #c9a2f2;
        --t-r1: #6fddbf;
        --t-r2: #f4a94e;
        --t-r3: #8ab4f8;
        --t-r4: #f28bc8;
        --t-r5: #c5d86d;
    }
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--fondo);
    color: var(--texto);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
    font-size: var(--letra);
    line-height: 1.5;
    /* Margen de seguridad de las teles (overscan) y de los móviles con muesca. */
    padding: max(2vh, env(safe-area-inset-top)) max(3vw, env(safe-area-inset-right)) max(2vh, env(safe-area-inset-bottom)) max(3vw, env(safe-area-inset-left));
}

.cabecera, .contenido, .pie {
    max-width: 60rem;
    margin: 0 auto;
}

.cabecera {
    padding-bottom: var(--hueco);
}

.marca {
    font-weight: 700;
    font-size: 1.15em;
    color: var(--texto);
    text-decoration: none;
}

h1 {
    font-size: clamp(1.6rem, 1.2rem + 2vw, 2.6rem);
    line-height: 1.2;
    margin: 0 0 0.5rem;
}

p {
    margin: 0 0 var(--hueco);
}

a {
    color: var(--acento);
}

:focus-visible {
    outline: 4px solid var(--foco);
    outline-offset: 3px;
    border-radius: 4px;
}

.subtitulo, .datos, .miga {
    color: var(--suave);
}

.miga {
    margin-bottom: 0.25rem;
}

.nivel {
    font-weight: 700;
    color: var(--texto);
}

.boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 48px;
    padding: 0.5em 1.1em;
    border: 2px solid var(--acento);
    border-radius: 0.6em;
    background: var(--tarjeta);
    color: var(--acento);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.boton.principal {
    background: var(--acento);
    color: var(--acento-texto);
}

.libros {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: var(--hueco);
}

.libro {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.9em 1.1em;
}

.libro .autor {
    color: var(--suave);
    font-weight: 400;
}

.buscar label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.buscar .fila {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.buscar input {
    font: inherit;
    font-size: 1.4em;
    width: 7ch;
    min-height: 56px;
    padding: 0.2em 0.4em;
    border: 2px solid var(--borde);
    border-radius: 0.5em;
    background: var(--tarjeta);
    color: var(--texto);
    text-align: center;
}

.error {
    color: var(--error);
    font-weight: 600;
    margin-top: 0.75rem;
}

.ayudas .antes {
    font-weight: 600;
}

.ayudas .pronto {
    color: var(--suave);
}

.marco-tablero {
    margin: var(--hueco) 0;
}

.tablero {
    display: block;
    width: min(92vw, 72vh, 100%);
    height: auto;
    margin: 0 auto;
}

details.solucion > summary {
    list-style: none;
}

details.solucion > summary::-webkit-details-marker {
    display: none;
}

.pie {
    margin-top: calc(var(--hueco) * 2);
    padding-top: var(--hueco);
    border-top: 1px solid var(--borde);
    font-size: 0.85em;
}

/* El tablero: un papel, una clase (las mismas de la app). */
.tablero text {
    text-anchor: middle;
    dominant-baseline: central;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
}

.tablero .t-fondo { fill: var(--t-fondo); }
.tablero .c-casa { fill: var(--t-casa); }
.tablero .c-patron { fill: var(--t-patron); }
.tablero .c-origen { fill: var(--t-origen); }
.tablero .c-objetivo { fill: var(--t-objetivo); }
.tablero .c-colocada { fill: var(--t-colocada); }
.tablero .c-clave { fill: var(--t-clave); }
.tablero .c-segunda { fill: var(--t-segunda); }
.tablero .c-contradiccion { fill: var(--t-contradiccion); }
.tablero .c-vecina { fill: var(--t-vecina); }
.tablero .c-mismo { fill: var(--t-mismo); }
.tablero .l-fina { stroke: var(--t-fina); }
.tablero .l-gruesa { stroke: var(--t-gruesa); }
.tablero .l-diagonal { stroke: var(--t-diagonal); stroke-dasharray: 4 4; }
.tablero .n-pista { fill: var(--t-pista); font-weight: 600; }
.tablero .n-colocado { fill: var(--t-colocado); }
.tablero .n-nuevo { fill: var(--t-nuevo); font-weight: 600; }
.tablero .n-conflicto { fill: var(--t-quitado); }
.tablero .n-hipotetico { fill: var(--t-hipotetico); font-style: italic; }
.tablero .n-hipotetico.actual { font-weight: 600; }
.tablero .n-paso { fill: var(--t-hipotetico); }
.tablero .k-normal { fill: var(--t-candidato); }
.tablero .k-patron { fill: var(--t-k-patron); font-weight: 600; }
.tablero .k-quitado { fill: var(--t-quitado); font-weight: 600; }
.tablero .k-segundo { fill: var(--t-k-segundo); font-weight: 600; }
.tablero .tachado { stroke: var(--t-quitado); }
.tablero .seleccion { stroke: var(--t-seleccion); }
.tablero .etiqueta { fill: var(--t-etiqueta); }
.tablero .enlace { fill: none; stroke-linecap: round; }
.tablero .enlace.debil { stroke-dasharray: 6 4; }
.tablero .r-enlace { stroke: var(--t-enlace); }
.tablero .r0 { stroke: var(--t-r0); }
.tablero .r1 { stroke: var(--t-r1); }
.tablero .r2 { stroke: var(--t-r2); }
.tablero .r3 { stroke: var(--t-r3); }
.tablero .r4 { stroke: var(--t-r4); }
.tablero .r5 { stroke: var(--t-r5); }

@media (prefers-reduced-motion: no-preference) {
    .boton { transition: background-color 0.15s, color 0.15s; }
}
