:root {
    --light: #f0d9b5;
    --dark: #b58863;
    --sel: #f6f669;
    --size: min(calc(92vw - 40px), 72vh, 560px);
}

/* Temas de tablero — se aplican como clase en #board */
#board.theme-classic { --light: #f0d9b5; --dark: #b58863; --sel: #f6f669; }
#board.theme-green   { --light: #eeeed2; --dark: #769656; --sel: #f6f669; }
#board.theme-blue    { --light: #dee3e6; --dark: #8ca2ad; --sel: #f7e07a; }
#board.theme-gray    { --light: #dcdcdc; --dark: #999999; --sel: #f6f669; }
#board.theme-wood    { --light: #e8c99b; --dark: #9b5a2c; --sel: #f6d860; }
#board.theme-coral   { --light: #f1dcd2; --dark: #c57b66; --sel: #f6f669; }
#board.theme-purple  { --light: #e9e2f3; --dark: #8769b0; --sel: #f6f669; }
#board.theme-midnight { --light: #6f7d93; --dark: #2e3a4f; --sel: #c9b458; }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #2b2b2b;
    color: #eee;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

header {
    text-align: center;
    margin: 24px 0 8px;
}

header h1 { margin: 0; font-size: 2rem; }
.subtitle { margin: 4px 0 0; color: #aaa; }

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 16px;
    flex: 1 0 auto;   /* empuja el footer al fondo en páginas cortas */
    width: 100%;
    box-sizing: border-box;
}

#board {
    width: var(--size);
    height: var(--size);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border: 4px solid #1a1a1a;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    user-select: none;
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--size) / 10);
    cursor: grab;
    position: relative;
}

.square.light { background: var(--light); }
.square.dark { background: var(--dark); }
.square.selected { background: var(--sel); }

