/* Banderas: Windows no tiene emojis de banderas (muestra las letras). Fuente con solo las banderas
   de Twemoji (paquete npm country-flag-emoji-polyfill, ver THIRD-PARTY-NOTICES.md); por el
   unicode-range el navegador la descarga solo si hay una bandera en pantalla. */
@font-face {
    font-family: "Twemoji Country Flags";
    src: url("../fonts/TwemojiCountryFlags.woff2") format("woff2");
    unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
    font-display: swap;
}

:root {
    --bg: #1b1512;
    --text: #f1e9dc;
    --muted: #b8a993;
    --accent: #e0a63a;
    --frame: #5b3a21;
    --felt: #1f4d33;
    --bar: #4a2f1b;
    --tray: #3a2415;
    --point-light: #d9c39a;
    --point-dark: #9a3a25;
    --white-checker: #f4eee3;
    --white-edge: #8d8274;
    --black-checker: #2a2624;
    --black-edge: #050505;
    color-scheme: dark;
}

/* Temas del tablero (Opciones → Tablero): el atributo va en <html> (index.html lo pone al arrancar)
   o en la muestra de cada tema. Solo cambian los colores del tablero y de las fichas, no los de la app.
   Clásico: nogal y paño verde. */
:root,
[data-board-theme="classic"] {
    --board-frame: #5b3a21;
    --board-bar: #4a2f1b;
    --board-tray: #3a2415;
    --board-felt: #1f4d33;
    --board-grain: 0.6;
    --board-label: #f1e9dc;
    --point-light: #d9c39a;
    --point-dark: #9a3a25;
    --white-checker: #f4eee3;
    --white-shade: #b9ab94;
    --white-inner-shade: #d2c5ae;
    --white-edge: #8d8274;
    --white-inner-edge: rgba(120, 104, 82, 0.55);
    --white-pip: #2a2624;
    --black-checker: #2a2624;
    --black-light: #6f6660;
    --black-inner-light: #4d4540;
    --black-shade: #0b0908;
    --black-edge: #050505;
    --black-pip: #f4eee3;
}

/* Roble: madera clara, paño beige, triángulos verdes y crema; fichas blancas y bordó. */
[data-board-theme="oak"] {
    --board-frame: #b07f48;
    --board-bar: #9c6d3b;
    --board-tray: #7d5530;
    --board-felt: #e3d2ad;
    --board-grain: 0.5;
    --board-label: #3b2714;
    --point-light: #fbf4e2;
    --point-dark: #2f5d46;
    --white-checker: #f7f3ea;
    --white-shade: #b8ad98;
    --white-inner-shade: #d8cfbd;
    --white-edge: #8a7d68;
    --white-inner-edge: rgba(120, 104, 82, 0.5);
    --white-pip: #3a0b12;
    --black-checker: #7a1f2b;
    --black-light: #b4505c;
    --black-inner-light: #9a3442;
    --black-shade: #340910;
    --black-edge: #24060b;
    --black-pip: #f7f3ea;
}

/* Océano: marco azul marino, paño azul, triángulos blancos y coral; fichas blancas y grafito. */
[data-board-theme="ocean"] {
    --board-frame: #1d3557;
    --board-bar: #172b48;
    --board-tray: #13243d;
    --board-felt: #2b5c88;
    --board-grain: 0.18;
    --board-label: #e6eef6;
    --point-light: #e8eef4;
    --point-dark: #e07a5f;
    --white-checker: #f4f6f8;
    --white-shade: #a9b4c0;
    --white-inner-shade: #cfd8e1;
    --white-edge: #7a8794;
    --white-inner-edge: rgba(90, 104, 120, 0.5);
    --white-pip: #1d3557;
    --black-checker: #2a2e35;
    --black-light: #69707b;
    --black-inner-light: #4b515a;
    --black-shade: #0d0f12;
    --black-edge: #07080a;
    --black-pip: #f4f6f8;
}

/* Noche: grafito sin veta, triángulos gris y verde azulado; fichas blancas y rojas. */
[data-board-theme="night"] {
    --board-frame: #25282d;
    --board-bar: #1d1f23;
    --board-tray: #18191c;
    --board-felt: #30353d;
    --board-grain: 0.12;
    --board-label: #c9ced6;
    --point-light: #8d96a3;
    --point-dark: #2f9e96;
    --white-checker: #eceff3;
    --white-shade: #a3a9b2;
    --white-inner-shade: #cdd2d9;
    --white-edge: #7b828c;
    --white-inner-edge: rgba(90, 96, 106, 0.5);
    --white-pip: #25282d;
    --black-checker: #c2413a;
    --black-light: #e57a72;
    --black-inner-light: #d65a52;
    --black-shade: #5e1712;
    --black-edge: #3d0d09;
    --black-pip: #fbeeee;
}

/* Arena: marco de nogal oscuro, paño color arena, triángulos ladrillo y pizarra; fichas blancas y negras. */
[data-board-theme="sand"] {
    --board-frame: #3b2416;
    --board-bar: #321e12;
    --board-tray: #28180e;
    --board-felt: #c9ae7c;
    --board-grain: 0.6;
    --board-label: #f1e9dc;
    --point-light: #3a3f44;
    --point-dark: #a8432a;
    --white-checker: #fbf8f2;
    --white-shade: #b3a68f;
    --white-inner-shade: #d9cfbd;
    --white-edge: #7f735f;
    --white-inner-edge: rgba(120, 104, 82, 0.55);
    --white-pip: #2a2624;
    --black-checker: #222120;
    --black-light: #6a6460;
    --black-inner-light: #48433f;
    --black-shade: #080707;
    --black-edge: #000;
    --black-pip: #fbf8f2;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Botones y controles comunes */

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--frame);
    background: var(--tray);
    color: var(--text);
    touch-action: manipulation;
}

.icon-button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.menu-button,
.controls button {
    min-height: 48px;
    padding: 0 18px;
    border-radius: 10px;
    border: 1px solid var(--frame);
    background: var(--tray);
    color: var(--text);
    font-size: 1rem;
    touch-action: manipulation;
}

.menu-button.primary,
.controls button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #2a1a0c;
    font-weight: 600;
}

/* Acciones secundarias (rendirse, cancelar): texto, sin ocupar un botón grande. */
.controls button.link-button {
    min-height: 32px;
    padding: 0;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 0.9rem;
}

.controls button:disabled {
    opacity: 0.4;
}