.piece { line-height: 1; }
.piece.glyph.white { color: #fff; text-shadow: 0 0 2px #000, 0 1px 2px rgba(0,0,0,.6); }
.piece.glyph.black { color: #111; text-shadow: 0 0 2px #999; }
.piece.img {
    width: 88%;
    height: 88%;
    pointer-events: auto;
    -webkit-user-drag: element;
}

.square.dragover { outline: 3px solid #4a90d9; outline-offset: -3px; }

.panel {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 1.1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.themes {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.themes h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #bbb;
    margin: 0;
}
.sel-label {
    color: #4a90d9;
    font-weight: 700;
}
.swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: var(--size);
}
.swatch {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    transition: transform .1s, border-color .1s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: #4a90d9; box-shadow: 0 0 0 2px rgba(74,144,217,.4); }
.swatch span { display: block; }
.swatch .l { background: var(--sw-light); }
.swatch .d { background: var(--sw-dark); }

/* Botones de set de piezas */
.pset {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 2px solid transparent;
    background: #e9e3d6;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .1s, border-color .1s;
}
.pset:hover { transform: scale(1.08); }
.pset.active { border-color: #4a90d9; box-shadow: 0 0 0 2px rgba(74,144,217,.4); }
.pset img { width: 100%; height: 100%; }
.pset-glyph { font-size: 1.6rem; color: #111; }

.credits {
    margin: 8px 0 24px;
    color: #888;
    font-size: 0.85rem;
    text-align: center;
}
.credits a { color: #6aa9e0; }

button {
    background: #4a90d9;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
}
button:hover { background: #3a7ec0; }

/* ===================== Auth / UI general ===================== */
a { color: #6aa9e0; }
.brand { color: #eee; text-decoration: none; }

.topnav {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 6px;
    font-size: 0.95rem;
}
.topnav .hi { color: #aaa; }
.inline { display: inline; margin: 0; }
.linkbtn {
    background: none;
    border: none;
    color: #6aa9e0;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0;
}
.linkbtn:hover { text-decoration: underline; }

.flashes { list-style: none; padding: 0; margin: 12px auto; max-width: 420px; }
.flash {
    padding: 10px 14px;
    border-radius: 8px;
    margin: 6px 0;
    font-size: 0.95rem;
}
.flash-success { background: #1f3d2b; color: #b6f0c6; border: 1px solid #2f6b46; }
.flash-error   { background: #41232a; color: #f3b6c0; border: 1px solid #7a3340; }

.card {
    background: #3a3a3a;
    border-radius: 12px;
    padding: 24px;
    max-width: 420px;
    margin: 16px auto;
    box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.card h2 { margin-top: 0; }

.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.9rem; color: #ccc; }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #555;
    background: #2b2b2b;
    color: #eee;
    font-size: 1rem;
}
.field input:focus { outline: 2px solid #4a90d9; border-color: #4a90d9; }
.field-check { margin: 10px 0; color: #ccc; font-size: 0.9rem; }
.field-errors { color: #f3b6c0; font-size: 0.85rem; margin: 2px 0 0; padding-left: 18px; }

.hint { color: #999; font-size: 0.82rem; margin: 4px 0 14px; }
.muted { color: #999; font-size: 0.9rem; margin-top: 16px; }
.warn { color: #f3b6c0; }

.btn-primary, .btn-danger, .btn {
    display: inline-block;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
}
.btn-primary { background: #4a90d9; }
.btn-primary:hover { background: #3a7ec0; }
.btn { background: #555; }
.btn:hover { background: #666; }
.btn-danger { background: #a23a4a; }
.btn-danger:hover { background: #8a2f3e; }

.profile { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 16px 0; }
.profile dt { color: #999; }
.profile dd { margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ===================== Workspace: navbar superior ===================== */
body.workspace { align-items: stretch; }

.navbar {
    width: 100%;
    position: sticky;   /* siempre visible: enmarca el área de trabajo junto al footer */
    top: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 20px;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: max(20px, env(safe-area-inset-left, 0px));
    padding-right: max(20px, env(safe-area-inset-right, 0px));
    min-height: 56px;
    background: #1f1f1f;
    border-bottom: 1px solid #333;
    box-shadow: 0 2px 10px rgba(0,0,0,.3);
}
.navbar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #eee;
    text-decoration: none;
    white-space: nowrap;
}
.brand-text {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.navbar .menu {
    list-style: none;
    display: flex;
    gap: 6px;
    margin: 0;
    padding: 0;
}
.navbar .menu a {
    display: block;
    padding: 8px 14px;
    border-radius: 8px;
    color: #cfcfcf;
    text-decoration: none;
    font-size: 0.95rem;
}
.navbar .menu a:hover { background: #2e2e2e; color: #fff; }
.navbar .menu a.active { background: #4a90d9; color: #fff; }

.navuser {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.navuser-name { color: #9ec5ef; text-decoration: none; font-weight: 600; }
.navuser-name:hover { text-decoration: underline; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #eee;
    font-size: 1.4rem;
    cursor: pointer;
}

/* Marca centrada en login/registro */
body.auth { justify-content: flex-start; }
.auth-brand {
    font-size: 2rem;
    font-weight: 700;
    color: #eee;
    text-align: center;
    margin: 40px 0 4px;
}

/* Responsive: menú colapsable en móvil */
@media (max-width: 720px) {
    .nav-toggle { display: block; order: 2; margin-left: auto; }
    .navbar { flex-wrap: wrap; gap: 10px; }
    .navbar .menu {
        order: 4;
        flex-basis: 100%;
        flex-direction: column;
        display: none;
        padding-top: 6px;
    }
    .navuser {
        order: 5;
        flex-basis: 100%;
        display: none;
        justify-content: flex-start;
        gap: 16px;
        padding-bottom: 6px;
    }
    .navbar.open .menu,
    .navbar.open .navuser { display: flex; }
    .navbar .menu a { padding: 12px 14px; } /* tap targets cómodos */
}

/* Link deshabilitado (p.ej. registro off) */
.disabled-link {
    color: #777;
    cursor: not-allowed;
    text-decoration: line-through;
    opacity: 0.7;
}

/* ===================== Logo ===================== */
.navbar-logo { height: 46px; display: block; }
.auth-logo { width: 230px; max-width: 78vw; height: auto; display: block; margin: 0 auto; }

/* ===================== Juego ===================== */
/* Base (móvil/angosto): una sola columna, todo apilado y centrado. */
.game {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 16px;
    width: 100%;
}
/* Escritorio: 3 columnas — tablero (auto, la más ancha) + 2 columnas angostas. */
@media (min-width: 1140px) {
    .game {
        display: grid;
        grid-template-columns: auto minmax(230px, 290px) minmax(230px, 290px);
        align-items: start;
        justify-content: center;
        gap: 20px;
        max-width: 1240px;
        margin: 0 auto;
    }
}
.board-col { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.status {
    font-size: 1.05rem;
    margin: 0;
    min-height: 1.4em;
    color: #eee;
}
/* Navegación de revisión (ver posiciones pasadas sin alterar la partida) */
.rev-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0;
    flex-wrap: wrap;
}
.rev-nav button {
    background: #2a2a2a;
    color: #ddd;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.95rem;
    cursor: pointer;
    line-height: 1;
}
.rev-nav button:hover:not(:disabled) { background: #373737; }
.rev-nav button:disabled { opacity: 0.35; cursor: default; }
.rev-label {
    margin-left: 6px;
    font-size: 0.85rem;
    color: #6ac26a;
    white-space: nowrap;
}
.rev-label.reviewing { color: #e0b341; }

.game-side, .game-extra {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 480px;   /* apilado: ancho completo hasta 480 */
}
@media (min-width: 1140px) {
    .game-side, .game-extra { width: auto; max-width: none; }  /* en grid las dimensiona la columna */
}
.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #353535;
    padding: 16px;
    border-radius: 10px;
}
.controls label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: #ccc; }
.controls select, .controls input {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #555;
    background: #2b2b2b;
    color: #eee;
    font-size: 16px; /* >=16px evita el zoom de iOS al enfocar */
    width: 100%;
}
.controls button { width: 100%; }

.moves-box { background: #353535; padding: 14px 16px; border-radius: 10px; }
.moves-box h3 { margin: 0 0 8px; font-size: 1rem; color: #bbb; }
.moves {
    max-height: 320px;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #ddd;
}
.moves .mv { margin-right: 4px; white-space: nowrap; }
.moves .mv b { color: #8aa; font-weight: 600; }

/* resaltados del tablero */
.square.lastmove { box-shadow: inset 0 0 0 4px rgba(255, 235, 90, 0.55); }
.square.hl-error { box-shadow: inset 0 0 0 4px rgba(229, 72, 77, 0.8); }
.square.hl-better { box-shadow: inset 0 0 0 4px rgba(76, 175, 80, 0.85); }

/* Coordenadas dentro del tablero (estilo lichess): número opuesto al color de casilla */
.coord {
    position: absolute;
    font-size: clamp(8px, calc(var(--size, 480px) / 50), 13px);
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    user-select: none;
    z-index: 2;
    opacity: 0.92;
}
.coord-rank { top: 2px; left: 3px; }
.coord-file { right: 3px; bottom: 2px; }
.square.light .coord { color: var(--dark); }
.square.dark .coord { color: var(--light); }

/* Anillo luminoso en la casilla de destino de una jugada sugerida (demo de análisis) */
.square.hl-dest::after {
    content: "";
    position: absolute;
    inset: 9%;
    border-radius: 50%;
    border: 3px solid currentColor;
    box-shadow: 0 0 12px 3px currentColor;
    pointer-events: none;
    z-index: 3;
    animation: destPulse 1.05s ease-in-out infinite;
}
.square.hl-better.hl-dest::after { color: rgba(76, 175, 80, 0.95); }
.square.hl-error.hl-dest::after { color: rgba(229, 72, 77, 0.95); }

/* Pieza "fantasma": lo que realmente se jugó, mostrado junto a la mejora propuesta */
.ghost-piece {
    position: absolute;
    top: 6%;
    left: 6%;
    width: 88%;
    height: 88%;
    opacity: 0.42;
    pointer-events: none;
    z-index: 1;
}
.square.ghost-sq { box-shadow: inset 0 0 0 3px rgba(229, 72, 77, 0.5); }
@keyframes destPulse {
    0%, 100% { transform: scale(0.9); opacity: 0.65; }
    50% { transform: scale(1.05); opacity: 1; }
}
.square.target::after {
    content: "";
    position: absolute;
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background: rgba(40, 40, 40, 0.35);
    pointer-events: none;
}
.square.target:has(.piece)::after {
    width: 84%;
    height: 84%;
    background: none;
    border: 4px solid rgba(40, 40, 40, 0.35);
    box-sizing: border-box;
}

/* ===================== Eval bar + precisión ===================== */
.board-row { display: flex; gap: 8px; align-items: stretch; }
.evalbar {
    width: 18px;
    height: var(--size);
    background: #2e3a4f;           /* lado negras (arriba) */
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 0 1px #000;
}
.evalfill {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 50%;
    background: #f0f0f0;           /* ventaja blancas (abajo) */
    transition: height .25s ease;
}
.evalnum {
    margin: 0;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: #cdd;
}
.acc-box { background: #353535; padding: 14px 16px; border-radius: 10px; }
.acc-box h3 { margin: 0 0 8px; font-size: 1rem; color: #bbb; }
.acc-row { display: flex; justify-content: space-between; padding: 3px 0; color: #ddd; }
.acc-row strong { color: #8ed18e; }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; }
.check input { width: auto; }

/* ===================== Arrastre natural + reloj ===================== */
#board { touch-action: none; }
.square.hover { box-shadow: inset 0 0 0 4px rgba(74,144,217,.85); }
.drag-ghost {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    will-change: left, top;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,.5));
}

.clock {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 1.6rem;
    background: #1f1f1f;
    color: #eee;
    padding: 6px 16px;
    border-radius: 8px;
    border: 2px solid #333;
    min-width: 110px;
    text-align: center;
    align-self: center;
}
.clock.active { border-color: #4a90d9; background: #243447; }
.clock.low { color: #f3a; }

/* ===================== Apertura + Estadísticas ===================== */
.opening { margin: 0; color: #9ec5ef; font-size: 0.95rem; }

.stats-wrap { max-width: 900px; margin: 0 auto; padding: 20px; width: 100%; }
.stat-summary { background: #353535; border-radius: 10px; padding: 16px 20px; margin: 12px 0 20px; }
.stat-big { font-size: 2rem; font-weight: 800; color: #8ed18e; }
.stat-sub { color: #aaa; }

.chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 240px;
    background: #2f2f2f;
    border-radius: 10px;
    padding: 14px;
    overflow-x: auto;
}
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 26px; height: 100%; }
.bar {
    width: 22px;
    background: linear-gradient(#6aa9e0, #3a7ec0);
    border-radius: 4px 4px 0 0;
    min-height: 3px;
    transition: height .3s;
}
.bar.never { background: linear-gradient(#8ed18e, #4caf50); }
.bar-lbl { font-size: 0.75rem; color: #ccc; margin-top: 4px; }
.chart-foot { margin-top: 10px; font-size: 0.82rem; }

.acc-detail { font-size: 0.82rem; color: #c9a86a; margin: -2px 0 8px; }

.evalgraph { width: var(--size); border-radius: 8px; overflow: hidden; margin-top: 4px; }
.stat-cards { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-cards .stat-summary { flex: 1; min-width: 220px; }

/* ===================== Online (humano vs humano) ===================== */
.online-box { background: #2d3a2d; border: 1px solid #3f5a3f; border-radius: 10px; padding: 14px 16px; }
.online-info { color: #cfe6cf; font-size: 0.95rem; margin-bottom: 8px; }
.online-wait { color: #f0d68a; margin-top: 8px; font-size: 0.9rem; }
.share-input {
    width: 100%; padding: 8px; border-radius: 6px; border: 1px solid #555;
    background: #2b2b2b; color: #eee; font-size: 16px; margin-bottom: 8px;
}

/* Margen inferior con safe-area (home indicator) en móvil */
main { padding-bottom: env(safe-area-inset-bottom, 0px); }
@media (max-width: 720px) {
    .game { padding: 12px; gap: 14px; }
}

/* ===================== Dashboard de inicio ===================== */
.home { max-width: 900px; margin: 0 auto; padding: 24px 20px; width: 100%; }
.home-hi { margin: 0 0 2px; }
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 18px;
}
.card-tile {
    display: block;
    background: #353535;
    border: 1px solid #444;
    border-radius: 12px;
    padding: 20px;
    text-decoration: none;
    color: #eee;
    transition: transform .12s, border-color .12s, background .12s;
}
.card-tile:hover { transform: translateY(-3px); border-color: #4a90d9; background: #3b3b3b; }
.card-ico { font-size: 2.2rem; line-height: 1; }
.card-tt { font-size: 1.15rem; font-weight: 700; margin-top: 10px; }
.card-sub { color: #aaa; font-size: 0.9rem; margin-top: 4px; }
.soon-badge {
    font-size: 0.68rem;
    font-weight: 700;
    background: #5a4a1f;
    color: #f0d68a;
    padding: 2px 7px;
    border-radius: 999px;
    vertical-align: middle;
    margin-left: 6px;
}

/* ===================== Analizar partidas ===================== */
.analyze-wrap { max-width: 1000px; margin: 0 auto; padding: 18px 16px; width: 100%; }
.analyzer { max-width: 1240px; margin: 0 auto; padding: 18px 16px; width: 100%; }
.games-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.games-table th, .games-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #3a3a3a; font-size: 0.92rem; }
.games-table th { color: #999; font-weight: 600; }
.game-row { cursor: pointer; }
.game-row:hover { background: #353535; }
.games-table .op { color: #9ec5ef; }
.games-table .link { color: #6aa9e0; white-space: nowrap; }
.rb { font-weight: 700; }
.rb-res { color: #8ed18e; }
.rb-draw { color: #d6c98a; }
.rb-none { color: #888; }

.back-link { color: #9ec5ef; text-decoration: none; font-size: 0.9rem; }
.an-head { margin: 8px 0 14px; }
.an-title { font-size: 1.2rem; font-weight: 700; color: #9ec5ef; }
.an-meta { color: #aaa; font-size: 0.92rem; margin-top: 2px; }
/* Base (móvil): una columna apilada. Escritorio: 3 columnas (tablero + coach + jugadas). */
.an-main { display: flex; flex-direction: column; align-items: center; gap: 16px; }
@media (min-width: 1140px) {
    .an-main {
        display: grid;
        grid-template-columns: auto minmax(280px, 380px) minmax(190px, 250px);
        align-items: start;
        justify-content: center;
        gap: 20px;
    }
    /* Columnas laterales de igual altura; si el contenido se pasa, scroll interno. */
    .an-main .coach-box,
    .an-main .moves-box {
        height: min(82vh, 700px);
        overflow-y: auto;
        box-sizing: border-box;
    }
}
.an-nav { display: flex; gap: 6px; margin-top: 10px; }
.an-nav button { background: #444; color: #eee; min-width: 46px; padding: 8px 0; font-size: 1rem; }
.an-nav button:hover { background: #555; }

.moves-an .mv-pair { display: inline-block; margin-right: 6px; white-space: nowrap; }
.moves-an .mv-an { cursor: pointer; padding: 1px 3px; border-radius: 4px; }
.moves-an .mv-an:hover { background: #444; }
.moves-an .mv-an.cur { background: #4a90d9; color: #fff; }
.cl-ic { font-size: 0.8em; margin-left: 1px; }
.c-inacc { filter: none; }
.c-mist {}
.c-blun {}

.coach-box { background: #2d3340; border: 1px solid #3f4a5f; border-radius: 10px; padding: 14px 16px; }
.coach-box .btn-primary { width: 100%; }
.coach-out { margin-top: 12px; }
.coach-summary { color: #dfe7f3; line-height: 1.5; margin-bottom: 12px; }
.coach-moment { background: #353b48; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.coach-moment:hover { background: #3d4555; }
.cm-head { font-size: 0.9rem; color: #f0d68a; margin-bottom: 4px; }
.cm-text { color: #cfd6e2; font-size: 0.92rem; line-height: 1.45; }

.game-id { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; color: #c9a86a; letter-spacing: 1px; font-size: 0.85rem; margin: 0; }
.an-meta .game-id { display: inline; }

/* Coach: análisis enriquecido */
.coach-stats { color: #8ed18e; font-weight: 700; margin-bottom: 8px; }
.coach-sec { margin: 8px 0; }
.coach-sec .cs-title { color: #9ec5ef; font-weight: 700; font-size: 0.9rem; }
.coach-sec .cs-text { color: #cfd6e2; font-size: 0.92rem; line-height: 1.45; }
.coach-list { margin: 8px 0; }
.coach-list .cl-t { font-weight: 700; font-size: 0.9rem; margin-bottom: 2px; }
.coach-list.good .cl-t { color: #8ed18e; }
.coach-list.improve .cl-t { color: #f0c66a; }
.coach-list ul { margin: 0; padding-left: 20px; }
.coach-list li { color: #cfd6e2; font-size: 0.9rem; line-height: 1.4; }
.coach-tip { background: #2f3a2f; border-left: 3px solid #6aa86a; padding: 8px 12px; border-radius: 6px; color: #d6e6d6; margin: 10px 0; font-size: 0.92rem; }
.coach-moments-t { color: #aaa; font-size: 0.85rem; margin: 12px 0 6px; }
.coach-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.coach-chip { border: none; border-radius: 999px; padding: 5px 12px; font-size: 0.82rem; cursor: pointer; color: #fff; }
.chip-good { background: #2f6b46; }
.chip-good:hover { background: #3a865a; }
.chip-bad { background: #7a3340; }
.chip-bad:hover { background: #97414f; }

.moment-why {
    margin-top: 10px;
    background: #2b2f3a;
    border-left: 3px solid #6aa9e0;
    padding: 8px 12px;
    border-radius: 6px;
    color: #d8e2f2;
    font-size: 0.9rem;
    line-height: 1.45;
}
.moment-why b { color: #9ec5ef; }

/* Conversión fallida (ganabas pero empataste/perdiste) */
.chip-missed { background: #8a6a1f; }
.chip-missed:hover { background: #a8842b; }
.coach-missed {
    background: #3a3320;
    border-left: 3px solid #e0b341;
    padding: 9px 12px;
    border-radius: 6px;
    color: #f0e3c0;
    font-size: 0.92rem;
    line-height: 1.45;
    margin: 10px 0;
}
.coach-missed b { color: #e8c45a; }

.coach-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.coach-controls select { padding: 7px; border-radius: 6px; border: 1px solid #555; background: #2b2b2b; color: #eee; font-size: 0.9rem; }
.coach-controls .btn-primary { flex: 1; min-width: 160px; }

.an-nav .nav-play { min-width: 84px; background: #3a5a3a; }
.an-nav .nav-play:hover { background: #46704a; }

.mv-ref { color: #f0d68a; cursor: pointer; border-bottom: 1px dotted #f0d68a; }
.mv-ref:hover { color: #fff; background: #5a4a1f; }

/* Rótulo de la demo de error (badge rojo): tu jugada vs. la mejora del motor */
#moveInfo.demo-error { color: #ef6b73; font-weight: 600; }
#moveInfo.demo-better { color: #7fd18a; font-weight: 600; }

/* Narración guiada: bloque que se está leyendo */
.coach-out .speaking { outline: 2px solid #f0d68a; background: #463a1a; border-radius: 6px; }

/* Modalito de carga */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; z-index: 2000; }
.modal-box { background: #2f2f2f; border: 1px solid #444; border-radius: 12px; padding: 22px 28px; text-align: center; color: #eee; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.spinner { width: 32px; height: 32px; border: 3px solid #555; border-top-color: #6aa9e0; border-radius: 50%; margin: 0 auto 12px; animation: spin .8s linear infinite; }

/* Modal educativo de "código OTP incorrecto" */
.otp-modal { background: rgba(0,0,0,.66); }
.otp-modal .otp-box {
    background: #23272e;
    border: 1px solid #2c313a;
    border-top: 3px solid #d8a657;
    border-radius: 12px;
    max-width: 380px;
    width: calc(100vw - 32px);
    padding: 28px 26px 22px;
    text-align: center;
    position: relative;
    animation: otpPop 0.18s ease-out;
}
@keyframes otpPop { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .otp-modal .otp-box { animation: none; } }
.otp-x { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: #9aa1ac; font-size: 1rem; cursor: pointer; padding: 6px; line-height: 1; }
.otp-x:hover { color: #e7e9ec; }
.otp-x:focus-visible { outline: 2px solid #d8a657; border-radius: 4px; }
.otp-ico {
    width: 54px; height: 54px; margin: 2px auto 14px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.9rem; color: #e0b341;
    background: rgba(224, 179, 65, 0.12); border: 2px solid rgba(224, 179, 65, 0.45);
}
.otp-box h3 { margin: 0 0 5px; font-size: 1.3rem; color: #e7e9ec; }
.otp-sub { margin: 0 0 12px; color: #9aa1ac; font-size: 0.95rem; line-height: 1.4; }
.otp-attempts { margin: 0 0 16px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.88rem; color: #caa05a; letter-spacing: 0.02em; }
.otp-attempts b { color: #e8c45a; font-size: 1.05rem; }
.otp-tip {
    display: flex; gap: 11px; text-align: left;
    background: #21252c; border-left: 3px solid #d8a657; border-radius: 8px;
    padding: 11px 13px; margin-bottom: 20px; font-size: 0.9rem; line-height: 1.45; color: #cfd6e2;
}
.otp-tip-ico { font-size: 1.25rem; line-height: 1.2; flex-shrink: 0; }
.otp-tip b { color: #e7e9ec; }
.otp-actions { display: flex; gap: 10px; }
.otp-actions .btn-primary, .otp-actions .btn { flex: 1; padding: 11px 12px; text-align: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Estadísticas avanzadas */
.stats-filters { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0 16px; }
.sf { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: #aaa; }
.sf select { padding: 7px; border-radius: 6px; border: 1px solid #555; background: #2b2b2b; color: #eee; font-size: 16px; }
.stat-h { margin: 22px 0 8px; font-size: 1.05rem; color: #cdd; }
.record-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: #333; margin: 4px 0 8px; }
.record-bar div { height: 100%; }
.rb-w { background: #4caf50; } .rb-d { background: #888; } .rb-l { background: #c0556a; }
.bar.bar-w { background: linear-gradient(#8ed18e, #4caf50); }
.bar.bar-l { background: linear-gradient(#e08a9a, #c0556a); }
.bar.bar-d { background: linear-gradient(#bbb, #888); }
.stats-wrap .games-table { display: block; overflow-x: auto; white-space: nowrap; }

/* Gráfico SVG de estadísticas */
.chart-scroll { overflow-x: auto; border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.35); }
.stat-svg { display: block; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0 4px; color: #aaa; font-size: 0.82rem; }
.chart-legend i.lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 4px; }
.chart-legend .lg-w { background: #4caf50; } .chart-legend .lg-d { background: #888; }
.chart-legend .lg-l { background: #b34255; } .chart-legend .lg-n { background: #9be39b; opacity: .6; }

.chart-legend .lg-n { background: #3f9d54; opacity: 1; border-radius: 50%; }

.sf input[type="date"] { padding: 6px 7px; border-radius: 6px; border: 1px solid #555; background: #2b2b2b; color: #eee; font-size: 16px; }

/* Contenedores de Chart.js */
.chart-box { position: relative; height: 280px; background: #242424; border-radius: 12px; padding: 12px; margin-bottom: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.3); }

/* Panel "en partida" */
.game-info { background: #111315; border: 1px solid #2a2d31; border-radius: 10px; padding: 14px 16px; }
.gi-top { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #8ed18e; margin-bottom: 12px; }
.gi-dot { width: 9px; height: 9px; border-radius: 50%; background: #4caf50; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(76,175,80,.55); } 70% { box-shadow: 0 0 0 7px rgba(76,175,80,0); } 100% { box-shadow: 0 0 0 0 rgba(76,175,80,0); } }
.game-info.finished .gi-top { color: #d6c98a; }
.game-info.finished .gi-dot { background: #777; animation: none; }
.gi-grid { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; margin-bottom: 12px; }
.gi-grid > div { display: contents; }
.gi-grid span { color: #8a8f97; font-size: 0.85rem; }
.gi-grid b { color: #eee; font-size: 0.92rem; text-align: right; }
.game-info .btn { width: 100%; }

/* ===================== Ejercicios de geometría ===================== */
.ex-wrap { max-width: 1000px; margin: 0 auto; padding: 18px 16px; width: 100%; }
.ex-main { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; justify-content: center; }
#exBoard {
    --size: min(calc(92vw - 40px), 70vh, 480px);
    width: var(--size);
    height: var(--size);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border: 4px solid #1a1a1a;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    user-select: none;
}
#exBoard .square { cursor: pointer; }
.square.ex-ok { box-shadow: inset 0 0 0 5px rgba(76, 175, 80, 0.9); }
.square.ex-bad { box-shadow: inset 0 0 0 5px rgba(229, 72, 77, 0.9); }
.square.ex-show { box-shadow: inset 0 0 0 5px rgba(240, 214, 138, 0.95); }

/* Diagonales: casilla de origen (alfil) y camino de la diagonal al enseñar el fallo */
.square.ex-from { box-shadow: inset 0 0 0 4px rgba(216, 166, 87, 0.9); }
.square.ex-path::after {
    content: "";
    position: absolute;
    inset: 38%;
    border-radius: 50%;
    background: rgba(240, 214, 138, 0.8);
    pointer-events: none;
}
.ex-dir { color: #d8a657; font-size: 1.35em; line-height: 1; vertical-align: middle; }

/* Color de casilla: velo sobre el tablero + botones de respuesta */
.ex-boardwrap { position: relative; }
.ex-veil {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: rgba(21, 23, 27, 0.96);
    border: 4px solid #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ex-veil span {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: clamp(48px, 14vw, 96px);
    font-weight: 700;
    color: #d8a657;
    letter-spacing: 0.04em;
    user-select: none;
}
.ex-answers { display: flex; gap: 12px; margin-top: 10px; }
.ex-ans {
    flex: 1;
    min-width: 130px;
    padding: 14px 18px;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: 10px;
    border: 2px solid #3a3a3a;
    cursor: pointer;
}
.ex-ans:disabled { opacity: 0.45; cursor: default; }
.ex-ans-w { background: #e8e4da; color: #1a1a1a; }
.ex-ans-w:hover:not(:disabled) { background: #fff; border-color: #d8a657; }
.ex-ans-b { background: #232323; color: #eee; }
.ex-ans-b:hover:not(:disabled) { background: #161616; border-color: #d8a657; }
.ex-ans:focus-visible { outline: 2px solid #d8a657; outline-offset: 2px; }
/* Botones numéricos (distancia de rey) */
.ex-answers-n { flex-wrap: wrap; }
.ex-ans-n {
    min-width: 54px;
    flex: 1;
    background: #2c2c2c;
    color: #eee;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.ex-ans-n:hover:not(:disabled) { background: #383838; border-color: #d8a657; }

/* Súper-resalte "mírala": se oscurece el tablero y la casilla pulsa en dorado */
#exBoard.ex-dim .square:not(.ex-spot):not(.ex-path):not(.ex-from):not(.ex-ok):not(.ex-show):not(.ex-bad) {
    filter: brightness(0.38) saturate(0.7);
    transition: filter 0.25s;
}
.square.ex-spot {
    z-index: 2;
    animation: spotPulse 0.9s ease-in-out infinite;
}
@keyframes spotPulse {
    0%, 100% { box-shadow: inset 0 0 0 5px #f0d68a, 0 0 18px 4px rgba(240, 214, 138, 0.45); }
    50% { box-shadow: inset 0 0 0 7px #ffe9a8, 0 0 34px 12px rgba(240, 214, 138, 0.85); }
}
@media (prefers-reduced-motion: reduce) {
    .square.ex-spot { animation: none; box-shadow: inset 0 0 0 6px #f0d68a, 0 0 24px 8px rgba(240, 214, 138, 0.6); }
}

.ex-timer { width: 100%; height: 8px; background: #2a2a2a; border-radius: 5px; overflow: hidden; margin-top: 10px; }
#exTimerBar { height: 100%; width: 100%; background: #6ac26a; border-radius: 5px; transition: width 0.05s linear, background 0.15s; }
/* La columna del tablero no debe crecer por enunciados largos (envuelven). */
.ex-main .board-col { max-width: min(92vw, 520px); min-width: 0; position: relative; }

/* Pantalla completa del área de práctica */
.ex-fs {
    position: absolute;
    top: 2px;
    right: 2px;
    z-index: 7;
    background: rgba(20, 22, 26, 0.78);
    color: #d8a657;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.95rem;
    line-height: 1.2;
    cursor: pointer;
}
.ex-fs:hover { background: rgba(35, 38, 44, 0.92); border-color: #d8a657; }
.ex-fs.fs-on { color: #eee; }
.ex-main .board-col:fullscreen {
    background: #15171b;
    justify-content: center;
    padding: 24px;
    overflow: auto;
    max-width: none;
}
.ex-main .board-col:fullscreen #exBoard {
    --size: min(80vh, 90vw, 780px);
    width: var(--size);
    height: var(--size);
}
.ex-main .board-col:fullscreen .ex-prompt {
    font-size: 1.5rem;
    max-width: min(80vh, 90vw, 780px);
}
.ex-main .board-col:fullscreen .ex-timer { max-width: min(80vh, 90vw, 780px); }
.ex-main .board-col:fullscreen .ex-fs { top: 14px; right: 14px; font-size: 1.05rem; }
.ex-prompt { font-size: 1.3rem; margin-top: 12px; text-align: center; color: #eee; min-height: 1.6em; max-width: 100%; }
.ex-target { color: #f0d68a; font-size: 1.55rem; letter-spacing: 1px; }

/* Barra de Práctica para puzzles: ID (enlace a Lichess) + estrellas 1-5 */
.ex-puzmeta {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px 14px;
    margin: 10px auto 0; max-width: var(--size, 520px);
    padding: 7px 12px;
    background: #1c1f25; border: 1px solid #2c313a;
    border-top: 2px solid #d8a657; border-radius: 8px;
    font-size: .85rem;
}
.ex-puzmeta .puz-id {
    color: #d8a657; font-weight: 600; text-decoration: none; letter-spacing: .3px;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
.ex-puzmeta .puz-id:hover { text-decoration: underline; }
.puz-rate { display: inline-flex; align-items: center; gap: 1px; }
.puz-rate-lbl { color: #8b93a0; margin-right: 6px; font-size: .8rem; }
.puz-star {
    background: none; border: none; padding: 0 2px;
    font-size: 1.3rem; line-height: 1; cursor: pointer;
    color: #39414f; transition: color .1s, transform .1s;
}
.puz-star:hover { transform: scale(1.18); }
.puz-star.on { color: #e0b341; }
.puz-star:focus-visible { outline: 2px solid #d8a657; outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .puz-star { transition: none; } .puz-star:hover { transform: none; } }

/* ===== Mis favoritas (galería de tácticas calificadas) ===== */
.fav-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.fav-filt {
    background: #21252c; border: 1px solid #2c313a; color: #cdd3dc;
    border-radius: 999px; padding: 5px 13px; cursor: pointer; font-size: .82rem;
    transition: background .1s, color .1s, border-color .1s;
}
.fav-filt:hover { border-color: #d8a657; }
.fav-filt.active { background: #d8a657; color: #1a1a1a; border-color: #d8a657; font-weight: 700; }
.fav-go { margin: 14px 0 4px; }
.fav-go label { display: block; color: #8b93a0; font-size: .8rem; margin-bottom: 5px; }
.fav-go-row { display: flex; gap: 8px; flex-wrap: wrap; }
.fav-go input {
    background: #15171b; border: 1px solid #2c313a; color: #eee;
    border-radius: 8px; padding: 8px 12px; font-size: .9rem; width: 170px;
    font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .5px;
}
.fav-go input:focus { outline: 2px solid #d8a657; border-color: #d8a657; }
.fav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-top: 14px; }
.fav-card {
    background: #1c1f25; border: 1px solid #2c313a; border-radius: 10px;
    padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.fav-board {
    width: 100%; aspect-ratio: 1 / 1; display: grid;
    grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
    border: 2px solid #11141a; border-radius: 6px; overflow: hidden;
}
.fav-sq { position: relative; }
.fav-sq.l { background: #e8c99b; }
.fav-sq.d { background: #9b5a2c; }
.fav-sq img { position: absolute; inset: 4%; width: 92%; height: 92%; }
.fav-sq.hl::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px rgba(224, 179, 65, .9); }
.fav-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.fav-rating { font-family: ui-monospace, Menlo, Consolas, monospace; color: #d8a657; font-weight: 700; font-size: .95rem; }
.fav-tag { color: #aeb6c2; font-size: .8rem; }
.fav-themes { color: #8b93a0; font-size: .78rem; line-height: 1.3; }
.fav-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.fav-actions .btn { padding: 6px 11px; font-size: .82rem; }
.fav-empty {
    color: #9aa3b0; background: #1c1f25; border: 1px dashed #2c313a;
    border-radius: 10px; padding: 22px; text-align: center; grid-column: 1 / -1;
}

/* ===== Solucionador de un puzzle (interactivo) ===== */
.solve-layout { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; margin-top: 14px; }
.solve-col { flex: 0 0 auto; }
.solve-board {
    width: min(86vw, 440px); aspect-ratio: 1 / 1; display: grid;
    grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
    border: 3px solid #11141a; border-radius: 6px; overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
.solve-board .fav-sq { cursor: pointer; }
.solve-board .fav-sq.sel::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 4px rgba(246, 246, 105, .85); }
.fav-sq.bad::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 4px rgba(214, 90, 90, .9); }
.solve-meta, #solveMeta { max-width: min(86vw, 440px); }
.solve-side { flex: 1 1 260px; min-width: 240px; }
.solve-prompt { font-size: 1.2rem; color: #eee; min-height: 2em; line-height: 1.4; }
.solve-ok { color: #8ed18e; }
.solve-bad { color: #e07a7a; }
.solve-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.ex-side { display: flex; flex-direction: column; gap: 14px; min-width: 260px; max-width: 340px; }
.ex-card { background: #2c2c2c; border: 1px solid #3a3a3a; border-radius: 10px; padding: 14px 16px; }
.ex-controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.ex-controls > label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: #ccc; }
.ex-controls .check { flex-direction: row; align-items: center; gap: 8px; }
.ex-controls select { padding: 7px; border-radius: 6px; border: 1px solid #555; background: #2b2b2b; color: #eee; }
.ex-card .btn-primary { width: 100%; }
.ex-live { margin-top: 10px; text-align: center; color: #ddd; font-size: 1.05rem; }
.ex-h { margin: 0 0 8px; font-size: 1rem; color: #bbb; }
.ex-score { font-size: 2rem; font-weight: 800; color: #8ed18e; line-height: 1.1; }
.ex-score small { font-size: 1rem; color: #aaa; font-weight: 600; }
.ex-stat { color: #cfd6e2; font-size: 0.92rem; margin-top: 4px; }
.ex-miss { background: #3a2b2e; border-radius: 6px; padding: 2px 6px; margin: 2px; display: inline-block; color: #f0b0b0; }
.ex-miss small { color: #c9a; }
.ex-best { background: #2f3a2f; border-left: 3px solid #6aa86a; border-radius: 6px; padding: 6px 10px; color: #d6e6d6; }
.ex-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.88rem; }
.ex-table th, .ex-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #3a3a3a; }
.ex-table th { color: #999; font-weight: 600; }
@media (max-width: 720px) { .ex-side { max-width: 100%; width: 100%; } }

/* Pestañas Práctica / Reporte */
.ex-tabs { display: flex; gap: 8px; margin: 6px 0 14px; }
.ex-tab {
    background: #2c2c2c; color: #bbb; border: 1px solid #3a3a3a; border-radius: 8px;
    padding: 7px 16px; font-size: 0.95rem; cursor: pointer;
}
.ex-tab:hover { background: #353535; }
.ex-tab.active { background: #d8a657; color: #1a1407; border-color: #d8a657; font-weight: 600; }

/* ============== Reporte: "dossier de entrenador" (tokens locales) ============== */
.ex-report {
    --bg: #15171b; --surface: #1c1f25; --surface-2: #21252c; --line: #2c313a;
    --ink: #e7e9ec; --ink-muted: #9aa1ac; --ink-faint: #6b7280;
    --brass: #d8a657; --brass-dim: #a87f3e;
    --d0: #a14b46; --d1: #b9774a; --d2: #9a8f55; --d3: #6f9358; --d4: #4f9466;
    --empty: #262b33;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
    max-width: 820px; margin: 0 auto; color: var(--ink);
}
.rep-empty { color: var(--ink-muted); background: var(--surface); border: 1px solid var(--line);
    border-radius: 8px; padding: 18px 20px; line-height: 1.5; }
.rep-empty b { color: var(--brass); }

/* etiqueta de sección tipo instrumento */
.rep-h {
    display: flex; align-items: center; gap: 8px; margin: 0 0 10px;
    font-size: 12px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
    color: var(--ink-muted);
}
.rep-tick { width: 14px; height: 2px; background: var(--brass); border-radius: 2px; }
.rep-sec { margin-top: 24px; }
.rep-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }

/* --- KPI principal + barra de secundarias --- */
.rep-hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: stretch; }
.rep-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    padding: 18px 20px; position: relative; overflow: hidden; }
.rep-kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brass); }
.rep-kpi-val { font-family: var(--mono); font-size: 40px; font-weight: 700; line-height: 1;
    color: var(--ink); font-variant-numeric: tabular-nums; }
.rep-kpi-lbl { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); margin-top: 6px; }
.rep-kpi-foot { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.rep-spark { width: 120px; height: 28px; }
.rep-delta { font-family: var(--mono); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rep-delta.up { color: var(--d4); }
.rep-delta.down { color: var(--d0); }
.rep-delta.flat { color: var(--ink-faint); }

.rep-statbar { background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    margin: 0; padding: 6px 4px; display: flex; flex-direction: column; justify-content: center; }
.rep-statbar > div { display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.rep-statbar > div:last-child { border-bottom: 0; }
.rep-statbar dt { font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); margin: 0; }
.rep-statbar dd { font-family: var(--mono); font-size: 17px; font-weight: 600; color: var(--ink);
    margin: 0; font-variant-numeric: tabular-nums; }

/* --- gráfico --- */
.rep-chart { height: 220px; position: relative; }

/* --- segmented control --- */
.rep-heat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 2px; }
.seg-btn { background: transparent; color: var(--ink-muted); border: 0; border-radius: 5px;
    padding: 5px 14px; font-size: 0.85rem; cursor: pointer; font-weight: 600; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--brass); color: #1a1407; }

/* --- mapa de calor con gutter de coordenadas --- */
.rep-heat-panel { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; justify-content: center; }
.heat-frame {
    --hs: min(calc(92vw - 80px), 408px);
    display: grid; grid-template-columns: auto var(--hs); grid-template-rows: var(--hs) auto;
    column-gap: 8px; row-gap: 6px;
}
.heat-ranks { display: grid; grid-template-rows: repeat(8, 1fr); }
.heat-ranks span, .heat-files span {
    display: flex; align-items: center; justify-content: center;
    font-family: var(--mono); font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums;
}
.heat-corner { width: 100%; }
.heat-files { grid-column: 2; display: grid; grid-template-columns: repeat(8, 1fr); }
.heat-board {
    width: var(--hs); height: var(--hs);
    display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
    gap: 2px; background: var(--line); border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
}
.heat-cell {
    display: flex; align-items: center; justify-content: center; position: relative;
    background: var(--empty); cursor: default; transition: filter 0.12s;
}
.heat-cell.has-data { cursor: pointer; }
.heat-cell.has-data:hover { filter: brightness(1.18); outline: 2px solid var(--brass); outline-offset: -2px; }
.heat-cell .hv {
    font-family: var(--mono); font-size: clamp(8px, calc(var(--hs, 408px) / 46), 13px);
    font-weight: 700; color: #f4f1ec; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    font-variant-numeric: tabular-nums;
}
.heat-cell.pulse { animation: heatPulse 0.7s ease 2; }
@keyframes heatPulse { 50% { outline: 3px solid var(--brass); outline-offset: -3px; } }

/* --- aside del mapa: leyenda + lectura + puntos débiles --- */
.heat-aside { flex: 1; min-width: 200px; max-width: 280px; display: flex; flex-direction: column; gap: 16px; }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-muted); }
.heat-legend-bar { flex: 1; height: 8px; border-radius: 4px;
    background: linear-gradient(90deg, var(--d0), var(--d1), var(--d2), var(--d3), var(--d4)); }
.heat-readout { font-family: var(--mono); font-size: 13px; color: var(--ink);
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
    padding: 10px 12px; min-height: 2.6em; line-height: 1.4; font-variant-numeric: tabular-nums; }
.heat-weak-lbl { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: 8px; }
.heat-weak-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.heat-weak-chip {
    font-family: var(--mono); font-weight: 700; font-size: 14px; color: var(--ink);
    background: var(--surface-2); border: 1px solid var(--d1); border-radius: 6px;
    padding: 5px 10px; cursor: pointer; display: inline-flex; align-items: baseline; gap: 6px;
}
.heat-weak-chip:hover { border-color: var(--brass); }
.heat-weak-chip small { color: var(--ink-faint); font-weight: 500; }

@media (max-width: 720px) {
    .rep-hero { grid-template-columns: 1fr; }
    .heat-aside { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .heat-cell, .heat-cell.pulse { animation: none; transition: none; }
}

/* ===================== Footer global (fijo, barra compacta) ===================== */
/* Reservar espacio para que el contenido no quede oculto tras la barra fija. */
body { padding-bottom: calc(46px + env(safe-area-inset-bottom, 0px)); }

.site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: #1a1c20;
    border-top: 1px solid #2c313a;
}
/* firma: una fila de tablero (octava horizontal) en tonos madera apagados */
.sf-rank {
    height: 4px;
    background: repeating-linear-gradient(
        90deg,
        #6b4a26 0 44px,
        #3a3026 44px 88px
    );
    opacity: 0.55;
}
.sf-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 8px 20px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}
.sf-brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.sf-logo { font-size: 0.95rem; font-weight: 700; color: #e7e9ec; letter-spacing: 0.02em; white-space: nowrap; }
.sf-knight { color: #d8a657; font-size: 1.1em; line-height: 1; }
.sf-tag { font-size: 0.74rem; color: #6b7280; letter-spacing: 0.04em; white-space: nowrap; }
.sf-nav { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.sf-nav a {
    color: #9aa1ac;
    text-decoration: none;
    font-size: 0.82rem;
    padding: 2px;
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.sf-nav a:hover { color: #d8a657; border-bottom-color: #d8a657; }
.sf-nav a:focus-visible { outline: 2px solid #d8a657; outline-offset: 3px; border-radius: 2px; }
.sf-legal {
    display: flex; align-items: baseline; gap: 10px; white-space: nowrap;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-variant-numeric: tabular-nums;
}
.sf-copy { font-size: 0.78rem; color: #9aa1ac; }
.sf-rights { font-size: 0.7rem; color: #6b7280; letter-spacing: 0.03em; }

@media (max-width: 860px) {
    .sf-tag, .sf-nav { display: none; }  /* en pantallas chicas: solo marca + legal */
}
@media (max-width: 480px) {
    .sf-rights { display: none; }
    .sf-inner { justify-content: center; }
}

/* Línea de la solución: compacta, en notación monoespaciada (cabe en un renglón) */
.ex-sol { display: block; font-size: 0.95rem; color: #9aa1ac; }
.ex-sol-moves {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.98rem;
    color: #f0d68a;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
@media (max-width: 560px) { .ex-sol-moves { white-space: normal; } }
.ex-main .board-col:fullscreen .ex-sol { font-size: 1.1rem; }

/* Botones de estudio tras fallar un puzzle: fila ordenada bajo la solución */
.ex-study-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
}
.ex-continue {
    display: inline-block;
    padding: 7px 18px;
    font-size: 0.9rem;
    white-space: nowrap;
}