.language {
    min-height: 40px;
    background: var(--tray);
    color: var(--text);
    border: 1px solid var(--frame);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 1rem;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    font-size: 0.95rem;
    cursor: pointer;
}

.toggle input {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    accent-color: var(--accent);
}

.hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

/* Menú (vertical) */

.menu {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-width: 480px;
    min-height: 100dvh;
    margin: 0 auto;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.menu-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border: 1px solid #3a2c22;
    border-radius: 12px;
    background: #241c17;
}

.menu-section h2 {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

    .field > span {
        flex: 0 0 auto;
    }

    /* Un desplegable toma el ancho de su opción más larga (por ejemplo, un país con nombre largo):
       se achica para no salirse del marco ni desplazar la pantalla hacia el costado. */
    .field > select {
        flex: 0 1 auto;
        min-width: 0;
        max-width: 65%;
        text-overflow: ellipsis;
    }

/* Cuenta y formularios */

/* Barra de la cuenta: el usuario a la izquierda; opciones, campanita y salir como íconos a la derecha. */
.account-bar {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 40px;
}

.account-user {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.account-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.account-name {
    overflow: hidden;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-name:hover {
    text-decoration: underline;
}

/* Campanita: lo pendiente de responder (desafíos, solicitudes de amistad) */

.bell {
    display: flex;
}

.bell-button,
.icon-action {
    position: relative;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--muted);
    cursor: pointer;
}

.bell-button:hover,
.bell-button[aria-expanded="true"],
.icon-action:hover {
    color: var(--text);
    background: var(--tray);
}

.bell-badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: #c8432b;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.bell-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
}

/* Debajo de la barra de la cuenta, alineado a la derecha como la campanita. */
.bell-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 95;
    display: flex;
    flex-direction: column;
    width: min(420px, calc(100vw - 24px));
    max-height: 70dvh;
    overflow-y: auto;
    padding: 12px 16px;
    border: 1px solid var(--frame);
    border-radius: 12px;
    background: #2a2019;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
    text-align: left;
}

.bell-panel h2 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.bell-panel .challenge:last-child {
    border-bottom: none;
}

.bell-panel .challenge-actions {
    flex-wrap: wrap;
    align-items: center;
}

.link-button {
    padding: 4px 6px;
    border: none;
    background: none;
    color: var(--accent);
    font-size: 0.95rem;
    text-decoration: underline;
    cursor: pointer;
}

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.tab {
    min-height: 40px;
    border: 1px solid var(--frame);
    border-radius: 8px;
    background: none;
    color: var(--muted);
    font-size: 0.95rem;
}

.tab.active {
    background: var(--tray);
    color: var(--text);
    font-weight: 600;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9rem;
}

.form-field input,
.form-field textarea {
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid var(--frame);
    border-radius: 8px;
    background: #1f1814;
    color: var(--text);
    font-size: 1rem;
}

.form-error {
    margin: 0;
    color: #e57373;
    font-size: 0.9rem;
}

.form-separator {
    margin: 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

a.menu-button {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

/* Menú principal y pantallas secundarias */

.menu-entries {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-entry {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 14px 16px;
    border: 1px solid #3a2c22;
    border-radius: 12px;
    background: #241c17;
    color: var(--text);
    text-align: left;
    font-size: 1.05rem;
    touch-action: manipulation;
}

.menu-entry small {
    color: var(--muted);
    font-size: 0.82rem;
}

.menu-entry:disabled {
    opacity: 0.45;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.page-header h1 {
    margin: 0;
    font-size: 1.3rem;
}

.choice-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-height: 56px;
    padding: 8px;
    border: 1px solid var(--frame);
    border-radius: 10px;
    background: var(--tray);
    color: var(--text);
    touch-action: manipulation;
}

.choice small {
    color: var(--muted);
}

.choice.selected {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.challenge {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid #3a2c22;
}

.challenge-actions,
.toast-actions {
    display: flex;
    gap: 8px;
}

.challenge-actions button,
.toast-actions button:not(.link-button) {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid var(--frame);
    background: var(--tray);
    color: var(--text);
}

.challenge-actions button.primary,
.toast-actions button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #2a1a0c;
    font-weight: 600;
}

.searching {
    align-items: center;
    text-align: center;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #3a2c22;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Avisos (desafíos recibidos, respuestas) */

.toasts {
    position: fixed;
    left: 50%;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(440px, calc(100% - 24px));
    transform: translateX(-50%);
}

.toast {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid var(--accent);
    border-radius: 12px;
    background: #2a2019;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

/* Juego: tablero a toda la altura y panel lateral */

/* La columna del tablero no es más ancha que el tablero (con la altura disponible manda la
   altura: 800 × 580): el ancho que sobra va al panel (hasta 300 px) y el conjunto se centra. Si
   no, en el celular apaisado quedaba un hueco junto al tablero y el panel, angosto, pegado al borde. */
.game {
    --board-max: calc((100dvh - 16px) * 800 / 580);
    display: grid;
    grid-template-columns: minmax(0, var(--board-max)) minmax(180px, 300px);
    justify-content: center;
    align-items: center;
    gap: 10px;
    max-width: 1280px;
    height: 100dvh;
    margin: 0 auto;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

.game-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-self: stretch;
    overflow-y: auto;
}

.game-panel-top {
    display: flex;
    justify-content: space-between;
}

.status {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: center;
    font-size: 0.9rem;
}

.chip {
    padding: 4px 8px;
    border-radius: 999px;
    border: 2px solid transparent;
    white-space: nowrap;
}

.chip.white {
    background: var(--white-checker);
    color: #2a2624;
}

.chip.black {
    background: var(--black-checker);
    color: var(--text);
}

.chip.on-turn {
    border-color: var(--accent);
}

.status .chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.chip .clock {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.chip .clock .delay {
    margin-right: 6px;
    color: var(--accent);
}

.chip.white .clock .delay {
    color: #9a6a12;
}

.chip .clock.low {
    color: #d9534f;
}

.game-panel .toggle {
    min-height: 32px;
    font-size: 0.85rem;
}

.match-score {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.match-score small {
    color: var(--accent);
    font-weight: 600;
}

.seat {
    position: relative;
    display: flex;
    flex-direction: column;
}

.chip-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.presence {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
    border-radius: 50%;
}

.presence.online { background: #5ccf7c; }
.presence.offline { background: #8a7d70; }

.speech {
    align-self: center;
    margin-top: 4px;
    padding: 3px 10px;
    border-radius: 10px;
    background: var(--accent);
    color: #2a1a0c;
    font-size: 0.85rem;
    font-weight: 600;
}

.quick-message-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 6px;
}

.quick-message-list button {
    min-height: 36px;
    border: 1px solid var(--frame);
    border-radius: 8px;
    background: var(--tray);
    color: var(--text);
    font-size: 0.85rem;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Celular en vertical sin pantalla completa: se pide girarlo. */

.rotate-overlay {
    display: none;
}

@media (orientation: portrait) and (max-width: 700px) {
    .rotate-overlay {
        position: fixed;
        inset: 0;
        z-index: 50;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 14px;
        padding: 24px;
        background: var(--bg);
        text-align: center;
    }

    .rotate-overlay p {
        margin: 0 0 8px;
        font-size: 1.15rem;
    }

    .rotate-overlay .menu-button {
        width: min(100%, 320px);
    }

    .rotate-icon {
        width: 72px;
        height: 72px;
        fill: none;
        stroke: var(--accent);
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
}

/* Tablero */

/* Dos SVG superpuestos con la misma caja: el fondo toma el tamaño del tablero dinámico. */
.board-wrap {
    position: relative;
    min-width: 0;
}

.board {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
    max-height: calc(100dvh - 16px);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Capa propia: las texturas se rasterizan una vez y no se repintan al animar las fichas. */
.board-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    will-change: transform;
}

.board-bg .frame { fill: var(--board-frame); }
.board-bg .felt { fill: var(--board-felt); }
.board-bg .bar { fill: var(--board-bar); }
.board-bg .tray { fill: var(--board-tray); }
.board-bg .point-light { fill: var(--point-light); }
.board-bg .point-dark { fill: var(--point-dark); }
.board-bg .point { stroke: rgba(0, 0, 0, 0.3); stroke-width: 0.8; }

/* El relleno de las capas de textura solo define la forma: el filtro genera el color. */
.board-bg .grain { fill: #000; }
.board-bg .grain.wood { opacity: var(--board-grain); }
.board-bg .grain.cloth { opacity: 0.28; }
.board-bg .frame-light { fill: url(#eg-light); }
.board-bg .bar-edge { fill: none; stroke: rgba(0, 0, 0, 0.45); stroke-width: 3; }
.board-bg .hinge { fill: #b08d4f; stroke: #5e4520; stroke-width: 1.5; opacity: 0.85; }
.board-bg .recess { stroke: rgba(0, 0, 0, 0.6); stroke-width: 3; }

.board-bg .point-label {
    fill: var(--board-label);
    opacity: 0.6;
    font-size: 11px;
    text-anchor: middle;
    dominant-baseline: central;
}

.board .highlight { pointer-events: none; }
.board .highlight.movable { fill: rgba(224, 166, 58, 0.18); }
.board .highlight.selected { fill: rgba(224, 166, 58, 0.45); }
.board .highlight.target { fill: rgba(90, 220, 130, 0.38); }

.board .checker {
    transition: transform 260ms ease-out;
    pointer-events: none;
}

/* La ficha elegida se levanta: más grande y con la sombra más lejos. */
.board .checker .lift { transition: transform 140ms ease-out; }
.board .checker.selected .lift { transform: scale(1.1); }
.board .shadows .checker.selected .lift { transform: translate(3px, 5px) scale(1.12); }

.board .shadows circle { fill: url(#eg-shadow); }
.board .shadows rect { fill: rgba(0, 0, 0, 0.35); }

.board .checker.white .body { fill: url(#eg-checker-white); stroke: var(--white-edge); stroke-width: 1.5; }
.board .checker.white .inner { fill: url(#eg-checker-white-inner); stroke: var(--white-inner-edge); stroke-width: 1.2; }
.board .checker.white .edge { fill: url(#eg-off-white); stroke: var(--white-edge); stroke-width: 1.5; }

.board .checker.black .body { fill: url(#eg-checker-black); stroke: var(--black-edge); stroke-width: 1.5; }
.board .checker.black .inner { fill: url(#eg-checker-black-inner); stroke: rgba(0, 0, 0, 0.7); stroke-width: 1.2; }
.board .checker.black .edge { fill: url(#eg-off-black); stroke: var(--black-edge); stroke-width: 1.5; }

.board .drop { fill: rgba(0, 0, 0, 0.35); }
.board .die .face { stroke-width: 1.5; }
.board .die.white .face { fill: url(#eg-die-white); stroke: var(--white-edge); }
.board .die.white circle { fill: var(--white-pip); }
.board .die.black .face { fill: url(#eg-die-black); stroke: var(--black-light); }
.board .die.black circle { fill: var(--black-pip); }
.board .die { cursor: pointer; }
.board .die.used { opacity: 0.3; }
.board .die.unusable { opacity: 0.3; filter: grayscale(1); }
.board .die.next .face { stroke: var(--accent); stroke-width: 3.5; }
.board .die.blocked { opacity: 0.6; }
.board .die.blocked .face { stroke: #d9534f; stroke-width: 3.5; }

/* Tirada nueva: los dados entran rodando desde el costado y rebotan al apoyarse (el segundo, un
   poco después). Va en el grupo interno: el externo tiene la posición como atributo transform. */
.board .die-roll {
    transform-box: fill-box;
    transform-origin: center;
    animation: die-roll 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
    animation-delay: calc(var(--die-index, 0) * 70ms);
}

@keyframes die-roll {
    0% { transform: translate(-70px, -18px) rotate(-320deg) scale(0.7); opacity: 0; }
    20% { opacity: 1; }
    60% { transform: translate(6px, 2px) rotate(14deg) scale(1.06); }
    80% { transform: translate(-2px, 0) rotate(-5deg) scale(0.98); }
    100% { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .board .die-roll { animation: none; }
}

.board .cube .face {
    fill: url(#eg-die-white);
    stroke: #6b625b;
}

.board .cube text {
    fill: #2a2624;
    font-size: 17px;
    font-weight: 700;
    text-anchor: middle;
}

/* Pips en la bandeja, junto al cubo: una píldora del color de las fichas de cada jugador; no reciben toques. */
.board .pips {
    pointer-events: none;
}

    .board .pips text {
        font-size: 15px;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        text-anchor: middle;
        dominant-baseline: central;
    }

    .board .pips .white rect {
        fill: var(--white-checker);
        stroke: var(--white-edge);
        stroke-width: 1.2;
    }

    .board .pips .white text {
        fill: var(--white-pip);
    }

    .board .pips .black rect {
        fill: var(--black-checker);
        stroke: var(--black-light);
        stroke-width: 1.2;
    }

    .board .pips .black text {
        fill: var(--black-pip);
    }

.board .hit {
    fill: transparent;
    cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
    .board .checker, .board .checker .lift { transition: none; }
}

/* Plantilla de Blazor: error y progreso de carga */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    color: #222;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

/* Pantalla de carga */
.splash {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 16px;
}

.splash-logo {
    width: min(80vw, 520px);
    max-height: 55vh;
    object-fit: contain;
}

.loading-bar {
    width: min(60vw, 320px);
    height: 6px;
    border-radius: 999px;
    background: #3a2c22;
    overflow: hidden;
}

    .loading-bar div {
        width: var(--blazor-load-percentage, 0%);
        height: 100%;
        background: var(--accent);
        transition: width 0.1s ease-out;
    }

.loading-progress-text {
    color: var(--muted);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

/* Logo en lugar del título del menú */
.menu-logo {
    margin: 12px 0 4px;
    text-align: center;
    line-height: 0;
}

    .menu-logo img {
        width: min(100%, 340px);
        height: auto;
        user-select: none;
        -webkit-user-select: none;
        -webkit-user-drag: none;
        -webkit-touch-callout: none;
    }

/* Al navegar, Blazor pone el foco en el título (FocusOnNavigate, para lectores de pantalla):
   ese foco no se dibuja (en el menú el título es el logo y quedaba con un borde blanco). */
h1:focus {
    outline: none;
}

/* Rating y ranking */
.account-rating {
    padding: 1px 8px;
    border-radius: 999px;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.rating-change {
    margin: 4px 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.rating-change.up {
    color: #7fc97f;
}

.rating-change.down {
    color: #e07a6a;
}

.ranking-you {
    margin: 0;
    font-weight: 600;
}

.ranking {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.ranking th,
.ranking td {
    padding: 8px 6px;
    text-align: left;
    border-bottom: 1px solid #3a2c22;
}

.ranking th:first-child,
.ranking td:first-child,
.ranking th:nth-child(n + 3),
.ranking td:nth-child(n + 3) {
    text-align: right;
}

.ranking-tabs {
    grid-template-columns: repeat(3, 1fr);
}

.ranking td.ranking-gain.up { color: #7fc97f; }
.ranking td.ranking-gain.down { color: #e07a6a; }

.ranking tr.me td {
    color: var(--accent);
    font-weight: 600;
}

/* Historial */
.history-filters {
    display: flex;
    gap: 10px;
}

.icon-choice {
    display: grid;
    place-items: center;
    width: 64px;
    height: 48px;
    padding: 0;
    border: 1px solid var(--frame);
    border-radius: 10px;
    background: var(--tray);
    color: var(--muted);
    touch-action: manipulation;
}

    .icon-choice svg {
        width: 28px;
        height: 28px;
        fill: currentColor;
    }

        /* Ojos y boca de la IA: "huecos" del color del botón. */
        .icon-choice svg .cut {
            fill: var(--tray);
        }

    .icon-choice.selected {
        border-color: var(--accent);
        box-shadow: inset 0 0 0 1px var(--accent);
        color: var(--accent);
    }

/* Una sola grilla para toda la lista (subgrid): las columnas se alinean entre los matches y con el encabezado. */
.history-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto auto;
    column-gap: 8px;
    row-gap: 8px;
}

    .history-list > *,
    .history-item > .history-grid {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: subgrid;
    }

.history-item {
    row-gap: 6px;
    padding: 10px 12px;
    border: 1px solid #3a2c22;
    border-radius: 12px;
    background: #241c17;
    color: var(--text);
    cursor: pointer;
    touch-action: manipulation;
}

    .history-item:focus-visible {
        outline: 2px solid var(--accent);
    }

.history-grid {
    align-items: center;
    row-gap: 4px;
    font-variant-numeric: tabular-nums;
}

.history-head {
    padding: 0 13px;
    color: var(--muted);
    font-size: 0.75rem;
}

    .history-head > span:nth-child(2) {
        grid-column: 2 / span 2;
        text-align: center;
    }

    .history-head > span:nth-child(3),
    .history-head > span:nth-child(4) {
        text-align: right;
    }

.history-player {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

    .history-player.mine .history-name {
        font-weight: 700;
    }

.history-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-rating {
    flex: 0 0 auto;
    color: var(--muted);
}

/* Puntos en la columna 2; el ícono del resultado ocupa las dos filas de la columna 3. */
.history-points {
    grid-column: 2;
    text-align: right;
    font-weight: 600;
}

.history-accuracy {
    grid-column: 4;
    text-align: right;
}

.history-luck {
    grid-column: 5;
    text-align: right;
    color: var(--muted);
}

    .history-luck.lucky {
        color: #7fc97f;
    }

    .history-luck.unlucky {
        color: #e07a6a;
    }

.history-outcome {
    grid-column: 3;
    grid-row: 1 / span 2;
    justify-self: center;
    display: grid;
    place-items: center;
    width: 1.4em;
    height: 1.4em;
    border-radius: 4px;
    font-weight: 700;
    color: #1b1512;
    background: var(--accent);
}

    .history-outcome.won {
        background: #7fc97f;
    }

    .history-outcome.lost {
        background: #e07a6a;
    }

.history-meta {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

    .history-meta small {
        color: var(--muted);
    }

.history-change {
    margin-left: 6px;
    white-space: nowrap;
}

    .history-change.up {
        color: #7fc97f;
    }

    .history-change.down {
        color: #e07a6a;
    }

.history-analysis {
    flex: 0 0 auto;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid var(--frame);
    background: var(--tray);
    color: var(--text);
    font-size: 0.85rem;
}

    .history-analysis.done {
        border-color: var(--accent);
        color: var(--accent);
    }

/* Jugadores: color con el que jugó, avatar y bandera */
.checker-dot {
    flex: 0 0 auto;
    width: 0.8em;
    height: 0.8em;
    border-radius: 50%;
    border: 1px solid var(--white-edge);
}

    .checker-dot.white {
        background: var(--white-checker);
    }

    .checker-dot.black {
        background: var(--black-checker);
        border-color: #6b625c;
    }

.avatar {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    width: 1.7em;
    height: 1.7em;
    border-radius: 6px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
}

    .avatar.bot {
        background: #3a2c22;
        color: var(--accent);
        font-size: 0.7rem;
    }

.flag {
    flex: 0 0 auto;
    font-family: "Twemoji Country Flags", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    line-height: 1;
}

.ranking-player {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Torneos */
.tournament-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    margin-bottom: 8px;
    padding: 10px 12px;
    border: 1px solid #3a2c22;
    border-radius: 12px;
    background: #241c17;
    color: var(--text);
    text-align: left;
    touch-action: manipulation;
}

    .tournament-item small {
        color: var(--muted);
    }

.tournament-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.badge {
    padding: 0 6px;
    border: 1px solid var(--frame);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.75rem;
}

    .badge.official {
        border-color: var(--accent);
        color: var(--accent);
    }

    .badge.registered {
        border-color: #7fc97f;
        color: #7fc97f;
    }

.tournament-status {
    margin: 4px 0;
    font-weight: 600;
}

.tournament-manage {
    display: flex;
    gap: 8px;
}

    .tournament-manage .menu-button {
        flex: 1 1 0;
    }

.tournament-players {
    margin: 0;
    padding: 0;
    list-style: none;
}

    .tournament-players li {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 4px 0;
        border-bottom: 1px solid #3a2c22;
        font-variant-numeric: tabular-nums;
    }

        .tournament-players li.mine .history-name {
            font-weight: 700;
            color: var(--accent);
        }

.seed {
    min-width: 1.4em;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: right;
}

/* Doble eliminación: título de cada parte del cuadro. Arena: la lista de matches y los puntos. */
.bracket-title {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
}

.arena-matches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.standings td.arena-score {
    font-weight: 700;
    color: var(--accent);
}

/* Tabla de posiciones de los formatos con tabla. */
.standings {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

    .standings th,
    .standings td {
        padding: 6px 4px;
        border-bottom: 1px solid #3a2c22;
        text-align: center;
    }

    .standings th {
        color: var(--muted);
        font-size: 0.8rem;
        font-weight: 600;
    }

        .standings th:nth-child(2),
        .standings td:nth-child(2) {
            text-align: left;
            width: 100%;
        }

    .standings tr.mine td {
        color: var(--accent);
        font-weight: 600;
    }

/* El torneo usa más ancho que el menú: en la PC el cuadro entra sin desplazarse. */
.menu.tournament {
    max-width: 1100px;
}

    /* Todo menos el cuadro va en la columna del menú. */
    .menu.tournament > :not(.bracket):not(.bracket-title) {
        width: 100%;
        max-width: 480px;
        margin-inline: auto;
    }

/* Cuadro: una columna por ronda; los cruces de cada ronda se reparten a lo alto para quedar
   entre los dos que los alimentan. En pantallas angostas se desplaza hacia el costado. */
.bracket {
    display: flex;
    justify-content: safe center;
    gap: 12px;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 6px;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    flex: 0 0 220px;
}

    .bracket-round h3 {
        margin: 0 0 6px;
        color: var(--muted);
        font-size: 0.8rem;
        font-weight: 600;
        text-align: center;
    }

.bracket-matches {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    justify-content: space-around;
    gap: 8px;
}

.bracket-match {
    display: flex;
    flex-direction: column;
    padding: 4px 6px;
    border: 1px solid #3a2c22;
    border-radius: 8px;
    background: #241c17;
}

    .bracket-match[role="button"] {
        cursor: pointer;
    }

    .bracket-match.mine {
        border-color: var(--accent);
    }

    .bracket-match.playing {
        box-shadow: inset 3px 0 0 #7fc97f;
    }

.bracket-side {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    padding: 2px 0;
    font-size: 0.85rem;
}

    .bracket-side .avatar {
        font-size: 0.7rem;
    }

    .bracket-side.winner .history-name {
        font-weight: 700;
    }

    .bracket-side.loser {
        opacity: 0.55;
    }

    .bracket-side.me .history-name {
        color: var(--accent);
    }

.bracket-score {
    margin-left: auto;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.bracket-empty {
    color: var(--muted);
    font-style: italic;
}

.bracket-live {
    color: #7fc97f;
    font-size: 0.75rem;
}

/* Nombres que llevan al perfil: se ven como texto, subrayados al pasar. */
.player-link {
    color: inherit;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    .player-link:hover,
    .player-link:focus-visible {
        text-decoration: underline;
    }

/* Perfil */
.profile-identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

    .profile-identity .avatar {
        width: 52px;
        height: 52px;
        border-radius: 10px;
        font-size: 1.6rem;
    }

    .profile-identity > div {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }

    .profile-identity strong {
        font-size: 1.2rem;
    }

    .profile-identity small {
        display: flex;
        align-items: center;
        gap: 6px;
        color: var(--muted);
    }

.profile-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.profile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px;
    border: 1px solid #3a2c22;
    border-radius: 10px;
    font-variant-numeric: tabular-nums;
}

    .profile-stat strong {
        font-size: 1.3rem;
    }

    .profile-stat small {
        color: var(--muted);
        text-align: center;
    }

.rating-chart {
    width: 100%;
    height: auto;
}

    .rating-chart .line {
        fill: none;
        stroke: var(--accent);
        stroke-width: 2;
        stroke-linejoin: round;
    }

    .rating-chart .area {
        fill: var(--accent);
        opacity: 0.12;
    }

    .rating-chart .last {
        fill: var(--accent);
    }

    .rating-chart .grid {
        stroke: #3a2c22;
        stroke-dasharray: 3 3;
    }

    .rating-chart text {
        fill: var(--muted);
        font-size: 10px;
    }

.profile-matches {
    margin: 0;
    padding: 0;
    list-style: none;
}

    .profile-matches li {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 6px 0;
        border-bottom: 1px solid #3a2c22;
    }

        .profile-matches li.can-open {
            cursor: pointer;
        }

.profile-match-opponent {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

    .profile-match-opponent small {
        color: var(--muted);
    }

.profile-match-score {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.profile-matches .history-outcome {
    grid-row: auto;
    grid-column: auto;
}

/* Perfil: quien mira contra el jugador, destacado arriba */
.head-to-head {
    border-color: var(--accent);
}

    .head-to-head h2 {
        color: var(--accent);
    }

    .head-to-head h3 {
        margin: 4px 0 0;
        color: var(--muted);
        font-size: 0.8rem;
        font-weight: normal;
    }

.h2h-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-variant-numeric: tabular-nums;
}

.h2h-side {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    color: var(--muted);
}

    .h2h-side small {
        overflow: hidden;
        max-width: 100%;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .h2h-side strong {
        font-size: 2.4rem;
        line-height: 1.1;
    }

    .h2h-side.ahead {
        color: var(--text);
    }

.h2h-dash {
    color: var(--muted);
    font-size: 1.6rem;
}

.h2h-bar {
    display: flex;
    overflow: hidden;
    height: 8px;
    border-radius: 4px;
}

    .h2h-bar .won {
        background: #7fc97f;
    }

    .h2h-bar .lost {
        background: #e07a6a;
    }

/* Amigos */
.friend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #3a2c22;
}

    .friend-row .ranking-player {
        min-width: 0;
    }

/* Espectadores: contador junto al marcador y la lista de partidas en vivo. */
.match-score .spectators {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--muted);
    font-weight: 600;
}

    .match-score .spectators svg {
        width: 16px;
        height: 16px;
        fill: currentColor;
    }

.spectating {
    color: var(--accent);
    text-align: center;
}

.live-match .history-player {
    width: 100%;
}

.live-score {
    margin-left: auto;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Repetición */
.replay-games {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.9rem;
}

    .replay-games button {
        min-width: 32px;
        min-height: 32px;
        border-radius: 8px;
        border: 1px solid var(--frame);
        background: var(--tray);
        color: var(--text);
        font-variant-numeric: tabular-nums;
    }

        .replay-games button.selected {
            border-color: var(--accent);
            box-shadow: inset 0 0 0 1px var(--accent);
            color: var(--accent);
        }

.replay-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

    .replay-controls button {
        flex: 1 1 0;
        min-width: 0;
        min-height: 40px;
        border-radius: 8px;
        border: 1px solid var(--frame);
        background: var(--tray);
        color: var(--text);
        font-size: 1rem;
    }

        .replay-controls button:disabled {
            opacity: 0.4;
        }

.replay-position {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.85rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* Con el análisis el panel puede no entrar: la lista conserva un alto propio y se desplaza por
   dentro (si no, quedaba en 0 y seguir la jugada movía el panel entero, flechas incluidas). */
.replay-steps {
    flex: 1 0 160px;
    min-height: 160px;
    margin: 0;
    padding: 0 0 0 1.6em;
    overflow-y: auto;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

    .replay-steps li {
        padding: 3px 4px;
        border-radius: 6px;
        cursor: pointer;
    }

        .replay-steps li.current {
            background: #3a2c22;
            color: var(--accent);
        }

/* Celular en horizontal: no entra la lista de jugadas (el momento actual ya se lee arriba). */
@media (max-height: 450px) {
    .replay-steps {
        display: none;
    }
}

/* Análisis de jugadas */
.analysis {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
}

    .analysis button {
        min-height: 36px;
        border-radius: 8px;
        border: 1px solid var(--frame);
        background: var(--tray);
        color: var(--text);
    }

    .analysis .analysis-start {
        border-color: var(--accent);
        color: var(--accent);
        font-weight: 600;
    }

    .analysis button:disabled {
        opacity: 0.5;
    }

    .analysis .hint {
        margin: 0;
    }

.analysis-summary {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--muted);
}

    .analysis-summary strong {
        color: var(--text);
    }

.analysis-move {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.candidates {
    margin: 0;
    padding-left: 1.6em;
    font-variant-numeric: tabular-nums;
}

    .candidates li span,
    .played-move span {
        color: var(--muted);
        margin-left: 6px;
    }

    .candidates li.played {
        color: var(--accent);
        font-weight: 600;
    }

.quality {
    font-weight: 600;
}

    .quality.good {
        color: #7fc97f;
    }

.quality.best,
.quality.excellent {
    color: #7fc97f;
}

.quality.doubtful,
.mark.doubtful {
    color: #e0c36a;
}

.quality.error,
.mark.error {
    color: #e0956a;
}

.quality.blunder,
.mark.blunder {
    color: #e06a6a;
}

.mark {
    margin-left: 6px;
    font-weight: 700;
}

/* Flechas de la jugada (repetición y análisis): no reciben toques. */
.move-arrows {
    pointer-events: none;
}

    .move-arrows line {
        stroke: var(--accent);
        stroke-width: 7;
        stroke-linecap: round;
        opacity: 0.85;
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
    }

#eg-arrow-head path {
    fill: var(--accent);
}

/* Tabla del análisis: una fila por categoría; los números filtran. */
.analysis-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

    /* Columnas fijas: los nombres largos se recortan con "…" en vez de ensanchar el panel. */
    .analysis-table th:first-child {
        width: 40%;
    }

    .analysis-table th,
    .analysis-table td {
        padding: 2px 4px;
        text-align: center;
        font-weight: normal;
    }

        .analysis-table th:first-child {
            text-align: left;
            color: var(--muted);
        }

    .analysis-table thead th {
        color: var(--text);
        font-weight: 600;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .analysis-table td button {
        min-width: 30px;
        min-height: 28px;
        padding: 0 6px;
        font-weight: 600;
    }

        .analysis-table td button.selected {
            border-color: var(--accent);
            box-shadow: inset 0 0 0 1px var(--accent);
        }

    .analysis-table tr.best td button,
    .analysis-table tr.excellent td button {
        color: #7fc97f;
    }

    .analysis-table tr.doubtful td button {
        color: #e0c36a;
    }

    .analysis-table tr.error td button {
        color: #e0956a;
    }

    .analysis-table tr.blunder td button {
        color: #e06a6a;
    }

    .analysis-table td button:disabled {
        color: var(--muted);
    }

    .analysis-table tfoot td,
    .analysis-table tfoot th {
        padding-top: 4px;
        border-top: 1px solid #3a2c22;
        color: var(--muted);
    }

.analysis-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
}

    .analysis-filter > span:first-child {
        flex: 1 0 100%;
        color: var(--accent);
    }

    .analysis .analysis-filter button {
        min-width: 32px;
        min-height: 32px;
    }

.candidates li button,
.analysis .played-move {
    min-height: 0;
    padding: 1px 6px;
    border: 1px solid transparent;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
}

.candidates li.shown button,
.analysis .played-move.shown {
    border-color: var(--accent);
    border-radius: 6px;
}

/* En la repetición el panel es más ancho: entra la tabla del análisis con los dos jugadores. */
.game.replay {
    grid-template-columns: minmax(0, var(--board-max)) minmax(200px, 320px);
}

    .game.replay .game-panel {
        overflow-x: hidden;
    }

/* Suerte: total por jugador y la tirada del momento. */
.analysis-table .luck-row td.lucky,
.roll-luck.lucky {
    color: #7fc97f;
}

.analysis-table .luck-row td.unlucky,
.roll-luck.unlucky {
    color: #e07a6a;
}

.roll-luck {
    color: var(--muted);
}

.analysis-table .luck-row.lucky td button {
    color: #7fc97f;
}

.analysis-table .luck-row.unlucky td button {
    color: #e07a6a;
}

.analysis-table .luck-row td button:disabled {
    color: var(--muted);
}

/* Lista de jugadas: las propias resaltadas, las del rival más tenues. */
.replay-steps li.mine {
    border-left: 3px solid var(--accent);
    background: rgba(224, 166, 58, 0.08);
    padding-left: 6px;
}

.replay-steps li.theirs {
    color: var(--muted);
    border-left: 3px solid transparent;
    padding-left: 6px;
}

.replay-steps li.current {
    color: var(--accent);
}

.analysis .refining {
    color: var(--accent);
}

/* Cubo: filas de errores en la tabla (con una línea arriba) y la decisión del momento. */
.analysis-table tbody tr.cube-row:first-of-type th,
.analysis-table tbody tr:not(.cube-row) + tr.cube-row th,
.analysis-table tbody tr:not(.cube-row) + tr.cube-row td {
    border-top: 1px solid #3a2c22;
}

.analysis-table tr.cube-row td button {
    color: #e0956a;
}

    .analysis-table tr.cube-row td button:disabled {
        color: var(--muted);
    }

/* "Match" junto a las partidas: la tabla del análisis es de todo el match. La partida que se ve
   queda con un borde suave para saber dónde está el tablero. */
.replay-games button.whole-match {
    padding: 0 10px;
}

.replay-games button.shown {
    border-color: var(--accent);
    border-style: dashed;
}

/* La marca del cubo va en un recuadro (como el cubo), para no confundirla con la de la jugada. */
.mark.cube {
    padding: 0 3px;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-size: 0.8em;
}

.analysis-cube {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cube-options {
    margin: 0;
    padding-left: 1.6em;
    font-variant-numeric: tabular-nums;
}

    .cube-options li span + span {
        margin-left: 6px;
        color: var(--muted);
    }

    .cube-options li.best {
        color: #7fc97f;
    }

.quality .depth {
    margin-left: 4px;
    font-weight: normal;
    color: var(--muted);
}

/* Tutorial: lista de lecciones y panel de la lección (texto del paso y respuesta al ejercicio). */
.lesson-entry strong {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lesson-number {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--tray);
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 700;
}

.lesson-entry.done .lesson-number {
    background: var(--accent);
    color: #2a1a0c;
}

.lesson-entry small {
    padding-left: 36px;
}

.lesson-progress {
    align-self: center;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.lesson-title {
    margin: 0;
    font-size: 1rem;
    color: var(--accent);
}

.lesson-text {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.45;
}

.lesson-feedback {
    margin: 0;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.lesson-feedback.right {
    background: rgba(127, 201, 127, 0.15);
    color: #a8dfa8;
}

.lesson-feedback.wrong {
    background: rgba(224, 122, 106, 0.15);
    color: #f0a598;
}

/* Por turnos: lista de partidas (la que te toca resaltada) y menú con aviso. */
.choice-group.daily {
    grid-template-columns: repeat(3, 1fr);
}

.daily-match {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 10px;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #3a2c22;
    border-radius: 10px;
    background: #241c17;
    color: var(--text);
    text-align: left;
    touch-action: manipulation;
}

.daily-match.your-turn {
    border-color: var(--accent);
}

.daily-player {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.daily-player strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.daily-player small,
.daily-settings {
    color: var(--muted);
    font-size: 0.8rem;
}

.daily-score {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.daily-status {
    color: var(--muted);
    font-size: 0.85rem;
}

.daily-match.your-turn .daily-status {
    color: var(--accent);
    font-weight: 600;
}

.daily-settings {
    text-align: right;
}

.menu-entry.attention {
    border-color: var(--accent);
}

.menu-entry.attention small {
    color: var(--accent);
    font-weight: 600;
}

.chip .clock.daily {
    font-size: 0.85rem;
}

/* Amigos para desafiar (Jugar vs Amigo y Por turnos), siempre a la vista. */
.friend-challenges {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 4px;
}

.friend-challenges h3 {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.friend-challenges .friend-row button {
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--frame);
    border-radius: 8px;
    background: var(--tray);
    color: var(--text);
}

.friend-challenges .friend-row button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #2a1a0c;
    font-weight: 600;
}

.friend-challenges .friend-row button:disabled {
    opacity: 0.6;
}

/* Aviso por abandonar matches: advertencia (ámbar) o bloqueo (rojo). */
.abandon-notice {
    border-left: 4px solid var(--accent);
}

.abandon-notice.blocked {
    border-left-color: #e57373;
}

.abandon-notice p {
    margin: 0.35rem 0 0;
}

/* Opciones: muestras de los temas del tablero (cada una con su atributo data-board-theme). */
.theme-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.theme-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem;
    border: 2px solid transparent;
    border-radius: 10px;
    background: var(--tray);
    color: var(--text);
    cursor: pointer;
}

    .theme-swatch.selected {
        border-color: var(--accent);
    }

    .theme-swatch svg {
        width: 100%;
        height: auto;
        display: block;
    }

    .theme-swatch span {
        font-size: 0.85rem;
    }

.swatch-frame { fill: var(--board-frame); }
.swatch-felt { fill: var(--board-felt); }
.swatch-point-light { fill: var(--point-light); }
.swatch-point-dark { fill: var(--point-dark); }
.swatch-white { fill: var(--white-checker); stroke: var(--white-edge); stroke-width: 1; }
.swatch-black { fill: var(--black-checker); stroke: var(--black-edge); stroke-width: 1; }

/* Arrastre de fichas (drag.js): sin gestos del navegador sobre el tablero, y la ficha arrastrada
   levantada, encima de todo y sin transición (sigue al dedo). */
.board.draggable {
    touch-action: none;
}

.board .drag-layer {
    pointer-events: none;
}

    .board .drag-layer .checker {
        transition: none;
    }

    .board .drag-layer .lift {
        transform: scale(1.12);
        filter: drop-shadow(3px 6px 4px rgba(0, 0, 0, 0.45));
    }

/* Repetición y posición: compartir y bajar. */
.replay-share {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

    .replay-share button {
        flex: 1 1 auto;
        padding: 0.35rem 0.5rem;
        border: 1px solid var(--frame);
        border-radius: 8px;
        background: var(--tray);
        color: var(--text);
        font-size: 0.8rem;
    }

/* Posición compartida: qué se ve (a quién le toca, match, cubo) y el campo para pegar un ID de GNU. */
.position-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.9rem;
}

    .position-info span {
        color: var(--muted);
    }

.position-form {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

    .position-form input {
        flex: 1;
        min-width: 0;
        font-family: ui-monospace, Consolas, monospace;
        font-size: 0.85rem;
    }

.position-open summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 0.85rem;
}

/* Ejercicios: números del jugador, temas, respuestas y resultado. */
.exercise-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    text-align: center;
}

.exercise-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

    .exercise-stat strong {
        font-size: 1.3rem;
        font-variant-numeric: tabular-nums;
    }

    .exercise-stat small {
        color: var(--muted);
    }

.exercise-topics {
    flex-wrap: wrap;
}

.exercise-actions,
.assist-actions {
    display: flex;
    gap: 0.5rem;
}

    .exercise-actions button,
    .assist-actions button {
        flex: 1;
        padding: 0.6rem 0.5rem;
        border: 1px solid var(--frame);
        border-radius: 8px;
        background: var(--tray);
        color: var(--text);
        font-size: 0.95rem;
    }

        .exercise-actions button.primary,
        .assist-actions button.primary {
            background: var(--accent);
            border-color: var(--accent);
            color: #1b1512;
            font-weight: 600;
        }

        .exercise-actions button:disabled,
        .assist-actions button:disabled {
            opacity: 0.5;
        }

.exercise-verdict {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

    .exercise-verdict.correct {
        color: #7fd18b;
    }

    .exercise-verdict.wrong {
        color: #e57373;
    }

    .exercise-verdict .rating-change {
        margin-left: 0.5rem;
        font-size: 0.9rem;
        color: var(--muted);
    }

.analysis .candidates li.best button {
    font-weight: 700;
}

.analysis .candidates li small {
    color: var(--muted);
    margin-left: 0.3rem;
}

/* Ayudas contra la IA: la pista y el aviso antes de un error, en el panel del juego. */
.assist-hint {
    margin: 0;
    font-size: 0.9rem;
    color: var(--accent);
}

.assist-warning {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.6rem;
    border: 1px solid #e57373;
    border-radius: 8px;
}

    .assist-warning p {
        margin: 0;
        font-size: 0.9rem;
    }

/* Oculto a la vista pero accesible (el input de archivo dentro de un botón). */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Importar un match .mat (en el historial). */
.match-import {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

    .match-import label.menu-button {
        position: relative;
        cursor: pointer;
        text-align: center;
    }

/* Clubes */
.club-description {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.club-members {
    margin: 0;
    padding: 0;
    list-style: none;
}

    .club-members li {
        padding: 4px 0;
        border-bottom: 1px solid #3a2c22;
    }

        .club-members li.mine .history-name {
            font-weight: 700;
            color: var(--accent);
        }

.club-member {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-variant-numeric: tabular-nums;
}

    .club-member .history-rating {
        margin-left: auto;
    }

.icon-button.small {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
}

.club-member-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0 2px 2em;
}

    .club-member-actions button {
        min-height: 36px;
        padding: 0 12px;
        border: 1px solid var(--frame);
        border-radius: 8px;
        background: var(--tray);
        color: var(--text);
    }

.badge.in-person {
    border-color: #7fb3d9;
    color: #7fb3d9;
}

.form-field textarea {
    resize: vertical;
    font-family: inherit;
}

/* Torneo presencial: cargar inscriptos y el resultado de un cruce */
.roster-add {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.result-panel {
    position: fixed;
    left: 50%;
    bottom: 16px;
    z-index: 95;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(420px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: 16px;
    border: 1px solid var(--accent);
    border-radius: 12px;
    background: #241c17;
    box-shadow: 0 8px 32px rgb(0 0 0 / 0.6);
    transform: translateX(-50%);
}

    .result-panel h2 {
        margin: 0;
        font-size: 1.1rem;
    }

    .result-panel .hint {
        margin: 0;
    }

.result-preview {
    margin: 0;
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.profile-clubs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

    .profile-clubs .badge {
        padding: 2px 10px;
        font-size: 0.85rem;
        text-decoration: none;
    }

.tournament-info a {
    color: var(--accent);
}

.friend-row .challenge-actions {
    align-items: center;
}

/* Menú: "Jugar" agrupa las formas de jugar y se despliega */
.menu-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.menu-chevron {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.15s;
}

.menu-group[aria-expanded="true"] {
    border-color: var(--accent);
}

    .menu-group[aria-expanded="true"] .menu-chevron {
        transform: rotate(180deg);
    }

.menu-subentries {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-left: 14px;
    padding-left: 12px;
    border-left: 2px solid var(--frame);
}

    .menu-subentries .menu-entry {
        padding: 11px 14px;
    }

/* Ligas */
.league-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.field input.number {
    width: 90px;
    min-height: 40px;
    padding: 6px 10px;
    border: 1px solid var(--frame);
    border-radius: 8px;
    background: #1f1814;
    color: var(--text);
    font-size: 1rem;
    text-align: right;
}

.tournament-league {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Premium: comparación de planes */
.premium-status {
    border-color: var(--accent);
}

    .premium-status strong {
        color: var(--accent);
    }

.plans {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

    .plans th,
    .plans td {
        padding: 8px 4px;
        border-bottom: 1px solid #3a2c22;
        text-align: center;
    }

        .plans th:first-child,
        .plans td:first-child {
            text-align: left;
        }

    .plans .premium {
        color: var(--accent);
        font-weight: 600;
    }

/* Política de privacidad y borrar la cuenta */
.legal h2 {
    margin-top: 8px;
}

.legal p,
.legal ul {
    margin: 0;
    line-height: 1.5;
}

.legal ul,
.delete-list {
    padding-left: 20px;
}

.legal a,
.menu-section a {
    color: var(--accent);
}

.menu-button.danger {
    border-color: #e57373;
    background: #5a2420;
    color: #fff;
}

    .menu-button.danger:disabled {
        opacity: 0.5;
    }

a.danger-link {
    color: #e57373;
}

.assist-hint a,
p.hint a {
    color: var(--accent);
}

/* "Entrar" en la barra de la cuenta, sin sesión */
.account-signin {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 16px 0 12px;
    border: 1px solid var(--accent);
    border-radius: 999px;
    background: var(--accent);
    color: #1b1512;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
}

    .account-signin:hover,
    .account-signin:focus-visible {
        filter: brightness(1.08);
    }
